Author:  A. Klenin  Time limit:  2 sec  
Input file:  input.txt  Memory limit:  16 Mb  
Output file:  output.txt 
ACM contests, like the one you are participating in, are hosted by the special software. That software, among other functions, preforms a job of accepting and evaluating teams' solutions (runs), and displaying results in a rank table. The scoring rules are as follows:
Your task is, given the list of N runs with submission time and result of each run, compute the rank table for C teams.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  A. Klenin  Time limit:  2 sec  
Input file:  input.txt  Memory limit:  64 Mb  
Output file:  output.txt 
The puzzle game of Sudoku is played on a board of N^{2} × N^{2} cells. The cells are grouped in N × N squares of N × N cells each. Each cell is either empty or contains a number between 1 and N^{2}.
The sudoku position is correct when numbers in each row, each column and each square are different. The goal of the game is, starting from some correct position, fill all empty cells so that the final position is still correct.
This game is fairly popular in the Internet, and there are many sites which allow visitors to solve puzzles online. Such sites always have a subroutine to determine a correctness of a given position.
You are to write such a routine.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  A. Klenin, T. Chistyakov  Time limit:  2 sec  
Input file:  input.txt  Memory limit:  256 Mb  
Output file:  output.txt 
Square raster image is represented by an array of N × N pixels. A texture tile is a square image in which the first row is equal to the last one, and the first column is equal to the last one. This property is valuable when covering the surface of graphics object with repeating copies of texture, because it allows "seamless" transitions between tiles.
Your program must, given an image, find its largest subimage which is a texture tile.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  A. Klenin  Time limit:  2 sec  
Input file:  input.txt  Memory limit:  64 Mb  
Output file:  output.txt 
Customer support department in an "Incomprehension Amateurs, Ltd" software company has call center for answering users' questions. Support prices are as follows:
1.  Answer to a question  10 USD 
2.  Correct answer to a question  20 USD 
3.  Correct answer to a question with explanation  40 USD 
4.  Correct answer to a question which was already correctly answered before  +10 USD for each previous correct answer 
So, for example, if user asks the same question three times, first receives incorrect answer, then correct one, and the third time correct answer with explanation, it will cost him 10 + 20 + (40 + 1 * 10) = 80 USD.
Customers are billed monthly according to call log. Company engineers review the log and for each question determine:
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  I. Ludov  Time limit:  1 sec  
Input file:  input.txt  Memory limit:  64 Mb  
Output file:  output.txt 
In a big and rich on natural resources country, the government started a campaign to control deforestation. In fact the government is not too interested in how many trees get fallen, but rather how effectively the wood is utilized. So a law was passed which requires every logging company to pay amount of money in proportion to amount of wood that it wastes during operation.
A felling quota on some territory was allotted to a company in this country. Company lorries may only transport logs of exactly L meters long. So when a tree gets sawed into logs, the remainder is wasted.
Trees in this country grow exactly 1 meter per year, so the company may decrease the amount of tax to be paid by simply waiting for some years. Your task is to determine the number of years needed to achieve smallest possible tax. If there is more than one answer, find minimal (earliest) one.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  A. Klenin  Time limit:  2 sec  
Input file:  input.txt  Memory limit:  64 Mb  
Output file:  output.txt 
Let us call a string of digits d_{1} d_{2}… d_{k} alternating string if the digits on even and odd positions form two disjoint sets.
For example, 121212 and 01234567 are alternating strings, while 11 and 5435 are not.
Your program must, given the string of digits, find its longest continuous alternating substring. If there is more than one longest substring, output the leftmost one.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  A. Klenin  Time limit:  2 sec  
Input file:  input.txt  Memory limit:  64 Mb  
Output file:  output.txt 
Colors on computer screen are represented by (r, g, b) triplets, where r, g, b are integer intensities of red, green and blue components.
Two colors (r_{1}, g_{1}, b_{1}) and (r_{2}, g_{2}, b_{2}) are distinct if min(r_{1} − r_{2}, g_{1} − g_{2}, b_{1} − b_{2}) ≥ D.
Your program will be given N (not necessarily distinct) colors. It must either calculate K new colors that are distinct from each other and from all initial colors, or determine that it is impossible.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  A. Klenin  Time limit:  2 sec  
Input file:  input.txt  Memory limit:  64 Mb  
Output file:  output.txt 
Igor is a computer science freshman student. As opposed to most of his classmates, he actually knows a little about computer programming. Because of this, other students often ask him to write their homework assignments for the "Introductory Programming" course.
He noticed that, although each assignment is unique, they usually follow a simple pattern. In particular, one assignment states:
"Count the number of integers in the array which are [greater thanless thanequal tonot equal to] [value]",
where parts in brackets differ from student to student. Assignments also contain sample input and output to encourage students to test their programs before submission.
Igor have many classmates, so to save time he decided to write a homework generator. He started with the following template:
count := 0; for i := 1 to N do if a[i] #cond# #value# then Inc(count);And now he wants to substitute #cond# and #value# based on the sample input from the assignment. Of course, generated program might be different from what was required in the assignment, but at least it would pass the sample test  his classmates are grateful to have even that. Do you know enough Introductory Programming to help Igor?
Your program will be given sample input  an array of N integer values, and the corresponding output R. It must find such substitution strings for #cond# and #value# that after execution of the code snippet above count will be equal to R, or determine that it is impossible.
The first line of output must contain one of the strings '<', '>', '=', '<>'  substitution for #cond#. The second line must contain an integer  substitution for #value#.
If there is no solution, output file must contain a single character '?' (ASCII 63). If there is more then one solution, output any of them.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 


2 


Author:  A. Klenin  Time limit:  5 sec  
Input file:  input.txt  Memory limit:  200 Mb  
Output file:  output.txt 
Input is the matrix A of N by N nonnegative integers.
A distance between two elements A_{i j} and A_{p q} is defined as i − p + j − q.
Your program must replace each zero element in the matrix with the nearest nonzero one. If there are two or more nearest nonzeroes, the zero must be left in place.
No.  Input file (input.txt ) 
Output file (output.txt ) 

1 

