problem_statement stringlengths 147 8.53k | input stringlengths 1 771 | output stringlengths 1 592 ⌀ | time_limit stringclasses 32
values | memory_limit stringclasses 21
values | tags stringlengths 6 168 |
|---|---|---|---|---|---|
E. Split Into Two Setstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp was recently given a set of n (number n — even) dominoes. Each domino contains two integers from 1 to n.Can he divide all the dominoes into two sets so that all the numbers on the dominoe... | 641 24 32 13 461 24 51 34 62 35 621 12 221 22 182 11 24 34 35 65 78 67 881 22 14 35 35 46 78 67 8 | YES NO NO YES YES NO | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', '*1600'] |
D. Not a Cheap Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet s be a string of lowercase Latin letters. Its price is the sum of the indices of letters (an integer between 1 and 26) that are included in it. For example, the price of the string abca is 1+2+... | 5abca2abca6codeforces1codeforces10codeforces100 | aa abc cdc codeforces | 2 seconds | 256 megabytes | ['greedy', '*1000'] |
C. Train and Queriestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlong the railroad there are stations indexed from 1 to 10^9. An express train always travels along a route consisting of n stations with indices u_1, u_2, \dots, u_n, where (1 \le u_i \le 10^9). Th... | 36 33 7 1 5 1 43 51 73 103 31 2 12 11 24 57 52 1 1 1 2 4 41 31 42 14 11 2 | YES NO NO YES YES NO NO YES YES NO YES | 3 seconds | 256 megabytes | ['data structures', 'greedy', '*1100'] |
B. Polycarp Writes a String from Memorytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has a poor memory. Each day he can remember no more than 3 of different letters. Polycarp wants to write a non-empty string of s consisting of lowercase Latin letters, ta... | 6lollipopsstringologyabracadabracodeforcestestf | 2 4 3 4 1 1 | 2 seconds | 256 megabytes | ['greedy', '*800'] |
A. Round Down the Pricetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAt the store, the salespeople want to make all prices round. In this problem, a number that is a power of 10 is called a round number. For example, the numbers 10^0 = 1, 10^1 = 10, 10^2 = 100 are ... | 712178209999999999000987654321 | 0 1 78 10 899999999 8000 887654321 | 1 second | 256 megabytes | ['constructive algorithms', '*800'] |
F. Pointstime limit per test6.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA triple of points i, j and k on a coordinate line is called beautiful if i < j < k and k - i \le d.You are given a set of points on a coordinate line, initially empty. You have to process queries of three t... | 7 5
8 5 3 2 1 5 6
| 0 0 1 2 5 1 5 | 6.5 seconds | 512 megabytes | ['combinatorics', 'data structures', 'implementation', 'math', 'matrices', '*2500'] |
E. Text Editortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou wanted to write a text t consisting of m lowercase Latin letters. But instead, you have written a text s consisting of n lowercase Latin letters, and now you want to fix it by obtaining the text t fro... | 69 4aaaaaaaaaaaaa7 3abacabaaaa5 4aabcdabcd4 2abbabb6 4barakabaka8 7questionproblem | 5 6 3 4 4 -1 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', 'strings', '*2500'] |
D. Permutation Restorationtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp had a permutation a of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).Then Monocarp calculated an array of integers b of size n... | 440 2 0 121 150 0 1 4 130 1 3 | 2 1 4 3 1 2 3 4 2 1 5 3 2 1 | 4 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', 'math', 'sortings', 'two pointers', '*1900'] |
C. Schedule Managementtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n workers and m tasks. The workers are numbered from 1 to n. Each task i has a value a_i — the index of worker who is proficient in this task.Every task should have a worker assigned to ... | 42 41 2 1 22 41 1 1 15 55 1 3 2 41 11 | 2 3 1 1 | 2 seconds | 256 megabytes | ['binary search', 'greedy', 'implementation', 'two pointers', '*1400'] |
B. Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecall that a permutation of length n is an array where each element from 1 to n occurs exactly once.For a fixed positive integer d, let's define the cost of the permutation p of length n as the number of... | 223 | 2 1 2 3 2 1 3 | 2 seconds | 256 megabytes | ['greedy', '*800'] |
A. Grass Fieldtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a field of size 2 \times 2. Each cell of this field can either contain grass or be empty. The value a_{i, j} is 1 if the cell (i, j) contains grass, or 0 otherwise.In one move, you can choose one ... | 30 00 01 00 11 11 1 | 0 1 2 | 1 second | 256 megabytes | ['implementation', '*800'] |
F. Puzzletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPupils Alice and Ibragim are best friends. It's Ibragim's birthday soon, so Alice decided to gift him a new puzzle. The puzzle can be represented as a matrix with 2 rows and n columns, every element of which is... | 5
0 1 0 1 0
1 1 0 0 1
1 0 1 0 1
0 0 1 1 0
| 5 | 1 second | 256 megabytes | ['constructive algorithms', 'dp', 'greedy', '*2600'] |
E. Serega the Piratetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle pirate Serega robbed a ship with puzzles of different kinds. Among all kinds, he liked only one, the hardest.A puzzle is a table of n rows and m columns, whose cells contain each number from ... | 3 3
2 1 3
6 7 4
9 8 5
| 0 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', '*2600'] |
D. River Lockstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently in Divanovo, a huge river locks system was built. There are now n locks, the i-th of them has the volume of v_i liters, so that it can contain any amount of water between 0 and v_i liters. Each l... | 5
4 1 5 4 1
6
1
6
2
3
4
5
| -1 3 -1 -1 4 3 | 2 seconds | 256 megabytes | ['binary search', 'dp', 'greedy', 'math', '*1900'] |
C. Helping the Naturetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Leon lives in the forest. He has recently noticed that some trees near his favourite path are withering, while the other ones are overhydrated so he decided to learn how to control the level... | 4
3
-2 -2 -2
3
10 4 7
4
4 -4 4 -4
5
1 -2 3 -4 5
| 2 13 36 33 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*1700'] |
B. Palindromic Numbers time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring a daily walk Alina noticed a long number written on the ground. Now Alina wants to find some positive number of same length without leading zeroes, such that the sum of these two numbers i... | 3
2
99
4
1023
3
385
| 32 8646 604 | 2 seconds | 256 megabytes | ['constructive algorithms', 'implementation', 'math', '*1100'] |
A. Optimal Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a table a of size n \times m. We will consider the table rows numbered from top to bottom from 1 to n, and the columns numbered from left to right from 1 to m. We will denote a cell that is... | 71 12 33 27 11 105 510000 10000 | 1 12 13 28 55 85 500099995000 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', '*800'] |
E. Three Days Gracetime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIbti was thinking about a good title for this problem that would fit the round theme (numerus ternarium). He immediately thought about the third derivative, but that was pretty lame so he decided to ... | 45 102 4 2 4 23 5012 2 32 406 352 51 5 | 0 1 2 4 | 4 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'math', 'number theory', 'two pointers', '*2600'] |
D. Almost Triple Deletionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n and an array a_1,a_2,\ldots,a_n.In one operation, you can choose an index i (1 \le i \lt n) for which a_i \neq a_{i+1} and delete both a_i and a_{i+1} from the array... | 571 2 3 2 1 3 31161 1 1 2 2 281 1 2 2 3 3 1 1121 5 2 3 3 3 4 4 4 4 3 3 | 3 1 0 4 2 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', '*2300'] |
C. The Third Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation a_1,a_2,\ldots,a_n of integers from 0 to n - 1. Your task is to find how many permutations b_1,b_2,\ldots,b_n are similar to permutation a. Two permutations a and b of siz... | 554 0 3 2 11040 1 2 361 2 4 0 5 381 3 7 2 5 0 6 4 | 2 1 1 4 72 | 1 second | 256 megabytes | ['combinatorics', 'constructive algorithms', 'math', '*1700'] |
B. Almost Ternary Matrixtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two even integers n and m. Your task is to find any binary matrix a with n rows and m columns where every cell (i,j) has exactly two neighbours with a different value than a_{i,j}.T... | 32 42 24 4 | 1 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'matrices', '*900'] |
A. The Third Three Number Problemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Your task is to find any three integers a, b and c (0 \le a, b, c \le 10^9) for which (a\oplus b)+(b\oplus c)+(a\oplus c)=n, or determine that there a... | 541122046194723326 | 3 3 1 -1 2 4 6 69 420 666 12345678 87654321 100000000 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
G. Long Binary Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a binary string t of length 10^{100}, and initally all of its bits are \texttt{0}. You are given a binary string s, and perform the following operation some times: Select some substring ... | 1
| 1 2 | 2 seconds | 256 megabytes | ['bitmasks', 'math', 'matrices', 'meet-in-the-middle', 'number theory', '*2900'] |
F. Equal Reversaltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an array a of length n. You may perform the following operation on it: Choose two indices l and r where 1 \le l \le r \le n and a_l = a_r. Then, reverse the subsegment from the l-th to the r-t... | 581 2 4 3 1 2 1 11 1 3 4 2 1 2 171 2 3 1 3 2 31 3 2 3 1 2 331 1 21 2 121 22 1111 | YES 2 5 8 1 6 YES 2 1 4 3 6 NO NO YES 0 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'implementation', 'math', '*2800'] |
E. PermutationForces IItime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation a of length n. Recall that permutation is an array consisting of n distinct integers from 1 to n in arbitrary order.You have a strength of s and perform n moves on the ... | 63 12 1 33 -1 -13 22 1 33 -1 -14 11 4 3 24 3 1 26 44 2 6 3 1 56 1 5 -1 3 -17 41 3 6 2 7 4 52 5 -1 -1 -1 4 -114 141 2 3 4 5 6 7 8 9 10 11 12 13 14-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 | 1 2 0 2 12 331032489 | 1 second | 256 megabytes | ['brute force', 'combinatorics', 'greedy', 'sortings', 'trees', 'two pointers', '*2300'] |
D. Fixed Point Guessingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Initially, there is an array a = [1, 2, \ldots, n], where n is an odd positive integer. The jury has selected \frac{n-1}{2} disjoint pairs of elements, and then the ... | 2
5
1 2 4 5
1 3 5
3
1 | ? 1 4 ? 3 5 ! 2 ? 1 1 ! 1 | 1 second | 256 megabytes | ['binary search', 'constructive algorithms', 'interactive', '*1600'] |
C. 3SUM Closuretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n. The array is called 3SUM-closed if for all distinct indices i, j, k, the sum a_i + a_j + a_k is an element of the array. More formally, a is 3SUM-closed if for all in... | 43-1 0 151 -2 -2 1 -360 0 0 0 0 04-1 2 -3 4 | YES NO YES NO | 1 second | 256 megabytes | ['brute force', 'data structures', '*1300'] |
B. Rising Sandtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n piles of sand where the i-th pile has a_i blocks of sand. The i-th pile is called too tall if 1 < i < n and a_i > a_{i-1} + a_{i+1}. That is, a pile is too tall if it has more sand than its two... | 35 22 9 2 4 14 41 3 2 13 11 3 1 | 2 0 1 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', '*800'] |
A. XOR Mixuptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an array a with n-1 integers. Let x be the bitwise XOR of all elements of the array. The number x is added to the end of the array a (now it has length n), and then the elements are shuffled.You are... | 444 3 2 556 1 10 7 1066 6 6 6 6 63100 100 0 | 3 7 6 0 | 1 second | 256 megabytes | ['bitmasks', 'brute force', '*800'] |
F. Too Many Constraintstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are asked to build an array a, consisting of n integers, each element should be from 1 to k.The array should be non-decreasing (a_i \le a_{i+1} for all i from 1 to n-1). You are also given ad... | 4
4 0 4
2 2 3
3 1 2 3
1 2 2
3 3 2
1 1 1
2 2 3 2
3 2 3 2
5 5 5
3 2 5 7
2 4 5 10
3 4 5 6
3 3 4 7
2 1 5 7
| 1 2 3 4 1 3 -1 1 2 2 5 5 | 2 seconds | 512 megabytes | ['2-sat', 'constructive algorithms', 'graphs', 'implementation', '*2800'] |
E. Coloringtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given n points on the plane, the coordinates of the i-th point are (x_i, y_i). No two points have the same coordinates.The distance between points i and j is defined as d(i,j) = |x_i - x_j| + |y_i - ... | 3
1 0
3 0
2 1
| 9 | 3 seconds | 512 megabytes | ['brute force', 'combinatorics', 'constructive algorithms', 'dp', 'geometry', 'graphs', 'greedy', 'implementation', 'math', '*2400'] |
D. Guess The Stringtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or ... | 5
4
u
2
g
e
s
1
| ? 2 1 5 ? 1 2 ? 2 1 2 ? 1 1 ? 1 3 ? 1 4 ? 2 4 5 ! guess | 4 seconds | 512 megabytes | ['binary search', 'constructive algorithms', 'interactive', '*1900'] |
C. awoo's Favorite Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two strings s and t, both of length n. Each character in both string is 'a', 'b' or 'c'.In one move, you can perform one of the following actions: choose an occurrence of "ab" ... | 5
3
cab
cab
1
a
b
6
abbabc
bbaacb
10
bcaabababc
cbbababaac
2
ba
ab
| YES NO YES YES NO | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'greedy', 'implementation', 'strings', 'two pointers', '*1400'] |
B. Promotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe store sells n items, the price of the i-th item is p_i. The store's management is going to hold a promotion: if a customer purchases at least x items, y cheapest of them are free.The management has not yet ... | 5 3
5 3 1 5 2
3 2
1 1
5 3
| 8 5 6 | 2 seconds | 256 megabytes | ['greedy', 'sortings', '*900'] |
A. Parkway Walktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are walking through a parkway near your house. The parkway has n+1 benches in a row numbered from 1 to n+1 from left to right. The distance between the bench i and i+1 is a_i meters.Initially, you hav... | 3
3 1
1 2 1
4 5
3 3 5 2
5 16
1 2 3 4 5
| 3 8 0 | 1 second | 256 megabytes | ['greedy', 'implementation', '*800'] |
H. Maximum Product?time limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a positive integer k. For a multiset of integers S, define f(S) as the following. If the number of elements in S is less than k, f(S)=0. Otherwise, define f(S) as the maximum produc... | 3 2
-1 2 4
| 10 | 1.5 seconds | 512 megabytes | ['brute force', 'combinatorics', 'dp', 'greedy', 'implementation', 'math', 'two pointers', '*3500'] |
G. Fishingprince Plays With Array Againtime limit per test6 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputSuppose you are given a 1-indexed sequence a of non-negative integers, whose length is n, and two integers x, y. In consecutive t seconds (t can be any positive real number), you... | 4 3
1 2
3 1 1 4
2 1 4
1 1 1
2 1 3
| 3.500000000000000 1.000000000000000 | 6 seconds | 1024 megabytes | ['brute force', 'data structures', 'geometry', 'math', '*3300'] |
F. Tree Recoverytime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputFishingprince loves trees. A tree is a connected undirected graph without cycles.Fishingprince has a tree of n vertices. The vertices are numbered 1 through n. Let d(x,y) denote the shortest distance on ... | 52002103001 0000003001 010000500000 01001 00000 0110000000 10000 0000000000 1101000000 | Yes 1 2 No Yes 1 3 2 3 No Yes 1 2 1 4 2 3 2 5 | 1 second | 512 megabytes | ['brute force', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', 'trees', '*2600'] |
E. Placing Jinastime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe say an infinite sequence a_{0}, a_{1}, a_2, \ldots is non-increasing if and only if for all i\ge 0, a_i \ge a_{i+1}.There is an infinite right and down grid. The upper-left cell has coordinates (0,0)... | 2
2 2 0
| 5 | 2 seconds | 512 megabytes | ['combinatorics', 'math', '*2000'] |
D. Permutation Graphtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array)... | 51121 251 4 2 3 552 1 5 3 4107 4 8 1 6 10 3 5 2 9 | 0 1 1 4 6 | 2 seconds | 512 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'divide and conquer', 'greedy', 'shortest paths', '*1900'] |
C. Fishingprince Plays With Arraytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFishingprince is playing with an array [a_1,a_2,\dots,a_n]. He also has a magic number m.He can do the following two operations on it: Select 1\le i\le n such that a_i is divisible by ... | 55 21 2 2 4 241 4 4 26 21 2 2 8 2 221 168 33 3 3 3 3 3 3 346 6 6 68 33 9 6 3 12 12 36 12169 3 2 2 2 3 4 12 4 12 4 12 4 12 4 48 33 9 6 3 12 12 36 12712 2 4 3 4 12 56 | Yes Yes No Yes No | 2 seconds | 512 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'math', '*1400'] |
B. NIT Destroys the Universetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputFor a collection of integers S, define \operatorname{mex}(S) as the smallest non-negative integer that does not appear in S.NIT, the cleaver, decides to destroy the universe. He is not so po... | 440 0 0 050 1 2 3 470 2 3 0 1 2 011000000000 | 0 1 2 1 | 2 seconds | 512 megabytes | ['greedy', '*900'] |
A. NIT orz!time limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputNIT, the cleaver, is new in town! Thousands of people line up to orz him. To keep his orzers entertained, NIT decided to let them solve the following problem related to \operatorname{or} z. Can you solve this... | 52 33 45 50 2 4 6 81 9105 77 15 30 29 273 3954874310293834 10284344 13635445 | 7 13 11 31 48234367 | 1 second | 512 megabytes | ['bitmasks', 'greedy', '*800'] |
E. Ambiguous Dominoestime limit per test8 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp and Monocarp are both solving the same puzzle with dominoes. They are given the same set of n dominoes, the i-th of which contains two numbers x_i and y_i. They are also both given the sam... | 1
1 2
| -1 | 8 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*2700'] |
D2. Tree Queries (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and D1 is the bound on the size of the tree.You are given an unrooted tree with n vertices. There is some hidden vertex x in that tree that you ar... | 3
1
2
1 2
10
2 4
2 1
5 7
3 10
8 6
6 1
1 3
4 7
9 6
| 0 1 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dp', 'greedy', 'trees', '*2300'] |
D1. Tree Queries (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and D2 is the bound on the size of the tree.You are given an unrooted tree with n vertices. There is some hidden vertex x in that tree that you ar... | 3
1
2
1 2
10
2 4
2 1
5 7
3 10
8 6
6 1
1 3
4 7
9 6
| 0 1 2 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'dfs and similar', 'dp', 'greedy', 'trees', '*2200'] |
C. Zero Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a grid with n rows and m columns. We denote the square on the i-th (1\le i\le n) row and j-th (1\le j\le m) column by (i, j) and the number there by a_{ij}. All numbers are equal to 1 or to -1... | 5
1 1
1
1 2
1 -1
1 4
1 -1 1 -1
3 4
1 -1 -1 -1
-1 1 1 -1
1 1 1 -1
3 4
1 -1 1 1
-1 1 -1 1
1 -1 1 1
| NO YES YES YES NO | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'dp', 'graphs', 'greedy', 'shortest paths', '*1700'] |
B. Circle Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMike and Joe are playing a game with some stones. Specifically, they have n piles of stones of sizes a_1, a_2, \ldots, a_n. These piles are arranged in a circle.The game goes as follows. Players take turns... | 2
1
37
2
100 100
| Mike Joe | 1 second | 256 megabytes | ['games', 'greedy', '*1000'] |
A. Subrectangle Guesstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMichael and Joe are playing a game. The game is played on a grid with n rows and m columns, filled with distinct integers. We denote the square on the i-th (1\le i\le n) row and j-th (1\le j\le m) c... | 3
1 1
3
4 4
2 12 6 10
3 15 16 4
1 13 8 11
14 7 9 5
2 3
-7 5 2
0 8 -3
| 1 9 4 | 1 second | 256 megabytes | ['games', '*800'] |
B. Paranoid Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call a binary string T of length m indexed from 1 to m paranoid if we can obtain a string of length 1 by performing the following two kinds of operations m-1 times in any order : Select any subst... | 5
1
1
2
01
3
100
4
1001
5
11111
| 1 3 4 8 5 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1200'] |
A. Creeptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDefine the score of some binary string T as the absolute difference between the number of zeroes and ones in it. (for example, T= 010001 contains 4 zeroes and 2 ones, so the score of T is |4-2| = 2).Define the c... | 5
1 1
1 2
5 2
4 5
3 7
| 10 011 0011000 101010101 0001111111 | 1 second | 256 megabytes | ['greedy', 'implementation', '*800'] |
F. I Might Be Wrongtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string S of length n indexed from 1 to n. You can perform the following operation any number of times (possibly zero):Choose two integers l and r (1 \le l \le r \le n). Let cnt... | 71121031014100051101061100002001000010001010011000 | 0 1 1 3 2 2 5 | 2 seconds | 256 megabytes | ['binary search', 'greedy', 'two pointers', '*3400'] |
E. Outermost Maximumstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYeri has an array of n + 2 non-negative integers : a_0, a_1, ..., a_n, a_{n + 1}.We know that a_0 = a_{n + 1} = 0.She wants to make all the elements of a equal to zero in the minimum number of oper... | 6
1 4 2 4 0 2
| 7 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*3400'] |
D. Decinc Dividingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call an array a of m integers a_1, a_2, \ldots, a_m Decinc if a can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if a = [3, 2, 4, 1, 5], we can ... | 3
2 3 1
| 6 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'divide and conquer', 'dp', 'greedy', '*2800'] |
C. Keshi in Search of AmShZtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAmShZ has traveled to Italy from Iran for the Thom Yorke concert. There are n cities in Italy indexed from 1 to n and m directed roads indexed from 1 to m. Initially, Keshi is located in the ... | 2 1
1 2
| 1 | 2 seconds | 256 megabytes | ['graphs', 'greedy', 'shortest paths', '*2300'] |
B. Fake Plastic Treestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is the vertex 1 and the parent of the vertex v is p_v.There is a number written on each vertex, initial... | 4
2
1
1 5
2 9
3
1 1
4 5
2 4
6 10
4
1 2 1
6 9
5 6
4 5
2 4
5
1 2 3 4
5 5
4 4
3 3
2 2
1 1
| 1 2 2 5 | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'greedy', 'trees', '*1700'] |
A. Directional Increasetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe have an array of length n. Initially, each element is equal to 0 and there is a pointer located on the first element.We can do the following two kinds of operations any number of times (possibl... | 7
2
1 0
4
2 -1 -1 0
4
1 -4 3 0
4
1 -1 1 -1
5
1 2 3 4 -10
7
2 -1 1 -2 0 0 0
1
0
| No Yes No No Yes Yes Yes | 1 second | 256 megabytes | ['greedy', '*1300'] |
H. Gamblingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMarian is at a casino. The game at the casino works like this.Before each round, the player selects a number between 1 and 10^9. After that, a dice with 10^9 faces is rolled so that a random number between 1... | 4
5
4 4 3 4 4
5
11 1 11 1 11
1
1000000000
10
8 8 8 9 9 6 6 9 6 6
| 4 1 5 1 2 2 1000000000 1 1 6 6 10 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'greedy', 'math', '*1700'] |
G. 2^Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of length n and an integer k, find the number of indices 1 \leq i \leq n - k such that the subarray [a_i, \dots, a_{i+k}] with length k+1 (not with length k) has the following property: If yo... | 6
4 2
20 22 19 84
5 1
9 5 3 2 1
5 2
9 5 3 2 1
7 2
22 12 16 4 3 22 12
7 3
22 12 16 4 3 22 12
9 3
3 9 12 3 9 12 3 9 12
| 2 3 2 3 1 0 | 1 second | 256 megabytes | ['data structures', 'dp', 'sortings', 'two pointers', '*1400'] |
F. 3SUMtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of positive integers with length n, determine if there exist three distinct indices i, j, k such that a_i + a_j + a_k ends in the digit 3.InputThe first line contains an integer t (1 \leq t \leq ... | 6
4
20 22 19 84
4
1 11 1 2022
4
1100 1100 1100 1111
5
12 34 56 78 90
4
1 9 8 4
6
16 38 94 25 18 99
| YES YES NO NO YES YES | 1 second | 256 megabytes | ['brute force', 'math', '*1300'] |
E. Binary Dequetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSlavic has an array of length n consisting only of zeroes and ones. In one operation, he removes either the first or the last element of the array. What is the minimum number of operations Slavic has to ... | 7
3 1
1 0 0
3 1
1 1 0
9 3
0 1 0 1 1 1 0 0 1
6 4
1 1 1 1 1 1
5 1
0 0 1 1 0
16 2
1 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1
6 3
1 0 1 0 0 0
| 0 1 3 2 2 7 -1 | 2 seconds | 256 megabytes | ['binary search', 'implementation', 'two pointers', '*1200'] |
D. The Clocktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVictor has a 24-hour clock that shows the time in the format "HH:MM" (00 \le HH \le 23, 00 \le MM \le 59). He looks at the clock every x minutes, and the clock is currently showing time s. How many different... | 6
03:12 360
00:00 1
13:22 2
15:15 10
11:11 1440
22:30 27
| 1 16 10 0 1 1 | 1 second | 256 megabytes | ['brute force', 'implementation', '*1100'] |
C. Where's the Bishop?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMihai has an 8 \times 8 chessboard whose rows are numbered from 1 to 8 from top to bottom and whose columns are numbered from 1 to 8 from left to right.Mihai has placed exactly one bishop on the ch... | 3
.....#..
#...#...
.#.#....
..#.....
.#.#....
#...#...
.....#..
......#.
#.#.....
.#......
#.#.....
...#....
....#...
.....#..
......#.
.......#
.#.....#
..#...#.
...#.#..
....#...
...#.#..
..#...#.
.#.....#
#.......
| 4 3 2 2 4 5 | 1 second | 256 megabytes | ['implementation', '*800'] |
B. All Distincttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSho has an array a consisting of n integers. An operation consists of choosing two distinct indices i and j and removing a_i and a_j from the array.For example, for the array [2, 3, 4, 2, 5], Sho can choo... | 4
6
2 2 2 3 3 3
5
9 1 9 9 1
4
15 16 16 15
4
10 100 1000 10000
| 2 1 2 4 | 1 second | 256 megabytes | ['greedy', 'sortings', '*800'] |
A. Marathontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given four distinct integers a, b, c, d. Timur and three other people are running a marathon. The value a is the distance that Timur has run and b, c, d correspond to the distances the other three par... | 4
2 3 4 1
10000 0 1 2
500 600 400 300
0 9999 10000 9998
| 2 0 1 3 | 1 second | 256 megabytes | ['implementation', '*800'] |
F. K-Set Treetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree G with n vertices and an integer k. The vertices of the tree are numbered from 1 to n.For a vertex r and a subset S of vertices of G, such that |S| = k, we define f(r, S) as the size o... | 3 2
1 2
1 3
| 25 | 3 seconds | 512 megabytes | ['combinatorics', 'dfs and similar', 'dp', 'math', 'trees', '*2500'] |
E. Number of Groupstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n colored segments on the number line. Each segment is either colored red or blue. The i-th segment can be represented by a tuple (c_i, l_i, r_i). The segment contains all the points in... | 2
5
0 0 5
1 2 12
0 4 7
1 9 16
0 13 19
3
1 0 1
1 1 2
0 3 4
| 2 3 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'dsu', 'graphs', 'greedy', 'sortings', '*2300'] |
D. Max GEQ Sumtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers. You are asked to find out if the inequality \max(a_i, a_{i + 1}, \ldots, a_{j - 1}, a_{j}) \geq a_i + a_{i + 1} + \dots + a_{j - 1} + a_{j} holds for all pairs of... | 3
4
-1 1 -1 2
5
-1 2 -3 2 -1
3
2 3 -1
| YES YES NO | 1.5 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'divide and conquer', 'implementation', 'two pointers', '*1800'] |
C. Sum of Substringstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string s of length n.Let's define d_i as the number whose decimal representation is s_i s_{i+1} (possibly, with a leading zero). We define f(s) to be the sum of all the valid d... | 3
4 0
1010
7 1
0010100
5 2
00110
| 21 22 12 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'math', 'strings', '*1400'] |
B. Shoe Shufflingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA class of students got bored wearing the same pair of shoes every day, so they decided to shuffle their shoes among themselves. In this problem, a pair of shoes is inseparable and is considered as a si... | 2
5
1 1 1 1 1
6
3 6 8 13 15 21
| 5 1 2 3 4 -1 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'two pointers', '*1000'] |
A. Beat The Oddstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven a sequence a_1, a_2, \ldots, a_n, find the minimum number of elements to remove from the sequence such that after the removal, the sum of every 2 consecutive elements is even.InputEach test contain... | 2
5
2 4 3 6 8
6
3 5 9 7 1 3
| 1 0 | 1 second | 256 megabytes | ['brute force', 'greedy', 'math', '*800'] |
G. Count the Trainstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n of independent carriages on the rails. The carriages are numbered from left to right from 1 to n. The carriages are not connected to each other. The carriages move to the left, so that th... | 3
4 2
6 2 3 7
3 2
4 7
5 4
10 13 5 2 6
2 4
5 2
1 5
3 2
13 4
769 514 336 173 181 373 519 338 985 709 729 702 168
12 581
6 222
7 233
5 117
| 3 4 4 4 2 3 5 6 6 5 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', 'sortings', '*2000'] |
F. Shifting Stringtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp found the string s and the permutation p. Their lengths turned out to be the same and equal to n.A permutation of n elements — is an array of length n, in which every integer from 1 to n occu... | 3
5
ababa
3 4 5 2 1
5
ababa
2 1 4 5 3
10
codeforces
8 6 1 7 5 2 9 3 10 4
| 1 6 12 | 3 seconds | 256 megabytes | ['graphs', 'math', 'number theory', 'strings', '*1700'] |
E. Price Maximizationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA batch of n goods (n — an even number) is brought to the store, i-th of which has weight a_i. Before selling the goods, they must be packed into packages. After packing, the following will be done... | 6
6 3
3 2 7 1 4 8
4 3
2 1 5 6
4 12
0 0 0 0
2 1
1 1
6 10
2 0 0 5 9 4
6 5
5 3 8 6 3 2
| 8 4 0 2 1 5 | 2 seconds | 256 megabytes | ['binary search', 'greedy', 'math', 'two pointers', '*1500'] |
D. Black and White Stripetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a stripe of checkered paper of length n. Each cell is either white or black.What is the minimum number of cells that must be recolored from white to black in order to have a segment of... | 4
5 3
BBWBW
5 5
BBWBW
5 1
BBWBW
1 1
W
| 1 2 0 1 | 2 seconds | 256 megabytes | ['implementation', 'two pointers', '*1000'] |
C. Restoring the Duration of Taskstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Polycarp completed n successive tasks.For each completed task, the time s_i is known when it was given, no two tasks were given at the same time. Also given is the time f_i w... | 4
3
0 3 7
2 10 11
2
10 15
11 16
9
12 16 90 195 1456 1569 3001 5237 19275
13 199 200 260 9100 10000 10914 91066 5735533
1
0
1000000000
| 2 7 1 1 1 1 183 1 60 7644 900 914 80152 5644467 1000000000 | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'implementation', '*800'] |
B. Array Decrementstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKristina has two arrays a and b, each containing n non-negative integers. She can perform the following operation on array a any number of times: apply a decrement to each non-zero element of the ar... | 6
4
3 5 4 1
1 3 2 0
3
1 2 1
0 1 0
4
5 3 7 2
1 1 1 1
5
1 2 3 4 5
1 2 3 4 6
1
8
0
1
4
6
| YES YES NO NO YES NO | 1 second | 256 megabytes | ['greedy', 'implementation', '*800'] |
A. Print a Pedestal (Codeforces logo?)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven the integer n — the number of available blocks. You must use all blocks to build a pedestal. The pedestal consists of 3 platforms for 2-nd, 1-st and 3-rd places respectively. ... | 6
11
6
10
100000
7
8
| 4 5 2 2 3 1 4 5 1 33334 33335 33331 2 4 1 3 4 1 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*800'] |
E. ANDfinitytime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBit Lightyear, to the ANDfinity and beyond!After graduating from computer sciences, Vlad has been awarded an array a_1,a_2,\ldots,a_n of n non-negative integers. As it is natural, he wanted to construct a g... | 4
5
1 2 3 4 5
2
0 2
2
3 12
4
3 0 0 0
| 0 1 2 3 4 5 2 2 2 1 3 11 3 3 1 1 1 | 4 seconds | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', '*2500'] |
D. Lena and Matrixtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLena is a beautiful girl who likes logical puzzles.As a gift for her birthday, Lena got a matrix puzzle!The matrix consists of n rows and m columns, and each cell is either black or white. The coordin... | 5
3 2
BW
WW
WB
3 3
WWB
WBW
BWW
2 3
BBB
BBB
5 5
BWBWB
WBWBW
BWBWB
WBWBW
BWBWB
9 9
WWWWWWWWW
WWWWWWWWW
BWWWWWWWW
WWWWWWWWW
WWWWBWWWW
WWWWWWWWW
WWWWWWWWW
WWWWWWWWW
WWWWWWWWB
| 2 1 2 2 1 2 3 3 6 5 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'geometry', 'shortest paths', '*1900'] |
C. Infected Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputByteland is a beautiful land known because of its beautiful trees.Misha has found a binary tree with n vertices, numbered from 1 to n. A binary tree is an acyclic connected bidirectional graph containin... | 4
2
1 2
4
1 2
2 3
2 4
7
1 2
1 5
2 3
2 4
5 6
5 7
15
1 2
2 3
3 4
4 5
4 6
3 7
2 8
1 9
9 10
9 11
10 12
10 13
11 14
11 15
| 0 2 2 10 | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'trees', '*1600'] |
B. Mystic Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is a little boy who lives in Byteland and he loves programming.Recently, he found a permutation of length n. He has to come up with a mystic permutation. It has to be a new permutation suc... | 4
3
1 2 3
5
2 3 4 5 1
4
2 3 1 4
1
1
| 2 3 1 1 2 3 4 5 1 2 4 3 -1 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*900'] |
A. Lex Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKuznecov likes art, poetry, and music. And strings consisting of lowercase English letters.Recently, Kuznecov has found two strings, a and b, of lengths n and m respectively. They consist of lowercase Engli... | 3
6 4 2
aaaaaa
bbbb
5 9 3
caaca
bedededeb
7 7 1
noskill
wxhtzdy
| aabaabaa aaabbcc dihktlwlxnyoz | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', 'sortings', 'two pointers', '*800'] |
C. Manipulating Historytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs a human, she can erase history of its entirety. As a Bai Ze (Hakutaku), she can create history out of nothingness.—Perfect Memento in Strict SenseKeine has the ability to manipulate history. Th... | 2
2
a
ab
b
cd
acd
3
z
a
a
aa
yakumo
ran
yakumoran
| a z | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'strings', '*1700'] |
B. Patchouli's Magical Talismantime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputShe is skilled in all kinds of magics, and is keen on inventing new one.—Perfect Memento in Strict SensePatchouli is making a magical talisman. She initially has n magical tokens. Their ma... | 4
2
1 9
3
1 1 2
3
2 4 8
3
1049600 33792 1280
| 0 1 3 10 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'greedy', 'sortings', '*800'] |
A. Cirno's Perfect Bitmasks Classroomtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputEven if it's a really easy question, she won't be able to answer it— Perfect Memento in Strict SenseCirno's perfect bitmasks classroom has just started!Cirno gave her students a posi... | 7
1
2
5
9
16
114514
1000000
| 3 3 1 1 17 2 64 | 1 second | 256 megabytes | ['bitmasks', 'brute force', '*800'] |
F. Koishi's Unconscious Permutationtime limit per test12 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputAs she closed the Satori's eye that could read minds, Koishi gained the ability to live in unconsciousness. Even she herself does not know what she is up to.— Subterranean AnimismKo... | 2 0
| 1 0 | 12 seconds | 1024 megabytes | ['fft', 'math', '*3500'] |
E. Become Big For Metime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputCome, let's build a world where even the weak are not forgotten!—Kijin Seija, Double Dealing CharactersShinmyoumaru has a mallet that can turn objects bigger or smaller. She is testing it out on a s... | 3
6 10 15
| 1 0 3 1 2 3 | 3 seconds | 512 megabytes | ['combinatorics', 'constructive algorithms', 'greedy', 'math', 'number theory', '*3500'] |
D. Cute numbertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRan is especially skilled in computation and mathematics. It is said that she can do unimaginable calculation work in an instant.—Perfect Memento in Strict SenseRan Yakumo is a cute girl who loves creatin... | 4
1 3 8 10
| 1 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'data structures', 'dsu', 'implementation', 'math', '*2900'] |
C. Sanae and Giant Robottime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIs it really?! The robot only existing in my imagination?! The Colossal Walking Robot?!!— Kochiya Sanae Sanae made a giant robot — Hisoutensoku, but something is wrong with it. To make matters wo... | 2
5 2
1 5 4 2 3
3 2 5 4 1
1 3
2 5
5 2
1 5 4 2 3
3 2 4 5 1
1 2
2 4
| YES NO | 1 second | 256 megabytes | ['binary search', 'brute force', 'data structures', 'dsu', 'greedy', 'sortings', '*2500'] |
B. Railway Systemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs for the technology in the outside world, it is really too advanced for Gensokyo to even look up to.—Yasaka Kanako, Symposium of Post-mysticismThis is an interactive problem.Under the direct supervisi... | 5 4
0
5
9
7
| ? 0000 ? 1110 ? 1111 ? 1101 ! 7 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'greedy', 'interactive', 'sortings', '*1700'] |
A. The Enchanted Foresttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe enchanted forest got its name from the magical mushrooms growing here. They may cause illusions and generally should not be approached.—Perfect Memento in Strict SenseMarisa comes to pick mus... | 45 25 6 1 2 35 75 6 1 2 31 29999995 700001000000000 1000000000 1000000000 1000000000 1000000000 | 12 37 1000000 5000349985 | 2 seconds | 256 megabytes | ['brute force', 'greedy', '*1600'] |
B. Odd Subarraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor an array [b_1, b_2, \ldots, b_m] define its number of inversions as the number of pairs (i, j) of integers such that 1 \le i < j \le m and b_i>b_j. Let's call array b odd if its number of inversions ... | 531 2 344 3 2 121 222 164 5 6 1 2 3 | 0 2 0 1 1 | 1 second | 256 megabytes | ['dp', 'greedy', '*800'] |
A. Everything Everywhere All But Onetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of n integers a_1, a_2, \ldots, a_n. After you watched the amazing film "Everything Everywhere All At Once", you came up with the following operation.In one ope... | 4
3
42 42 42
5
1 2 3 4 5
4
4 3 2 1
3
24 2 22
| YES YES NO NO | 1 second | 256 megabytes | ['greedy', '*800'] |
E. The Ultimate LIS Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt turns out that this is exactly the 100-th problem of mine that appears in some programming competition. So it has to be special! And what can be more special than another problem about LIS... | 2 6
1 2 3 4 5
1 5
1 5
4 5
5 4
1 4
2 5
| -1 -1 2 -1 4 0 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*3500'] |
D2. Permutation Weight (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a hard version of the problem. The difference between the easy and hard versions is that in this version, you have to output the lexicographically smallest permutation with t... | 322 142 3 1 455 4 3 2 1 | 1 2 1 3 4 2 1 3 4 2 5 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*3500'] |
D1. Permutation Weight (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an easy version of the problem. The difference between the easy and hard versions is that in this version, you can output any permutation with the smallest weight.You are giv... | 322 142 3 1 455 4 3 2 1 | 1 2 1 3 4 2 1 4 2 3 5 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dsu', '*2800'] |
C. Bring Balancetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlina has a bracket sequence s of length 2n, consisting of n opening brackets '(' and n closing brackets ')'. As she likes balance, she wants to turn this bracket sequence into a balanced bracket sequenc... | 32(())5())((()))(6())((()))(() | 0 2 3 4 9 10 1 2 11 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', '*2600'] |
B. Linguisticstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlina has discovered a weird language, which contains only 4 words: \texttt{A}, \texttt{B}, \texttt{AB}, \texttt{BA}. It also turned out that there are no spaces in this language: a sentence is written by ... | 8
1 0 0 0
B
0 0 1 0
AB
1 1 0 1
ABAB
1 0 1 1
ABAAB
1 1 2 2
BAABBABBAA
1 1 2 3
ABABABBAABAB
2 3 5 4
AABAABBABAAABABBABBBABB
1 3 3 10
BBABABABABBBABABABABABABAABABA
| NO YES YES YES YES YES NO YES | 1 second | 256 megabytes | ['greedy', 'implementation', 'sortings', 'strings', '*2000'] |
A. Circular Local MiniMaxtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a_1, a_2, \ldots, a_n. Is it possible to arrange them on a circle so that each number is strictly greater than both its neighbors or strictly smaller than both its neigh... | 4
3
1 1 2
4
1 9 8 4
4
2 0 2 2
6
1 1 1 11 111 1111
| NO YES 1 8 4 9 NO YES 1 11 1 111 1 1111 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*1100'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.