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 d1 d2… dk 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: | I. Ludov, A.Klenin | Time limit: | 2 sec | |
Input file: | input.txt | Memory limit: | 64 Mb | |
Output file: | output.txt |
A large software company has started a new high-budget project -- the game console platform called "Y-Sphere". The company is proud of its sophisticated development process standards, and has recently received a prestigious CMM (Capacity for Managers Maximization) certificate.
Using those powerful standards, it was easily calculated that the project will need precisely S developers. Now the only problem is how to manage them efficiently. Fortunately, CMM process has the answer: of course a proper management hierarchy is needed, that can be built by following few simple rules:
The company has managers of N different capacities. It has unlimited number of managers of each capacity.
Your program must plan a proper management hierarchy or determine that it is impossible.
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
Author: | I. Ludov | Time limit: | 2 sec | |
Input file: | input.txt | Memory limit: | 64 Mb | |
Output file: | output.txt |
In the year 2030 International Space Station 2 was launched. It had a torus shape to enable artificial gravity generation. (A torus is a circular tube with circular cross-section). Advanced spacesuit technology and micro-rocket engines allowed for prolonged and easy spacewalks.
During one such spacewalk a crew member was looking at the station from an open space and wondered where should he fly to get to the station surface as fast as possible. Since he was cosmonaut and not astronaut, he had good mathematics education. So after a return to the station he quickly wrote a program which constructed the shortest line from any given point in space to the surface of a given torus.
Can you do this too?
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 (r1, g1, b1) and (r2, g2, b2) are distinct if min(|r1 − r2|, |g1 − g2|, |b1 − b2|) ≥ 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: | 3 sec | |
Input file: | input.txt | Memory limit: | 64 Mb | |
Output file: | output.txt |
Consider an infinite plane divided into square cells with the side of 1. The spiral starts at cell (0, 0) and consists of N straight segments. First segment runs from the starting cell in the direction of x axis, each following segment takes a 90° turn to the right. Segment number i contains exactly ai cells.
Segments do not overlap except at joint cells, which are treated as belonging to both adjacent segments.
A square window on the plane consists of S × S cells and is defined by coordinates of top left cell (x, y) (y axis is directed upwards).
Your program will be given coordinates of K square windows, and must determine, for each window, the number of cells inside it belonging to the spiral.
For example, a spiral below is defined by input of sample test 3. Cells marked with 'x' are inside the first window from the same test.
x | x | x | |||
x | x | x | |||
x | x | x |
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
Author: | D. Vikharev | Time limit: | 2 sec | |
Input file: | input.txt | Memory limit: | 64 Mb | |
Output file: | output.txt |
As is customary, Ivan has shot an arrow to hit a potential bride. He did not know the local swamp was not inhabited by frogs -- neither regular nor princess ones. Anyway, the arrow did not fall into the swamp, but flew over to the other side. To retrieve it Ivan has to cross the swamp.
The swamp is a strip of width Y stretching indefinitely both to the east and to the west. Ivan stands at the southern border of the swamp, and wants to get to the northern border. Ivan has a map showing N hummocks capable of holding his weight.
Hummocks are too far from each other to jump, so Ivan has found a plank of length M to use as a bridge. Hummocks are also too slippery to stand on, so Ivan decided to break a plank in two parts (of lengths L and M − L) and use them to move in the following way: he would stand on first part, throw the second part over to the nearby hummock, step onto the second part, pick up the first part, walk with it across the second one. Repeating this procedure as necessary, Ivan hopes to reach the other side of the swamp as fast as possible.
Ivan can choose any value of L such that 0 < L < M. Important condition is that Ivan must always stand on the plank. He can, however, put both parts of the plank between the same two hummocks and/or use the parts in any order he wants (for example, put part 1 between hummocks A and B, move to hummock B, put part 2 between hummocks B and C, step onto part 2 staying at hummock B, pick part 1 and put it between B and D, move to hummock D taking part 2 with him).
Your program will be given the swamp width, plank length and hummocks coordinates. It must calculate the shortest distance Ivan has to walk to cross the swamp or determine that he can not do so. Distance is measured from hummock to hummock, even if plank part is longer than the distance between hummocks.
Output must contain a single floating point number -- the shortest distance Ivan has to travel with at least 3 correct decimal digits. If there is no solution, output must contain the number −1. An image below illustrates a solution to the first sample.
1 ≤ N ≤ 100, 1 ≤ Y, M ≤ 1000, 0 ≤ xi, yi ≤ 1000
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 |
|
|
Автор: | A. Klenin | Ограничение времени: | 5 сек | |
Входной файл: | input.txt | Ограничение памяти: | 64 Мб | |
Выходной файл: | output.txt |
Когда вы проектируете дизайн всплывающих диалоговых форм для интерактивных программ, важно назначить горячие клавиши (так же известные как клавиши быстрого доступа) на каждый элемент диалогового окна для ускорения работы через клавиатуру.
Для придания смысла, горячие клавиши, как правило, назначаются на основании первых букв в заголовке/названии активных элементов диалога. Ручное назначение горячих клавиш может быть утомительным занятием и не защищено от ошибок, т.к. необходимо следить за тем, чтобы случайно не назначить одну и ту же клавишу на разные элементы.
Вашей программе подается на вход список заголовков. Она должна будет назначить столько уникальных горячих клавиш, сколько вообще возможно. Каждая назначенная горячая клавиша должна быть символом соответсвующего заголовка элемента.
Для каждой комбинации позицией считается самое крайнее от начала строки (заголовка элемента) появление символа горячей клавиши. Из всех возможных решений с одинаковым количеством горячих клавиш, ваша программа должна выбрать единственное с минимальной суммой позиций горячих клавиш. Если решений с такой минимальной суммой несколько, то выведите любое из них.
Входной файл содержит количество заголовков N, за которым следует N строк с названиями заголовков.
Выходной файл должен содержать N строк с одинаковыми заголовками, как и во входном файле. В каждом заголовке, которому была назначена какая-то комбинации, перед самым левым вхождением символа из горячей клавиши необходимо добавить символ '&' (ASCII 38).
1 ≤ N ≤ 10, все заголовки имеют длину от 1 до 10 символов и состоят из строчных латинских букв.
№ | Входной файл (input.txt ) |
Выходной файл (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|