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 |
|---|---|---|---|---|---|
H. Hard Cuttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string s. You have to cut it into any number of non-intersecting substrings, so that the sum of binary integers denoted by these substrings is a power of 2. Each element of s should be... | 4
00000
01101
0111011001011
000111100111110
| -1 3 1 3 4 4 5 5 8 1 2 3 3 4 4 5 6 7 7 8 10 11 12 13 13 5 1 5 6 7 8 11 12 14 15 15 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'divide and conquer', 'math', '*3400'] |
G. Euclid Guesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's consider Euclid's algorithm for finding the greatest common divisor, where t is a list:function Euclid(a, b): if a < b: swap(a, b) if b == 0: return a r = reminder from dividi... | 7 20
1 8 1 6 3 2 3
| 3 19 11 15 9 3 7 | 1 second | 256 megabytes | ['constructive algorithms', 'flows', 'graph matchings', 'math', 'number theory', '*2800'] |
F. Diverse Segmentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers. Also you are given m subsegments of that array. The left and the right endpoints of the j-th segment are l_j and r_j respectively.You are allowed to make no mo... | 5
7 3
1 1 2 1 3 3 5
1 4
4 5
2 4
5 2
10 1 6 14 1
4 5
2 4
4 5
5 7 5 6
2 2
1 3
2 4
3 3
3 4
7 3
2 2 2 7 8 2 2
4 4
4 4
5 5
1 1
123
1 1
| 2 0 1 0 0 | 2 seconds | 256 megabytes | ['data structures', 'two pointers', '*2600'] |
E. MEX vs DIFFtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n non-negative integers. In one operation you can change any number in the array to any other non-negative integer.Let's define the cost of the array as \operatorname{DIFF}(a) ... | 4
4 1
3 0 1 2
4 1
0 2 4 5
7 2
4 13 0 0 13 1337 1000000000
6 2
1 2 8 0 0 0
| 0 1 2 0 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'constructive algorithms', 'data structures', 'greedy', 'two pointers', '*2100'] |
D. Trapstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n traps numbered from 1 to n. You will go through them one by one in order. The i-th trap deals a_i base damage to you.Instead of going through a trap, you can jump it over. You can jump over no more t... | 5
4 4
8 7 1 4
4 1
5 10 11 5
7 5
8 2 5 15 11 2 8
6 3
1 2 3 4 5 6
1 1
7
| 0 21 9 6 0 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*1700'] |
C. Column Swappingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a grid with n rows and m columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order.... | 5
2 3
1 2 3
1 1 1
2 2
4 1
2 3
2 2
2 1
1 1
2 3
6 2 1
5 4 3
2 1
1
2
| 1 1 -1 1 2 1 3 1 1 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'implementation', 'sortings', '*1400'] |
B. Z mod X = Ctime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three positive integers a, b, c (a < b < c). You have to find three positive integers x, y, z such that:x \bmod y = a, y \bmod z = b, z \bmod x = c.Here p \bmod q denotes the remainder from d... | 4
1 3 4
127 234 421
2 7 8
59 94 388
| 12 11 4 1063 234 1484 25 23 8 2221 94 2609 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
A. Digit Minimizationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an integer n without zeros in its decimal representation. Alice and Bob are playing a game with this integer. Alice starts first. They play the game in turns.On her turn, Alice must swap an... | 3
12
132
487456398
| 2 1 3 | 1 second | 256 megabytes | ['constructive algorithms', 'games', 'math', 'strings', '*800'] |
F. MCMF?time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integer arrays a and b (b_i \neq 0 and |b_i| \leq 10^9). Array a is sorted in non-decreasing order.The cost of a subarray a[l:r] is defined as follows:If \sum\limits_{j = l}^{r} b_j \neq 0, t... | 8 4
1 2 4 5 9 10 10 13
6 -1 1 -3 2 1 -1 1
2 3
6 7
3 5
2 6
| 2 0 9 15 | 3 seconds | 256 megabytes | ['data structures', 'flows', 'graphs', 'greedy', 'sortings', 'two pointers', '*2700'] |
E. Unordered Swapstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice had a permutation p of numbers from 1 to n. Alice can swap a pair (x, y) which means swapping elements at positions x and y in p (i.e. swap p_x and p_y). Alice recently learned her first sorting... | 4 3
2 3 4 1
1 4
2 1
1 3
| 2 3 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', 'greedy', 'math', 'sortings', 'trees', '*2700'] |
D. Circular Spanning Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n nodes arranged in a circle numbered from 1 to n in the clockwise order. You are also given a binary string s of length n.Your task is to construct a tree on the given n nodes satisfy... | 3401102106110110 | YES 2 1 3 4 1 4 NO YES 2 3 1 2 5 6 6 2 3 4 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', 'trees', '*2000'] |
C. LIS or Reverse LIS?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n positive integers. Let \text{LIS}(a) denote the length of longest strictly increasing subsequence of a. For example, \text{LIS}([2, \underline{1}, 1, \underline{3}]) ... | 3
3
6 6 6
6
2 5 4 5 2 4
4
1 3 2 2
| 1 3 2 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'math', '*1400'] |
B. AND Sortingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p of integers from 0 to n-1 (each of them occurs exactly once). Initially, the permutation is not sorted (that is, p_i>p_{i+1} for at least one 1 \le i \le n - 1). The permutati... | 4
4
0 1 3 2
2
1 0
7
0 1 2 3 5 6 4
5
0 3 2 1 4
| 2 0 4 1 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'sortings', '*1100'] |
A. Palindromic Indicestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a palindromic string s of length n.You have to count the number of indices i (1 \le i \le n) such that the string after removing s_i from s still remains a palindrome. For example, co... | 3
3
aba
8
acaaaaca
2
dd
| 1 4 2 | 1 second | 256 megabytes | ['greedy', 'strings', '*800'] |
F. Unique Occurrencestime limit per test6 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given a tree, consisting of n vertices. Each edge has an integer value written on it.Let f(v, u) be the number of values that appear exactly once on the edges of a simple path between vert... | 3
1 2 1
1 3 2
| 4 | 6 seconds | 1024 megabytes | ['data structures', 'dfs and similar', 'divide and conquer', 'dp', 'dsu', 'trees', '*2300'] |
E. Labyrinth Adventurestime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou found a map of a weirdly shaped labyrinth. The map is a grid, consisting of n rows and n columns. The rows of the grid are numbered from 1 to n from bottom to top. The columns of the grid are... | 2
1 1 1 1
10
1 1 1 1
1 1 1 2
1 1 2 1
1 1 2 2
1 2 1 2
1 2 2 1
1 2 2 2
2 1 2 1
2 1 2 2
2 2 2 2
| 0 1 1 2 0 2 1 0 1 0 | 6 seconds | 512 megabytes | ['data structures', 'dp', 'matrices', 'shortest paths', '*2600'] |
D. Required Lengthtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two integer numbers, n and x. You may perform several operations with the integer x.Each operation you perform is the following one: choose any digit y that occurs in the decimal represe... | 2 1
| -1 | 2 seconds | 512 megabytes | ['brute force', 'dfs and similar', 'dp', 'hashing', 'shortest paths', '*1700'] |
C. Double Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b, both consisting of n integers.In one move, you can choose two indices i and j (1 \le i, j \le n; i \neq j) and swap a_i with a_j and b_i with b_j. You have to perform the... | 3
2
1 2
1 2
2
2 1
1 2
4
2 3 1 2
2 3 2 3
| 0 -1 3 3 1 3 2 4 3 | 2 seconds | 256 megabytes | ['implementation', 'sortings', '*1200'] |
B. Card Tricktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp has just learned a new card trick, and can't wait to present it to you. He shows you the entire deck of n cards. You see that the values of cards from the topmost to the bottommost are integers a_... | 3
2
1 2
3
1 1 1
4
3 1 4 2
2
3 1
5
2 1 5 4 3
5
3 2 1 2 1
| 2 3 3 | 2 seconds | 256 megabytes | ['implementation', 'math', '*800'] |
A. Game with Cardstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob play a game. Alice has n cards, the i-th of them has the integer a_i written on it. Bob has m cards, the j-th of them has the integer b_j written on it.On the first turn of the game, the... | 4
1
6
2
6 8
4
1 3 3 7
2
4 2
1
50
2
25 50
10
1 2 3 4 5 6 7 8 9 10
2
5 15
| Bob Bob Alice Alice Alice Bob Bob Bob | 2 seconds | 256 megabytes | ['games', 'greedy', '*800'] |
F. Lenient Vertex Covertime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a simple connected undirected graph, consisting of n vertices and m edges. The vertices are numbered from 1 to n.A vertex cover of a graph is a set of vertices such that each edge h... | 4
6 5
1 3
2 4
3 4
3 5
4 6
4 6
1 2
2 3
3 4
1 4
1 3
2 4
8 11
1 3
2 4
3 5
4 6
5 7
6 8
1 2
3 4
5 6
7 8
7 2
4 5
1 2
2 3
3 4
1 3
2 4
| YES 001100 NO YES 01100110 YES 0110 | 5 seconds | 512 megabytes | ['dfs and similar', 'divide and conquer', 'dsu', 'graphs', 'trees', '*2600'] |
E. Moving Chipstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a board of size 2 \times n (2 rows, n columns). Some cells of the board contain chips. The chip is represented as '*', and an empty space is represented as '.'. It is guaranteed that there ... | 5
1
*
.
2
.*
**
3
*.*
.*.
4
**.*
**..
5
**...
...**
| 0 2 3 5 5 | 2 seconds | 256 megabytes | ['bitmasks', 'dp', 'greedy', '*2000'] |
D. Dog Walkingtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are walking with your dog, and now you are at the promenade. The promenade can be represented as an infinite line. Initially, you are in the point 0 with your dog. You decided to give some freedom to ... | 3 2
5 0 -4
| 6 | 4 seconds | 256 megabytes | ['brute force', 'greedy', 'math', '*2400'] |
C. Binary Stringtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of characters 0 and/or 1.You have to remove several (possibly zero) characters from the beginning of the string, and then several (possibly zero) characters from the ... | 5
101110110
1001001001001
0000111111
00000
1111
| 1 3 0 0 0 | 2 seconds | 512 megabytes | ['binary search', 'greedy', 'strings', 'two pointers', '*1600'] |
B. Robotstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere is a field divided into n rows and m columns. Some cells are empty (denoted as E), other cells contain robots (denoted as R).You can send a command to all robots at the same time. The command can be of o... | 6
1 3
ERR
2 2
ER
RE
2 2
ER
ER
1 1
R
4 3
EEE
EEE
ERR
EER
3 3
EEE
EER
REE
| YES NO YES YES YES NO | 2 seconds | 512 megabytes | ['implementation', '*800'] |
A. Minimums and Maximumstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAn array is beautiful if both of the following two conditions meet: there are at least l_1 and at most r_1 elements in the array equal to its minimum; there are at least l_2 and at most r_2 el... | 7
3 5 4 6
5 8 5 5
3 3 10 12
1 5 3 3
1 1 2 2
2 2 1 1
6 6 6 6
| 4 5 13 3 3 3 6 | 2 seconds | 512 megabytes | ['brute force', 'math', '*800'] |
F. Formalism for Formalismtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYura is a mathematician, and his cognition of the world is so absolute as if he have been solving formal problems a hundred of trillions of billions of years. This problem is just that!Conside... | 1
0
| 10 | 3 seconds | 256 megabytes | ['bitmasks', 'dp', 'math', '*2600'] |
E. Typical Party in Dormtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday is a holiday in the residence hall — Oleh arrived, in honor of which the girls gave him a string. Oleh liked the gift a lot, so he immediately thought up and offered you, his best friend, ... | 7
ab??aba
8
a
b
ab
abc
abcd
abcde
abcdef
abcdefg
| 14 13 55 105 171 253 351 465 | 2 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'dp', 'strings', '*2400'] |
D. Toss a Coin to Your Graph...time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Masha was walking in the park and found a graph under a tree... Surprised? Did you think that this problem would have some logical and reasoned story? No way! So, the problem...Ma... | 6 7 4
1 10 2 3 4 5
1 2
1 3
3 4
4 5
5 6
6 2
2 5
| 4 | 3 seconds | 256 megabytes | ['binary search', 'dfs and similar', 'dp', 'graphs', '*1900'] |
C. Rooks Defenderstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a square chessboard of size n \times n. Rows are numbered from top to bottom with numbers from 1 to n, and columns — from left to right with numbers from 1 to n. So, each cell is denoted with ... | 8 10
1 2 4
3 6 2 7 2
1 3 2
3 6 2 7 2
1 4 3
3 2 6 4 8
2 4 3
3 2 6 4 8
1 4 8
3 2 6 4 8
| No Yes Yes No Yes | 1 second | 256 megabytes | ['data structures', 'implementation', '*1400'] |
B. Stone Age Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the... | 5 5
1 2 3 4 5
1 1 5
2 10
1 5 11
1 4 1
2 1
| 19 50 51 42 5 | 2 seconds | 256 megabytes | ['data structures', 'implementation', '*1200'] |
A. AvtoBustime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSpring has come, and the management of the AvtoBus bus fleet has given the order to replace winter tires with summer tires on all buses.You own a small bus service business and you have just received an order ... | 4
4
7
24
998244353998244352
| 1 1 -1 4 6 166374058999707392 249561088499561088 | 1 second | 256 megabytes | ['brute force', 'greedy', 'math', 'number theory', '*900'] |
B2. Tokitsukaze and Good 01-String (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tok... | 5
10
1110011000
8
11001111
2
00
2
11
6
100110
| 3 2 0 3 0 1 0 1 3 1 | 1 second | 256 megabytes | ['dp', 'greedy', 'implementation', '*1800'] |
B1. Tokitsukaze and Good 01-String (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 that the harder version asks additionally for a minimum number of subsegments.Tok... | 5
10
1110011000
8
11001111
2
00
2
11
6
100110
| 3 0 0 0 3 | 1 second | 256 megabytes | ['implementation', '*800'] |
A. Tokitsukaze and All Zero Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTokitsukaze has a sequence a of length n. For each operation, she selects two numbers a_i and a_j (i \ne j; 1 \leq i,j \leq n). If a_i = a_j, change one of them to 0. Otherwise cha... | 3
3
1 2 3
3
1 2 2
3
1 2 0
| 4 3 2 | 1 second | 256 megabytes | ['implementation', '*800'] |
F. Tokitsukaze and Gemstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputTokitsukaze has a sequence with length of n. She likes gems very much. There are n kinds of gems. The gems of the i-th kind are on the i-th position, and there are a_i gems of the same kind on th... | 5 2 2
1 1 1 2 2
| 6428 | 4 seconds | 512 megabytes | ['dp', 'math', '*3500'] |
E. Tokitsukaze and Beautiful Subsegmentstime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputTokitsukaze has a permutation p of length n.Let's call a segment [l,r] beautiful if there exist i and j satisfying p_i \cdot p_j = \max\{p_l, p_{l+1}, \ldots, p_r \}, where l \l... | 8 3
1 3 5 2 4 7 6 8
1 3
1 1
1 8
| 2 0 10 | 4 seconds | 1024 megabytes | ['data structures', '*2900'] |
D. Tokitsukaze and Permutationstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTokitsukaze has a permutation p. She performed the following operation to p exactly k times: in one operation, for each i from 1 to n - 1 in order, if p_i > p_{i+1}, swap p_i, p_{i+1}. Af... | 3
5 0
0 1 2 3 4
5 2
-1 1 2 0 0
5 2
0 1 1 0 0
| 1 6 6 | 2 seconds | 256 megabytes | ['dp', 'math', '*2500'] |
C. Tokitsukaze and Two Colorful Tapestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTokitsukaze has two colorful tapes. There are n distinct colors, numbered 1 through n, and each color appears exactly once on each of the two tapes. Denote the color of the i-th pos... | 3
6
1 5 4 3 2 6
5 3 1 4 6 2
6
3 5 4 6 2 1
3 6 4 5 2 1
1
1
1
| 18 10 0 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', 'greedy', '*1900'] |
B. Tokitsukaze and Meetingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTokitsukaze is arranging a meeting. There are n rows and m columns of seats in the meeting hall.There are exactly n \cdot m students attending the meeting, including several naughty students an... | 3
2 2
1100
4 2
11001101
2 4
11001101
| 2 3 4 3 2 3 4 3 5 4 6 5 2 3 3 3 4 4 4 5 | 1 second | 256 megabytes | ['data structures', 'implementation', 'math', '*1700'] |
A. Tokitsukaze and Strange Inequalitytime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTokitsukaze has a permutation p of length n. Recall that a permutation p of length n is a sequence p_1, p_2, \ldots, p_n consisting of n distinct integers, each of which from 1 to... | 3
6
5 3 6 1 4 2
4
1 2 3 4
10
5 1 6 2 8 3 4 10 9 7
| 3 0 28 | 1.5 seconds | 256 megabytes | ['brute force', 'data structures', 'dp', '*1600'] |
H2. Maximum Crossings (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the two versions is that in this version n \leq 2 \cdot 10^5 and the sum of n over all test cases does not exceed 2 \cdot 10^5.A terminal is a row of n equ... | 474 1 4 6 7 7 522 11132 2 2 | 6 1 0 3 | 1 second | 256 megabytes | ['data structures', 'divide and conquer', 'sortings', '*1500'] |
H1. Maximum Crossings (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the two versions is that in this version n \leq 1000 and the sum of n over all test cases does not exceed 1000.A terminal is a row of n equal segments numb... | 474 1 4 6 7 7 522 11132 2 2 | 6 1 0 3 | 1 second | 256 megabytes | ['brute force', '*1400'] |
G. White-Black Balanced Subtreestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree consisting of n vertices numbered from 1 to n. The root is vertex 1. There is also a string s denoting the color of each vertex: if s_i = \texttt{B}, then vert... | 371 1 2 3 3 5WBBWWBW21BW81 2 3 4 5 6 7BWBWBWBW | 2 1 4 | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'trees', '*1300'] |
F. Longest Striketime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of length n and an integer k, you are tasked to find any two numbers l and r (l \leq r) such that: For each x (l \leq x \leq r), x appears in a at least k times (i.e. k or more array ... | 47 211 11 12 13 13 14 145 16 3 5 2 16 44 3 4 3 3 414 21 1 2 2 2 3 3 3 3 4 4 4 4 4 | 13 14 1 3 -1 1 4 | 1 second | 256 megabytes | ['data structures', 'greedy', 'implementation', 'sortings', 'two pointers', '*1300'] |
E. Eating Queriestime limit per test3.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTimur has n candies. The i-th candy has a quantity of sugar equal to a_i. So, by eating the i-th candy, Timur consumes a quantity of sugar equal to a_i.Timur will ask you q queries regarding his cand... | 38 74 3 3 1 1 4 5 911050141522304 11 2 3 431 2546 | 1 2 -1 2 3 4 8 1 1 -1 | 3.5 seconds | 256 megabytes | ['binary search', 'greedy', 'sortings', '*1100'] |
D. X-Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTimur's grandfather gifted him a chessboard to practice his chess skills. This chessboard is a grid a with n rows and m columns with each cell having a non-negative integer written on it. Timur's challenge is t... | 44 41 2 2 12 4 2 42 2 3 12 4 2 42 1103 31 1 11 1 11 1 13 30 1 11 0 11 1 0 | 20 1 5 3 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', '*1000'] |
C. Most Similar Wordstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n words of equal length m, consisting of lowercase Latin alphabet letters. The i-th word is denoted s_i.In one move you can choose any position in any single word and change the lette... | 62 4bestcost6 3abbzbabefcduooozzz2 7aaabbbcbbaezfe3 2ababab2 8aaaaaaaazzzzzzzz3 1auy | 11 8 35 0 200 4 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', 'implementation', 'math', 'strings', '*800'] |
B. Equal Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n boxes with different quantities of candies in each of them. The i-th box has a_i candies inside.You also have n friends that you want to give the candies to, so you decided to give each frien... | 551 2 3 4 561000 1000 5 1000 1000 1000101 2 3 5 1 2 7 9 13 538 8 8110000000 | 10 4975 38 0 0 | 1 second | 256 megabytes | ['greedy', 'math', 'sortings', '*800'] |
A. Lucky?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA ticket is a string consisting of six digits. A ticket is considered lucky if the sum of the first three digits is equal to the sum of the last three digits. Given a ticket, output if it is lucky or not. Note ... | 5213132973894045207000000055776 | YES NO YES YES NO | 1 second | 256 megabytes | ['implementation', '*800'] |
G. Sorting Pancakestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNastya baked m pancakes and spread them on n dishes. The dishes are in a row and numbered from left to right. She put a_i pancakes on the dish with the index i.Seeing the dishes, Vlad decided to brin... | 6 19
5 3 2 3 3 3
| 2 | 2 seconds | 256 megabytes | ['dp', '*2300'] |
F. Vlad and Unfinished Businesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad and Nastya live in a city consisting of n houses and n-1 road. From each house, you can get to the other by moving only along the roads. That is, the city is a tree.Vlad lives in a h... | 33 11 321 31 26 43 51 6 2 11 33 43 55 65 26 23 25 31 33 43 55 65 2 | 3 7 2 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'greedy', 'trees', '*1800'] |
E. Replace With the Previous, Minimizetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s of lowercase Latin letters. The following operation can be used: select one character (from 'a' to 'z') that occurs at least once in the string. And repl... | 43 2cba4 5fgde7 5gndcafb4 19ekyv | aaa agaa bnbbabb aapp | 2 seconds | 256 megabytes | ['dsu', 'greedy', 'strings', '*1500'] |
D. Vertical Pathstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree consisting of n vertices. Vertices are numbered from 1 to n. Any vertex can be the root of a tree.A tree is a connected undirected graph without cycles. A rooted tree is a t... | 653 1 3 3 141 1 4 171 1 2 3 4 5 61164 4 4 4 1 242 2 2 2 | 3 3 3 1 5 1 2 1 4 2 2 1 2 2 4 3 1 7 1 2 3 4 5 6 7 1 1 1 3 3 4 1 5 2 2 6 1 3 3 2 2 1 1 3 1 4 | 2 seconds | 256 megabytes | ['graphs', 'implementation', 'trees', '*1300'] |
C. Detective Tasktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp bought a new expensive painting and decided to show it to his n friends. He hung it in his room. n of his friends entered and exited there one by one. At one moment there was no more than one ... | 8
0
1
1110000
?????
1?1??0?0
0?0???
??11
??0??
| 1 1 2 5 4 1 1 3 | 2 seconds | 256 megabytes | ['implementation', '*1100'] |
B. Make It Increasingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven n integers a_1, a_2, \dots, a_n. You can perform the following operation on them: select any element a_i (1 \le i \le n) and divide it by 2 (round down). In other words, you can replace any ... | 7
3
3 6 5
4
5 3 2 1
5
1 2 3 4 5
1
1000000000
4
2 8 7 5
5
8 26 5 21 10
2
5 14
| 2 -1 0 0 4 11 0 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*900'] |
A. Food for Animalstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the pet store on sale there are: a packs of dog food; b packs of cat food; c packs of universal food (such food is suitable for both dogs and cats). Polycarp has x dogs and y cats. Is it possibl... | 7
1 1 4 2 3
0 0 0 0 0
5 5 0 4 6
1 1 1 1 1
50000000 50000000 100000000 100000000 100000000
0 0 0 100000000 100000000
1 3 2 2 5
| YES YES NO YES YES NO NO | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
G. Remove Directed Edgestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a directed acyclic graph, consisting of n vertices and m edges. The vertices are numbered from 1 to n. There are no multiple edges and self-loops.Let \mathit{in}_v be the number of... | 3 3
1 2
2 3
1 3
| 2 | 2 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', '*2000'] |
F. Desktop Rearrangementtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friend Ivan asked you to help him rearrange his desktop. The desktop can be represented as a rectangle matrix of size n \times m consisting of characters '.' (empty cell of the desktop) and... | 4 4 8
..**
.*..
*...
...*
1 3
2 3
3 1
2 3
3 4
4 3
2 3
2 2
| 3 4 4 3 4 5 5 5 | 3 seconds | 256 megabytes | ['data structures', 'greedy', 'implementation', '*1800'] |
E. Breaking the Walltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's ter... | 5
20 10 30 10 20
| 10 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'constructive algorithms', 'greedy', 'math', '*2000'] |
D. A-B-C Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three arrays a, b and c. Initially, array a consists of n elements, arrays b and c are empty.You are performing the following algorithm that consists of two steps: Step 1: while a is not em... | 3
4
3 1 5 3
3
3 2 1
1
7331
| YES NO YES | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'sortings', '*1200'] |
C. Infinite Replacementtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting only of Latin letters 'a', and a string t, consisting of lowercase Latin letters.In one move, you can replace any letter 'a' in the string s with a string t. ... | 3
aaaa
a
aa
abc
a
b
| 1 -1 2 | 2 seconds | 256 megabytes | ['combinatorics', 'implementation', 'strings', '*1000'] |
B. Dictionarytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe Berland language consists of words having exactly two letters. Moreover, the first letter of a word is different from the second letter. Any combination of two different Berland letters (which, by the ... | 7
ab
ac
az
ba
bc
zx
zy
| 1 2 25 26 27 649 650 | 2 seconds | 512 megabytes | ['combinatorics', 'math', '*800'] |
A. Number Transformationtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two integers x and y. You want to choose two strictly positive (greater than zero) integers a and b, and then apply the following operation to x exactly a times: replace x with b \... | 3
3 75
100 100
42 13
| 2 5 3 1 0 0 | 2 seconds | 512 megabytes | ['constructive algorithms', 'math', '*800'] |
F. Anti-Theft Road Planningtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.A city has n^2 buildings divided into a grid of n rows and n columns. You need to build a road of some length D(A,B) of your choice between each pair of adjacen... | 2 4
14
1
14
3
| 1 8 2 4 1 2 1 1 1 2 2 1 | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'divide and conquer', 'greedy', 'interactive', 'math', '*2400'] |
E. Power or XOR?time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe symbol \wedge is quite ambiguous, especially when used without context. Sometimes it is used to denote a power (a\wedge b = a^b) and sometimes it is used to denote the XOR operation (a\wedge b=a\opl... | 3 2
3 1 2
| 1110 | 2 seconds | 512 megabytes | ['bitmasks', 'combinatorics', 'math', 'number theory', '*2500'] |
D. Lost Arithmetic Progressiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLong ago, you thought of two finite arithmetic progressions A and B. Then you found out another sequence C containing all elements common to both A and B. It is not hard to see that C is al... | 8-3 1 7-1 2 4-9 3 110 6 32 5 57 5 42 2 1110 5 30 2 92 4 3-11 4 121 12 2-27 4 7-17 8 2-8400 420 10000000000 4620 10 | 0 10 -1 0 -1 21 0 273000 | 1 second | 256 megabytes | ['combinatorics', 'math', 'number theory', '*1900'] |
C. Palindrome Basistime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Let's call some positive integer a without leading zeroes palindromic if it remains the same after reversing the order of its digits. Find the number of distinct w... | 2
5
12
| 7 74 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'math', 'number theory', '*1500'] |
B. A Perfectly Balanced String?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a string s perfectly balanced if for all possible triplets (t,u,v) such that t is a non-empty substring of s and u and v are characters present in s, the difference between the ... | 5
aba
abb
abc
aaaaa
abcba
| YES NO YES YES NO | 1 second | 256 megabytes | ['brute force', 'greedy', 'strings', '*1100'] |
A. Subtle Substring Subtractiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game with strings. There will be t rounds in the game. In each round, there will be a string s consisting of lowercase English letters. Alice moves first and bo... | 5
aba
abc
cba
n
codeforces
| Alice 2 Alice 4 Alice 4 Bob 14 Alice 93 | 1 second | 256 megabytes | ['games', 'greedy', 'strings', '*800'] |
I. PermutationForcestime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou have a permutation p of integers from 1 to n.You have a strength of s and will perform the following operation some times: Choose an index i such that 1 \leq i \leq |p| and |i-p_i| \leq s. Fo... | 3
3 2 1
| 1 | 5 seconds | 1024 megabytes | ['data structures', 'greedy', '*3000'] |
H. Zigu Zagutime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a binary string a of length n consisting only of digits 0 and 1. You are given q queries. In the i-th query, you are given two indices l and r such that 1 \le l \le r \le n. Let s=a[l,r]. You are al... | 5 3
11011
2 4
1 5
3 5
| 1 3 2 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*2700'] |
G. Cross Xortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a grid with r rows and c columns, where the square on the i-th row and j-th column has an integer a_{i, j} written on it. Initially, all elements are set to 0. We are allowed to do the following ope... | 3 3
?10
1??
010
| 1 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'math', 'matrices', '*3200'] |
F2. Checker for Array Shufflingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputoolimry has an array a of length n which he really likes. Today, you have changed his array to b, a permutation of a, to make him sad.Because oolimry is only a duck, he can only perform th... | 422 11 241 2 3 33 3 2 122 12 141 2 3 33 2 3 1 | AC AC WA WA | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*2800'] |
F1. Array Shufflingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputoolimry has an array a of length n which he really likes. Today, you have changed his array to b, a permutation of a, to make him sad.Because oolimry is only a duck, he can only perform the following ... | 2
2
2 1
4
1 2 3 3
| 1 2 3 3 2 1 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', '*2000'] |
E. notepad.exetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There are n words in a text editor. The i-th word has length l_i (1 \leq l_i \leq 2000). The array l is hidden and only known by the grader. The text editor displays words in... | 6
0
4
2
| ? 1 ? 9 ? 16 ! 32 | 1 second | 256 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'interactive', '*2200'] |
D. Cyclic Rotationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an array a of length n. You may perform the following operation any number of times: Choose two indices l and r where 1 \le l < r \le n and a_l = a_r. Then, set a[l \ldots r] = [a_{l+1}, a_{l... | 5
5
1 2 3 3 2
1 3 3 2 2
5
1 2 4 2 1
4 2 2 1 1
5
2 4 5 5 2
2 2 4 5 5
3
1 2 3
1 2 3
3
1 1 2
2 1 1
| YES YES NO YES NO | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'two pointers', '*1700'] |
C. Unequal Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n. We define the equality of the array as the number of indices 1 \le i \le n - 1 such that a_i = a_{i + 1}. We are allowed to do the following operation: Select two i... | 451 1 1 1 152 1 1 1 261 1 2 3 3 461 2 1 4 5 4 | 2 1 2 0 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', '*1100'] |
B. I love AAABtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a string good if its length is at least 2 and all of its characters are \texttt{A} except for the last character which is \texttt{B}. The good strings are \texttt{AB},\texttt{AAB},\texttt{AAAB},... | 4
AABAB
ABB
AAAAAAAAB
A
| YES NO YES NO | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', '*800'] |
A. Log Choppingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n logs, the i-th log has a length of a_i meters. Since chopping logs is tiring work, errorgorn and maomao90 have decided to play a game.errorgorn and maomao90 will take turns chopping the logs w... | 2
4
2 4 2 1
1
1
| errorgorn maomao90 | 1 second | 256 megabytes | ['games', 'implementation', 'math', '*800'] |
F. Permutation Countingtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputCalculate the number of permutations p of size n with exactly k inversions (pairs of indices (i, j) such that i < j and p_i > p_j) and exactly x indices i such that p_i > p_{i+1}.Yep, that's the ... | 5
10 6 4
7 3 1
163316 11 7
136373 11 1
325902 11 11
| 465 12 986128624 7636394 57118194 | 4 seconds | 512 megabytes | ['brute force', 'combinatorics', 'dp', 'fft', 'math', '*2700'] |
E. Preordertime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a rooted tree of 2^n - 1 vertices. Every vertex of this tree has either 0 children, or 2 children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, o... | 4
BAAAAAAAABBABAB
| 16 | 2 seconds | 512 megabytes | ['combinatorics', 'divide and conquer', 'dp', 'dsu', 'hashing', 'sortings', 'trees', '*2100'] |
D. Insert a Progressiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence of n integers a_1, a_2, \dots, a_n. You are also given x integers 1, 2, \dots, x.You are asked to insert each of the extra integers into the sequence a. Each integer can ... | 4
1 5
10
3 8
7 2 10
10 2
6 1 5 7 3 3 9 10 10 1
4 10
1 3 1 2
| 9 15 31 13 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', '*1600'] |
C. Dolce Vitatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTurbulent times are coming, so you decided to buy sugar in advance. There are n shops around that sell sugar: the i-th shop sells one pack of sugar for a_i coins, but only one pack to one customer each day... | 4
3 7
2 1 2
5 9
10 20 30 40 50
1 1
1
2 1000
1 1
| 11 0 1 1500 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'greedy', 'math', '*1200'] |
B. Consecutive Points Segmenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n points with integer coordinates on a coordinate axis OX. The coordinate of the i-th point is x_i. All points' coordinates are distinct and given in strictly increasing order... | 5
2
1 4
3
1 2 3
4
1 2 3 7
1
1000000
3
2 5 6
| YES YES NO YES YES | 2 seconds | 256 megabytes | ['brute force', 'math', 'sortings', '*1000'] |
A. String Buildingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a string s. You have to determine whether it is possible to build the string s out of strings aa, aaa, bb and/or bbb by concatenating them. You can use the strings aa, aaa, bb and/or bbb... | 8
aaaabbb
bbaaaaabbb
aaaaaa
abab
a
b
aaaab
bbaaa
| YES YES YES NO NO NO NO YES | 2 seconds | 512 megabytes | ['implementation', '*800'] |
F. Jee, You See?time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring their training for the ICPC competitions, team "Jee You See" stumbled upon a very basic counting problem. After many "Wrong answer" verdicts, they finally decided to give up and destroy turn-off ... | 3 1 5 1
| 13 | 2 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'dp', '*2400'] |
E. Hemose on the Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter the last regional contest, Hemose and his teammates finally qualified to the ICPC World Finals, so for this great achievement and his love of trees, he gave you this problem as the name of hi... | 2
2
1 2
2 3
3 4
3
1 2
2 3
3 4
1 5
1 6
5 7
5 8
| 3 5 1 3 6 4 2 7 5 1 2 8 11 4 13 9 15 6 14 3 7 10 5 12 | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'dfs and similar', 'trees', '*2200'] |
D. Very Suspicioustime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.They love equilateral triangles and want to create n equilateral triangles on the grid by addi... | 4
1
2
3
4567
| 2 2 3 83 | 1 second | 256 megabytes | ['binary search', 'brute force', 'geometry', 'greedy', 'implementation', 'math', '*1700'] |
C. Where is the Pizza?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile searching for the pizza, baby Hosssam came across two permutations a and b of length n.Recall that a permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. ... | 9
7
1 2 3 4 5 6 7
2 3 1 7 6 5 4
2 0 1 0 0 0 0
1
1
1
0
6
1 5 2 4 6 3
6 5 3 1 4 2
6 0 0 0 0 0
8
1 6 4 7 2 3 8 5
3 2 8 1 4 5 6 7
1 0 0 7 0 3 0 5
10
1 8 6 2 4 7 9 3 10 5
1 9 2 3 4 10 8 6 7 5
1 9 2 3 4 10 8 6 7 5
7
1 2 3 4 5 6 7
2 3 1 7 6 5 4
0 0 0 0 0 0 0
5
1 2 3 4 5
1 2 3 4 5
0 0 0 0 0
5
1 2 3 4 5
1 2 3 5 4
0 0 0 0 0
3
1 ... | 4 1 2 2 1 8 1 2 2 | 1 second | 256 megabytes | ['data structures', 'dfs and similar', 'dsu', 'graphs', 'implementation', 'math', '*1400'] |
B. Dorms Wartime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHosssam decided to sneak into Hemose's room while he is sleeping and change his laptop's password. He already knows the password, which is a string s of length n. He also knows that there are k special lette... | 10
9
iloveslim
1 s
7
joobeel
2 o e
7
basiozi
2 s i
6
khater
1 r
7
abobeih
6 a b e h i o
5
zondl
5 a b c e f
6
shoman
2 a h
7
shetwey
2 h y
5
samez
1 m
6
mouraz
1 m
| 5 2 3 5 1 0 3 5 2 0 | 1 second | 256 megabytes | ['brute force', 'implementation', 'strings', '*1100'] |
A. Prof. Slimtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Prof. Slim decided to leave the kingdom of the GUC to join the kingdom of the GIU. He was given an easy online assessment to solve before joining the GIU. Citizens of the GUC were happy sad to see t... | 4
7
7 3 2 -11 -13 -17 -23
6
4 10 25 47 71 96
6
71 -35 7 -4 -11 -25
6
-45 9 -48 -67 -55 7
| NO YES YES NO | 1 second | 256 megabytes | ['greedy', 'implementation', 'sortings', '*800'] |
H. Maximal ANDtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet \mathsf{AND} denote the bitwise AND operation, and \mathsf{OR} denote the bitwise OR operation.You are given an array a of length n and a non-negative integer k. You can perform at most k operations o... | 4
3 2
2 1 1
7 0
4 6 6 28 6 6 12
1 30
0
4 4
3 1 3 1
| 2 4 2147483646 1073741825 | 2 seconds | 256 megabytes | ['bitmasks', 'greedy', 'math', '*1300'] |
G. Fall Downtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a grid with n rows and m columns, and three types of cells: An empty cell, denoted with '.'. A stone, denoted with '*'. An obstacle, denoted with the lowercase Latin letter 'o'. All stones fall ... | 3
6 10
.*.*....*.
.*.......*
...o....o.
.*.*....*.
..........
.o......o*
2 9
...***ooo
.*o.*o.*o
5 5
*****
*....
*****
....*
*****
| .......... ...*....*. .*.o....o. .*........ .*......** .o.*....o* ....**ooo .*o**o.*o ..... *...* ***** ***** ***** | 1 second | 256 megabytes | ['dfs and similar', 'implementation', '*1200'] |
F. Eating Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n candies put from left to right on a table. The candies are numbered from left to right. The i-th candy has weight w_i. Alice and Bob eat candies. Alice can eat any number of candies from the... | 4
3
10 20 10
6
2 1 4 2 4 1
5
1 2 4 8 16
9
7 3 20 5 15 1 11 8 10
| 2 6 0 7 | 1 second | 256 megabytes | ['binary search', 'data structures', 'greedy', 'two pointers', '*1100'] |
E. 2-Letter Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven n strings, each of length 2, consisting of lowercase Latin alphabet letters from 'a' to 'k', output the number of pairs of indices (i, j) such that i < j and the i-th string and the j-th string... | 4
6
ab
cb
db
aa
cc
ef
7
aa
bb
cc
ac
ca
bb
aa
4
kk
kk
ab
ab
5
jf
jf
jk
jk
jk
| 5 6 0 6 | 2 seconds | 256 megabytes | ['data structures', 'math', 'strings', '*1200'] |
D. Colorful Stamptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA row of n cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used i... | 12
5
BRBBW
1
B
2
WB
2
RW
3
BRB
3
RBB
7
WWWWWWW
9
RBWBWRRBW
10
BRBRBRBRRB
12
BBBRWWRRRWBR
10
BRBRBRBRBW
5
RBWBW
| YES NO NO NO YES YES YES NO YES NO YES NO | 1 second | 256 megabytes | ['implementation', '*1100'] |
C. Odd/Even Incrementstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a=[a_1,a_2,\dots,a_n] of n positive integers, you can do operations of two types on it: Add 1 to every element with an odd index. In other words change the array as follows: a_1 := ... | 4
3
1 2 1
4
2 2 2 3
4
2 2 2 2
5
1000 1 1000 1 1000
| YES NO YES YES | 1 second | 256 megabytes | ['greedy', 'greedy', 'implementation', 'math', '*800'] |
B. Tripletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of n elements, print any value that appears at least three times or print -1 if there is no such value.InputThe first line contains an integer t (1 \leq t \leq 10^4) — the number of test cases.... | 7
1
1
3
2 2 2
7
2 2 3 3 4 2 2
8
1 4 3 4 3 2 4 1
9
1 1 1 2 2 2 3 3 3
5
1 5 2 4 3
4
4 4 4 4
| -1 2 2 4 3 -1 4 | 1 second | 256 megabytes | ['implementation', 'sortings', '*800'] |
A. Division?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCodeforces separates its users into 4 divisions by their rating: For Division 1: 1900 \leq \mathrm{rating} For Division 2: 1600 \leq \mathrm{rating} \leq 1899 For Division 3: 1400 \leq \mathrm{rating} \le... | 7
-789
1299
1300
1399
1400
1679
2300
| Division 4 Division 4 Division 4 Division 4 Division 3 Division 2 Division 1 | 1 second | 256 megabytes | ['implementation', '*800'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.