problem_statement
stringlengths
147
8.53k
input
stringlengths
1
771
output
stringlengths
1
592
time_limit
stringclasses
32 values
memory_limit
stringclasses
21 values
tags
stringlengths
6
168
E. Fixed Pointstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a sequence of integers a_1, a_2, \ldots, a_n. In one move, you can select any element of the sequence and delete it. After an element is deleted, all elements to the right are shifted to the left...
4 7 6 1 1 2 3 4 5 6 5 2 5 1 3 2 3 5 2 5 5 5 5 4 8 4 1 2 3 3 2 2 5 5
1 2 -1 2
1 second
256 megabytes
['binary search', 'brute force', 'dp', '*2000']
D2. Domino (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and D1 is that you don't have to provide the way to construct the answer in D1, but you have to do it in this problem.There's a table of n \times m cells...
8 4 4 2 2 3 0 3 2 3 1 2 0 2 4 2 5 2 2 2 17 16 2 1 1
YES accx aegx bega bdda YES aha aha YES zz aa zz NO YES aaza bbza NO YES bbaabbaabbaabbaay ddccddccddccddccy NO
1 second
256 megabytes
['constructive algorithms', 'implementation', 'math', '*2100']
D1. Domino (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and D2 is that you don't have to provide the way to construct the answer in this problem, but you have to do it in D2.There's a table of n \times m cells...
8 4 4 2 2 3 0 3 2 3 1 2 0 2 4 2 5 2 2 2 17 16 2 1 1
YES YES YES NO YES NO YES NO
1 second
256 megabytes
['constructive algorithms', 'math', '*1700']
C. Interesting Storytime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputStephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!To compose a story, Stephen wrote out n words consisting of the first 5 lowercase l...
6 3 bac aaada e 3 aba abcde aba 2 baba baba 4 ab ab c bc 5 cbdca d a d e 3 b c ca
3 2 0 2 3 2
4 seconds
256 megabytes
['greedy', 'sortings', 'strings', '*1500']
B2. Wonderful Coloring - 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is an extension of the problem "Wonderful Coloring - 1". It has quite many differences, so you should read this statement completely.Recently, Paul and Mary have found a new favor...
6 10 3 3 1 1 1 1 10 3 10 10 2 4 4 1 1 1 1 1 1 1 13 1 3 1 4 1 5 9 2 6 5 3 5 8 9 13 2 3 1 4 1 5 9 2 6 5 3 5 8 9 13 3 3 1 4 1 5 9 2 6 5 3 5 8 9
1 1 0 2 3 2 2 1 3 3 4 2 1 3 1 0 0 1 1 0 1 1 1 0 1 1 1 0 2 1 2 2 1 1 1 1 2 1 0 2 2 1 1 3 2 1 3 3 1 2 2 3 2 0
2 seconds
256 megabytes
['binary search', 'constructive algorithms', 'data structures', 'greedy', '*1400']
B1. Wonderful Coloring - 1time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a simplified version of the problem B2. Perhaps you should read the problem B2 before you start solving B1.Paul and Mary have a favorite string s which consists of lowercase letters of ...
5 kzaaa codeforces archive y xxxxxx
2 5 3 0 1
1 second
256 megabytes
['greedy', 'strings', '*800']
A. Polycarp and Coinstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp must pay exactly n burles at the checkout. He has coins of two nominal values: 1 burle and 2 burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of...
6 1000 30 1 32 1000000000 5
334 333 10 10 1 0 10 11 333333334 333333333 1 2
1 second
256 megabytes
['greedy', 'math', '*800']
F. Jumping Aroundtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an infinite pond that can be represented with a number line. There are n rocks in the pond, numbered from 1 to n. The i-th rock is located at an integer coordinate a_i. The coordinates of the ...
7 4 4 5 1 5 10 13 20 22 28 4 1 7 2 7 3 3 2
Yes No Yes Yes
5 seconds
256 megabytes
['binary search', 'data structures', 'divide and conquer', 'dp', 'dsu', 'graphs', 'shortest paths', '*2700']
E. Stringforcestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s of length n. Each character is either one of the first k lowercase Latin letters or a question mark.You are asked to replace every question mark with one of the first k lowercase...
10 2 a??ab????b
4
3 seconds
256 megabytes
['binary search', 'bitmasks', 'brute force', 'dp', 'strings', 'two pointers', '*2500']
D. Excellent Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call an integer array a_1, a_2, \dots, a_n good if a_i \neq i for each i.Let F(a) be the number of pairs (i, j) (1 \le i < j \le n) such that a_i + a_j = i + j.Let's say that an array a_1, a_2,...
4 3 0 3 4 -3 5 42 -33 55 69 -42 146
4 10 143922563 698570404
2 seconds
256 megabytes
['binary search', 'combinatorics', 'constructive algorithms', 'implementation', 'math', 'sortings', 'two pointers', '*2300']
C. Manhattan Subarraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.Let's say that three points p, q, r form a ba...
3 4 2 4 1 3 5 6 9 1 9 6 2 13 37
10 12 3
2 seconds
256 megabytes
['brute force', 'geometry', 'greedy', 'implementation', '*1700']
B. Maximum Cost Deletiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s of length n consisting only of the characters 0 and 1.You perform the following operation until the string becomes empty: choose some consecutive substring of equal char...
3 3 2 0 000 5 -2 5 11001 6 1 -4 100111
6 15 -2
2 seconds
256 megabytes
['greedy', 'math', '*1000']
A. Find The Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call an array a consisting of n positive (greater than 0) integers beautiful if the following condition is held for every i from 1 to n: either a_i = 1, or at least one of the numbers a_i - 1 and ...
4 1 8 7 42
1 3 3 7
1 second
256 megabytes
['greedy', 'math', '*800']
B. Gregor and the Pawn Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a chessboard of size n by n. The square in the i-th row from top and j-th column from the left is labelled (i,j).Currently, Gregor has some pawns in the n-th row. There are also enemy...
4 3 000 111 4 1111 1111 3 010 010 5 11001 00000
3 4 0 0
1 second
256 megabytes
['dfs and similar', 'dp', 'flows', 'graph matchings', 'graphs', 'greedy', 'implementation', '*800']
A. Gregor and Cryptographytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.Gregor's favorite prime number is P. Greg...
2 17 5
3 5 2 4
1 second
256 megabytes
['math', 'number theory', '*800']
E. Gregor and the Two Painterstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo painters, Amin and Benj, are repainting Gregor's living room ceiling! The ceiling can be modeled as an n \times m grid.For each i between 1 and n, inclusive, painter Amin applies a_i l...
3 4 11 9 8 5 10 6 7 2
2
4 seconds
256 megabytes
['data structures', 'divide and conquer', 'graphs', 'greedy', 'math', '*3400']
D2. Gregor and the Odd Cows (Hard)time limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference from the easy version is that in this version the coordinates can be both odd and even.There are n fence-posts at distinct ...
3 0 0 2 0 0 4
1
6 seconds
256 megabytes
['brute force', 'geometry', 'math', 'number theory', '*3300']
D1. Gregor and the Odd Cows (Easy)time limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference from the hard version is that in this version all coordinates are even.There are n fence-posts at distinct coordinates on a...
3 0 0 2 0 0 4
1
6 seconds
256 megabytes
['bitmasks', 'geometry', 'math', 'number theory', '*2300']
C. The Three Little Pigstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThree little pigs from all over the world are meeting for a convention! Every minute, a triple of 3 new pigs arrives on the convention floor. After the n-th minute, the convention ends.The big ba...
2 3 1 5 6
9 6 1
1 second
512 megabytes
['combinatorics', 'dp', 'fft', 'math', '*2500']
B. Integers Have Friendstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBritish mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that "every positive integer was one of his personal friends."It turns out that positive integers c...
4 5 1 5 2 4 6 4 8 2 5 10 2 1000 2000 8 465 55 3 54 234 12 45 78
3 3 2 6
2 seconds
256 megabytes
['binary search', 'data structures', 'divide and conquer', 'math', 'number theory', 'two pointers', '*1800']
A. Web of Liestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen you play the game of thrones, you win, or you die. There is no middle ground.Cersei Lannister, A Game of Thrones by George R. R. MartinThere are n nobles, numbered from 1 to n. Noble i has a power of...
4 3 2 1 1 3 3 4 4 3 1 2 3 2 3 1 3
2 1
2 seconds
256 megabytes
['brute force', 'graphs', 'greedy', '*1400']
G. How Many Paths?time limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a directed graph G which can contain loops (edges from a vertex to itself). Multi-edges are absent in G which means that for all ordered pairs (u, v) exists at most one edge from u to v....
5 6 7 1 4 1 3 3 4 4 5 2 1 5 5 5 6 1 0 3 3 1 2 2 3 3 1 5 0 4 4 1 2 2 3 1 4 4 3
1 0 1 2 -1 -1 1 -1 -1 -1 1 0 0 0 0 1 1 2 1
4 seconds
512 megabytes
['dfs and similar', 'dp', 'graphs', 'trees', '*2100']
F. Array Stabilization (GCD version)time limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array of positive integers a = [a_0, a_1, \dots, a_{n - 1}] (n \ge 2).In one step, the array a is replaced with another array of length n, in which each element is t...
5 4 16 24 10 5 4 42 42 42 42 3 4 6 4 5 1 2 3 4 5 6 9 9 27 9 9 63
3 0 2 1 1
4 seconds
512 megabytes
['binary search', 'brute force', 'data structures', 'divide and conquer', 'number theory', 'two pointers', '*1900']
E. Air Conditionerstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOn a strip of land of length n there are k air conditioners: the i-th air conditioner is placed in cell a_i (1 \le a_i \le n). Two or more air conditioners cannot be placed in the same cell (i.e. all...
5 6 2 2 5 14 16 10 1 7 30 5 5 3 1 4 2 5 3 1 4 2 5 7 1 1 1000000000 6 3 6 1 3 5 5 5
15 14 15 16 16 17 36 35 34 33 32 31 30 31 32 33 1 2 3 4 5 1000000000 1000000001 1000000002 1000000003 1000000004 1000000005 1000000006 5 6 5 6 6 5
2 seconds
512 megabytes
['data structures', 'dp', 'implementation', 'shortest paths', 'sortings', 'two pointers', '*1500']
D. Co-growing Sequencetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA sequence of non-negative integers a_1, a_2, \dots, a_n is called growing if for all i from 1 to n - 1 all ones (of binary representation) in a_i are in the places of ones (of binary representati...
5 4 1 3 7 15 4 1 2 4 8 5 1 2 3 4 5 4 11 13 15 1 1 0
0 0 0 0 0 1 3 7 0 1 0 3 2 0 2 0 14 0
2 seconds
512 megabytes
['bitmasks', 'constructive algorithms', 'greedy', '*1300']
C. Pair Programmingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMonocarp and Polycarp are learning new programming techniques. Now they decided to try pair programming.It's known that they have worked together on the same file for n + m minutes. Every minute exac...
5 3 2 2 2 0 0 5 4 3 2 2 0 5 0 6 0 2 2 1 0 2 3 5 4 4 6 0 8 0 0 7 0 9 5 4 1 8 7 8 0 0
2 0 0 5 0 2 0 6 5 -1 0 6 0 7 0 8 0 9 -1
2 seconds
512 megabytes
['greedy', 'two pointers', '*1100']
B. Alphabetical Stringstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA string s of length n (1 \le n \le 26) is called alphabetical if it can be obtained using the following algorithm: first, write an empty string to s (i.e. perform the assignment s := ""); then...
11 a ba ab bac ihfcbadeg z aa ca acb xyz ddcba
YES YES YES YES YES NO NO NO NO NO NO
2 seconds
512 megabytes
['greedy', 'implementation', 'strings', '*800']
A. Shortest Path with Obstacletime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are three cells on an infinite 2-dimensional grid, labeled A, B, and F. Find the length of the shortest path from A to B if: in one move you can go to any of the four adjacent cell...
7 1 1 3 3 2 2 2 5 2 1 2 3 1000 42 1000 1 1000 1000 1 10 3 10 2 10 3 8 7 8 3 7 2 1 4 1 1 1 1 344 1 10 1 1
4 6 41 4 4 2 334
2 seconds
512 megabytes
['implementation', 'math', '*800']
B. AquaMoon and Stolen Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAquaMoon had n strings of length m each. n is an odd number.When AquaMoon was gone, Cirno tried to pair these n strings together. After making \frac{n-1}{2} pairs, she found out that there w...
3 3 5 aaaaa bbbbb ccccc aaaaa bbbbb 3 4 aaaa bbbb cccc aabb bbaa 5 6 abcdef uuuuuu kekeke ekekek xyzklm xbcklf eueueu ayzdem ukukuk
ccccc cccc kekeke
1 second
256 megabytes
['interactive', 'math', '*1200']
A. AquaMoon and Two Arraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAquaMoon and Cirno are playing an interesting game with arrays. Cirno has prepared two arrays a and b, both consist of n non-negative integers. AquaMoon can perform the following operation an a...
4 4 1 2 3 4 3 1 2 4 2 1 3 2 1 1 0 0 5 4 3 2 1 0 0 1 2 3 4
2 2 1 3 1 -1 0 6 1 4 1 4 1 5 1 5 2 5 2 5
1 second
256 megabytes
['brute force', 'greedy', '*800']
F. AquaMoon and Potatoestime limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAquaMoon has three integer arrays a, b, c of length n, where 1 \leq a_i, b_i, c_i \leq n for all i.In order to accelerate her potato farming, she organizes her farm in a manner based on these th...
5 4 1 2 3 4 5 2 3 4 5 1 5 1 2 3 4 2 5 1 2 3 2 4 2 5
3 0 2
7 seconds
512 megabytes
['brute force', 'data structures', 'dp', '*3500']
E2. AquaMoon and Time Stop (hard version)time limit per test7 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputNote that the differences between easy and hard versions are the constraints on n and the time limit. You can make hacks only if both versions are solved.AquaMoon knew through ...
2 1 1 2 1 2 2 3 2 3
2
7 seconds
1024 megabytes
['data structures', 'dp', '*3500']
E1. AquaMoon and Time Stop (easy version)time limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputNote that the differences between easy and hard versions are the constraints on n and the time limit. You can make hacks only if both versions are solved.AquaMoon knew through ...
2 1 1 2 1 2 2 3 2 3
2
3 seconds
1024 megabytes
['data structures', 'dp', '*3500']
D. AquaMoon and Wrong Coordinatetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCirno gives AquaMoon a problem. There are m people numbered from 0 to m - 1. They are standing on a coordinate axis in points with positive integer coordinates. They are facing right (i....
5 7 6 9 9 6 9 10 7 10 8 10 11 11 11 10 8 12 12 12 12 9 14 13 12 10 13 11 14 16 14 14 12 15 18 15 15
4 13
2 seconds
256 megabytes
['constructive algorithms', 'interactive', 'math', '*3000']
C. AquaMoon and Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCirno has prepared n arrays of length n each. Each array is a permutation of n integers from 1 to n. These arrays are special: for all 1 \leq i \leq n, if we take the i-th element of each ar...
3 7 1 2 3 4 5 6 7 2 3 4 5 6 7 1 3 4 5 6 7 1 2 4 5 6 7 1 2 3 5 6 7 1 2 3 4 6 7 1 2 3 4 5 7 1 2 3 4 5 6 1 2 3 4 5 7 6 1 3 4 5 6 7 2 1 4 5 6 7 3 2 1 5 6 7 4 2 3 1 6 7 5 2 3 4 1 7 6 2 3 4 5 1 7 2 3 4 5 6 5 4 5 1 2 3 3 5 2 4 1 1 2 3 4 5 5 2 4 1 3 3 4 5 1 2 2 3 4 5 1 1 3 5 2 4 4 1 3 5 2 2 4 1 3 5 5 1 2 3 4 6 2 3 4 5 6 1 3 1 ...
1 1 2 3 4 5 6 7 2 1 3 5 6 10 4 1 3 6 7 8 9
2 seconds
256 megabytes
['2-sat', 'brute force', 'combinatorics', 'constructive algorithms', 'graph matchings', 'graphs', '*2800']
B. AquaMoon and Chesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCirno gave AquaMoon a chessboard of size 1 \times n. Its cells are numbered with integers from 1 to n from left to right. In the beginning, some of the cells are occupied with at most one pawn, and ...
6 4 0110 6 011011 5 01010 20 10001111110110111000 20 00110110100110111101 20 11101111011000100010
3 6 1 1287 1287 715
1 second
256 megabytes
['combinatorics', 'math', '*1900']
A. AquaMoon and Strange Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAquaMoon has n friends. They stand in a row from left to right, and the i-th friend from the left wears a T-shirt with a number a_i written on it. Each friend has a direction (left or right)....
3 4 4 3 2 5 4 3 3 2 2 5 1 2 3 5 4
YES YES NO
1 second
256 megabytes
['sortings', '*1500']
E. The Final Pursuittime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFinally, you have defeated Razor and now, you are the Most Wanted street racer. Sergeant Cross has sent the full police force after you in a deadly pursuit. Fortunately, you have found a hiding spot...
3 1 0 1 2 0 1 1 2 2 3 3 0 3 0 1 0 5 0 7 1 2 1 4 2 5 2 6 3 5 3 6 3 7 4 6 4 7
0 1 0 0 0 1 3 2 0 0 1 1 5 3 0 7 2 6 1 4 -1
3 seconds
256 megabytes
['bitmasks', 'constructive algorithms', 'divide and conquer', 'graphs', 'greedy', 'math', '*2700']
D2. RPD and Rap Sheet (Hard Version)time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that here 2\leq k\leq 100. You can make hacks only if both the versions of the problem are solved.This is an interacti...
2 5 2 0 0 1 5 3 0 0 1
3 4 5 1 4 6
5 seconds
256 megabytes
['brute force', 'constructive algorithms', 'interactive', 'math', '*2200']
D1. RPD and Rap Sheet (Easy Version)time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is that here k=2. You can make hacks only if both the versions of the problem are solved.This is an interactive problem.E...
1 5 2 0 0 1
3 4 5
5 seconds
256 megabytes
['bitmasks', 'constructive algorithms', 'interactive', 'math', '*1700']
C. Need for Pink Slipstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter defeating a Blacklist Rival, you get a chance to draw 1 reward slip out of x hidden valid slips. Initially, x=3 and these hidden valid slips are Cash Slip, Impound Strike Release Marker and P...
4 0.2 0.2 0.6 0.2 0.4 0.2 0.4 0.8 0.4998 0.4998 0.0004 0.1666 0.3125 0.6561 0.0314 0.2048
1.532000000000 1.860000000000 5.005050776521 4.260163673896
1 second
256 megabytes
['bitmasks', 'brute force', 'dfs and similar', 'implementation', 'math', 'probabilities', '*1900']
B. Customising the Tracktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHighway 201 is the most busy street in Rockport. Traffic cars cause a lot of hindrances to races, especially when there are a lot of them. The track which passes through this highway can be divid...
3 3 1 2 3 4 0 1 1 0 10 8 3 6 11 5 2 1 7 10 4
0 4 21
1 second
256 megabytes
['combinatorics', 'greedy', 'math', '*900']
A. Exciting Betstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWelcome to Rockport City!It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappo...
4 8 5 1 2 4 4 3 9
3 1 1 0 0 0 6 3
1 second
256 megabytes
['greedy', 'math', 'number theory', '*900']
E2. Abnormal Permutation Pairs (hard version)time limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference between the easy version and the hard version is the constraints on n. You can only make hacks if both versions ...
4 403458273
17
4 seconds
512 megabytes
['combinatorics', 'dp', 'fft', 'math', '*2700']
E1. Abnormal Permutation Pairs (easy version)time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference between the easy version and the hard version is the constraints on n. You can only make hacks if both versions a...
4 403458273
17
1 second
512 megabytes
['combinatorics', 'dp', 'fft', 'math', '*2400']
D. Priority Queuetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a sequence A, where its elements are either in the form + x or -, where x is an integer.For such a sequence S where its elements are either in the form + x or -, define f(S) as follows: ...
4 - + 1 + 2 -
16
3 seconds
512 megabytes
['combinatorics', 'dp', 'implementation', 'math', 'ternary search', '*2200']
C. Strange Functiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet f(i) denote the minimum positive integer x such that x is not a divisor of i.Compute \sum_{i=1}^n f(i) modulo 10^9+7. In other words, compute f(1)+f(2)+\dots+f(n) modulo 10^9+7.InputThe first line...
6 1 2 3 4 10 10000000000000000
2 5 7 10 26 366580019
1 second
256 megabytes
['math', 'number theory', '*1600']
B. Plus and Multiplytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere is an infinite set generated as follows: 1 is in this set. If x is in this set, x \cdot a and x+b both are in this set. For example, when a=3 and b=6, the five smallest elements of the set a...
5 24 3 5 10 3 6 2345 1 4 19260817 394 485 19260817 233 264
Yes No Yes No Yes
3 seconds
512 megabytes
['constructive algorithms', 'math', 'number theory', '*1500']
A. Odd Settime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a multiset (i. e. a set that can contain multiple equal integers) containing 2n integers. Determine if you can split it into exactly n pairs (i. e. each element should be in exactly one pair) so ...
5 2 2 3 4 5 3 2 3 4 5 5 5 1 2 4 1 2 3 4 1 5 3 2 6 7 3 4
Yes No No Yes No
1 second
256 megabytes
['math', '*800']
B. Pleasant Pairstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots, a_n consisting of n distinct integers. Count the number of pairs of indices (i, j) such that i < j and a_i \cdot a_j = i + j.InputThe first line contains one int...
3 2 3 1 3 6 1 5 5 3 1 5 9 2
1 1 3
2 seconds
256 megabytes
['brute force', 'implementation', 'math', 'number theory', '*1200']
A. Pretty Permutationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cats in a line, labeled from 1 to n, with the i-th cat at position i. They are bored of gyrating in the same spot all day, so they want to reorder themselves such that no cat is in the ...
2 2 3
2 1 3 1 2
1 second
256 megabytes
['constructive algorithms', 'greedy', 'implementation', '*800']
E. Tasty Dishestime limit per test10 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputNote that the memory limit is unusual.There are n chefs numbered 1, 2, \ldots, n that must prepare dishes for a king. Chef i has skill i and initially has a dish of tastiness a_i where |a_i| \leq i. Each...
5 1 0 -2 -2 4 4 2 3 4 5 1 3 1 4 1 5 0 7 1 1 1 5 2 4 3 1 1 1 5 2 3 2 1 2 2 4 2 5 1 1 981 4 5
57 71 316 278497818
10 seconds
64 megabytes
['math', 'matrices', '*3500']
D. Inverse Inversionstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou were playing with permutation p of length n, but you lost it in Blair, Alabama!Luckily, you remember some information about the permutation. More specifically, you remember an array b of length...
3 0 0 0 7 2 1 2 2 2 3 1 2 1 2 1 2 2 2 3
1 2 3 2 1 3
5 seconds
512 megabytes
['binary search', 'brute force', 'data structures', '*3200']
C2. Converging Array (Hard Version)time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that in this version 1 \le q \le 10^5. You can make hacks only if both versions of the problem are solved.There is a pr...
3 2 3 4 2 1 5 -1 0 1 -100000 100000
56 28 4 60 0
5 seconds
256 megabytes
['dp', 'math', '*2900']
C1. Converging Array (Easy Version)time limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.There is a process that ...
3 2 3 4 2 1 1 -1
56
5 seconds
256 megabytes
['dp', 'math', '*2700']
B. Tree Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n nodes. You generate an array from the tree by marking nodes one by one.Initially, when no nodes are marked, a node is equiprobably chosen and marked from the entire tre...
3 1 2 1 3
166666669
2 seconds
256 megabytes
['brute force', 'combinatorics', 'dp', 'graphs', 'math', 'probabilities', 'trees', '*2300']
A. Great Graphstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFarmer John has a farm that consists of n pastures connected by one-directional roads. Each road has a weight, representing the time it takes to go from the start to the end of the road. The roads could ...
3 3 0 2 3 2 0 1000000000 1 0
-3 0 0
2 seconds
256 megabytes
['constructive algorithms', 'graphs', 'greedy', 'shortest paths', 'sortings', '*1400']
F. Strange Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya has an array of n integers a_1, a_2, \ldots, a_n. Vasya thinks that all numbers in his array are strange for some reason. To calculate how strange the i-th number is, Vasya created the following a...
5 5 4 3 2 1
2 1 1 2 2
2 seconds
256 megabytes
['data structures', 'greedy', 'sortings', '*2600']
E. Game with Cardstime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Alice's computer is broken, so she can't play her favorite card game now. To help Alice, Bob wants to answer n her questions. Initially, Bob holds one card with number 0 in the left hand and one...
2 10 3 0 3 0 2 2 0 4 0 2
Yes 0 1
2.5 seconds
256 megabytes
['binary search', 'constructive algorithms', 'data structures', 'dp', 'greedy', 'implementation', '*2500']
D. PriceFixedtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store  — "PriceFixed". Here are some rules of that store: The store ha...
3 3 4 1 3 1 5
8
1 second
256 megabytes
['binary search', 'greedy', 'implementation', 'sortings', 'two pointers', '*1600']
C. Stable Groupstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n students numerated from 1 to n. The level of the i-th student is a_i. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their ...
8 2 3 1 1 5 8 12 13 20 22
2
1 second
256 megabytes
['greedy', 'sortings', '*1200']
B. Love Songtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up q questions about this song. Each question is about a subsegment of the s...
7 3 abacaba 1 3 2 5 1 7
4 7 11
2 seconds
256 megabytes
['dp', 'implementation', 'strings', '*800']
A. Contest Starttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n people participating in some contest, they start participating in x minutes intervals. That means the first participant starts at time 0, the second participant starts at time x, the third — ...
4 4 2 5 3 1 2 3 3 10 2000000000 1 2000000000
5 3 3 1999999999000000000
1 second
256 megabytes
['combinatorics', 'geometry', 'greedy', 'math', '*1000']
G. Gift Settime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has x of red and y of blue candies. Using them, he wants to make gift sets. Each gift set contains either a red candies and b blue candies, or a blue candies and b red candies. Any candy can belong ...
9 10 12 2 5 1 1 2 2 52 311 13 27 1000000000 1000000000 1 1 1000000000 1 1 1000000000 1 1000000000 1000000000 1 1 2 1 1 7 8 1 2 4 1 2 3
3 0 4 1000000000 1 1 1 5 0
2 seconds
256 megabytes
['binary search', 'greedy', 'math', 'ternary search', '*2100']
F. Interesting Functiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers l and r, where l < r. We will add 1 to l until the result is equal to r. Thus, there will be exactly r-l additions performed. For each such addition, let's look at the ...
4 1 9 9 10 10 20 1 1000000000
8 2 11 1111111110
2 seconds
256 megabytes
['binary search', 'dp', 'math', 'number theory', '*1500']
E. Funny Substringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp came up with a new programming language. There are only two types of statements in it: "x := s": assign the variable named x the value s (where s is a string). For example, the statement v...
4 6 a := h b := aha c = a + b c = c + c e = c + c d = a + c 15 x := haha x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x x = x + x 1 haha := hah 5 haahh := aaaha ahhhh = haahh + haahh haahh = haahh + haahh ahhhh = ahhhh + haahh ahhaa = ha...
3 32767 0 0
2 seconds
256 megabytes
['data structures', 'hashing', 'implementation', 'matrices', 'strings', '*2100']
D. Another Problem About Dividing Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers a and b. In one turn, you can do one of the following operations: Take an integer c (c > 1 and a should be divisible by c) and replace a with \frac{...
8 36 48 2 36 48 3 36 48 4 2 8 1 2 8 2 1000000000 1000000000 1000000000 1 2 1 2 2 1
YES YES YES YES YES NO YES NO
2 seconds
256 megabytes
['constructive algorithms', 'math', 'number theory', '*1700']
C. Number of Pairstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers. Find the number of pairs (i, j) (1 \le i < j \le n) where the sum of a_i + a_j is greater than or equal to l and less than or equal to r (that is, l \le a_i + a...
4 3 4 7 5 1 2 5 5 8 5 1 2 4 3 4 100 1000 1 1 1 1 5 9 13 2 5 5 1 1
2 7 0 1
2 seconds
256 megabytes
['binary search', 'data structures', 'math', 'two pointers', '*1300']
B. Friends and Candiestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has n friends, the i-th of his friends has a_i candies. Polycarp's friends do not like when they have different numbers of candies. In other words they want all a_i to be the same. To sol...
5 4 4 5 2 5 2 0 4 5 10 8 5 1 4 1 10000 7 1 1 1 1 1 1 1
2 1 -1 0 0
2 seconds
256 megabytes
['greedy', 'math', '*800']
A. Stone Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.Each turn Polycarp can destroy either ston...
5 5 1 5 4 3 2 8 2 1 3 4 5 6 8 7 8 4 2 3 1 8 6 7 5 4 3 4 2 1 4 2 3 1 4
2 4 5 3 2
2 seconds
256 megabytes
['brute force', 'dp', 'greedy', '*800']
F. Figure Fixingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a connected undirected graph made of n nodes and m edges. The i-th node has a value v_i and a target value t_i.In an operation, you can choose an edge (i, j) and add k to both v_i and v_j, wher...
2 4 4 5 1 2 -3 3 3 10 1 1 2 1 4 3 2 3 4 4 4 5 8 6 6 -3 1 15 4 1 2 1 4 3 2 3 4
YES NO
2 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'math', '*2200']
E2. Erase and Extend (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is the constraints on n and k. You can make hacks only if all versions of the problem are solved.You have a string s, and ...
8 16 dbcadabc
dbcadabcdbcadabc
2 seconds
256 megabytes
['binary search', 'data structures', 'greedy', 'hashing', 'string suffix structures', 'strings', 'two pointers', '*2200']
E1. Erase and Extend (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is the constraints on n and k. You can make hacks only if all versions of the problem are solved.You have a string s, and ...
8 16 dbcadabc
dbcadabcdbcadabc
2 seconds
256 megabytes
['binary search', 'brute force', 'dp', 'greedy', 'hashing', 'implementation', 'string suffix structures', 'strings', 'two pointers', '*1600']
D. Deleting Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game. They start with a positive integer n and take alternating turns doing operations on it. Each turn a player can subtract from n one of its divisors that isn't 1 or n...
4 1 4 12 69
Bob Alice Alice Bob
2 seconds
256 megabytes
['games', 'math', 'number theory', '*1700']
C. Challenging Cliffstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are a game designer and want to make an obstacle course. The player will walk from left to right. You have n heights of mountains already selected and want to arrange them so that the absolute ...
2 4 4 2 1 2 2 3 1
2 4 1 2 1 3
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'implementation', 'math', '*1200']
B. Bad Boytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRiley is a very bad boy, but at the same time, he is a yo-yo master. So, he decided to use his yo-yo skills to annoy his friend Anton.Anton's room can be represented as a grid with n rows and m columns. Let (i...
7 2 3 1 1 4 4 1 2 3 5 2 2 5 1 2 1 3 1 3 1 1 1 1 1 1000000000 1000000000 1000000000 50
1 2 2 3 4 1 4 4 3 1 1 5 5 1 1 1 1 1 2 1 1 1 1 1 50 1 1 1000000000
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*900']
A. Arithmetic Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn array b of length k is called good if its arithmetic mean is equal to 1. More formally, if \frac{b_1 + \cdots + b_k}{k}=1.Note that the value \frac{b_1+\cdots+b_k}{k} is not rounded up or down. For...
4 3 1 1 1 2 1 2 4 8 4 6 2 1 -2
0 1 16 1
1 second
256 megabytes
['greedy', 'math', '*800']
F. Omkar and Akmartime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar and Akmar are playing a game on a circular board with n (2 \leq n \leq 10^6) cells. The cells are numbered from 1 to n so that for each i (1 \leq i \leq n-1) cell i is adjacent to cell i+1 and c...
2
4
3 seconds
256 megabytes
['chinese remainder theorem', 'combinatorics', 'constructive algorithms', 'fft', 'games', 'geometry', 'math', 'meet-in-the-middle', 'string suffix structures', '*2600']
E. Omkar and Foresttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar's most recent follower, Ajit, has entered the Holy Forest. Ajit realizes that Omkar's forest is an n by m grid (1 \leq n, m \leq 2000) of some non-negative integers. Since the forest is blessed...
4 3 4 0000 00#0 0000 2 1 # # 1 2 ## 6 29 ############################# #000##0###0##0#0####0####000# #0#0##00#00##00####0#0###0#0# #0#0##0#0#0##00###00000##00## #000##0###0##0#0##0###0##0#0# #############################
2 3 3 319908071
2 seconds
256 megabytes
['combinatorics', 'graphs', 'math', 'shortest paths', '*2300']
D. Omkar and Medianstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputUh oh! Ray lost his array yet again! However, Omkar might be able to help because he thinks he has found the OmkArray of Ray's array. The OmkArray of an array a with elements a_1, a_2, \ldots, a_{2k...
5 4 6 2 1 3 1 4 5 4 -8 5 6 -7 2 3 3 4 2 1 2 3
NO YES NO YES YES
2 seconds
256 megabytes
['data structures', 'greedy', 'implementation', '*2000']
C. Diluc and Kaeyatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe tycoon of a winery empire in Mondstadt, unmatched in every possible way. A thinker in the Knights of Favonius with an exotic appearance.This time, the brothers are dealing with a strange piece of ...
5 3 DDK 6 DDDDDD 4 DKDK 1 D 9 DKDKDDDDK
1 2 1 1 2 3 4 5 6 1 1 1 2 1 1 1 1 2 1 2 1 1 3
2 seconds
256 megabytes
['data structures', 'dp', 'hashing', 'number theory', '*1500']
B. Prinzessin der Verurteilungtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputI, Fischl, Prinzessin der Verurteilung, descend upon this land by the call of fate an — Oh, you are also a traveler from another world? Very well, I grant you permission to travel with me....
3 28 qaabzwsxedcrfvtgbyhnujmiklop 13 cleanairactbd 10 aannttoonn
ac f b
2 seconds
256 megabytes
['brute force', 'constructive algorithms', 'strings', '*1200']
A. Omkar and Bad Storytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar has received a message from Anton saying "Your story for problem A is confusing. Just make a formal statement." Because of this, Omkar gives you an array a = [a_1, a_2, \ldots, a_n] of n dis...
4 3 3 0 9 2 3 4 5 -7 3 13 -2 8 4 4 8 12 6
yes 4 6 0 3 9 yEs 5 5 3 1 2 4 NO Yes 6 8 12 6 2 4 10
2 seconds
256 megabytes
['brute force', 'constructive algorithms', '*800']
F. String Distancetime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputSuppose you are given two strings a and b. You can apply the following operation any number of times: choose any contiguous substring of a or b, and sort the characters in it in non-descending order....
4 zzz bac abc acb
4015
2 seconds
1024 megabytes
['binary search', 'brute force', 'data structures', 'hashing', 'implementation', 'strings', '*3000']
E. Gold Transfertime limit per test4.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree. Each vertex contains a_i tons of gold, which costs c_i per one ton. Initially, the tree consists only a root numbered 0 with a_0 tons of gold and price c_0 per ton.There a...
5 5 2 2 0 2 1 0 3 4 2 2 4 1 0 1 3 2 4 2
2 4 4 10 1 3
4.5 seconds
256 megabytes
['binary search', 'data structures', 'dp', 'greedy', 'interactive', 'trees', '*2200']
D. Playoff Tournamenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 ...
3 0110?11 6 5 1 6 ? 7 ? 1 ? 5 ? 1 1
1 2 3 3 5 4
2 seconds
256 megabytes
['data structures', 'dfs and similar', 'dp', 'implementation', 'trees', '*1800']
C. Unstable Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of the characters 0, 1, and ?.Let's call a string unstable if it consists of the characters 0 and 1 and any two adjacent characters are different (i. e. it has the ...
3 0?10 ??? ?10??1100
8 6 25
2 seconds
256 megabytes
['binary search', 'dp', 'greedy', 'implementation', 'strings', 'two pointers', '*1400']
B. Array Reoderingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers.Let's call a pair of indices i, j good if 1 \le i < j \le n and \gcd(a_i, 2a_j) > 1 (where \gcd(x, y) is the greatest common divisor of x and y).Find ...
3 4 3 6 5 3 2 1 7 5 1 4 2 4 1
4 0 9
2 seconds
256 megabytes
['brute force', 'greedy', 'math', 'number theory', 'sortings', '*900']
A. Fair Playofftime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFour players participate in the playoff tournament. The tournament is held according to the following scheme: the first player will play with the second, and the third player with the fourth, then the wi...
4 3 7 9 5 4 5 6 9 5 3 8 1 6 5 3 2
YES NO YES NO
2 seconds
256 megabytes
['brute force', 'implementation', '*800']
H. Lost Nodestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.As he qualified for IOI this year, Little Ericyi was given a gift from all his friends: a tree of n nodes!On the flight to IOI Little Ericyi was very bored, so he decided to ...
4 3 2 2 1 2 4 1 1 2 2
3 ? 1 ? 2 ? 3 ! 4 1
4 seconds
256 megabytes
['constructive algorithms', 'dp', 'graphs', 'interactive', 'sortings', 'trees', '*3500']
G. A New Beginningtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAnnie has gotten bored of winning every coding contest and farming unlimited rating. Today, she is going to farm potatoes instead.Annie's garden is an infinite 2D plane. She has n potatoes to plant, a...
2 1 1 2 2
0
5 seconds
256 megabytes
['data structures', 'dp', 'geometry', 'sortings', '*3300']
F2. Falling Sand (Hard Version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved.Little Dormi has ...
5 7 #....#. .#.#... #....#. #....## #.#.... 4 1 1 1 0 3 1
3
2 seconds
512 megabytes
['dfs and similar', 'dp', 'graphs', 'greedy', '*3000']
F1. Falling Sand (Easy Version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved.Little Dormi has ...
5 7 #....#. .#.#... #....#. #....## #.#.... 4 1 1 1 0 3 1
3
2 seconds
512 megabytes
['dfs and similar', 'graphs', 'greedy', '*2500']
E. Lost Arraytime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Note: the XOR-sum of an array a_1, a_2, \ldots, a_n (1 \le a_i \le 10^9) is defined as a_1 \oplus a_2 \oplus \ldots \oplus a_n, where \oplus denotes the bitwise XOR operati...
5 3 4 0 1
? 1 2 3 ? 2 3 5 ? 4 1 5 ! 7
1.5 seconds
256 megabytes
['graphs', 'greedy', 'interactive', 'shortest paths', '*2300']
D. Lost Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Little Dormi was faced with an awkward problem at the carnival: he has to guess the edges of an unweighted tree of n nodes! The nodes of the tree are numbered from 1 to n.The ...
4 0 1 2 2 1 0 1 1
? 1 ? 2 ! 4 2 1 2 2 3
3 seconds
256 megabytes
['constructive algorithms', 'interactive', 'trees', '*1800']
C. Little Alawn's Puzzletime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen he's not training for IOI, Little Alawn enjoys playing with puzzles of various types to stimulate his brain. Today, he's playing with a puzzle that consists of a 2 \times n grid where eac...
2 4 1 4 2 3 3 2 1 4 8 2 6 5 1 4 3 7 8 3 8 7 5 1 2 4 6
2 8
2.5 seconds
256 megabytes
['combinatorics', 'dp', 'dsu', 'graphs', 'math', '*1300']
B. Histogram Uglinesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Dormi received a histogram with n bars of height a_1, a_2, \ldots, a_n for Christmas. However, the more he played with his new histogram, the more he realized its imperfections, so today he ...
2 4 4 8 9 6 6 2 1 7 4 0 0
17 12
2 seconds
256 megabytes
['greedy', 'implementation', 'math', '*1100']
A. Colour the Flagtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag).You are given an n \times m grid of "R", "W", and "."...
3 4 6 .R.... ...... ...... .W.... 4 4 .R.W .... .... .... 5 1 R W R W R
YES WRWRWR RWRWRW WRWRWR RWRWRW NO YES R W R W R
1.5 seconds
256 megabytes
['brute force', 'implementation', '*800']
J. Pawnstime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an infinite chessboard, divided into cells. The cell (x, y) is the cell on the intersection of the x_i-th row and y_i-th column. n black pawns are placed on the board, the i-th black pawn occupies the ...
3 1 1 5 1 2 2
1
5 seconds
256 megabytes
['*special problem']
I. Excursionstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIrina works in an excursion company in Saratov. Today, she is going to organize excursions in the cities of Saratov and Engels.There are n_1 sights in Saratov and n_2 sights in Engels. The cities are separ...
2 1 2 10 20 1 1 2 1
10
2 seconds
512 megabytes
['*special problem', 'constructive algorithms', 'dfs and similar', 'flows', 'graph matchings', 'graphs']