Since he was a child, Juan's dream has always been to fly, to go beyond the sky, to reach the stars. Due to the physical limitations of his human condition, he decides to get to work to build a flying car that will make his dreams come true.
After a long time studying the necessary engineering, and after many failed attempts, Juan has almost managed to build the vehicle: he just needs the engine, the steering wheel, and the spare tire (he also doesn't have brakes, but his optimism tells him that he won't need them). Many stores around have the three pieces he needs, but for convenience, he decides that he will only go to one store, the one that is the cheapest in total.
Can you help him decide which store he should go to?
The input starts with an integer $$$T$$$, the number of test cases. Each case begins with $$$n$$$, the number of stores. It is followed by $$$n$$$ lines, each containing 3 integers $$$a_{i}$$$, $$$b_{i}$$$, $$$c_{i}$$$, indicating the prices of the engine, the steering wheel, and the spare tire respectively at the $$$i$$$-th store.
For each case, print a line with the number of the store Juan should go to. The stores are numbered from $$$1$$$ to $$$n$$$ according to their order of appearance in the input. In case of a tie, choose the store with the lowest number.
$$$1 \leq n \leq 10^6$$$, $$$1 \leq a_i,b_i,c_i \leq 10^8$$$
It is guaranteed that the sum of the $$$n$$$ in all cases does not exceed $$$10^7$$$.
3 2 7 1 3 5 2 1 3 9 8 2 10 14 1 1 8 11 4 23 42 13 7 12 38 10 9 24 8 10 10
2 1 4
Francis Folk was a prominent programmer. His skills in computing had led him to earn large amounts of money. Not knowing what to do with his fortune, he started at a young age to spend it on cars that he collected in various garages across Europe and North America.
Upon his death, his only daughter will inherit his entire fortune, with one condition: she must give one of his cars, whichever she chooses, to Johnny Deutsch, his arch-nemesis.
Of course, Francis's daughter will not let her pride prevent her from inheriting the fruits of her father's life, so she wants to give Johnny the worst car he has, but she doesn't understand cars. Her best friend has suggested that she give him the oldest one.
Francis started buying cars when he turned 18 in 2001, and he always bought new cars and registered them in Spain, where the license plates consisted of four digits followed by three letters (the letters take precedence over the numbers; for example, the plate 9999BBB is older than the plate 0000ZZZ).
Francis has prepared a list of all the license plates of his vehicles; can you tell him which one is the oldest?
A number n followed by n lines, each containing a sequence of 4 digits and 3 letters.
The oldest license plate.
$$$1 \leq n \leq 10000$$$
There are 4 test files; each is worth 25 points.
6 2839PFF 5975HPP 1558PFT 5624FSD 8367RSH 8700LJT
5624FSD
Santi is a great lover of horseback riding and loves to spend time on his horse Lucy. However, lately he cannot ride comfortably because he knows that he has not yet managed to solve the last game his father gave him, flipping rectangles. The game consists of a rectangular board with white and black squares, and Santi's goal is to turn all the squares white. To do this, he can make moves of the following type: He selects a square on the board and flips all the squares in the subrectangle that has as its top-left corner the one Santi has chosen and as its bottom-right corner the bottom-right square of the board (flipping any square that is in the same row as the one he has chosen or lower and in the same column as the one he has chosen or further to the right). Since Santi wants to get back to riding his horse as soon as possible, he wants to solve the game in the minimum number of moves possible, and he asks for your help.
Note: Flipping a square means changing its color. That is, if it was white, it becomes black and vice versa.
Example of a move to understand the dynamics of the game:
If Santi has the board
1 0 1
1 1 0
and selects the bold square, the result will be as follows, with the squares that have changed marked in italics:
1 1 0
1 0 1
The input starts with an integer $$$t$$$, the number of cases. It is followed by the $$$t$$$ cases, each described by two integers $$$n$$$, $$$m$$$ (the dimensions of the board) and $$$n$$$ rows with $$$m$$$ numbers each, separated by spaces. These numbers describe the board and can be $$$0$$$ if the initial square is white or $$$1$$$ if the initial square is black.
Print $$$t$$$ lines, each with a single integer, the minimum number of moves that Santi needs to solve the game.
$$$1 \leq t \leq 40$$$
19 Points $$$ 1 \leq n, m \leq 5 $$$
27 Points $$$ 1 \leq n, m \leq 80 $$$
8 Points $$$ n = 1, 1 \leq m \leq 1000$$$
16 Points $$$ 1 \leq n, m \leq 1000 $$$ and the initial board is painted like a chessboard, alternating the colors white and black so that there are no two adjacent squares of the same color (as in the last example)
30 Points $$$ 1 \leq n, m \leq 1000 $$$
3 2 3 1 0 1 1 1 0 4 2 0 0 0 1 1 0 1 1 5 5 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
4 3 9
Professor Oak is typing a text on his computer and, as usual, he uses only his two index fingers. The text consists solely of uppercase letters without accents, the characters ",", ".", ":", ";", "'", "?", "!", and spaces and line breaks. All characters, except for spaces and line breaks, have an associated key, which is shown in the keyboard layout below.
Professor Oak starts typing with his left index finger on the F key and his right index finger on the J key. At any moment, he can move either of his fingers to one of the four adjacent keys (or three or two if he is at the edge of the keyboard) and it takes him one second to make this movement. Additionally, he is capable of moving both fingers simultaneously. His prodigious skill also allows him to press a key instantly (i.e., in zero seconds) if one of his two index fingers is on it. The space bar and the ENTER key, which correspond to spaces and line breaks, are very large, so Professor Oak presses them with the tip of his nose, also instantly.
Given the text that Professor Oak has written, determine the time it took him to write it, knowing that he does so optimally. You can assume that Professor Oak has infinitely flexible arms, meaning he can intertwine them without any problem.
The input begins with an integer $$$t \geq 1$$$, the number of cases. Each case consists of a text, which consists of uppercase letters without accents, the characters ",", ".", ":", ";", "'", "?", "!", and spaces and line breaks. The end of the text will be indicated by the character "-". The cases are separated by a line break.
Print a single integer: the time that Professor Oak took to write the text.
In all inputs, $$$1 \leq t \leq 10$$$.
5 Points: The text contains only the characters 'F', 'J', spaces, and line breaks and does not exceed 1000 characters in total.
10 Points: The text contains only two characters that are not spaces or line breaks and does not exceed 1000 characters in total.
35 Points: The text does not exceed 16 characters.
50 Points: The text does not exceed 1000 characters.
1 FJ RU EI WO QP-
4
1 HELLO THERE! WELCOME TO THE WORLD OF POKEMON! MY NAME IS OAK. PEOPLE CALL ME THE POKEMON PROF. THIS WORLD IS INHABITED BY CREATURES CALLED POKEMON. FOR SOME PEOPLE, POKEMON ARE PETS. OTHERS USE THEM FOR FIGHTS. MYSELF... I STUDY POKEMON AS A PROFESSION. -
295
1 PALPATINE: DID YOU EVER HEAR THE TRAGEDY OF DARTH PLAGUEIS THE WISE? ANAKIN: NO. PALPATINE: I THOUGHT NOT. IT'S NOT A STORY THE JEDI WOULD TELL YOU. IT'S A SITH LEGEND. DARTH PLAGUEIS WAS A DARK LORD OF THE SITH, SO POWERFUL AND SO WISE HE COULD USE THE FORCE TO INFLUENCE THE MIDICHLORIANS TO CREATE LIFE... HE HAD SUCH A KNOWLEDGE OF THE DARK SIDE, HE COULD EVEN KEEP THE ONES HE CARED ABOUT FROM DYING. ANAKIN: COULD HE ACTUALLY SAVE PEOPLE FROM DEATH? PALPATINE: THE DARK SIDE OF THE FORCE IS A PATHWAY TO MANY ABILITIES SOME CONSIDER TO BE UNNATURAL. ANAKIN: WHAT HAPPENED TO HIM? PALPATINE: HE BECAME SO POWERFUL... THE ONLY THING HE WAS AFRAID OF WAS LOSING HIS POWER, WHICH EVENTUALLY, OF COURSE, HE DID. UNFORTUNATELY, HE TAUGHT HIS APPRENTICE EVERYTHING HE KNEW, THEN HIS APPRENTICE KILLED HIM IN HIS SLEEP. IRONIC. HE COULD SAVE OTHERS FROM DEATH, BUT NOT HIMSELF. ANAKIN: IS IT POSSIBLE TO LEARN THIS POWER? PALPATINE: NOT FROM A JEDI. -
1126