problem_statement stringlengths 147 8.53k | input stringlengths 1 771 | output stringlengths 1 592 ⌀ | time_limit stringclasses 32
values | memory_limit stringclasses 21
values | tags stringlengths 6 168 |
|---|---|---|---|---|---|
C. No Prime Differencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given integers n and m. Fill an n by m grid with the integers 1 through n\cdot m, in such a way that for any two adjacent cells in the grid, the absolute difference of the values in those... | 34 45 76 4 | 16 7 1 9 12 8 2 3 13 4 10 11 14 5 6 15 29 23 17 9 5 6 2 33 27 21 15 11 7 1 32 31 25 19 20 16 10 26 30 24 18 14 8 4 35 34 28 22 13 12 3 2 3 7 11 8 9 1 10 17 13 5 4 18 14 6 12 19 23 15 21 20 24 16 22 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1400'] |
B. Minimize Permutation Subarraystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p of size n. You want to minimize the number of subarrays of p that are permutations. In order to do so, you must perform the following operation exactly onc... | 831 2 331 3 251 3 2 5 464 5 6 1 2 398 7 6 3 2 1 4 5 9107 10 5 1 9 8 3 2 6 4108 5 10 9 2 1 3 4 6 7102 3 5 7 10 1 8 6 4 9 | 2 3 1 1 5 2 1 4 9 5 8 8 6 10 5 4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*1100'] |
A. Blackboard Listtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo integers were written on a blackboard. After that, the following step was carried out n-2 times: Select any two integers on the board, and write the absolute value of their difference on the board... | 939 2 7315 -4 114-9 1 11 -1053 0 0 0 378 16 8 0 8 16 840 0 0 01027 1 24 28 2 -1 26 25 28 276600000000 800000000 0 -200000000 1000000000 80000000030 -1000000000 1000000000 | 9 11 -9 3 8 0 -1 600000000 0 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
F. Editorial for Twotime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland Intercollegiate Contest has just finished. Monocarp and Polycarp, as the jury, are going to conduct an editorial. Unfortunately, the time is limited, since they have to finish before the clo... | 65 41 10 1 1 15 31 20 5 15 35 31 20 3 15 510 610 8 20 14 3 8 6 4 16 1110 59 9 2 13 15 19 4 9 13 121 11 | 2 6 5 21 18 1 | 4 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', 'implementation', '*2400'] |
E. Playoff Fixingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output2^k teams participate in a playoff tournament. The teams are numbered from 1 to 2^k, in order of decreasing strength. So, team 1 is the strongest one, team 2^k is the weakest one. A team with a smaller... | 2
1 2 3 4
| 0 | 2 seconds | 256 megabytes | ['combinatorics', 'trees', '*2200'] |
D. Bracket Coloringtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For ... | 48((())))(4(())4))((3(() | 2 2 2 2 1 2 2 2 1 1 1 1 1 1 1 1 1 1 1 -1 | 2 seconds | 512 megabytes | ['constructive algorithms', 'greedy', '*1400'] |
C. Best Binary Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of the characters 0, 1 and/or ?. Let's call it a pattern.Let's say that the binary string (a string where each character is either 0 or 1) matches the pattern if... | 4??01?101001??10?0?1?10?10 | 00011 10100 111101 011110010 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*1000'] |
B. Comparison Stringtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a string s of length n, where each character is either < or >.An array a consisting of n+1 elements is compatible with the string s if, for every i from 1 to n, the character s_i repre... | 44<<>>4>><<5>>>>>7<><><>< | 3 3 6 2 | 2 seconds | 512 megabytes | ['greedy', '*900'] |
A. Grasshopper on a Linetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers x and k. Grasshopper starts in a point 0 on an OX axis. In one move, it can jump some integer distance, that is not divisible by k, to the left or to the right.What's ... | 310 210 33 4 | 2 7 3 1 10 1 3 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
B. Astrophysiciststime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn many, many years, far, far away, there will be a launch of the first flight to Mars. To celebrate the success, n astrophysicists working on the project will be given bonuses of a total value of k go... | 53 3 1002 1 1491 2 1336 16 673 8 22 | 100 0 26 72 176 | 1 second | 256 megabytes | ['greedy', 'math', '*1100'] |
A. Destroyertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJohn is a lead programmer on a destroyer belonging to the space navy of the Confederacy of Independent Operating Systems. One of his tasks is checking if the electronic brains of robots were damaged during b... | 560 1 2 0 1 090 0 0 0 1 1 1 2 230 0 219950 1 2 3 4 | YES YES NO NO YES | 1 second | 256 megabytes | ['implementation', 'sortings', '*800'] |
F. Good Graphtime limit per test7 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a bipartite graph G with the vertex set in the left part L, in the right part R, and m edges connecting these two sets. We know that |L| = |R| = n.For any subset S \subseteq L, let N(S) denot... | 3 8
1 4
1 5
1 6
2 4
2 5
2 6
3 5
3 6
| YES 6 1 4 1 5 2 5 2 6 3 6 3 4 | 7 seconds | 256 megabytes | ['bitmasks', 'dfs and similar', 'graph matchings', 'graphs', 'implementation', '*3500'] |
E. Old Mobiletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the latest mission of the starship U.S.S. Coder, Captain Jan Bitovsky was accidentally teleported to the surface of an unknown planet. Trying to find his way back, Jan found an artifact from planet ... | 1 2
0
| 666666674 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'probabilities', '*3500'] |
D. Doctor's Brown Hypothesistime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe rebels have been crushed in the most recent battle with the imperial forces, but there is a ray of new hope.Meanwhile, on one of the conquered planets, Luke was getting ready for an ille... | 7 8 346
1 2
1 3
2 4
3 4
4 5
5 1
6 7
7 6
| 5 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'math', 'number theory', '*2900'] |
C. Twin Clusterstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFamous worldwide astrophysicist Mleil waGrasse Tysok recently read about the existence of twin galaxy clusters. Before he shares this knowledge with the broader audience in his podcast called S.tarT-ok,... | 424 15 0 7 11 8 3 210 1 2 300 0315 63 57 39 61 25 42 61 50 41 27 41 56 23 17 27 | 2 4 6 6 2 2 3 4 1 1 2 2 1 1 4 10 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'math', 'probabilities', '*2600'] |
B. Lotterytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputn people indexed with integers from 1 to n came to take part in a lottery. Each received a ticket with an integer from 0 to m.In a lottery, one integer called target is drawn uniformly from 0 to m. k tickets ... | 3 6 2
1 4 5
| 4 2 | 2 seconds | 256 megabytes | ['binary search', 'brute force', 'greedy', 'math', 'two pointers', '*2500'] |
A. k-th equalitytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider all equalities of form a + b = c, where a has A digits, b has B digits, and c has C digits. All the numbers are positive integers and are written without leading zeroes. Find the k-th lexicograp... | 71 1 1 92 2 3 12 2 1 11 5 6 421 6 6 100000005 5 6 30315688156 6 6 1000000000000 | 2 + 1 = 3 10 + 90 = 100 -1 9 + 99996 = 100005 -1 78506 + 28543 = 107049 -1 | 1 second | 256 megabytes | ['brute force', 'implementation', 'math', '*1700'] |
F. Typewritertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Polycarp was given an unusual typewriter as a gift! Unfortunately, the typewriter was defective and had a rather strange design.The typewriter consists of n cells numbered from left to right from... | 3
2 3 1
0
| 1 | 3 seconds | 256 megabytes | ['brute force', 'math', '*2500'] |
E. MEX of LCMtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n. A positive integer x is called good if it is impossible to find a subsegment^{\dagger} of the array such that the least common multiple of all its elements is equal to... | 631 2 351 2 3 4 522 311000000000121 8 4 2 3 5 7 2 9 10 11 13127 2 5 4 2 1 1 2 3 11 8 9 | 4 7 1 1 16 13 | 2 seconds | 512 megabytes | ['binary search', 'data structures', 'implementation', 'math', 'number theory', '*2300'] |
D. Survey in Classtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputZinaida Viktorovna has n students in her history class. The homework for today included m topics, but the students had little time to prepare, so i-th student learned only topics from l_i to r_i inclu... | 64 82 64 82 71 53 31 32 32 23 51 51 51 53 51 13 35 54 71 71 33 34 52 41 32 4 | 6 4 0 2 12 2 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'greedy', 'implementation', 'sortings', '*1900'] |
C. Game with Reversingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game. They have two strings S and T of the same length n consisting of lowercase latin letters. Players take turns alternately, with Alice going first.On her turn, Alice... | 75abcdeabxde5helloolleo2abcd7aaaaaaaabbbbba1qq6yoyoyooyoyoy8abcdefghhguedfbh | 1 2 3 9 0 2 6 | 1 second | 256 megabytes | ['games', 'greedy', 'math', 'strings', '*1200'] |
B. Maximum Strengthtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFedya is playing a new game called "The Legend of Link", in which one of the character's abilities is to combine two materials into one weapon. Each material has its own strength, which can be represe... | 653 57179 23913 37132228 13222854943329752812629795 5515758193968886336688 1914 | 4 19 11 0 163 28 | 1 second | 256 megabytes | ['greedy', 'math', '*1000'] |
A. Unit Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an array a of length n, which elements are equal to -1 and 1. Let's call the array a good if the following conditions are held at the same time: a_1 + a_2 + \ldots + a_n \ge 0; a_1 \cdot a_2 \cdot \... | 74-1 -1 1 -15-1 -1 -1 1 14-1 1 -1 13-1 -1 -151 1 1 1 11-12-1 -1 | 1 1 0 3 0 1 2 | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
G. Ksyusha and Chinchillatime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKsyusha has a pet chinchilla, a tree on n vertices and huge scissors. A tree is a connected graph without cycles. During a boring physics lesson Ksyusha thought about how to entertain her pet.C... | 491 24 37 95 44 63 28 71 761 21 34 31 56 161 23 23 44 56 551 35 35 23 4 | 2 2 8 -1 1 3 -1 | 3 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dp', 'dsu', 'greedy', 'implementation', 'trees', '*1800'] |
F. Ira and Flamencotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIra loves Spanish flamenco dance very much. She decided to start her own dance studio and found n students, ith of whom has level a_i.Ira can choose several of her students and set a dance with them.... | 97 48 10 10 9 6 11 75 34 2 2 3 68 21 5 2 2 3 1 3 33 33 3 35 13 4 3 10 712 35 2 1 1 4 3 5 5 5 2 7 51 113 21 2 32 21 2 | 5 2 10 0 5 11 1 2 1 | 2 seconds | 256 megabytes | ['combinatorics', 'constructive algorithms', 'data structures', 'implementation', 'math', 'sortings', 'two pointers', '*1700'] |
E. Round Dancetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputn people came to the festival and decided to dance a few round dances. There are at least 2 people in the round dance and each person has exactly two neighbors. If there are 2 people in the round dance th... | 1062 1 4 3 6 562 3 1 5 6 492 3 2 5 6 5 8 9 822 144 3 2 152 3 4 5 165 3 4 1 1 253 5 4 1 266 3 2 5 4 365 1 4 3 4 2 | 1 3 2 2 1 3 1 1 1 2 1 1 1 1 2 2 1 2 1 1 | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'shortest paths', '*1600'] |
D. Flippertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p of length n.A permutation is an array consisting of n distinct integers from 1 to n in any order. For example, \{2,3,1,5,4\} is a permutation, while \{1,2,2\} is not (since 2 appe... | 952 3 1 5 494 1 6 7 2 8 5 3 944 3 2 122 163 2 4 1 5 673 2 1 5 7 6 41010 2 5 6 1 9 3 8 4 744 2 1 311 | 5 4 1 3 2 9 4 1 6 7 2 8 5 3 3 2 1 4 1 2 6 5 3 2 4 1 7 6 4 5 3 2 1 9 3 8 4 7 1 10 2 5 6 3 4 2 1 1 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', '*1400'] |
C. Vlad Building Beautiful Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad was given an array a of n positive integers. Now he wants to build a beautiful array b of length n from it.Vlad considers an array beautiful if all the numbers in it are positive and... | 752 6 8 4 351 4 7 6 942 6 4 1075 29 13 9 10000001 11 352 1 2 4 252 4 5 4 342 5 5 4 | NO YES YES YES YES NO NO | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
B. Restore the Weathertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a containing the weather forecast for Berlandia for the last n days. That is, a_i — is the estimated air temperature on day i (1 \le i \le n).You are also given an array b — ... | 35 21 3 5 3 92 5 11 2 46 1-1 3 -2 0 -5 -1-4 0 -1 4 0 03 37 7 79 4 8 | 2 2 5 4 11 0 4 -1 0 -4 0 8 4 9 | 1 second | 256 megabytes | ['greedy', 'sortings', '*900'] |
A. Musical Puzzletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVlad decided to compose a melody on his guitar. Let's represent the melody as a sequence of notes corresponding to the characters 'a', 'b', 'c', 'd', 'e', 'f', and 'g'.However, Vlad is not very experien... | 54abab7abacaba6aaaaaa7abcdefg5babdd | 2 4 1 6 4 | 1 second | 256 megabytes | ['implementation', 'strings', '*800'] |
F. Zombiestime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp plays a computer game in a post-apocalyptic setting. The zombies have taken over the world, and Polycarp with a small team of survivors is defending against hordes trying to invade their base. The zo... | 3 3 10 3
0 2
1 7
4 7
| 18 | 4 seconds | 256 megabytes | ['binary search', 'dp', '*3200'] |
E. Combinatorics Problemtime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputRecall that the binomial coefficient \binom{x}{y} is calculated as follows (x and y are non-negative integers): if x < y, then \binom{x}{y} = 0; otherwise, \binom{x}{y} = \frac{x!}{y! \cdot (... | 5 8 2 3 100 2
| 1283 | 4 seconds | 1024 megabytes | ['brute force', 'combinatorics', 'dp', '*2200'] |
D2. Red-Blue Operations (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is the maximum values of n and q.You are given an array, consisting of n integers. Initially, all elements are red.You can apply ... | 4 10
5 2 8 4
1 2 3 4 5 6 7 8 9 10
| 3 4 5 6 7 8 8 10 8 12 | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'implementation', 'math', '*2400'] |
D1. Red-Blue Operations (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is the maximum values of n and q.You are given an array, consisting of n integers. Initially, all elements are red.You can apply ... | 4 10
5 2 8 4
1 2 3 4 5 6 7 8 9 10
| 3 4 5 6 7 8 8 10 8 12 | 2 seconds | 256 megabytes | ['binary search', 'greedy', 'implementation', 'math', '*2100'] |
C. Contrast Valuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor an array of integers [a_1, a_2, \dots, a_n], let's call the value |a_1-a_2|+|a_2-a_3|+\cdots+|a_{n-1}-a_n| the contrast of the array. Note that the contrast of an array of size 1 is equal to 0.You ... | 451 3 3 3 724 241 1 1 175 4 2 1 0 0 4 | 2 2 1 3 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1200'] |
B. Maximum Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots, a_n, where all elements are different.You have to perform exactly k operations with it. During each operation, you do exactly one of the following two actions (you ... | 65 12 5 1 10 65 22 5 1 10 63 11 2 36 115 22 12 10 13 116 215 22 12 10 13 115 1999999996 999999999 999999997 999999998 999999995 | 21 11 3 62 46 3999999986 | 2 seconds | 256 megabytes | ['brute force', 'sortings', 'two pointers', '*1100'] |
A. New Palindrometime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA palindrome is a string that reads the same from left to right as from right to left. For example, abacaba, aaaa, abba, racecar are palindromes.You are given a string s consisting of lowercase Latin l... | 3codedocggaabaa | YES NO NO | 2 seconds | 256 megabytes | ['strings', '*800'] |
B. Array mergingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b both of length n.You will merge^\dagger these arrays forming another array c of length 2 \cdot n. You have to find the maximum length of a subarray consisting of equal va... | 412231 2 34 5 621 22 151 2 2 2 22 1 1 1 1 | 2 1 2 5 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1000'] |
A. Twin Permutationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation^\dagger a of length n.Find any permutation b of length n such that a_1+b_1 \le a_2+b_2 \le a_3+b_3 \le \ldots \le a_n+b_n.It can be proven that a permutation b that satisf... | 551 2 4 5 321 21133 2 141 4 3 2 | 1 2 4 3 5 2 1 1 1 2 3 1 2 3 4 | 1 second | 256 megabytes | ['constructive algorithms', '*800'] |
F. The Third Gracetime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given n intervals and m points on the number line. The i-th intervals covers coordinates [l_i,r_i] and the i-th point is on coordinate i and has coefficient p_i.Initially, all points are not ... | 22 81 53 878 0 50 0 0 0 0 301 61 50 0 0 0 0 100 | 108 0 | 5 seconds | 1024 megabytes | ['data structures', 'dp', '*3200'] |
E. Bully Sorttime limit per test10 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputOn a permutation p of length n, we define a bully swap as follows: Let i be the index of the largest element p_i such that p_i \neq i. Let j be the index of the smallest element p_j such that i < j. S... | 8 5
6 2 1 5 3 4 7 8
1 8
2 3
4 7
7 8
3 6
| 5 6 9 8 7 | 10 seconds | 1024 megabytes | ['data structures', 'math', '*3500'] |
D. Mex Treetime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree with n nodes. For each node, you either color it in 0 or 1.The value of a path (u,v) is equal to the MEX^\dagger of the colors of the nodes from the shortest path between u and v.The val... | 431 22 341 21 31 4101 21 33 43 51 65 72 86 96 101 | 8 15 96 1 | 3 seconds | 256 megabytes | ['brute force', 'dp', 'trees', '*2800'] |
C. Hyperregular Bracket Stringstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer n and k intervals. The i-th interval is [l_i,r_i] where 1 \leq l_i \leq r_i \leq n.Let us call a regular bracket sequence^{\dagger,\ddagger} of length n hyperregu... | 76 05 08 11 310 23 46 91000 3100 701200 801300 90128 51 123 2011 144 918 194 31 41 41 4 | 5 0 0 4 839415253 140 2 | 3 seconds | 256 megabytes | ['combinatorics', 'greedy', 'hashing', 'math', 'number theory', 'sortings', '*2400'] |
B. The BOSS Can Count Pairstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b, both of length n.Your task is to count the number of pairs of integers (i,j) such that 1 \leq i < j \leq n and a_i \cdot a_j = b_i+b_j.InputEach test contain... | 332 3 23 3 184 2 8 2 1 2 7 53 5 8 8 1 1 6 584 4 8 8 8 8 8 88 8 8 8 8 8 8 8 | 2 7 1 | 4 seconds | 512 megabytes | ['brute force', 'math', '*2000'] |
A. Copil Copac Draws Treestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCopil Copac is given a list of n-1 edges describing a tree of n vertices. He decides to draw it using the following algorithm: Step 0: Draws the first vertex (vertex 1). Go to step 1. Step 1... | 264 51 31 23 41 675 62 42 71 31 24 5 | 2 3 | 3 seconds | 256 megabytes | ['dfs and similar', 'dp', 'graphs', 'trees', '*1400'] |
H. Don't Blame Metime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSadly, the problem setter couldn't think of an interesting story, thus he just asks you to solve the following problem.Given an array a consisting of n positive integers, count the number of non-empty ... | 65 11 1 1 1 14 00 1 2 35 15 5 7 4 21 2312 00 2 0 2 0 2 0 2 0 2 0 210 663 0 63 5 5 63 63 4 12 13 | 31 10 10 1 4032 15 | 2 seconds | 256 megabytes | ['bitmasks', 'combinatorics', 'dp', 'math', '*1700'] |
G. Hits Differenttime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn a carnival game, there is a huge pyramid of cans with 2023 rows, numbered in a regular pattern as shown. If can 9^2 is hit initially, then all cans colored red in the picture above would fall. You... | 1091234561014341000000 | 156 1 5 10 21 39 46 146 63145186 58116199242129511 | 2.5 seconds | 256 megabytes | ['data structures', 'dp', 'implementation', 'math', '*1600'] |
F. Forever Wintertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA snowflake graph is generated from two integers x and y, both greater than 1, as follows: Start with one central vertex. Connect x new vertices to this central vertex. Connect y new vertices to ea... | 321 2021 205 2013 201 311 310 34 819 814 89 712 717 718 616 62 66 157 158 1520 153 157 61 21 32 42 53 63 79 89 33 66 22 15 22 74 33 8 | 5 3 2 2 2 3 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'math', '*1300'] |
E. The Lakestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an n \times m grid a of non-negative integers. The value a_{i,j} represents the depth of water at the i-th row and j-th column. A lake is a set of cells such that: each cell in the set has a_... | 53 31 2 03 4 00 0 51 103 30 1 11 0 11 1 15 51 1 1 1 11 0 0 0 11 0 5 0 11 0 0 0 11 1 1 1 15 51 1 1 1 11 0 0 0 11 1 4 0 11 0 0 0 11 1 1 1 1 | 10 0 7 16 21 | 3 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', 'implementation', '*1100'] |
D. Gold Rushtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputInitially you have a single pile with n gold nuggets. In an operation you can do the following: Take any pile and split it into two piles, so that one of the resulting piles has exactly twice as many gold... | 116 49 44 218 2727 427 227 101 13 15 1746001 2984004 | YES YES NO NO YES YES NO YES YES NO NO | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'dp', 'implementation', '*1000'] |
C. Mr. Perfectly Finetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVictor wants to become "Mr. Perfectly Fine". For that, he needs to acquire a certain set of skills. More precisely, he has 2 skills he needs to acquire. Victor has n books. Reading book i takes him... | 642 003 104 014 0053 013 015 012 109 1015 1139 118 017 1064 016 017 018 009 011 0048 009 109 118 11 | 7 5 5 9 -1 8 | 2 seconds | 256 megabytes | ['bitmasks', 'greedy', 'implementation', '*800'] |
B. Blank Spacetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary array a of n elements, a binary array is an array consisting only of 0s and 1s. A blank space is a segment of consecutive elements consisting of only 0s. Your task is to find the len... | 551 0 0 1 040 1 1 11031 1 191 0 0 0 1 0 0 0 1 | 2 1 1 0 3 | 1 second | 256 megabytes | ['implementation', '*800'] |
A. Love Storytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTimur loves codeforces. That's why he has a string s having length 10 made containing only lowercase Latin letters. Timur wants to know how many indices string s differs from the string "codeforces".For exa... | 5coolforsezcadafurciecodeforcespaiuforcesforcescode | 4 5 0 4 9 | 1 second | 256 megabytes | ['implementation', 'strings', '*800'] |
B. Permutation Swaptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an unsorted permutation p_1, p_2, \ldots, p_n. To sort the permutation, you choose a constant k (k \ge 1) and do some operations on the permutation. In one operation, you can choose two ... | 733 1 243 4 1 274 2 6 7 5 3 191 6 7 4 9 2 3 8 561 5 3 4 2 6103 10 5 2 9 6 7 8 1 4111 11 6 4 8 3 7 5 9 10 2 | 1 2 3 4 3 2 3 | 1 second | 256 megabytes | ['math', 'number theory', '*900'] |
A. Divisible Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. Please find an array a_1, a_2, \ldots, a_n that is perfect.A perfect array a_1, a_2, \ldots, a_n satisfies the following criteria: 1 \le a_i \le 1000 for all 1 \le... | 71234567 | 1 2 4 1 2 3 2 8 6 4 3 4 9 4 5 1 10 18 8 5 36 3 6 21 24 10 6 14 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
F. Copium Permutationtime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given a permutation a_1,a_2,\ldots,a_n of the first n positive integers. A subarray [l,r] is called copium if we can rearrange it so that it becomes a sequence of consecutive integers, or ... | 555 2 1 4 342 1 4 31187 5 8 1 4 2 6 3101 4 5 3 7 8 9 2 10 6 | 15 15 11 10 9 9 10 8 8 7 7 1 1 36 30 25 19 15 13 12 9 9 55 55 41 35 35 25 22 22 19 17 17 | 2 seconds | 1024 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*3500'] |
E. Bus Routestime limit per test2.5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThere is a country consisting of n cities and n - 1 bidirectional roads connecting them such that we can travel between any two cities using these roads. In other words, these cities and roads form a tr... | 45 21 22 33 42 51 45 25 11 22 33 42 51 52 01 26 31 22 33 44 55 61 32 54 6 | YES NO 1 3 NO 1 2 NO 1 6 | 2.5 seconds | 1024 megabytes | ['binary search', 'constructive algorithms', 'dfs and similar', 'greedy', 'trees', '*3400'] |
D. Two Centroidstime limit per test1.5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given a tree (an undirected connected acyclic graph) which initially only contains vertex 1. There will be several queries to the given tree. In the i-th query, vertex i + 1 will appear and b... | 52131 141 2 371 2 3 2 5 2101 2 2 4 5 5 7 8 9 | 0 0 1 0 1 0 0 1 0 1 2 3 0 1 2 1 0 1 0 1 2 | 1.5 seconds | 1024 megabytes | ['data structures', 'dfs and similar', 'greedy', 'trees', '*2800'] |
C. Palindrome Partitiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA substring is a continuous and non-empty segment of letters from a given string, without any reorders.An even palindrome is a string that reads the same backward as forward and has an even length... | 66abaaba1a2aa6abcdef12accabccbacca6abbaaa | 3 0 1 0 14 6 | 1 second | 256 megabytes | ['binary search', 'brute force', 'data structures', 'dp', 'hashing', 'strings', '*2600'] |
B2. Range Sorting (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and the easy version is the constraints on t and n.You are given an array a, consisting of n distinct integers a_1, a_2, \ldots, a_n. Define the b... | 526 433 10 644 8 7 259 8 2 4 6122 6 13 3 15 5 10 8 16 9 11 18 | 1 2 8 16 232 | 1 second | 256 megabytes | ['binary search', 'data structures', 'dp', 'greedy', '*2400'] |
B1. Range Sorting (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between this problem and the hard version is the constraints on t and n.You are given an array a, consisting of n distinct integers a_1, a_2, \ldots, a_n. Define the b... | 526 433 10 644 8 7 259 8 2 4 6122 6 13 3 15 5 10 8 16 9 11 18 | 1 2 8 16 232 | 1 second | 256 megabytes | ['binary search', 'dp', 'dsu', 'greedy', 'trees', 'two pointers', '*2000'] |
A. Counting Orderstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays a and b each consisting of n integers. All elements of a are pairwise distinct.Find the number of ways to reorder a such that a_i > b_i for all 1 \le i \le n, modulo 10^9 + 7.T... | 569 6 8 4 5 24 1 5 6 3 134 3 23 4 912132 3 41 3 3122 3 7 10 23 28 29 50 69 135 420 10001 1 2 3 5 8 13 21 34 55 89 144 | 32 0 1 0 13824 | 1 second | 256 megabytes | ['combinatorics', 'math', 'sortings', 'two pointers', '*1100'] |
F. Fading into Fogtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There are n distinct hidden points with real coordinates on a two-dimensional Euclidean plane. In one query, you can ask some line ax + by + c = 0 and get the projection... | 1
2
1 1 2.5 1
1.500000001 1.500000000 2 2
| ? 0 1 -1 ? 0.2 -0.2 0 ! 1 3 2.5 0.500000001 | 4 seconds | 256 megabytes | ['geometry', 'interactive', 'math', 'probabilities', '*2800'] |
E. Walk the Runwaytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA fashion tour consists of m identical runway shows in different cities. There are n models willing to participate in the tour, numbered from 1 to n. People in different cities have different views on... | 3 5
10 10 10 10 10
1 2 3 4 5
1 5 2 3 4
2 3 4 5 1
| 30 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'data structures', 'dp', 'graphs', 'implementation', 'sortings', '*2400'] |
D. Running Milestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a street with n sights, with sight number i being i miles from the beginning of the street. Sight number i has beauty b_i. You want to start your morning jog l miles and end it r miles from the... | 455 1 4 2 341 1 1 169 8 7 6 5 47100000000 1 100000000 1 100000000 1 100000000 | 8 1 22 299999996 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', '*1700'] |
C. Dreaming of Freedomtime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBecause to take away a man's freedom of choice, even his freedom to make the wrong choice, is to manipulate him as though he were a puppet and not a person.— Madeleine L'EngleThere are n program... | 53 24 25 31000000 10000001 1000000 | YES NO YES NO YES | 2.5 seconds | 256 megabytes | ['greedy', 'math', 'number theory', '*1300'] |
B. Lunatic Never Contenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array a of n non-negative integers. Let's define f(a, x) = [a_1 \bmod x, a_2 \bmod x, \dots, a_n \bmod x] for some positive integer x. Find the biggest x, such that f(a, x) is a pali... | 421 283 0 1 2 0 3 2 1103100 1 1000000000 | 1 2 0 999999900 | 2 seconds | 256 megabytes | ['math', 'number theory', '*1100'] |
A. Trust Nobodytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a group of n people. Some of them might be liars, who always tell lies. Other people always tell the truth. The i-th person says "There are at least l_i liars amongst us". Determine if what peopl... | 721 222 220 0111055 5 3 3 565 3 6 6 3 5 | 1 -1 0 -1 0 3 4 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', 'sortings', '*1200'] |
B. LuoTianyi and the Tabletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuoTianyi gave an array b of n \cdot m integers. She asks you to construct a table a of size n \times m, filled with these n \cdot m numbers, and each element of the array must be used exactly ... | 52 21 3 1 42 2-1 -1 -1 -12 37 8 9 -3 10 83 24 8 -3 0 -7 14 3-32030 59554 16854 -85927 68060 -64460 -79547 90932 85063 82703 -12001 38762 | 9 0 64 71 1933711 | 1 second | 256 megabytes | ['greedy', 'math', '*1000'] |
A. LuoTianyi and the Palindrome Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuoTianyi gives you a palindrome^{\dagger} string s, and she wants you to find out the length of the longest non-empty subsequence^{\ddagger} of s which is not a palindrome string. ... | 4abacabaaaacodeforcesecrofedoclol | 6 -1 18 2 | 1 second | 256 megabytes | ['greedy', 'strings', '*800'] |
E. LuoTianyi and Cartridgetime limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputLuoTianyi is watching the anime Made in Abyss. She finds that making a Cartridge is interesting. To describe the process of making a Cartridge more clearly, she abstracts the original problem... | 3
1 2 2
1 1 2
1 2 2 1
1 3 1 2
| 8 | 3 seconds | 1024 megabytes | ['data structures', 'trees', '*3500'] |
D. LuoTianyi and the Functiontime limit per test7 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputLuoTianyi gives you an array a of n integers and the index begins from 1.Define g(i,j) as follows: g(i,j) is the largest integer x that satisfies \{a_p:i\le p\le j\}\subseteq\{a_q:x\le q\... | 6 4
1 2 2 1 3 4
1 1 4 5
2 3 3 3
3 6 1 2
6 6 6 6
| 6 6 0 6 | 7 seconds | 1024 megabytes | ['data structures', '*3000'] |
C. LuoTianyi and XOR-Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuoTianyi gives you a tree with values in its vertices, and the root of the tree is vertex 1.In one operation, you can change the value in one vertex to any non-negative integer.Now you need to... | 6
3 5 7 5 8 4
1 2
1 3
1 4
3 5
4 6
| 3 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'dp', 'dsu', 'greedy', 'trees', '*2500'] |
B2. LuoTianyi and the Floating Islands (Hard Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that in this version k\le n. You can make hacks only if both versions of the problem are solved. Ch... | 4 2
1 2
2 3
3 4
| 666666674 | 2 seconds | 256 megabytes | ['combinatorics', 'dfs and similar', 'math', 'probabilities', 'trees', '*2300'] |
B1. LuoTianyi and the Floating Islands (Easy Version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is that in this version k\le\min(n,3). You can make hacks only if both versions of the problem are solve... | 4 2
1 2
2 3
3 4
| 666666674 | 2 seconds | 256 megabytes | ['combinatorics', 'math', 'probabilities', 'trees', '*1800'] |
A. LuoTianyi and the Showtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n people taking part in a show about VOCALOID. They will sit in the row of seats, numbered 1 to m from left to right.The n people come and sit in order. Each person occupies a seat in... | 103 105 5 54 61 -2 -2 15 7-1 -1 4 -2 -26 75 -2 -2 -2 -2 -26 6-1 1 4 5 -1 46 8-1 -1 -1 3 -1 -26 75 -1 -2 -2 -2 -23 1-2 -2 12 55 -21 2-1 | 1 3 5 6 5 5 5 1 2 1 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1400'] |
F. Random Walktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices and n - 1 edges, and each vertex v has a counter c(v) assigned to it.Initially, there is a chip placed at vertex s and all counters, except c(s), are set to 0... | 3 1 3
1 2
2 3
| 2 2 1 | 2 seconds | 256 megabytes | ['dp', 'graphs', 'math', 'probabilities', 'trees', '*2600'] |
E. Removing Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are playing a game on a graph. They have an undirected graph without self-loops and multiple edges. All vertices of the graph have degree equal to 2. The graph may consist of several comp... | 6 2 3
1 2
2 3
3 1
4 5
5 6
6 4
| Bob | 2 seconds | 256 megabytes | ['brute force', 'dp', 'games', 'graphs', 'math', '*2500'] |
D. Unique Palindromestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA palindrome is a string that reads the same backwards as forwards. For example, the string abcba is palindrome, while the string abca is not.Let p(t) be the number of unique palindromic substrings... | 710 25 105 63 1334 23 43 34 23 43 44 14510 34 6 104 5 810 44 6 7 104 5 7 8 | YES abcbbcabcb YES foo YES ayda YES wada NO YES abcbcacbab NO | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', 'strings', '*1900'] |
C. Strongly Compositetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA prime number is an integer greater than 1, which has exactly two divisors. For example, 7 is a prime, since it has two divisors \{1, 7\}. A composite number is an integer greater than 1, which ha... | 823 633 4 522 333 10 14225 301108093 3 3 5 5 5 7 7 72012 15 2 2 2 2 2 3 3 3 17 21 21 21 30 6 6 33 31 39 | 1 1 0 2 2 3 4 15 | 2 seconds | 256 megabytes | ['greedy', 'math', 'number theory', '*1300'] |
B. Sort with Steptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's define a permutation of length n as an array p of length n, which contains every number from 1 to n exactly once.You are given a permutation p_1, p_2, \dots, p_n and a number k. You need to sort t... | 64 13 1 2 44 23 4 1 24 23 1 4 210 34 5 9 1 8 6 10 2 3 710 34 6 9 1 8 5 10 2 3 710 34 6 9 1 8 5 10 3 2 7 | 0 0 1 0 1 -1 | 1 second | 256 megabytes | ['brute force', 'math', 'sortings', '*900'] |
A. A-characteristictime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider an array a_1, a_2, \dots, a_n consisting of numbers 1 and -1. Define A-characteristic of this array as a number of pairs of indices 1 \le i < j \le n, such that a_i \cdot a_j = 1.Find any arr... | 72 02 13 13 23 35 45 5 | YES 1 -1 YES 1 1 YES 1 -1 1 NO YES 1 1 1 YES -1 1 -1 1 1 NO | 1 second | 256 megabytes | ['combinatorics', 'constructive algorithms', 'math', '*800'] |
G2. Magic Triples (Hard Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The only difference is that in this version, a_i \le 10^9.For a given sequence of n integers a, a triple (i, j, k) is called magic if: 1 \le i,... | 751 7 7 2 736 2 1891 2 3 4 5 6 7 8 941000 993 986 17971 10 100 1000 10000 100000 100000081 1 2 2 4 4 8 891 1 1 2 2 2 4 4 4 | 6 1 3 0 9 16 45 | 4 seconds | 256 megabytes | ['brute force', 'data structures', 'math', 'number theory', '*2200'] |
G1. Magic Triples (Easy Version)time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The only difference is that in this version, a_i \le 10^6.For a given sequence of n integers a, a triple (i, j, k) is called magic if: 1 \le i,... | 751 7 7 2 736 2 1891 2 3 4 5 6 7 8 941000 993 986 17971 10 100 1000 10000 100000 100000081 1 2 2 4 4 8 891 1 1 2 2 2 4 4 4 | 6 1 3 0 9 16 45 | 4 seconds | 256 megabytes | ['brute force', 'data structures', 'math', 'number theory', '*1700'] |
F. Gardening Friendstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo friends, Alisa and Yuki, planted a tree with n vertices in their garden. A tree is an undirected graph without cycles, loops, or multiple edges. Each edge in this tree has a length of k. Initial... | 43 2 32 13 15 4 12 14 25 43 46 5 34 16 12 65 13 210 6 41 31 99 77 66 49 22 88 55 10 | 2 12 17 32 | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'dp', 'graphs', 'trees', '*1700'] |
E. Making Anti-Palindromestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting of lowercase English letters. In one operation, you are allowed to swap any two characters of the string s.A string s of length n is called an anti-palindro... | 1010codeforces3abc10taarrrataa10dcbdbdcccc4wwww12cabbaccabaac10aadaaaaddc14aacdaaaacadcdc6abccba12dcbcaebacccd | 0 -1 1 1 -1 3 -1 2 2 2 | 1 second | 256 megabytes | ['greedy', 'math', 'strings', '*1600'] |
D. Super-Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation is a sequence n integers, where each integer from 1 to n appears exactly once. For example, [1], [3,5,2,1,4], [1,3,2] are permutations, while [2,3,2], [4,3,1], [0] are not.Given a perm... | 41236 | 1 2 1 -1 6 5 2 3 4 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', '*1200'] |
C. Bun Lovertime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTema loves cinnabon rolls — buns with cinnabon and chocolate in the shape of a "snail".Cinnabon rolls come in different sizes and are square when viewed from above. The most delicious part of a roll is the ... | 4456179179179 | 26 37 50 32105178545472401 | 3 seconds | 256 megabytes | ['math', '*800'] |
B. Karina and Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKarina has an array of n integers a_1, a_2, a_3, \dots, a_n. She loves multiplying numbers, so she decided that the beauty of a pair of numbers is their product. And the beauty of an array is the max... | 745 0 2 13-1 1 052 0 -1 -4 06-8 4 3 7 1 -960 3 -2 5 -4 -421000000000 9100000007-1 -7 -2 -5 -4 -6 -3 | 10 0 4 72 16 910000000000000000 42 | 2 seconds | 256 megabytes | ['greedy', 'math', 'sortings', '*800'] |
A. TubeTube Feedtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMushroom Filippov cooked himself a meal and while having his lunch, he decided to watch a video on TubeTube. He can not spend more than t seconds for lunch, so he asks you for help with the selection of ... | 55 91 5 7 6 63 4 7 1 94 44 3 3 21 2 3 45 75 5 5 5 52 1 3 9 74 3354 71 69 9642 24 99 12 17955 6677 88 | 3 2 3 -1 2 | 1 second | 256 megabytes | ['brute force', 'implementation', '*800'] |
F. Timbertime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a beautiful alley with trees in front of a shopping mall. Unfortunately, it has to go to make space for the parking lot.The trees on the alley all grow in a single line. There are n spots for trees, i... | 6 1 4
| 4 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'fft', 'math', '*2600'] |
E. Rearrange Bracketstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. Fo... | 70()0(())1(())5()1(()()(()))2((())()(()())((())))3((())()(()())((()))) | 0 1 0 0 1 4 2 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', 'sortings', 'strings', '*2100'] |
D. Black Cellstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing with a really long strip consisting of 10^{18} white cells, numbered from left to right as 0, 1, 2 and so on. You are controlling a special pointer that is initially in cell 0. Also, you h... | 42 31 31 44 2010 13 16 1911 14 17 202 31 31 102 499 999999999100 1000000000 | 8 -1 7 1000000004 | 4 seconds | 256 megabytes | ['binary search', 'brute force', 'greedy', 'math', '*1900'] |
C. Tear It Aparttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s, consisting of lowercase Latin letters.In one operation, you can select several (one or more) positions in it such that no two selected positions are adjacent to each other. The... | 5abacabacodeforcesooooooooabcdefmewheniseearulhiiarul | 1 3 0 2 4 | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'math', 'strings', '*1300'] |
B. Sort the Subarraytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMonocarp had an array a consisting of n integers. He has decided to choose two integers l and r such that 1 \le l \le r \le n, and then sort the subarray a[l..r] (the subarray a[l..r] is the part of... | 376 7 3 4 4 6 56 3 4 4 7 6 531 2 11 1 232 2 12 1 2 | 2 5 1 3 2 3 | 2 seconds | 512 megabytes | ['brute force', 'greedy', '*1100'] |
A. Matchingtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAn integer template is a string consisting of digits and/or question marks.A positive (strictly greater than 0) integer matches the integer template if it is possible to replace every question mark in the te... | 8???09031??7?5?9??99 | 90 9 0 1 0 100 90 100 | 2 seconds | 512 megabytes | ['combinatorics', 'math', '*800'] |
B. JoJo's Incredible Adventurestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDid you think there was going to be a JoJo legend here? But no, that was me, Dio!Given a binary string s of length n, consisting of characters 0 and 1. Let's build a square table of size n... | 501101011110101010 | 0 1 2 6 1 | 1 second | 256 megabytes | ['math', 'strings', 'two pointers', '*1100'] |
A. Yura's New Nametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter holding one team contest, boy Yura got very tired and wanted to change his life and move to Japan. In honor of such a change, Yura changed his name to something nice.Fascinated by this idea he al... | 7^______^___^_^^^_^___^^_^^_^^^^^_^_^^___^^_ | 5 5 1 1 0 3 2 | 1 second | 256 megabytes | ['implementation', 'strings', '*800'] |
F. Willy-nilly, Crack, Into Release!time limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou have long dreamed of working in a large IT company and finally got a job there. You have studied all existing modern technologies for a long time and are ready to apply all your... | 2 4
aa
ac
dd
ac
| 2 12 4 4 -1 12 12 | 3 seconds | 1024 megabytes | ['data structures', 'dp', '*3500'] |
E. Roads in E Citytime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.As is well known, the city "E" has never had its roads repaired in its a thousand and a half years old history. And only recently the city administration repaired some o... | 2
2 2
1 2
2 1
1
0
1
1
3 3
1 2
2 3
3 1
1
1
1
0
1
1
1
1 | - 1 ? 1 ? 2 - 2 + 1 ? 1 ! 1 0 - 1 ? 2 ? 1 - 2 ? 3 ? 3 + 1 ? 3 ? 2 ? 1 ! 1 1 1 | 3 seconds | 256 megabytes | ['interactive', 'math', 'probabilities', 'trees', '*3200'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.