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 N2 × N2 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 N2.
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 | 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 than|less than|equal to|not 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: | I. Tuphanov | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Young programmer Vasya is learning the beginnings of the algorithm complexity theory. For starters, he wants to be able to quickly estimate the number of iterations of nested loops. As a first example, he wrote the following code:
C | Pascal |
long long f(int n) { long long ans = 0; for (int i = 1; i <= n; i++) for (int j = i+1; j <= n; j++) for (int k = j+1; k <= n; k++) ans++; return ans; } |
function f(n: integer): int64; var i, j, k: integer; begin result := 0; for i := 1 to n do for j := i+1 to n do for k := j+1 to n do inc(result); end; |
Using your knowledge of the subject,
help Vasya calculate f(n)
for given n.
Input file contains an integer n.
Output file must contain a single integer — f(n)
.
1 ≤ n ≤ 106
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | T.Chistyakov, A. Klenin | Time limit: | 2 sec | |
Input file: | input.txt | Memory limit: | 32 Mb | |
Output file: | output.txt |
At the running contest, jury used a new computerized stopwatch system to ensure the most accurate measuring of results. Unfortunately, despite very successfull trials, the system malfunctioned during the actual contest.
Jury was so confident in the new system that it did not use the old mechanical stopwatches. So the only way to determine outcome was to compare visual impressions of the people watching the contest. M such impressions were recorded, each in one of two forms: "runner A finished before runner B" and "runners A and B finished at the same time".
You task is to assign a place pi to each of N runners, such that
Additionally, places must be allocated as densely as possible, i.e. 1 ≤ pi ≤ K for minimum possible value of K.
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
Author: | T. Chistyakov, A. Klenin | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
For given integers P and N you need to find all such values of x < 10N, that N last digits of xP are non-zero and equal.
Fortunately, there is not so many numbers showing this property. For example, for P = 2 and N = 2 there exist only 4 of them:
12, 38, 62, 88
Output the number of existing numbers X, then all these numbers in any order.
2 ≤ P ≤ 100
2 ≤ N ≤ 9
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
Author: | A. Klenin | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 64 Mb | |
Output file: | output.txt |
Your task is the most trivial one: given non-negative integer N, output N + 1.
The only complication is that the integer is given in an unknown base between 2 and 36 inclusive. Because of that, your program should output all possible distinct answers in lexicographically increasing order.
N contains from 1 to 100 digits
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | A. Klenin | Time limit: | 2 sec | |
Input file: | input.txt | Memory limit: | 4 Mb | |
Output file: | output.txt |
Given the sequence of integers A1, A2, …, AN, find a number As such that there exists exactly one Am > As, and for all k ≠ m Ak ≤ As.
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: | StdAlg | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 16 Mb | |
Output file: | output.txt |
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
Автор: | А. Кленин | Ограничение времени: | 2 сек | |
Входной файл: | input.txt | Ограничение памяти: | 8 Мб | |
Выходной файл: | output.txt |
Для изготовления качественной табуретки необходимы 4 ножки одинаковой длины. На табуреткоизготовительную фабрику поступило N ножек, имеющих слегка различающиеся длины L1, L2, … LN. Научно-исследовательский отдел фабрики обнаружил, что выпуск табуреток можно увеличить, если укорачивать некоторые ножки. При этом отпиленная часть выбрасывается.
Требуется определить минимальное количество распилов, необходимых для для изготовления N / 4 качественных табуреток.
Входной файл содержит число N, за которым следуют N чисел Li — длины ножек. Все числа целые.
№ | Входной файл (input.txt ) |
Выходной файл (output.txt ) |
---|---|---|
1 |
|
|
Автор: | X командный чемпионат Санкт-Петербурга по программированию - V Открытая Кировская командная олимпиада | Ограничение времени: | 2 сек | |
Входной файл: | a.in | Ограничение памяти: | 8 Мб | |
Выходной файл: | a.out |
Одна из команд-участниц олимпиады решила вернуться домой на электричках. При этом ребята хотят попасть домой как можно раньше. К сожалению, не все электрички идут от города, где проводится олимпиада, до станции, на которой живут ребята. И, что еще более обидно, не все электрички, которые идут мимо их станции, останавливаются на ней (равно как вообще, электрички останавливаются далеко не на всех станциях, мимо которых они идут).
Все станции на линии пронумерованы числами от 1 до N. При этом станция номер 1 находится в городе, где проводится олимпиада, и в момент времени 0 ребята приходят на станцию. Станция, на которую нужно попасть ребятам, имеет номер E.
Напишите программу, которая по данному расписанию движения электричек вычисляет минимальное время, за которое ребятам удастся добраться домой.
№ | Входной файл (a.in ) |
Выходной файл (a.out ) |
---|---|---|
1 |
|
|
Автор: | Известная | Ограничение времени: | 2 сек | |
Входной файл: | input.txt | Ограничение памяти: | 256 Мб | |
Выходной файл: | output.txt |
Дана последовательность из N целых чисел. Для каждого числа вывести ближайшее к нему справа в этой последовательности, которое будет больше него. Для чисел, которым найти ближайшее большее не удалось, вывести сами эти числа.
Входной файл содержит целое число N за которым следует N целых чисел ai - исходная последовательность.
В выходной файл необходимо вывести N целых чисел bi, таких что bi является ответом на задачу для числа ai.
1 ≤ N ≤ 106
|ai| ≤ 109
№ | Входной файл (input.txt ) |
Выходной файл (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | A. Klenin | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Consider a sequence of numbers a1, …, aN, representing heights. Let's say that element ai has a visibility radius d if ai ≥ aj for all j such that 1 ≤ j ≤ N and |i − j| < d.
You task is to find maximum di for every ai.
Input file contains integer N followed by N integers ai.
Output file must contain N integers di — maximum visibility for every ai. If maximum visibility radius for element ai is unlimited, output di = 0.
1 ≤ N ≤ 106, 0 ≤ ai ≤ 109
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | StdAlg | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 8 Mb | |
Output file: | output.txt |
You are to write a program that performs a topological sorting of a directed graph. Graph contains N vertices, numbered with integers from 1 to N, and M edges.
In other words, given a partial order on numbers from 1 to N, your program must produce some linear order on these numbers which does not conflict with the given partial order.
These pairs may also be considered comparisons where the first number precedes the second one.
Output file must contain a permutation of integers from 1 to N — numbers of vertices sorted in topological order. (That is, representing a linear order.) If ordering is not possible, output file must contain a single number − 1.
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|