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
C. Music Festivaltime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output The boy Vitya loves to listen to music very much. He knows that n albums are due to be released this Friday, i-th of which contains k_i tracks. Of course, Vitya has already listened to all the tracks, ...
2454 9 4 6 81728 611423 421 822 827 9
4 4
1 second
512 megabytes
['binary search', 'data structures', 'dp', 'greedy', 'sortings', '*1900']
B. Buying giftstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output Little Sasha has two friends, whom he wants to please with gifts on the Eighth of March. To do this, he went to the largest shopping center in the city.There are n departments in the mall, each of which...
221 22 151 52 73 34 102 5
0 1
3 seconds
512 megabytes
['data structures', 'greedy', 'sortings', '*1800']
A. The Very Beautiful Blankettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKirill wants to weave the very beautiful blanket consisting of n \times m of the same size square patches of some colors. He matched some non-negative integer to each color. Thus, in our pro...
45 54 44 66 6
25 9740 1549 9744 1553 9748 1550 1551 1554 1555 1558 10252 2061 10256 2065 10260 2062 2063 2066 2067 2070 10764 2573 10768 2577 10772 16 3108 3109 3112 3113 3110 3111 3114 3115 3620 3621 3624 3625 3622 3623 3626 3627 24 548 549 552 553 556 557 550 551 554 555 558 559 1060 1061 1064 1065 1068 1069 1062 1063 1066 1067 10...
1 second
256 megabytes
['bitmasks', 'constructive algorithms', '*1600']
G. Symmetreetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKid was gifted a tree of n vertices with the root in the vertex 1. Since he really like symmetrical objects, Kid wants to find out if this tree is symmetrical. For example, the trees in the picture above a...
661 51 61 22 32 471 51 33 61 44 74 291 22 42 33 51 77 67 88 9102 99 102 36 74 31 23 82 56 5103 28 109 74 28 22 14 56 55 71
YES NO YES NO NO YES
2 seconds
256 megabytes
['dfs and similar', 'hashing', 'implementation', 'trees', '*2200']
F. Dasha and Nightmarestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDasha, an excellent student, is studying at the best mathematical lyceum in the country. Recently, a mysterious stranger brought n words consisting of small latin letters s_1, s_2, \ldots, s_n to...
10ftlabcdefghijklmnopqrstuvwxyabcdeffghijkllmnopqrsttuvwxyffftlaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyythedevidbcdefghhiiiijklmnopqrsuwxyzgorillasilverbackabcdefgijklmnopqrstuvwxyz
5
4 seconds
512 megabytes
['bitmasks', 'hashing', 'meet-in-the-middle', 'strings', '*1900']
E2. Unforgivable Curse (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a complex version of the problem. This version has no additional restrictions on the number k.The chief wizard of the Wizengamot once caught the evil wizard Drahyrt, but the ...
76 3talantatltna7 1abacabaaaaabbc12 6abracadabraaavadakedavra5 3acciocicao5 4lumosmolus4 3uwjttwju4 3kvpxvxpk
YES YES NO YES NO YES NO
1 second
256 megabytes
['brute force', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'strings', '*1500']
E1. Unforgivable Curse (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an easy version of the problem. In this version, k is always 3.The chief wizard of the Wizengamot once caught the evil wizard Drahyrt, but the evil wizard has returned and wa...
76 3talantatltna7 3abacabaaaaabbc12 3abracadabraaavadakedavra5 3acciocicao5 3lumosmolus4 3uwjttwju4 3kvpxvxpk
YES YES NO YES NO YES NO
1 second
256 megabytes
['brute force', 'constructive algorithms', 'dsu', 'graphs', 'greedy', 'strings', '*1400']
D. Remove Two Letterstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDmitry has a string s, consisting of lowercase Latin letters.Dmitry decided to remove two consecutive characters from the string s and you are wondering how many different strings can be obtained a...
76aaabcc10aaaaaaaaaa6abcdef7abacaba6cccfff4abba5ababa
4 1 5 3 3 3 1
2 seconds
256 megabytes
['data structures', 'greedy', 'hashing', 'strings', '*1200']
C2. Powering the Hero (hard version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a hard version of the problem. It differs from the easy one only by constraints on n and t.There is a deck of n cards, each of which is characterized by its power. There are ...
553 3 3 0 060 3 3 0 0 371 2 3 0 4 5 071 2 5 0 4 3 053 1 0 0 4
6 6 8 9 4
2 seconds
256 megabytes
['data structures', 'greedy', '*1100']
C1. Powering the Hero (easy version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an easy version of the problem. It differs from the hard one only by constraints on n and t.There is a deck of n cards, each of which is characterized by its power. There are...
553 3 3 0 060 3 3 0 0 371 2 3 0 4 5 071 2 5 0 4 3 053 1 0 0 4
6 6 8 9 4
2 seconds
256 megabytes
['data structures', 'greedy', '*1000']
B. Count the Number of Pairstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKristina has a string s of length n, consisting only of lowercase and uppercase Latin letters. For each pair of lowercase letter and its matching uppercase letter, Kristina can get 1 burl. H...
511 2aAaaBACacbE2 2ab4 1aaBB6 0abBAcC5 3cbccb
5 0 1 3 2
2 seconds
256 megabytes
['greedy', 'strings', '*1000']
A. Is It a Cat?time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou were walking down the street and heard a sound. The sound was described by the string s consisting of lowercase and uppercase Latin characters. Now you want to find out if the sound was a cat meowing...
74meOw14mMmeoOoWWWwwwW3mew7MmeEeUw4MEOW6MmyaVW5meowA
YES YES NO NO YES NO NO
2 seconds
256 megabytes
['implementation', 'strings', '*800']
H. Tree Cuttingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree with n vertices.A hero k times do the following operation: Choose some edge. Remove it. Take one of the two remaining parts and delete it. Write the number of vertices in the rem...
3 1 2 2 3 2 2 1
4
2 seconds
512 megabytes
['bitmasks', 'dfs and similar', 'dp', '*3200']
G. Count Votingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n people that will participate in voting. Each person has exactly one vote.i-th person has a team t_i (1 \leq t_i \leq n) where t_i = t_j means i, j are in the same team. By the rules each perso...
3 1 1 1 1 2 3
2
1 second
256 megabytes
['combinatorics', 'dp', 'math', '*2600']
F. Halve or Subtracttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array of positive integers a_1, a_2, \ldots, a_n, of length n. You are also given a positive integer b.You are allowed to perform the following operations (possibly several) times in any ...
73 2 1 19 3 52 1 2 01000000000 15 3 1 12 8 3 19 36 9 4 21 2 3 4 5 63 10 3 31 2 35 1 0 0999999999 999999999 999999999 999999999 9999999995 5 4 35 9 10 7 4
11 500000001 23 6 0 4999999995 6
1 second
256 megabytes
['binary search', 'brute force', 'dp', 'greedy', 'sortings', '*2700']
E. City Uniontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n \times m grid. Some cells are filled and some are empty.A city is a maximal (by inclusion) set of filled cells such that it is possible to get from any cell in the set to any other cell in t...
111 3#.#2 2.##.4 4..##...##...##..6 6.##...##..............##.....#...###6 5.#..#.#..#.#..#.#.##.#...##...5 5######...##.#.##...######4 4.##.##.##.##.##.5 5..###....#.....#....#....5 6.##...##....#....#....##...##.6 5..##....##....##....##....##..5 4..##..#...#.#...#...
### .# ## ..## ..## ###. ##.. .##... ###... ..#... ..#### ...### ...### .#### .#### .#### .#### .#... ##... ##### ##### ##### ##### ##### .##. #### #### .##. ..### ..### ..#.. ###.. #.... .##... ###... ###### ...### ...##. ..##. ..### ..### ###.. ###.. .##.. ..## ..#. ..#. ###. #...
1 second
256 megabytes
['constructive algorithms', 'dfs and similar', 'dsu', 'geometry', 'greedy', 'implementation', 'math', '*2300']
D2. Hot Start Up (hard version)time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is a hard version of the problem. The constraints of t, n, k are the only difference between versions.You have a device with two CPUs. You also have k programs, numbered 1 through k, ...
93 21 2 23 22 14 21 2 1 25 32 14 31 2 3 1100 100 1001 1 15 22 1 2 1 165 4554 75 31 3 2 1 22 2 21 1 15 11 1 1 1 110000000009999999995 61 6 1 4 13 6 4 1 4 51 1 1 1 4 11 334 5 61 2 38 33 3 3 1 2 3 2 110 10 810 10 5
6 11 301 225 8 4999999996 11 6 63
1 second
512 megabytes
['data structures', 'dp', '*2100']
D1. Hot Start Up (easy version)time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an easy version of the problem. The constraints of t, n, k are the only difference between versions.You have a device with two CPUs. You also have k programs, numbered 1 through k,...
93 21 2 23 22 14 21 2 1 25 32 14 31 2 3 1100 100 1001 1 15 22 1 2 1 165 4554 75 31 3 2 1 22 2 21 1 15 11 1 1 1 110000000009999999995 61 6 1 4 13 6 4 1 4 51 1 1 1 4 11 334 5 61 2 38 33 3 3 1 2 3 2 110 10 810 10 5
6 11 301 225 8 4999999996 11 6 63
1 second
512 megabytes
['dp', '*1900']
C. Double Lexicographically Minimumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s. You can reorder the characters to form a string t. Define t_{\mathrm{max}} to be the lexicographical maximum of t and t in reverse order.Given s determine th...
12aaababbabcaabbaabbbaaabbabbbabbbbabbcceagaffcaba
a aba bab bca abba abbba ababa bbab bbabb bbcca agea acffba
2 seconds
256 megabytes
['greedy', 'strings', '*1700']
B. Equalize by Dividetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \ldots, a_n of positive integers.You can make this operation multiple (possibly zero) times: Choose two indices i, j (1 \leq i, j \leq n, i \neq j). Assign a_i := ...
10110031 1 122 125 534 3 243 3 4 422 10055 3 6 7 863 3 80 3 8 3419 40 19 55
0 0 -1 0 2 1 3 2 1 4 3 1 4 2 1 3 2 4 6 2 1 2 1 2 1 2 1 2 1 2 1 8 5 2 4 2 3 2 1 3 1 3 2 1 4 1 5 1 4 5 1 3 1 3 1 3 1 9 4 2 2 1 1 2 1 2 3 2 3 2 1 4 2 4 3 4
1 second
256 megabytes
['brute force', 'constructive algorithms', 'greedy', 'math', '*1200']
A. Recent Actionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn Codeforces the "Recent Actions" field shows the last n posts with recent actions.Initially, there are posts 1, 2, \ldots, n in the field (this is in order from top to down). Also there are infinitely...
101 123 25 44 55 9 9 5 75 56 7 8 9 103 44 4 4 44 45 5 6 63 54 5 5 5 44 205 5 24 24 24 5 6 7 8 9 10 12 13 14 15 16 17 18 19 205 77 8 7 11 7 12 106 78 11 7 8 8 8 12
1 -1 2 1 -1 5 2 1 5 4 3 2 1 -1 -1 1 -1 -1 3 1 -1 2 1 8 7 3 1 7 6 4 2 1 -1 -1 7 3 2 1
1 second
256 megabytes
['data structures', 'greedy', 'implementation', 'math', '*800']
F. Gifts from Grandfather Ahmedtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGrandfather Ahmed's School has n+1 students. The students are divided into k classes, and s_i students study in the i-th class. So, s_1 + s_2 + \ldots + s_k = n+1.Due to the upcoming April...
4 2 7 7 7 127 2 3
1 7 7 7 127 1
1 second
256 megabytes
['dp', 'math', 'number theory', '*2500']
E. Multitest Generatortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call an array b_1, b_2, \ldots, b_m a test if b_1 = m - 1.Let's call an array b_1, b_2, \ldots, b_m a multitest if the array b_2, b_3, \ldots, b_m can be split into b_1 non-empty subarrays s...
341 2 1 773 1 3 1 2 1 142 7 1 1
0 1 1 0 1 1 0 1 1 1 1 1
2 seconds
256 megabytes
['brute force', 'dp', '*2300']
D. Shocking Arrangementtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \ldots, a_n consisting of integers such that a_1 + a_2 + \ldots + a_n = 0.You have to rearrange the elements of the array a so that the following condition is sat...
7 4 3 4 -2 -5 5 2 2 2 -3 -3 8 -3 -3 1 1 1 1 1 1 3 0 1 -1 7 -3 4 3 4 -4 -4 0 1 0 7 -18 13 -18 -17 12 15 13
Yes -5 -2 3 4 Yes -3 2 -3 2 2 Yes 1 1 1 -3 1 1 1 -3 Yes -1 0 1 Yes 4 -4 4 -4 0 3 -3 No Yes 13 12 -18 15 -18 13 -17
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'math', '*1600']
C. Candy Storetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe store sells n types of candies with numbers from 1 to n. One candy of type i costs b_i coins. In total, there are a_i candies of type i in the store.You need to pack all available candies in packs, ea...
5420 36 214 520 73444 52002 102020 257 76 515 210 37 7510 111 55 12 28 267 1212 35 39 129 31000000000 10000
2 1 3 2 5
3 seconds
256 megabytes
['greedy', 'math', 'number theory', '*1700']
B. Three Sevenstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLottery "Three Sevens" was held for m days. On day i, n_i people with the numbers a_{i, 1}, \ldots, a_{i, n_i} participated in the lottery.It is known that in each of the m days, only one winner was sele...
3341 2 4 832 9 121 4221 222 1441 2 3 4111413
8 2 1 -1 2 1 4 3
2 seconds
256 megabytes
['brute force', 'data structures', 'greedy', 'implementation', '*1000']
A. Showstoppertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a_1, a_2, \ldots, a_n and b_1, b_2, \ldots, b_n.In one operation, you can choose any integer i from 1 to n and swap the numbers a_i and b_i.Determine whether, after using any (pos...
737 9 77 6 9410 10 15 1510 16 15 152100 9999 10011191 2 3 4 5 6 7 8 99 9 9 9 9 9 6 6 671 1 2 2 1 1 21 2 1 2 1 2 1230 45 30
Yes No Yes Yes Yes No No
2 seconds
256 megabytes
['greedy', 'implementation', 'sortings', '*800']
F. Li Hua and Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLi Hua has a tree of n vertices and n-1 edges. The vertices are numbered from 1 to n.A pair of vertices (u,v) (u < v) is considered cute if exactly one of the following two statements is true: u is t...
7 2 1 1 3 1 4 4 6 4 7 6 5 2 5 6
11 15 19
2 seconds
256 megabytes
['data structures', 'dfs and similar', 'divide and conquer', 'dsu', 'trees', '*3000']
E. Li Hua and Arraytime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLi Hua wants to solve a problem about \varphi — Euler's totient function. Please recall that \varphi(x)=\sum\limits_{i=1}^x[\gcd(i,x)=1].^{\dagger,\ddagger}He has a sequence a_1,a_2,\cdots,a_n and he...
5 4 8 1 6 3 7 2 1 5 2 3 4 1 1 3 2 3 4
10 2 1
3 seconds
512 megabytes
['brute force', 'data structures', 'dsu', 'math', 'number theory', 'two pointers', '*2300']
D. Li Hua and Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLi Hua has a tree of n vertices and n-1 edges. The root of the tree is vertex 1. Each vertex i has importance a_i. Denote the size of a subtree as the number of vertices in it, and the importance as t...
7 4 1 1 1 1 1 1 1 1 2 1 3 2 4 2 5 3 6 6 7 1 6 2 3 1 6 1 2
2 3 3
2 seconds
256 megabytes
['brute force', 'data structures', 'dfs and similar', 'dp', 'implementation', 'trees', '*1900']
C. Li Hua and Chesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Li Ming and Li Hua are playing a game. Li Hua has a chessboard of size n\times m. Denote (r, c) (1\le r\le n, 1\le c\le m) as the cell on the r-th row from the top and o...
2 3 4 1 2 5 3 3 1 2
? 2 3 ? 2 4 ! 2 2 ? 2 2 ? 5 2 ? 5 3 ! 5 1
1 second
256 megabytes
['constructive algorithms', 'greedy', 'interactive', '*1600']
B. Li Hua and Patterntime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLi Hua has a pattern of size n\times n, each cell is either blue or red. He can perform exactly k operations. In each operation, he chooses a cell and changes its color from red to blue or from blue...
34 01 1 1 10 0 0 11 0 1 01 1 1 14 31 0 1 11 0 0 00 1 0 11 1 0 15 40 0 0 0 00 1 1 1 10 1 0 0 01 1 1 1 10 0 0 0 0
NO YES YES
1 second
256 megabytes
['constructive algorithms', 'greedy', '*1100']
A. Li Hua and Mazetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a rectangular maze of size n\times m. Denote (r,c) as the cell on the r-th row from the top and the c-th column from the left. Two cells are adjacent if they share an edge. A path is a sequenc...
34 42 2 3 36 71 1 2 39 95 1 3 6
4 2 3
1 second
256 megabytes
['constructive algorithms', 'flows', 'graphs', 'greedy', 'implementation', '*800']
F. Strange Triplestime limit per test10 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a triple of positive integers (a, b, n) strange if the equality \frac{an}{nb} = \frac{a}{b} holds, where an is the concatenation of a and n and nb is the concatenation of n and b. For the ...
5 6 10
7
10 seconds
256 megabytes
['brute force', 'math', 'number theory', '*2900']
E. Colored Subgraphstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp has a tree, consisting of n vertices.He is going to select some vertex r and perform the following operations on each vertex v from 1 to n: set d_v equal to the distance from v to r (the ...
441 22 33 451 21 31 41 531 33 273 22 57 53 11 61 4
4 1 3 3
2 seconds
256 megabytes
['dfs and similar', 'dp', 'games', 'greedy', 'trees', '*2500']
D. Maximum Subarraytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots, a_n, consisting of n integers. You are also given two integers k and x.You have to perform the following operation exactly once: add x to the elements on exact...
44 1 22 -1 2 32 2 3-1 23 0 53 2 46 2 -84 -1 9 -3 7 -8
5 7 0 44
2 seconds
512 megabytes
['data structures', 'dp', 'greedy', 'two pointers', '*2000']
C. Maximum Settime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA set of positive integers S is called beautiful if, for every two integers x and y from this set, either x divides y or y divides x (or both).You are given two integers l and r. Consider all beautiful se...
43 1113 371 224 100
2 4 2 6 5 1 5 7
2 seconds
512 megabytes
['binary search', 'math', '*1600']
B. Asterisk-Minor Templatetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings a and b, consisting of lowercase Latin letters.A template t is string, consisting of lowercase Latin letters and asterisks (character '*'). A template is called aster...
6aaabzzzbcodeforcesatcodercodeforcestokitlxaaaaaaaaaaabcdabcdcf
YES *b YES *co* NO YES a*a*a*a YES abcd NO
2 seconds
256 megabytes
['implementation', 'strings', '*1000']
A. Typical Interview Problemtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe FB-string is formed as follows. Initially, it is empty. We go through all positive integers, starting from 1, in ascending order, and do the following for each integer: if the current i...
33FFB8BFFBFFBF3BBB
YES YES NO
2 seconds
512 megabytes
['brute force', 'implementation', 'strings', '*800']
G. Removal Sequencestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a simple undirected graph, consisting of n vertices and m edges. The vertices are numbered from 1 to n. The i-th vertex has a value a_i written on it.You will be removing vertices from...
43 21 0 12 31 23 31 2 01 22 31 35 63 0 2 1 01 24 14 23 42 35 11 00
1 0 4 0
4 seconds
256 megabytes
['bitmasks', 'dfs and similar', 'graphs', '*2700']
F. Blocking Chipstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree, consisting of n vertices. There are k chips, placed in vertices a_1, a_2, \dots, a_k. All a_i are distinct. Vertices a_1, a_2, \dots, a_k are colored black initially. The remainin...
551 22 33 44 51351 22 33 44 521 251 22 33 44 522 161 21 32 42 53 631 4 6111
2 0 1 2 0
3 seconds
256 megabytes
['binary search', 'constructive algorithms', 'dfs and similar', 'greedy', 'trees', '*2400']
E. Explosions?time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing yet another game where you kill monsters using magic spells. There are n cells in the row, numbered from 1 to n. Initially, the i-th cell contains the i-th monster with h_i health.You have...
531 1 144 1 2 145 10 15 1014291 2 3 2 2 2 3 2 1
3 6 15 42 12
2 seconds
256 megabytes
['binary search', 'data structures', 'dp', 'greedy', 'math', '*2200']
D. Triangle Coloringtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph consisting of n vertices and n edges, where n is divisible by 6. Each edge has a weight, which is a positive (greater than zero) integer.The graph has the following...
12 1 3 3 7 8 5 2 2 2 2 4 2
36
3 seconds
512 megabytes
['combinatorics', 'math', '*1600']
C. Tea Tastingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tea manufacturer decided to conduct a massive tea tasting. n sorts of tea will be tasted by n tasters. Both the sorts of tea and the tasters are numbered from 1 to n. The manufacturer prepared a_i milli...
4310 20 159 8 6157413 8 5 43 4 2 131000000000 1000000000 10000000001 1 1000000000
9 9 12 5 3 8 6 4 1 2 2999999997
2 seconds
256 megabytes
['binary search', 'data structures', 'implementation', '*1500']
B. Ideal Pointtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n one-dimensional segments (each segment is denoted by two integers — its endpoints).Let's define the function f(x) as the number of segments covering point x (a segment covers the point x i...
44 31 37 92 53 62 91 43 71 32 43 51 46 75 5
YES NO NO YES
2 seconds
256 megabytes
['brute force', 'geometry', 'greedy', '*900']
A. Two Towerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are two towers consisting of blocks of two colors: red and blue. Both towers are represented by strings of characters B and/or R denoting the order of blocks in them from the bottom to the top, where...
44 3BRBBRBR4 7BRBRRRBRBRB3 4RBRBRBR5 4BRBRRBRBR
YES YES YES NO
2 seconds
256 megabytes
['brute force', 'implementation', 'strings', '*800']
E. Labeling the Tree with Distancestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an unweighted tree of n vertices numbered from 1 to n and a list of n-1 integers a_1, a_2, \ldots, a_{n-1}. A tree is a connected undirected graph without cycles. You wi...
6 2 1 0 1 2 1 2 2 3 2 4 4 5 4 6
2 2 4
4 seconds
256 megabytes
['data structures', 'dp', 'greedy', 'hashing', 'implementation', 'trees', '*2400']
D. Counting Factorizationstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe prime factorization of a positive integer m is the unique way to write it as \displaystyle m=p_1^{e_1}\cdot p_2^{e_2}\cdot \ldots \cdot p_k^{e_k}, where p_1, p_2, \ldots, p_k are prime num...
2 1 3 2 3
2
4 seconds
256 megabytes
['combinatorics', 'divide and conquer', 'dp', 'math', 'number theory', '*1900']
C. Scoring Subsequencestime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe score of a sequence [s_1, s_2, \ldots, s_d] is defined as \displaystyle \frac{s_1\cdot s_2\cdot \ldots \cdot s_d}{d!}, where d!=1\cdot 2\cdot \ldots \cdot d. In particular, the score of an ...
331 2 321 155 5 5 5 5
1 1 2 1 1 1 2 3 4 5
2.5 seconds
256 megabytes
['binary search', 'greedy', 'math', 'two pointers', '*1300']
B. Not Dividingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of n positive integers a_1, a_2, \ldots, a_n. In one operation, you can choose any number of the array and add 1 to it. Make at most 2n operations so that the array satisfies the f...
342 4 3 631 2 324 2
4 5 6 7 3 2 3 4 2
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'math', '*900']
A. Prefix and Suffix Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMarcos loves strings a lot, so he has a favorite string s consisting of lowercase English letters. For this string, he wrote down all its non-empty prefixes and suffixes (except for s) on a pie...
54bcd cd a d abc ab3i io i oi2g g3t al lt a4bba a ab a abb ba
NO YES YES NO YES
1 second
256 megabytes
['strings', '*800']
F. Rebrendingtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKostya and Zhenya — the creators of the band "Paper" — after the release of the legendary album decided to create a new band "Day movers", for this they need to find two new people.They invited n people to...
3 31 3 21 22 31 3
2 1 1
4 seconds
256 megabytes
['brute force', 'data structures', 'divide and conquer', 'implementation', '*2600']
E. Velepin and Marketingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe famous writer Velepin is very productive. Recently, he signed a contract with a well-known publication and now he needs to write k_i books for i-th year. This is not a problem for him at all...
5 1 2 2 2 2 3 2 3 4
5 5 3
2 seconds
256 megabytes
['binary search', 'data structures', 'dp', 'greedy', 'sortings', 'two pointers', '*2600']
D. Moscow Gorillastime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn winter, the inhabitants of the Moscow Zoo are very bored, in particular, it concerns gorillas. You decided to entertain them and brought a permutation p of length n to the zoo.A permutation of leng...
31 3 22 1 3
2
2 seconds
256 megabytes
['binary search', 'dp', 'greedy', 'implementation', 'math', 'two pointers', '*1800']
C. Dora and Searchtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you know, the girl Dora is always looking for something. This time she was given a permutation, and she wants to find such a subsegment of it that none of the elements at its ends is either the mini...
431 2 342 1 4 371 3 2 4 6 5 762 3 6 5 4 1
-1 1 4 2 6 -1
1 second
256 megabytes
['constructive algorithms', 'data structures', 'two pointers', '*1200']
B. Fedya and Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor his birthday recently Fedya was given an array a of n integers arranged in a circle, For each pair of neighboring numbers (a_1 and a_2, a_2 and a_3, \ldots, a_{n - 1} and a_n, a_n and a_1) the abso...
43 -24 -42 -15 -3
10 0 1 2 1 0 -1 0 -1 0 1 16 -2 -1 -2 -1 0 1 2 3 4 5 4 3 2 1 0 -1 6 1 0 -1 0 1 0 16 2 3 2 1 0 -1 0 -1 0 -1 0 1 2 1 0 1
1 second
256 megabytes
['constructive algorithms', 'math', '*1100']
A. Yet Another Promotiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe famous store "Second Food" sells groceries only two days a month. And the prices in each of days differ. You wanted to buy n kilos of potatoes for a month. You know that on the first day of t...
55 43 15 43 23 43 520 1510 21000000000 9000000001000000000 8
9 10 9 135 888888888900000000
1 second
256 megabytes
['greedy', 'math', '*800']
F2. Graph Coloring (hard version)time limit per test5.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and the hard version is the constraint on n.You are given an undirected complete graph on n vertices. A complete graph is a graph where each pair ...
3
6
5.5 seconds
512 megabytes
['brute force', 'combinatorics', 'divide and conquer', 'dp', 'fft', 'graphs', '*2900']
F1. Graph Coloring (easy version)time limit per test5.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and the hard version is the constraint on n.You are given an undirected complete graph on n vertices. A complete graph is a graph where each pair ...
3
6
5.5 seconds
512 megabytes
['combinatorics', 'dp', 'graphs', '*2700']
E. Divisors and Tabletime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an n \times n multiplication table and a positive integer m = m_1 \cdot m_2. A n \times n multiplication table is a table with n rows and n columns numbered from 1 to n, where a_{i,...
33 72 110 10 156 1 210
6 2 10 0 8 5
2.5 seconds
256 megabytes
['brute force', 'dfs and similar', 'dp', 'number theory', '*2400']
D. Fixed Prefix Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n permutations a_1, a_2, \dots, a_n, each of length m. Recall that a permutation of length m is a sequence of m distinct integers from 1 to m.Let the beauty of a permutation p_...
33 42 4 1 31 2 4 32 1 3 42 21 22 18 103 4 9 6 10 2 7 8 1 53 9 1 8 5 7 4 10 2 63 10 1 7 5 9 6 4 2 81 2 3 4 8 6 10 7 9 51 2 3 4 10 6 8 5 7 99 6 1 2 10 4 7 8 3 57 9 3 2 5 6 4 8 1 109 4 3 7 5 6 1 10 8 2
1 4 4 2 2 10 8 1 6 8 10 1 7
2 seconds
256 megabytes
['binary search', 'bitmasks', 'data structures', 'hashing', 'math', 'sortings', '*1700']
C. Min Max Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p of length n (a permutation of length n is an array of length n in which each integer from 1 to n occurs exactly once).You can perform the following operation any number of t...
451 5 4 2 331 2 342 1 4 365 2 4 1 6 3
2 0 1 3
2 seconds
256 megabytes
['binary search', 'brute force', 'greedy', 'math', 'two pointers', '*1500']
B. Stand-up Comediantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEve is a beginner stand-up comedian. Her first show gathered a grand total of two spectators: Alice and Bob.Eve prepared a_1 + a_2 + a_3 + a_4 jokes to tell, grouped by their type: type 1: both Al...
45 0 0 00 0 0 52 5 10 63 0 0 7
5 1 15 7
2 seconds
256 megabytes
['greedy', 'math', '*1200']
A. GamingForcestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is playing a computer game. He's going to kill n monsters, the i-th of them has h_i health.Monocarp's character has two spells, either of which he can cast an arbitrary number of times (possibly...
341 2 1 232 4 251 2 3 4 5
3 3 5
2 seconds
256 megabytes
['greedy', 'sortings', '*800']
G2. Teleporters (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions are the locations you can teleport to.Consider the points 0,1,\dots,n+1 on the number line. There is a teleporter located on each of t...
105 61 1 1 1 18 32100 52 13 6 9 4 100 351 154 54 3 2 15 92 3 1 4 15 82 3 1 4 14 32 3 4 14 95 4 3 32 147 55 600000000500000000 400000000 300000000 200000000 100000000
2 3 0 1 3 2 1 1 2 2
1 second
256 megabytes
['binary search', 'greedy', 'sortings', '*1900']
G1. Teleporters (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and hard versions are the locations you can teleport to.Consider the points 0, 1, \dots, n on the number line. There is a teleporter located on each of ...
105 61 1 1 1 18 32100 52 13 6 9 4 100 351 154 54 3 2 15 92 3 1 4 15 82 3 1 4 14 32 3 4 14 95 4 3 32 147 55 600000000500000000 400000000 300000000 200000000 100000000
2 2 0 1 2 2 1 1 1 2
1 second
256 megabytes
['greedy', 'sortings', '*1100']
F. Range Update Point Querytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a_1, a_2, \dots, a_n, you need to handle a total of q updates and queries of two types: 1 l r — for each index i with l \leq i \leq r, update the value of a_i to the sum of th...
35 81 420 69 1434 20231 2 32 22 32 41 2 52 12 32 52 39999 10001 1 22 12 21 112 1
6 15 1434 1 6 7 36 1 1
2 seconds
256 megabytes
['binary search', 'brute force', 'data structures', '*1500']
E. Negatives and Positivestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a consisting of n elements, find the maximum possible sum the array can have after performing the following operation any number of times: Choose 2 adjacent elements and flip ...
53-1 -1 -151 5 -5 0 231 2 36-1 10 9 8 7 62-1 -1
1 13 6 39 2
2 seconds
256 megabytes
['dp', 'greedy', 'sortings', '*1100']
D. Distinct Splittime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's denote the f(x) function for a string x as the number of distinct characters that the string contains. For example f(\texttt{abc}) = 3, f(\texttt{bbbbb}) = 1, and f(\texttt{babacaba}) = 3.Given a...
52aa7abcabcd5aaaaa10paiumoment4aazz
2 7 2 10 3
2 seconds
256 megabytes
['brute force', 'greedy', 'strings', '*1000']
C. Prepend and Appendtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTimur initially had a binary string^{\dagger} s (possibly of length 0). He performed the following operation several (possibly zero) times: Add \texttt{0} to one end of the string and \texttt{1} t...
931004011151010161010107101011011210211101011011010
1 2 5 0 3 1 0 2 4
1 second
256 megabytes
['implementation', 'two pointers', '*800']
B. Following Directionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlperen is standing at the point (0,0). He is given a string s of length n and performs n moves. The i-th move is as follows: if s_i = \texttt{L}, then move one unit left; if s_i = \texttt{R}, ...
77UUURDDL2UR8RRRUUDDD3LLL4DUUR5RUDLL11LLLLDDRUDRD
YES YES NO NO YES YES NO
1 second
256 megabytes
['geometry', 'implementation', '*800']
A. Codeforces Checkingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven a lowercase Latin character (letter), check if it appears in the string \texttt{codeforces}.InputThe first line of the input contains an integer t (1 \leq t \leq 26) — the number of test case...
10abcdefghij
NO NO YES YES YES YES NO NO NO NO
1 second
256 megabytes
['implementation', 'strings', '*800']
G. Tokens on Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected connected graph, some vertices of which contain tokens and/or bonuses. Consider a game involving one player  — you.You can move tokens according to the following rules: At...
68 102 47 82 4 5 61 22 32 43 43 54 65 65 76 87 85 41 1531 22 33 44 52 11 021 24 31 223 41 22 32 45 43 25 3 42 41 22 33 44 51 01 111
YES NO YES YES YES YES
2 seconds
256 megabytes
['constructive algorithms', 'dfs and similar', 'graphs', 'shortest paths', '*2300']
F. Timofey and Black-White Treetime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTimofey came to a famous summer school and found a tree on n vertices. A tree is a connected undirected graph without cycles.Every vertex of this tree, except c_0, is colored white. The v...
66 64 1 3 5 22 46 55 33 41 34 24 1 33 12 31 410 310 7 6 5 2 9 8 1 41 21 34 54 36 48 79 810 81 87 37 5 1 2 4 61 23 24 53 46 57 69 79 3 1 4 2 6 8 54 18 94 82 67 32 43 55 410 21 8 5 10 6 9 4 3 710 77 83 69 77 64 21 67 59 2
3 2 1 1 1 3 1 1 3 2 2 2 2 2 1 1 1 4 2 2 1 1 1 5 1 1 1 1 1 1 1 4 3 2 2 1 1 1 1 1
4 seconds
256 megabytes
['brute force', 'dfs and similar', 'divide and conquer', 'graphs', 'greedy', 'math', 'shortest paths', 'trees', '*2100']
E. Vlad and a Pair of Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad found two positive numbers a and b (a,b>0). He discovered that a \oplus b = \frac{a + b}{2}, where \oplus means the bitwise exclusive OR , and division is performed without rounding..Si...
6251061836
3 1 -1 13 7 -1 25 11 50 22
1 second
256 megabytes
['bitmasks', 'constructive algorithms', '*1400']
D. Matryoshkastime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMatryoshka is a wooden toy in the form of a painted doll, inside which you can put a similar doll of a smaller size.A set of nesting dolls contains one or more nesting dolls, their sizes are consecutive p...
1062 2 3 4 3 1511 8 7 10 961000000000 1000000000 1000000000 1000000000 1000000000 100000000081 1 4 4 2 3 2 361 2 3 2 3 4710 11 11 12 12 13 1378 8 9 9 10 10 1184 14 5 15 6 16 7 1785 15 6 14 8 12 9 1154 2 2 3 4
2 1 6 2 2 2 2 2 4 3
2 seconds
256 megabytes
['data structures', 'greedy', 'sortings', '*1200']
C. Premutationtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA sequence of n numbers is called permutation if it contains all integers from 1 to n exactly once. For example, the sequences [3, 1, 4, 2], [1] and [2,1] are permutations, but [1,2,1], [0,1] and [1,3,4] ...
544 2 14 2 32 1 34 1 332 31 31 254 2 1 32 1 3 54 2 3 54 1 3 54 2 1 542 3 41 3 41 2 31 2 432 11 32 3
4 2 1 3 1 2 3 4 2 1 3 5 1 2 3 4 2 1 3
3 seconds
256 megabytes
['brute force', 'implementation', 'math', '*1000']
B. Taisia and Dicetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTaisia has n six-sided dice. Each face of the die is marked with a number from 1 to 6, each number from 1 to 6 is used once.Taisia rolls all n dice at the same time and gets a sequence of values a_1, a...
72 2 12 4 24 9 55 17 113 15 104 4 35 20 15
1 1 2 2 1 2 2 4 6 4 2 3 2 5 5 5 1 1 1 1 1 4 5 5 5
1 second
256 megabytes
['greedy', 'greedy', 'math', '*800']
A. Polycarp and the Day of Pitime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn March 14, the day of the number \pi is celebrated all over the world. This is a very important mathematical constant equal to the ratio of the circumference of a circle to its diameter.Po...
900034141592653141592653589793238462643383279314203141531415926535827182314159265358979323846264338327
0 1 0 0 3 5 12 0 30
1 second
256 megabytes
['implementation', 'math', 'strings', '*800']
F. Serval and Brain Powertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputServal loves Brain Power and his brain power problem.Serval defines that a string T is powerful iff T can be obtained by concatenating some string T' multiple times. Formally speaking, T is pow...
buaa
2
2 seconds
256 megabytes
['bitmasks', 'brute force', 'dp', 'greedy', 'implementation', 'strings', '*2700']
E. Serval and Music Gametime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputServal loves playing music games. He meets a problem when playing music games, and he leaves it for you to solve.You are given n positive integers s_1 < s_2 < \ldots < s_n. f(x) is defined as th...
431 2 441 2 7 94344208 591000 4779956 540342951633 1661 1741 2134 2221
26 158 758737625 12334970
2 seconds
256 megabytes
['brute force', 'dp', 'implementation', 'math', 'number theory', '*2500']
D. Serval and Shift-Shift-Shifttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputServal has two n-bit binary integer numbers a and b. He wants to share those numbers with Toxel.Since Toxel likes the number b more, Serval decides to change a into b by some (possibly ze...
3500111110001113001000
2 3 -2 0 -1
2 seconds
256 megabytes
['bitmasks', 'brute force', 'constructive algorithms', 'implementation', '*2200']
C. Serval and Toxel's Arraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToxel likes arrays. Before traveling to the Paldea region, Serval gave him an array a as a gift. This array has n pairwise distinct elements.In order to get more arrays, Toxel performed m op...
33 21 2 31 42 51 111 110 104 6 9 12 16 20 2 10 19 71 35 42 172 186 117 18 175 55 52 2
13 1 705
2 seconds
256 megabytes
['combinatorics', 'dp', 'implementation', 'math', '*1500']
B. Serval and Inversion Magictime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputServal has a string s that only consists of 0 and 1 of length n. The i-th character of s is denoted as s_i, where 1\leq i\leq n.Serval can perform the following operation called Inversion Ma...
34100151001070111011
Yes Yes No
1 second
256 megabytes
['brute force', 'implementation', 'strings', 'two pointers', '*800']
A. Serval and Mocha's Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMocha likes arrays, and Serval gave her an array consisting of positive integers as a gift.Mocha thinks that for an array of positive integers a, it is good iff the greatest common divisor of ...
623 631 2 433 6 1315 35 21435 10 35 1451261 227821 143 4171 1941
No Yes Yes No Yes Yes
1 second
256 megabytes
['brute force', 'math', 'number theory', '*800']
F. XOR, Tree, and Queriestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree of n vertices. The vertices are numbered from 1 to n.You will need to assign a weight to each edge. Let the weight of the i-th edge be a_i (1 \leq i \leq n-1). The weight o...
4 4 1 2 2 3 3 4 1 4 3 2 4 2 1 3 1 2 3 1
No
3 seconds
256 megabytes
['bitmasks', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'implementation', 'trees', '*2500']
E. Sum Over Zerotime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \ldots, a_n of n integers. Consider S as a set of segments satisfying the following conditions. Each element of S should be in form [x, y], where x and y are integers be...
5 3 -3 -2 5 -4
4
1 second
256 megabytes
['data structures', 'dfs and similar', 'dp', '*2200']
D. Moving Dotstime limit per test1.5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputWe play a game with n dots on a number line.The initial coordinate of the i-th dot is x_i. These coordinates are distinct. Every dot starts moving simultaneously with the same constant speed.Each dot m...
4 1 2 4 6
11
1.5 seconds
1024 megabytes
['binary search', 'brute force', 'combinatorics', 'math', 'two pointers', '*2000']
C. Matching Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n. Pair the integers 1 to 2n (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct. Formally, let (a_i, b_i) be the p...
4 1 2 3 4
Yes 1 2 No Yes 1 6 3 5 4 2 No
1 second
256 megabytes
['constructive algorithms', 'greedy', 'math', '*1300']
B. Sum of Two Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe sum of digits of a non-negative integer a is the result of summing up its digits together when written in the decimal system. For example, the sum of digits of 123 is 6 and the sum of digits of ...
5 1 161 67 1206 19
1 0 67 94 60 7 1138 68 14 5
1 second
256 megabytes
['constructive algorithms', 'greedy', 'implementation', 'math', 'probabilities', '*1100']
A. One and Twotime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence a_1, a_2, \ldots, a_n. Each element of a is 1 or 2.Find out if an integer k exists so that the following conditions are met. 1 \leq k \leq n-1, and a_1 \cdot a_2 \cdot \ldots \c...
362 2 1 2 1 231 2 141 1 1 1
2 -1 1
1 second
256 megabytes
['brute force', 'implementation', 'math', '*800']
I. Treasure Hunttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDefine the beauty value of a sequence b_1,b_2,\ldots,b_c as the maximum value of \sum\limits_{i=1}^{q}b_i + \sum\limits_{i=s}^{t}b_i, where q, s, t are all integers and s > q or t\leq q. Note that b_i =...
4780 59 100 -52 -86 -62 758-48 -14 -26 43 -41 34 13 551742056 -60 62 13 88 -48 64 36 -10 19 94 25 -69 88 87 79 -70 74 -26 59
5924 2548 148 98887
2 seconds
512 megabytes
['data structures', 'divide and conquer', 'two pointers', '*3400']
H. Codeforces Scoreboardtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are participating in a Codeforces Round with n problems. You spend exactly one minute to solve each problem, the time it takes to submit a problem can be ignored. You can only solve at most ...
4410000 1000000000 200610000 1000000000 99992 999991010 10101000000000 1000000000 99999999961 8 19 29 42 14 34 13 12 19 510 12 584 10 14 19 81 14 34 15 62 9 61 11 102 19 124 19 14105 12 75 39 122 39 113 23 155 30 113 17 135 29 143 17 113 36 183 9 8
3999961003 53 78 180
3 seconds
512 megabytes
['binary search', 'data structures', 'dp', 'geometry', '*3300']
G. Colorful Tree Againtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAn edge-weighted tree of n nodes is given with each edge colored in some color. Each node of this tree can be blocked or unblocked, all nodes are unblocked initially.A simple path is a path in a g...
5 4 4 1 3 4 5 2 4 4 3 1 3 2 1 2 5 1 0 4 0 3 0 2 1 3
5 5 0 3
2 seconds
512 megabytes
['brute force', 'data structures', 'trees', '*3000']
F. Inverse Transformationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation scientist is studying a self-transforming permutation a consisting of n elements a_1,a_2,\ldots,a_n.A permutation is a sequence of integers from 1 to n of length n containing each ...
105 31 2 3 4 57 21 2 3 4 5 6 78 9981 2 3 4 5 6 7 86 16 3 5 4 1 24 84 2 1 39 11 5 4 8 7 6 3 2 95 99999992 3 4 5 17 978432204 6 1 2 7 5 33 10000000002 1 312 38 9 10 1 5 3 11 4 7 6 12 2
YES 2 3 4 1 5 YES 6 2 5 7 1 3 4 YES 2 3 4 5 6 7 8 1 YES 3 1 6 4 2 5 YES 4 2 1 3 NO YES 3 4 5 1 2 YES 2 5 4 6 3 7 1 NO YES 3 7 8 6 5 1 12 10 11 4 2 9
1 second
256 megabytes
['constructive algorithms', 'implementation', 'math', '*2500']
E. The Harmonization of XORtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of exactly n numbers [1,2,3,\ldots,n] along with integers k and x.Partition the array in exactly k non-empty disjoint subsequences such that the bitwise XOR of all numbe...
715 6 711 4 55 3 24 1 46 1 711 5 511 6 5
YES 3 6 10 11 3 5 12 14 3 3 9 13 3 1 2 4 2 8 15 1 7 YES 2 1 4 2 2 7 2 3 6 5 5 8 9 10 11 NO YES 4 1 2 3 4 YES 6 1 2 3 4 5 6 NO NO
1 second
256 megabytes
['bitmasks', 'constructive algorithms', 'greedy', 'math', '*2100']
D. Game on Axistime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n points 1,2,\ldots,n, each point i has a number a_i on it. You're playing a game on them. Initially, you are at point 1. When you are at point i, take following steps: If 1\le i\le n, go to i+...
9102-1 021 -121 13-1 -2 -131 -2 -14-1 4 -2 151 1 1 1 -451 1 1 1 1
2 8 6 7 20 17 34 30 40
1 second
256 megabytes
['combinatorics', 'dfs and similar', 'dsu', 'graphs', 'implementation', '*1900']
C. Remove the Brackettime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRSJ has a sequence a of n integers a_1,a_2, \ldots, a_n and an integer s. For each of a_2,a_3, \ldots, a_{n-1}, he chose a pair of non-negative integers x_i and y_i such that x_i+y_i=a_i and (x_i-s)...
105 02 0 1 3 45 15 3 4 3 57 27 6 5 4 3 2 15 11 2 3 4 55 21 2 3 4 54 00 1 1 15 54 3 5 6 44 10 2 1 03 99999200000 200000 2000006 81397976 129785 12984 78561 173685 15480
0 18 32 11 14 0 16 0 40000000000 2700826806
1 second
256 megabytes
['dp', 'greedy', 'math', '*1600']
B. Number Factorizationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an integer n.Consider all pairs of integer arrays a and p of the same length such that n = \prod a_i^{p_i} (i.e. a_1^{p_1}\cdot a_2^{p_2}\cdot\ldots) (a_i>1;p_i>0) and a_i is the product of ...
71001086413005619210000000002999999018
20 10 22 118 90 2 333333009
1 second
256 megabytes
['greedy', 'math', 'number theory', '*1100']
A. Exponential Equationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n.Find any pair of integers (x,y) (1\leq x,y\leq n) such that x^y\cdot y+y^x\cdot x = n.InputThe first line contains a single integer t (1\leq t\leq 10^4) — the number of ...
537423125020732790
-1 -1 2 3 5 5 3 13
1 second
256 megabytes
['constructive algorithms', 'math', '*800']