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 |
|---|---|---|---|---|---|
G. A Battle Against a Dragontime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA squad of n warriors is defending a castle from a dragon attack. There are m barricades between the castle and the dragon.The warriors are numbered from 1 to n. The i-th warrior knows k_i a... | 2 4
1
2
4
2
10 5
3 4
| 10 | 4 seconds | 256 megabytes | ['*special problem', 'data structures', 'dp', '*2500'] |
F. Kotlinforcestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputKotlinforces is a web platfrom that hosts programming competitions.The staff of Kotlinforces is asked to schedule n programming competitions on the next m days. Each competition is held in multiple stage... | 3 7
3 2
2 2
2 2
| 2 5 1 | 2 seconds | 512 megabytes | ['*special problem', 'constructive algorithms', 'dp', '*2000'] |
E. Fix the Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For ex... | 6
4
))((
1
4
))((
0
4
()()
0
6
))(()(
101
6
))(()(
001
5
(((((
11
| 2 0 0 4 1 -1 | 2 seconds | 256 megabytes | ['*special problem', 'bitmasks', 'dp', 'greedy', '*1700'] |
D. Sweepstaketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKotlin Heroes competition is nearing completion. This time n programmers took part in the competition. Now organizers are thinking how to entertain spectators as well. One of the possibilities is holding s... | 2 3
1 2
2 1
2 1
| 3 | 2 seconds | 256 megabytes | ['*special problem', 'brute force', 'constructive algorithms', 'implementation', 'math', '*1800'] |
C. Rhymetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's say that two strings s and t rhyme if both strings have length at least k, and their last k characters are equal. For example, if k = 3, the strings abcd and cebcd rhyme, the strings ab and ab don't rhyme... | 3
1
kotlin heroes 1
2
join kotlin 1
episode eight 0
4
abc abcdef 0
xyz zzz 1
aaa bba 0
c d 0
| 1 0 2 1 2 0 | 2 seconds | 256 megabytes | ['*special problem', 'implementation', '*1800'] |
B. Epic Noveltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlex has bought a new novel that was published in n volumes. He has read these volumes one by one, and each volume has taken him several (maybe one) full days to read. So, on the first day, he was reading ... | 4
1
1 1
100 1
99
4
10 1
20 4
16
100
1 1
100 100
42
100
1 1
100 2
99
| 1 2 42 1 | 2 seconds | 256 megabytes | ['*special problem', 'math', '*1300'] |
A. Sequence of Comparisonstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time, Petya had an array of integers a of length n. But over time, the array itself was lost, and only n-1 results of comparisons of neighboring array elements remained. In other w... | 4
>>>
<><=<
=
<<==
| > ? = < | 2 seconds | 256 megabytes | ['*special problem', '*800'] |
F. Palindromic Hamiltonian Pathtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a simple undirected graph with n vertices, n is even. You are going to write a letter on each vertex. Each letter should be one of the first k letters of the Latin alphabet.... | 4 3 3
1 2
2 3
3 4
| 9 | 5 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'dp', 'graphs', 'hashing', '*3000'] |
E. Playoff Restorationtime limit per test4 secondsmemory limit per test512 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 1337 75275197
| 5 3 5 2 1 5 5 3 | 4 seconds | 512 megabytes | ['bitmasks', 'brute force', 'hashing', 'implementation', 'meet-in-the-middle', '*2600'] |
D. Inconvenient Pairstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a city that can be represented as a square grid with corner points in (0, 0) and (10^6, 10^6).The city has n vertical and m horizontal streets that goes across the whole city, i. e. the i-... | 2
2 2 4
0 1000000
0 1000000
1 0
1000000 1
999999 1000000
0 999999
5 4 9
0 1 2 6 1000000
0 4 8 1000000
4 4
2 5
2 2
6 3
1000000 1
3 8
5 8
8 8
6 8
| 2 5 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'implementation', 'sortings', 'two pointers', '*1900'] |
C. Jury Meetingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputn people gathered to hold a jury meeting of the upcoming competition, the i-th member of the jury came up with a_i tasks, which they want to share with each other.First, the jury decides on the order whi... | 4
2
1 2
3
5 5 5
4
1 3 3 7
6
3 4 2 1 3 3
| 1 6 0 540 | 2 seconds | 256 megabytes | ['combinatorics', 'math', '*1500'] |
B. Chess Tournamenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA chess tournament will be held soon, where n chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a l... | 3
3
111
2
21
4
2122
| YES X== =X= ==X NO YES X--+ +X++ +-X- --+X | 2 seconds | 256 megabytes | ['constructive algorithms', '*1000'] |
A. Balanced Substringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n.s[l; r] is a continuous substring of letters from index l to ... | 4
1
a
6
abbaba
6
abbaba
9
babbabbaa
| -1 -1 1 6 3 6 2 5 | 2 seconds | 256 megabytes | ['implementation', '*800'] |
F. One-Four Overloadtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice has an empty grid with n rows and m columns. Some of the cells are marked, and no marked cells are adjacent to the edge of the grid. (Two squares are adjacent if they share a side.) Alice want... | 5 5
.....
.XXX.
.X.X.
.XXX.
.....
| YES 4 1 4 4 1 4 5 5 5 1 4 5 1 5 4 1 5 5 5 4 1 4 4 1 4 | 2 seconds | 256 megabytes | ['2-sat', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'implementation', '*2700'] |
E. Non-Decreasing Dilemmatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice has recently received an array a_1, a_2, \dots, a_n for her birthday! She is very proud of her array, and when she showed her friend Bob the array, he was very happy with her present too!... | 5 6
3 1 4 1 5
2 2 5
2 1 3
1 4 4
2 2 5
1 2 6
2 2 5
| 6 4 10 7 | 2 seconds | 256 megabytes | ['data structures', 'divide and conquer', 'math', '*2200'] |
D. Expression Evaluation Errortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn the board, Bob wrote n positive integers in base 10 with sum s (i. e. in decimal numeral system). Alice sees the board, but accidentally interprets the numbers on the board as base-11 i... | 6
97 2
17 1
111 4
100 2
10 9
999999 3
| 70 27 17 3 4 100 4 10 90 1 1 2 1 1 1 1 1 1 999900 90 9 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'math', '*2000'] |
C. Carrying Conundrumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column two columns to the left.For example,... | 5
100
12
8
2021
10000
| 9 4 7 44 99 | 2 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'dp', 'math', '*1600'] |
B. MEXor Mixuptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice gave Bob two integers a and b (a > 0 and b \ge 0). Being a curious boy, Bob wrote down an array of non-negative integers with \operatorname{MEX} value of all elements equal to a and \operatorname{XO... | 5
1 1
2 1
2 0
1 10000
2 10000
| 3 2 3 2 3 | 2 seconds | 256 megabytes | ['bitmasks', 'greedy', '*1000'] |
A. Domino Disastertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice has a grid with 2 rows and n columns. She fully covers the grid using n dominoes of size 1 \times 2 — Alice may place them vertically or horizontally, and each cell should be covered by exactly ... | 4
1
U
2
LR
5
LRDLR
6
UUUUUU
| D LR LRULR DDDDDD | 2 seconds | 256 megabytes | ['implementation', 'strings', '*800'] |
H. Xor-quiztime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.You are given two integers c and n. The jury has a randomly generated set A of distinct positive integers not greater than c (it is generated from all such possible sets with e... | 10 6
1 4 2 11 4 4 4
| 7 10 2 3 5 7 1 6 1 4 5 6 8 10 | 4 seconds | 256 megabytes | ['constructive algorithms', 'dp', 'interactive', 'math', 'number theory', '*3200'] |
G. Four Verticestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected weighted graph, consisting of n vertices and m edges.Some queries happen with this graph: Delete an existing edge from the graph. Add a non-existing edge to the graph. At t... | 6 6
1 3 6
4 3 1
1 4 1
2 6 4
2 4 2
5 4 3
4
1 2 5 2
0 1 4
0 3 4
1 6 1 3
| 4 3 3 7 5 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'graphs', 'greedy', 'implementation', 'shortest paths', '*3100'] |
F. Points Movementtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n points and m segments on the coordinate line. The initial coordinate of the i-th point is a_i. The endpoints of the j-th segment are l_j and r_j — left and right endpoints, respectively.Yo... | 2
4 11
2 6 14 18
0 3
4 5
11 15
3 5
10 13
16 16
1 4
8 12
17 19
7 13
14 19
4 12
-9 -16 12 3
-20 -18
-14 -13
-10 -7
-3 -1
0 4
6 11
7 9
8 10
13 15
14 18
16 17
18 19
| 5 22 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'implementation', 'sortings', '*2600'] |
E. Buds Re-hangingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex v (different from root) is the previous to v vertex on the shortest path from the ... | 5
7
1 2
1 3
1 4
2 5
2 6
4 7
6
1 2
1 3
2 4
2 5
3 6
2
1 2
7
7 3
1 5
1 3
4 6
4 7
2 1
6
2 1
2 3
4 5
3 4
3 6
| 2 2 1 2 1 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dp', 'greedy', 'trees', '*2000'] |
D2. Seating Arrangements (hard version) time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is the hard version of the problem. The only difference is that in this version 1 \le n \le 300.In the cinema seats can be represented as the table with n rows and m columns. T... | 7
1 2
1 2
3 2
1 1 2 2 3 3
3 3
3 4 4 1 1 1 1 1 2
2 2
1 1 2 1
4 2
50 50 50 50 3 50 50 50
4 2
6 6 6 6 2 2 9 6
2 9
1 3 3 3 3 3 1 1 3 1 3 1 1 3 3 1 1 3
| 1 0 4 0 0 0 1 | 1 second | 256 megabytes | ['data structures', 'greedy', 'implementation', 'sortings', 'two pointers', '*1600'] |
D1. Seating Arrangements (easy version) time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is the easy version of the problem. The only difference is that in this version n = 1.In the cinema seats can be represented as the table with n rows and m columns. The rows ar... | 4
1 3
1 2 3
1 5
2 1 5 3 3
1 2
2 1
1 6
2 3 2 1 1 1
| 3 6 0 1 | 1 second | 256 megabytes | ['data structures', 'greedy', 'sortings', '*1100'] |
C. MAX-MEX Cuttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA binary string is a string that consists of characters 0 and 1. A bi-table is a table that has exactly two rows of equal length, each being a binary string.Let \operatorname{MEX} of a bi-table be the smal... | 4
7
0101000
1101100
5
01100
10101
2
01
01
6
000000
111111
| 8 8 2 12 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'dp', 'greedy', '*1000'] |
B. MIN-MEX Cuttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA binary string is a string that consists of characters 0 and 1.Let \operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \operatornam... | 6
01
1111
01100
101
0000
01010
| 1 0 2 1 1 2 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'dp', 'greedy', '*800'] |
A. Median Maximizationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two positive integers n and s. Find the maximum possible median of an array of n non-negative integers (not necessarily distinct), such that the sum of its elements is equal to s.A me... | 8
1 5
2 5
3 5
2 1
7 17
4 14
1 1000000000
1000000000 1
| 5 2 2 0 4 4 1000000000 0 | 1 second | 256 megabytes | ['binary search', 'greedy', 'math', '*800'] |
F. Tubular Bellstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDo you know what tubular bells are? They are a musical instrument made up of cylindrical metal tubes. In an orchestra, tubular bells are used to mimic the ringing of bells.Mike has tubular bells, too! T... | 3
5
8 10 7 6 9
5
24 25 28 27 26
7
1 2 3 4 5 6 7
| ? 1 2 40 ? 2 5 90 ? 3 1 56 ? 4 5 18 ! 8 10 7 6 9 ? 1 5 312 ? 2 4 675 ! 24 25 28 27 26 ? 1 4 4 ? 2 5 10 ? 3 7 21 ? 6 2 6 ? 2 5 10 ? 1 2 2 ? 1 2 2 ? 1 2 2 ? 1 2 2 ? 1 2 2 ! 1 2 3 4 5 6 7 | 5 seconds | 512 megabytes | ['interactive', 'math', 'number theory', 'probabilities', '*2900'] |
E. Rescue Niwen!time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output Morning desert sun horizonRise above the sands of time...Fates Warning, "Exodus"After crossing the Windswept Wastes, Ori has finally reached the Windtorn Ruins to find the Heart of the Forest! However,... | 7
5
acbac
8
acabacba
12
aaaaaaaaaaaa
10
abacabadac
8
dcbaabcd
3
cba
6
sparky
| 9 17 12 29 14 3 9 | 2 seconds | 512 megabytes | ['dp', 'greedy', 'string suffix structures', 'strings', '*2500'] |
D2. Two Hundred Twenty One (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 that the hard version does require you to output the numbers of the rods to be removed. You can m... | 3
14 1
+--++---++-++-
1 14
14 3
+--++---+++---
1 14
6 12
3 10
4 10
+-+-
1 1
1 2
1 3
1 4
2 2
2 3
2 4
3 3
3 4
4 4
| 2 5 8 2 1 11 1 9 0 1 1 2 1 2 1 2 2 1 3 1 2 2 2 3 1 3 1 3 2 3 4 1 4 | 2 seconds | 512 megabytes | ['data structures', 'math', '*2200'] |
D1. Two Hundred Twenty One (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 that the easy version does not require you to output the numbers of the rods to be removed. You c... | 3
14 1
+--++---++-++-
1 14
14 3
+--++---+++---
1 14
6 12
3 10
4 10
+-+-
1 1
1 2
1 3
1 4
2 2
2 3
2 4
3 3
3 4
4 4
| 2 2 1 0 1 2 1 2 1 2 1 1 2 1 | 2 seconds | 512 megabytes | ['data structures', 'dp', 'math', '*1700'] |
C. Ringstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output Frodo was caught by Saruman. He tore a pouch from Frodo's neck, shook out its contents —there was a pile of different rings: gold and silver..."How am I to tell which is the One?!" the mage howled."Throw them o... | 7
6
101111
9
111000111
8
10000000
5
11011
6
001111
3
101
30
100000000000000100000000000000
| 3 6 1 3 1 9 4 9 5 8 1 4 1 5 3 5 1 6 2 4 1 2 2 3 1 15 16 30 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1500'] |
B. Scenes From a Memorytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the hypnosis session, Nicholas suddenly remembered a positive integer n, which doesn't contain zeros in decimal notation. Soon, when he returned home, he got curious: what is the maximum nu... | 7
3
237
5
44444
3
221
2
35
3
773
1
4
30
626221626221626221626221626221
| 2 27 1 4 1 1 2 35 2 77 1 4 1 6 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', 'math', 'number theory', '*1000'] |
A. The Miracle and the Sleepertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers l and r, l\le r. Find the largest possible value of a \bmod b over all pairs (a, b) of integers for which r\ge a \ge b \ge l.As a reminder, a \bmod b is a remaind... | 4
1 1
999999999 1000000000
8 26
1 999999999
| 0 1 12 499999999 | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
D1. Up the Strip (simplified version)time limit per test6 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputThis version of the problem differs from the next one only in the constraint on n.Note that the memory limit in this problem is lower than in others.You have a vertical strip with n... | 3 998244353
| 5 | 6 seconds | 128 megabytes | ['brute force', 'data structures', 'dp', 'math', 'number theory', '*1700'] |
C. Deep Down Belowtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn a certain video game, the player controls a hero characterized by a single integer value: power. The hero will have to beat monsters that are also characterized by a single integer value: armor.On ... | 2
1
1 42
2
3 10 15 8
2 12 11
| 43 13 | 2 seconds | 512 megabytes | ['binary search', 'greedy', 'sortings', '*1300'] |
A. Simply Strange Sorttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have a permutation: an array a = [a_1, a_2, \ldots, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.Consider the following algorithm of sorting the permutation in... | 3
3
3 2 1
7
4 5 7 1 3 2 6
5
1 2 3 4 5
| 3 5 0 | 2 seconds | 512 megabytes | ['brute force', 'implementation', 'sortings', '*800'] |
F2. Nearest Beautiful Number (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is a complicated version of problem F1. The difference between them is the constraints (F1: k \le 2, F2: k \le 10).You are given an integer n. Find the minimum integer x suc... | 6
2021 3
177890 2
34512 3
724533 4
998244353 1
12345678 10
| 2021 181111 34533 724542 999999999 12345678 | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dfs and similar', 'dp', 'greedy', '*2100'] |
F1. Nearest Beautiful Number (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is a simplified version of problem F2. The difference between them is the constraints (F1: k \le 2, F2: k \le 10).You are given an integer n. Find the minimum integer x such... | 4
1 1
221 2
177890 2
998244353 1
| 1 221 181111 999999999 | 1 second | 256 megabytes | ['binary search', 'bitmasks', 'brute force', 'constructive algorithms', 'dfs and similar', 'greedy', '*1900'] |
E. Polycarp and String Transformationtime limit per test3.0 smemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string): he adds to the right to the string t the string s, i.e. h... | 7
abacabaaacaac
nowyouknowthat
polycarppoycarppoyarppyarppyrpprppp
isi
everywherevrywhrvryhrvrhrvhv
haaha
qweqeewew
| abacaba bac -1 polycarp lcoayrp is si everywhere ewyrhv -1 -1 | 3.0 s | 256 megabytes | ['binary search', 'implementation', 'sortings', 'strings', '*1800'] |
D. Make a Power of Twotime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n. In 1 move, you can do one of the following actions: erase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after ... | 12
1052
8888
6
75
128
1
301
12048
1504
6656
1000000000
687194767
| 2 3 1 3 0 0 2 1 3 4 9 2 | 1 second | 256 megabytes | ['greedy', 'math', 'strings', '*1300'] |
C. Infinity Tabletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has found a table having an infinite number of rows and columns. The rows are numbered from 1, starting from the topmost one. The columns are numbered from 1, starting from the leftmost one.Ini... | 7
11
14
5
4
1
2
1000000000
| 2 4 4 3 1 3 2 1 1 1 1 2 31623 14130 | 1 second | 256 megabytes | ['implementation', 'math', '*800'] |
B. Who's Opposite?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSome number of people (this number is even) have stood in a circle. The people stand in the circle evenly. They are numbered clockwise starting from a person with the number 1. Each person is looking t... | 7
6 2 4
2 3 1
2 4 10
5 3 4
1 3 2
2 5 4
4 3 2
| 8 -1 -1 -1 4 1 -1 | 1 second | 256 megabytes | ['math', '*800'] |
A. Dislike of Threestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp doesn't like integers that are divisible by 3 or end with the digit 3 in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.Polycarp starts to wri... | 10
1
2
3
4
5
6
7
8
9
1000
| 1 2 4 5 7 8 10 11 14 1666 | 1 second | 256 megabytes | ['implementation', '*800'] |
E. Mocha and Starstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMocha wants to be an astrologer. There are n stars which can be seen in Zhijiang, and the brightness of the i-th star is a_i. Mocha considers that these n stars form a constellation, and she uses (a_1... | 2 4
1 3
1 2
| 4 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'fft', 'math', 'number theory', '*2200'] |
D2. Mocha and Diana (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.A forest... | 3 2 2
1 2
2 3
1 2
1 3
| 0 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'trees', 'two pointers', '*2500'] |
D1. Mocha and Diana (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.A forest ... | 3 2 2
1 2
2 3
1 2
1 3
| 0 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'dsu', 'graphs', 'greedy', 'trees', '*1400'] |
C. Mocha and Hikingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe city where Mocha lives in is called Zhijiang. There are n+1 villages and 2n-1 directed roads in this city. There are two kinds of roads: n-1 roads are from village i to village i+1, for all 1\leq... | 2
3
0 1 0
3
1 1 0
| 1 4 2 3 4 1 2 3 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', '*1200'] |
B. Mocha and Red and Bluetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs their story unravels, a timeless tale is told once again...Shirahime, a friend of Mocha's, is keen on playing the music game Arcaea and sharing Mocha interesting puzzles to solve. This day, S... | 5
7
?R???BR
7
???R???
1
?
1
B
10
?R??RB??B?
| BRRBRBR BRBRBRB B B BRRBRBBRBR | 1 second | 256 megabytes | ['dp', 'greedy', '*900'] |
A. Mocha and Mathtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMocha is a young girl from high school. She has learned so much interesting knowledge from her teachers, especially her math teacher. Recently, Mocha is learning about binary system and very interested ... | 4
2
1 2
3
1 1 3
4
3 11 3 7
5
11 7 15 3 7
| 0 1 3 3 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'math', '*900'] |
F. Strange Sorttime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have a permutation: an array a = [a_1, a_2, \ldots, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.Consider the following algorithm of sorting the permutation in increa... | 3
3
3 2 1
7
4 5 7 1 3 2 6
5
1 2 3 4 5
| 3 5 0 | 2 seconds | 512 megabytes | ['data structures', 'sortings', '*3300'] |
E. Down Belowtime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn a certain video game, the player controls a hero characterized by a single integer value: power.On the current level, the hero got into a system of n caves numbered from 1 to n, and m tunnels between th... | 3
4 4
11 22 13
8 7 5
1 2
2 3
3 4
4 1
4 4
11 22 13
5 7 8
1 2
2 3
3 4
4 1
5 7
10 40 20 30
7 2 10 5
1 2
1 5
2 3
2 4
2 5
3 4
4 5
| 15 15 19 | 5 seconds | 512 megabytes | ['binary search', 'dfs and similar', 'graphs', 'greedy', 'meet-in-the-middle', 'shortest paths', '*3000'] |
D. Top-Notch Insertionstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputConsider the insertion sort algorithm used to sort an integer sequence [a_1, a_2, \ldots, a_n] of length n in non-decreasing order.For each i in order from 2 to n, do the following. If a_i \ge a_... | 3
3 0
3 2
2 1
3 1
5 3
3 1
4 1
5 3
| 10 1 21 | 3 seconds | 512 megabytes | ['combinatorics', 'data structures', '*2600'] |
C. Bottom-Tier Reversalstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have a permutation: an array a = [a_1, a_2, \ldots, a_n] of distinct integers from 1 to n. The length of the permutation n is odd.You need to sort the permutation in increasing order.In one ... | 3
3
1 2 3
5
3 4 5 2 1
3
2 1 3
| 4 3 3 3 3 2 3 5 -1 | 2 seconds | 512 megabytes | ['constructive algorithms', 'greedy', '*2000'] |
B. Up the Striptime limit per test6 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputNote that the memory limit in this problem is lower than in others.You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.You also have a token that is initially pl... | 3 998244353
| 5 | 6 seconds | 128 megabytes | ['brute force', 'dp', 'math', 'number theory', 'two pointers', '*1900'] |
A. Charmed by the Gametime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAlice and Borys are playing tennis.A tennis match consists of games. In each game, one of the players is serving and the other one is receiving.Players serve in turns: after a game where Alice is ... | 3
2 1
1 1
0 5
| 4 0 1 2 3 2 0 2 2 2 3 | 2 seconds | 512 megabytes | ['brute force', 'math', '*1300'] |
E. Assiut Chesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.ICPC Assiut Community decided to hold a unique chess contest, and you were chosen to control a queen and hunt down the hidden king, while a member of ICPC Assiut Community c... | 1
Left
Right
Done | 7 5 7 6 7 7 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'interactive', '*2800'] |
D. Ezzat and Gridtime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMoamen was drawing a grid of n rows and 10^9 columns containing only digits 0 and 1. Ezzat noticed what Moamen was drawing and became interested in the minimum number of rows one needs to remove to m... | 3 6
1 1 1
1 7 8
2 7 7
2 15 15
3 1 1
3 15 15
| 0 | 2.5 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', '*2200'] |
C. Moamen and XORtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMoamen and Ezzat are playing a game. They create an array a of n non-negative integers where every element is less than 2^k.Moamen wins if a_1 \,\&\, a_2 \,\&\, a_3 \,\&\, \ldots \,\&\, a_n \ge a_1 \op... | 3
3 1
2 1
4 0
| 5 2 1 | 2 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'dp', 'math', 'matrices', '*1700'] |
B. Moamen and k-subarraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMoamen has an array of n distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once: Split the array into exactly k non-empt... | 3
5 4
6 3 4 2 1
4 2
1 -4 0 -2
5 1
1 2 3 4 5
| Yes No Yes | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*1100'] |
A. Ezzat and Two Subsequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEzzat has an array of n integers (maybe negative). He wants to split it into two non-empty subsequences a and b, such that every element from the array belongs to exactly one subsequence, an... | 4
3
3 1 2
3
-7 -6 -6
3
2 2 2
4
17 3 5 -3
| 4.500000000 -12.500000000 4.000000000 18.666666667 | 1 second | 256 megabytes | ['brute force', 'math', 'sortings', '*800'] |
H. DIY Treetime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output William really likes puzzle kits. For one of his birthdays, his friends gifted him a complete undirected edge-weighted graph consisting of n vertices.He wants to build a spanning tree of this graph, such t... | 10 5
5 3 4 2 1
29 49 33 12 55 15 32 62 37
61 26 15 58 15 22 8 58
37 16 9 39 20 14 58
10 15 40 3 19 55
53 13 37 44 52
23 59 58 4
69 80 29
89 28
48
| 95 | 6 seconds | 256 megabytes | ['graphs', 'greedy', 'math', 'probabilities', '*3300'] |
G. Gates to Another Worldtime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output As mentioned previously William really likes playing video games. In one of his favorite games, the player character is in a universe where every planet is designated by a binary number from... | 3 3
ask 0 7
block 3 6
ask 0 7
| 1 0 | 4 seconds | 1024 megabytes | ['bitmasks', 'data structures', 'dsu', 'two pointers', '*3300'] |
F. Sports Bettingtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output William is not only interested in trading but also in betting on sports matches. n teams participate in each match. Each team is characterized by strength a_i. Each two teams i < j play with each oth... | 2
1 2
| 1 | 4 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'dp', 'graphs', 'math', 'probabilities', '*2500'] |
E. Equilibriumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output William has two arrays a and b, each consisting of n items.For some segments l..r of these arrays William wants to know if it is possible to equalize the values of items in these segments using a balanc... | 8 5
0 1 2 9 3 2 7 5
2 2 1 9 4 1 5 8
2 6
1 7
2 4
7 8
5 8
| 1 3 1 -1 -1 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', '*2200'] |
D. Take a Guesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output This is an interactive taskWilliam has a certain sequence of integers a_1, a_2, \dots, a_n in his mind, but due to security concerns, he does not want to reveal it to you completely. William is ready t... | 7 6
2
7 | and 2 5 or 5 6 finish 5 | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'interactive', 'math', '*1800'] |
C. Compressed Bracket Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers c_1, c_2, \dots, c_n where c_i is the number of ... | 5
4 1 2 3 1
| 5 | 1 second | 256 megabytes | ['brute force', 'implementation', '*1800'] |
B. Take Your Places!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output William has an array of n integers a_1, a_2, \dots, a_n. In one move he can swap two neighboring items. Two items a_i and a_j are considered neighboring if the condition |i - j| = 1 is satisfied.Wi... | 5
3
6 6 1
1
9
6
1 1 1 2 2 2
2
8 6
6
6 2 3 4 5 1
| 1 0 3 -1 2 | 1 second | 256 megabytes | ['implementation', '*1300'] |
A. A Variety of Operationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output William has two numbers a and b initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer ... | 6
1 2
3 5
5 3
6 6
8 0
0 0
| -1 2 2 1 2 0 | 1 second | 256 megabytes | ['math', '*800'] |
F. Good Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an undirected graph consisting of n vertices with weighted edges.A simple cycle is a cycle of the graph without repeated vertices. Let the weight of the cycle be the XOR of weights of edges it con... | 9 12
6 1 0
1 3 1
3 6 0
6 2 0
6 4 1
3 4 1
2 4 0
2 5 0
4 5 0
7 8 1
8 9 1
9 7 0
| YES YES YES YES YES NO YES YES NO YES YES NO | 2 seconds | 256 megabytes | ['data structures', 'dsu', 'graphs', 'trees', '*2700'] |
E. Boring Segmentstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n segments on a number line, numbered from 1 to n. The i-th segments covers all integer points from l_i to r_i and has a value w_i.You are asked to select a subset of these segments (pos... | 5 12
1 5 5
3 4 10
4 10 6
11 12 5
10 12 3
| 3 | 3 seconds | 256 megabytes | ['data structures', 'sortings', 'trees', 'two pointers', '*2100'] |
D. Say No to Palindromestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call the string beautiful if it does not contain a substring of length at least 2, which is a palindrome. Recall that a palindrome is a string that reads the same way from the first charac... | 5 4
baacb
1 3
1 5
4 5
2 3
| 1 2 0 1 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'dp', 'strings', '*1600'] |
C. Coin Rowstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game on a matrix, consisting of 2 rows and m columns. The cell in the i-th row in the j-th column contains a_{i, j} coins in it.Initially, both Alice and Bob are standing in a ce... | 3
3
1 3 7
3 5 1
3
1 3 9
3 5 1
1
4
7
| 7 8 0 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'dp', 'implementation', '*1300'] |
B. Two Tablestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an axis-aligned rectangle room with width W and height H, so the lower left corner is in point (0, 0) and the upper right corner is in (W, H).There is a rectangular table standing in this room. Th... | 5
8 5
2 1 7 4
4 2
5 4
2 2 5 4
3 3
1 8
0 3 1 6
1 5
8 1
3 0 6 1
5 1
8 10
4 5 7 8
8 5
| 1.000000000 -1 2.000000000 2.000000000 0.000000000 | 2 seconds | 256 megabytes | ['brute force', '*1300'] |
A. PizzaForcestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of 6 slices, medium ones consist of 8 slices, and large pizzas consist of 10 slices each. ... | 6
12
15
300
1
9999999999999999
3
| 30 40 750 15 25000000000000000 15 | 2 seconds | 256 megabytes | ['brute force', 'math', '*900'] |
E. Youtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree with n nodes. As a reminder, a tree is a connected undirected graph without cycles.Let a_1, a_2, \ldots, a_n be a sequence of integers. Perform the following operation exactly n times: Sele... | 2
3
2 1
1 3
2
1 2
| 3 1 0 2 0 | 5 seconds | 256 megabytes | ['dfs and similar', 'dp', 'math', 'number theory', '*2600'] |
D. Dianetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n. Find any string s of length n consisting only of English lowercase letters such that each non-empty substring of s occurs in s an odd number of times. If there are multiple such strin... | 4
3
5
9
19
| abc diane bbcaabbba youarethecutestuwuu | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'strings', '*1800'] |
C. Mikasatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers n and m. Find the \operatorname{MEX} of the sequence n \oplus 0, n \oplus 1, \ldots, n \oplus m. Here, \oplus is the bitwise XOR operator.\operatorname{MEX} of the sequence of non-neg... | 5
3 5
4 6
3 2
69 696
123456 654321
| 4 3 0 640 530866 | 1 second | 256 megabytes | ['binary search', 'bitmasks', 'greedy', 'implementation', '*1800'] |
B. Cobbtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a_1, a_2, \ldots, a_n and an integer k. Find the maximum value of i \cdot j - k \cdot (a_i | a_j) over all pairs (i, j) of integers with 1 \le i < j \le n. Here, | is the bitwise OR opera... | 4
3 3
1 1 3
2 2
1 2
4 3
0 1 2 3
6 6
3 2 0 0 5 6
| -1 -4 3 12 | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'greedy', 'math', '*1700'] |
A. Cherrytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a_1, a_2, \ldots, a_n. Find the maximum value of max(a_l, a_{l + 1}, \ldots, a_r) \cdot min(a_l, a_{l + 1}, \ldots, a_r) over all pairs (l, r) of integers for which 1 \le l < r \le n.In... | 4
3
2 4 3
4
3 2 3 1
2
69 69
6
719313 273225 402638 473783 804745 323328
| 12 6 4761 381274500335 | 1 second | 256 megabytes | ['greedy', '*800'] |
I. Stairstime limit per test10 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputFor a permutation p of numbers 1 through n, we define a stair array a as follows: a_i is length of the longest segment of permutation which contains position i and is made of consecutive values in sorted ord... | 6
3 3 3 1 1 1
| 6 | 10 seconds | 1024 megabytes | ['combinatorics', 'divide and conquer', 'dp', 'fft', 'math', '*3400'] |
H. XOR and Distancetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n distinct elements and an integer k. Each element in the array is a non-negative integer not exceeding 2^k-1.Let's define the XOR distance for a number x as th... | 3 3
6 0 3
| 3 1 1 2 2 1 1 3 | 3 seconds | 512 megabytes | ['bitmasks', 'divide and conquer', 'trees', '*2900'] |
G. Common Divisor Graphtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a sequence of distinct integers a_1, \ldots, a_n, each representing one node of a graph. There is an edge between two nodes if the two values are not coprime, i. e. they have a common di... | 3 3
2 10 3
1 2
1 3
2 3
| 0 1 1 | 4 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'dsu', 'graphs', 'hashing', 'math', 'number theory', '*2700'] |
F. Pairwise Modulotime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as p_k = \sum_{1 \le i, j \le k} a_i \bmod a_j, where x \bmod y denotes the remainder when x is divided... | 4
6 2 7 3
| 0 2 12 22 | 4 seconds | 256 megabytes | ['data structures', 'math', '*2300'] |
E. Permutation Shifttime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn identity permutation of length n is an array [1, 2, 3, \dots, n].We performed the following operations to an identity permutation of length n: firstly, we cyclically shifted it to the right by k... | 4
4 1
2 3 1 4
3 1
1 2 3
3 1
3 2 1
6 0
1 2 3 4 6 5
| 1 3 1 0 3 0 1 2 0 | 3 seconds | 256 megabytes | ['brute force', 'combinatorics', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'math', '*2100'] |
D. Backspacetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings s and t, both consisting of lowercase English letters. You are going to type the string s character by character, from the first character to the last one.When typing a character, ... | 4
ababa
ba
ababa
bb
aaa
aaaa
aababa
ababa
| YES NO NO YES | 2 seconds | 256 megabytes | ['dp', 'greedy', 'strings', 'two pointers', '*1500'] |
C. Penaltytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a simplified penalty phase at the end of a football match.A penalty phase consists of at most 10 kicks, the first team takes the first kick, the second team takes the second kick, then the first team... | 4
1?0???1001
1111111111
??????????
0100000000
| 7 10 6 9 | 3 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'greedy', '*1200'] |
B. Reverse Stringtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a string s and a chip, which you can place onto any character of this string. After placing the chip, you move it to the right several (maybe zero) times, i. e. you perform the following opera... | 6
abcdef
cdedcb
aaa
aaaaa
aab
baaa
ab
b
abcdef
abcdef
ba
baa
| YES YES NO YES YES NO | 3 seconds | 256 megabytes | ['brute force', 'dp', 'hashing', 'implementation', 'strings', '*1300'] |
A. Digits Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's define S(x) to be the sum of digits of number x written in decimal system. For example, S(5) = 5, S(10) = 1, S(322) = 7.We will call an integer x interesting if S(x + 1) < S(x). In each test you will ... | 5
1
9
10
34
880055535
| 0 1 1 3 88005553 | 1 second | 256 megabytes | ['math', 'number theory', '*800'] |
I. Organizing a Music Festivaltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are the organizer of the famous "Zurich Music Festival". There will be n singers who will perform at the festival, identified by the integers 1, 2, \dots, n. You must choose in which or... | 3 1
2 1 3
| 4 | 1 second | 256 megabytes | ['dfs and similar', 'math', '*3400'] |
H. Guess the Perimetertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet us call a point of the plane admissible if its coordinates are positive integers less than or equal to 200.There is an invisible rectangle such that: its vertices are all admissible; its sid... | 13 5 123 80
| null | 1 second | 256 megabytes | ['binary search', 'interactive', 'number theory', '*3300'] |
G. A Serious Refereetime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputAndrea has come up with what he believes to be a novel sorting algorithm for arrays of length n. The algorithm works as follows.Initially there is an array of n integers a_1,\, a_2,\, \dots,\, a_n. T... | 4 3
3 1 2 3
3 2 3 4
2 1 2
| ACCEPTED | 1 second | 512 megabytes | ['bitmasks', 'brute force', 'dfs and similar', 'sortings', '*3000'] |
F. Telepantingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn ant moves on the real line with constant speed of 1 unit per second. It starts at 0 and always moves to the right (so its position increases by 1 each second).There are n portals, the i-th of which is ... | 4
3 2 0
6 5 1
7 4 0
8 1 1
| 23 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dp', 'sortings', '*2200'] |
E. Colors and Intervalstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe numbers 1, \, 2, \, \dots, \, n \cdot k are colored with n colors. These colors are indexed by 1, \, 2, \, \dots, \, n. For each 1 \le i \le n, there are exactly k numbers colored with color i... | 4 3
2 4 3 1 1 4 2 3 2 1 3 4
| 4 5 1 7 8 11 6 12 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', 'sortings', '*2300'] |
D. Array Differentiationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence of n integers a_1, \, a_2, \, \dots, \, a_n.Does there exist a sequence of n integers b_1, \, b_2, \, \dots, \, b_n such that the following property holds? For each 1 \l... | 5
5
4 -7 -1 5 10
1
0
3
1 10 100
4
-3 2 10 2
9
25 -171 250 174 152 242 100 -205 -258
| YES YES NO YES YES | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dfs and similar', 'dp', 'graphs', 'math', '*1800'] |
C. Maximize the Intersectionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn a circle lie 2n distinct points, with the following property: however you choose 3 chords that connect 3 disjoint pairs of points, no point strictly inside the circle belongs to all 3 cho... | 4
4 2
8 2
1 5
1 1
2 1
2 0
10 6
14 6
2 20
9 10
13 18
15 12
11 7
| 4 0 1 14 | 1 second | 256 megabytes | ['combinatorics', 'constructive algorithms', 'geometry', 'greedy', 'sortings', '*1800'] |
B. Running for Goldtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Olympic Games have just started and Federico is eager to watch the marathon race.There will be n athletes, numbered from 1 to n, competing in the marathon, and all of them have taken part in 5 imp... | 4
1
50000 1 50000 50000 50000
3
10 10 20 30 30
20 20 30 10 10
30 30 10 20 20
3
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
6
9 5 3 7 1
7 4 1 6 8
5 6 7 3 2
6 7 8 8 6
4 2 2 4 5
8 3 6 9 4
| 1 -1 1 5 | 1 second | 256 megabytes | ['combinatorics', 'graphs', 'greedy', 'sortings', '*1500'] |
A. Subsequence Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA string s of length n, consisting of lowercase letters of the English alphabet, is given.You must choose some number k between 0 and n. Then, you select k characters of s and permute them howe... | 4
3
lol
10
codeforces
5
aaaaa
4
dcba
| 2 6 0 4 | 1 second | 256 megabytes | ['sortings', 'strings', '*800'] |
F. Equidistant Verticestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is an undirected connected graph without cycles.You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) ... | 3
4 2
1 2
2 3
2 4
3 3
1 2
2 3
5 3
1 2
2 3
2 4
4 5
| 6 0 1 | 1 second | 256 megabytes | ['brute force', 'combinatorics', 'dfs and similar', 'dp', 'trees', '*2200'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.