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 |
|---|---|---|---|---|---|
B. Social Distancetime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputm chairs are arranged in a circle sequentially. The chairs are numbered from 0 to m-1. n people want to sit in these chairs. The i-th of them wants at least a[i] empty chairs both on his right and l... | 6
3 2
1 1 1
2 4
1 1
2 5
2 1
3 8
1 2 1
4 12
1 2 1 3
4 19
1 2 1 3
| NO YES NO YES NO YES | 1.5 seconds | 256 megabytes | ['greedy', 'math', 'sortings', '*900'] |
A. Direction Changetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a grid with n rows and m columns. Rows and columns are numbered from 1 to n, and from 1 to m. The intersection of the a-th row and b-th column is denoted by (a, b). Initially, you are st... | 6
1 1
2 1
1 3
4 2
4 6
10 5
| 0 1 -1 6 10 17 | 1 second | 256 megabytes | ['implementation', 'math', '*800'] |
F. Yin Yangtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangular grid with n rows and m columns. n and m are divisible by 4. Some of the cells are already colored black or white. It is guaranteed that no two colored cells share a corner or an e... | 4
8 8
.W.W....
.....B.W
.W.W....
.....W.W
B.B.....
....B.B.
B.W.....
....B.B.
8 8
B.W..B.W
........
W.B..W.B
........
........
B.W..B.W
........
W.B..W.B
8 12
W.B.........
....B...B.W.
B.B.........
....B...B.B.
.B..........
........B...
.W..B.B...W.
............
16 16
.W............W.
...W..W..W.W....
.B...........B.W
... | YES BWWWWWWW BWBBBBBW BWBWWWBW BWBWBWBW BWBWBWBW BWBBBWBW BWWWWWBW BBBBBBBW NO YES WWBBBBBBBBBB BWWWBBBBBBWB BBBWBBBWWWWB BBBWBBBWBBBB BBBWBBBWBBBB BBBWWWWWBBBB BWWWBBBWWWWB BBBBBBBBBBBB YES WWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWW WBBBBBBBBBBBBBWW WBBBWBWWWWBWWBWW WBBWWBBBWWBWWBWW WBWWWBWWWWBWWBWW WBBWWBBBWWBWWBWW WWBWWWWWWW... | 3 seconds | 256 megabytes | ['implementation', '*3500'] |
E. Centroid Probabilitiestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider every tree (connected undirected acyclic graph) with n vertices (n is odd, vertices numbered from 1 to n), and for each 2 \le i \le n the i-th vertex is adjacent to exactly one vertex ... | 3
| 1 1 0 | 3 seconds | 256 megabytes | ['combinatorics', 'dp', 'fft', 'math', '*3000'] |
D. Edge Eliminationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree (connected, undirected, acyclic graph) with n vertices. Two edges are adjacent if they share exactly one endpoint. In one move you can remove an arbitrary edge, if that edge is a... | 5
2
1 2
3
1 2
2 3
4
1 2
2 3
3 4
5
1 2
2 3
3 4
3 5
7
1 2
1 3
2 4
2 5
3 6
3 7
| YES 2 1 NO YES 2 3 3 4 2 1 YES 3 5 2 3 2 1 4 3 NO | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'dp', 'trees', '*2900'] |
C. Half Queen Covertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a board with n rows and n columns, numbered from 1 to n. The intersection of the a-th row and b-th column is denoted by (a, b).A half-queen attacks cells in the same row, same column, an... | 1
| 1 1 1 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*2400'] |
B. Optimal Partitiontime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers. You should divide a into continuous non-empty subarrays (there are 2^{n-1} ways to do that).Let s=a_l+a_{l+1}+\ldots+a_r. The value of a subarray a... | 5
3
1 2 -3
4
0 -2 3 -4
5
-1 -2 3 -1 -1
6
-1 2 -3 4 -5 6
7
1 -1 -1 1 -1 -1 1
| 1 2 1 6 -1 | 4 seconds | 256 megabytes | ['data structures', 'dp', '*2100'] |
A. Make it Increasingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n positive integers, and an array b, with length n. Initially b_i=0 for each 1 \leq i \leq n.In one move you can choose an integer i (1 \leq i \leq n), and ad... | 5
1 2 3 4 5
| 4 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'math', '*1300'] |
L. Labyrinthtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLeslie and Leon entered a labyrinth. The labyrinth consists of n halls and m one-way passages between them. The halls are numbered from 1 to n.Leslie and Leon start their journey in the hall s. Right away, ... | 5 5 1
1 2
2 3
1 4
4 3
3 5
| Possible 3 1 2 3 3 1 4 3 | 3 seconds | 512 megabytes | ['dfs and similar', 'graphs', '*1800'] |
K. Kingdom Partitiontime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe King is gone. After the King's rule, all the roads in the Kingdom are run down and need repair. Three of the King's children, Adrian, Beatrice and Cecilia, are dividing the Kingdom between thems... | 6 7
1 3
1 2 10
2 3 5
1 3 7
4 5 3
3 6 100
4 6 3
5 6 8
| 16 ABBCBA | 3 seconds | 512 megabytes | ['flows', '*3200'] |
J. Job Lookuptime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputJulia's n friends want to organize a startup in a new country they moved to. They assigned each other numbers from 1 to n according to the jobs they have, from the most front-end tasks to the most back-end... | 4
0 566 1 0
566 0 239 30
1 239 0 1
0 30 1 0
| 2 4 2 0 | 3 seconds | 512 megabytes | ['constructive algorithms', 'dp', 'shortest paths', 'trees', '*2100'] |
I. Interactive Treasure Hunttime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There is a grid of n\times m cells. Two treasure chests are buried in two different cells of the grid. Your task is to find both of them. You can make two type... | 1
2 3
1
1
3
0
1
| SCAN 1 2 DIG 1 2 SCAN 2 2 DIG 1 1 DIG 1 3 | 3 seconds | 512 megabytes | ['brute force', 'constructive algorithms', 'geometry', 'interactive', 'math', '*2200'] |
F. Fancy Stacktime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLittle Fiona has a collection of n blocks of various sizes a_1, a_2, \ldots, a_n, where n is even. Some of the blocks can be equal in size. She would like to put all these blocks one onto another to form ... | 241 2 3 481 1 2 3 4 4 6 7 | 2 4 | 3 seconds | 512 megabytes | ['combinatorics', 'dp', 'implementation', '*2200'] |
E. Even Splittime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA revolution has recently happened in Segmentland. The new government is committed to equality, and they hired you to help with land redistribution in the country.Segmentland is a segment of length l kilom... | 6 3
1 3 5
| 0 2 2 4 4 6 | 3 seconds | 512 megabytes | ['binary search', 'constructive algorithms', 'greedy', 'math', '*2500'] |
D. Deletive Editingtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDaisy loves playing games with words. Recently, she has been playing the following Deletive Editing word game with Daniel. Daisy picks a word, for example, "DETERMINED". On each game turn, Daniel cal... | 6DETERMINED TRMEDETERMINED TERMPSEUDOPSEUDOHYPOPARATHYROIDISM PEPADEINSTITUTIONALIZATION DONATIONCONTEST CODESOLUTION SOLUTION | YES NO NO YES NO YES | 3 seconds | 512 megabytes | ['greedy', '*900'] |
C. Connect the Pointstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given three points on a plane. You should choose some segments on the plane that are parallel to coordinate axes, so that all three points become connected. The total length of the chosen s... | 1 1
3 5
8 6
| 3 1 1 1 5 1 5 8 5 8 5 8 6 | 3 seconds | 512 megabytes | ['brute force', 'constructive algorithms', 'geometry', '*1800'] |
B. Budget Distributiontime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDistributing budgeted money with limited resources and many constraints is a hard problem. A budget plan consists of t topics; i-th topic consists of n_i items. For each topic, the optimal relativ... | 1 5
3 1 7 10 700 400 100
0 2 10 50 102
| 1.0555555555555556 0.8666666666666667 0.5476190476190478 0.12745098039215708 0.0 | 3 seconds | 512 megabytes | ['*3300'] |
A. Admissible Maptime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA map is a matrix consisting of symbols from the set of 'U', 'L', 'D', and 'R'.A map graph of a map matrix a is a directed graph with n \cdot m vertices numbered as (i, j) (1 \le i \le n; 1 \le j \le m... | RDUL
| 2 | 3 seconds | 512 megabytes | ['*3300'] |
E. MinimizORtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n non-negative integers, numbered from 1 to n.Let's define the cost of the array a as \displaystyle \min_{i \neq j} a_i | a_j, where | denotes the bitwise OR operation.There are ... | 256 1 3 2 141 22 32 42 540 2 1 107374182341 22 31 33 4 | 7 3 3 1 2 3 1 1073741823 | 3 seconds | 256 megabytes | ['bitmasks', 'brute force', 'data structures', 'divide and conquer', 'greedy', 'implementation', 'two pointers', '*2500'] |
D. GCD Guesstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There is a positive integer 1 \le x \le 10^9 that you have to guess.In one query you can choose two positive integers a \neq b. As an answer to this query you will get \gcd(x ... | 2
1
8
1
| ? 1 2 ? 12 4 ! 4 ? 2000000000 1999999999 ! 1000000000 | 3 seconds | 256 megabytes | ['bitmasks', 'chinese remainder theorem', 'constructive algorithms', 'games', 'interactive', 'math', 'number theory', '*2000'] |
C. Tree Infectiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent of a vertex v (different from root) is the previous to v vertex on the shortest path from the r... | 571 1 1 2 2 455 5 1 42133 161 1 1 1 1 | 4 4 2 3 4 | 1 second | 256 megabytes | ['binary search', 'greedy', 'sortings', 'trees', '*1600'] |
B. Array Cloning Techniquetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers. Initially there is only one copy of the given array.You can do operations of two types: Choose any array and clone it. After that there is one more copy... | 61178960 1 3 3 7 02-1000000000 100000000044 3 2 152 5 7 6 371 1 1 1 1 1 1 | 0 6 2 5 7 0 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*900'] |
A. GCD vs LCMtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer n. You have to find 4 positive integers a, b, c, d such that a + b + c + d = n, and \gcd(a, b) = \operatorname{lcm}(c, d).If there are several possible answers you can outp... | 5478910 | 1 1 1 1 2 2 2 1 2 2 2 2 2 4 2 1 3 5 1 1 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
F. In Every Generation...time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output In every generation there is a Chosen One. She alone will stand against the vampires, the demons, and the forces of darkness. She is the Slayer. — Joss Whedon InputA string s (3 \le |s| \le 7) ... | tourist
| ooggqjx | 1 second | 256 megabytes | ['*special problem', 'strings'] |
E. Are You Safe?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSeven boys and seven girls from Athens were brought before King Minos. The evil king laughed and said "I hope you enjoy your stay in Crete".With a loud clang, the doors behind them shut, and darkness rei... | 10
atzxcodera
mzhappyayc
mineodteri
trxesonaac
mtollexcxc
hjikeoutlc
eascripsni
rgvymnjcxm
onzazwswwg
geothermal
| YES | 1 second | 256 megabytes | ['*special problem', 'implementation'] |
B. Mike's Sequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou won't find this sequence on OEIS.InputOne integer r (-45 \le r \le 2999).OutputOne integer.ExampleInput
2999
Output
3000
| 2999
| 3000 | 1 second | 256 megabytes | ['*special problem', 'divide and conquer', 'implementation', 'math'] |
O. Circular Mazetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a circular maze such as the ones shown in the figures. Determine if it can be solved, i.e., if there is a path which goes from the center to the outside of the maze which does not touch... | 2
5
C 1 180 90
C 5 250 230
C 10 150 140
C 20 185 180
S 1 20 180
6
C 1 180 90
C 5 250 230
C 10 150 140
C 20 185 180
S 1 20 180
S 5 10 0
| YES NO | 2 seconds | 256 megabytes | ['brute force', 'dfs and similar', 'graphs', 'implementation'] |
N. Drone Phototime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputToday, like every year at SWERC, the n^2 contestants have gathered outside the venue to take a drone photo. Jennifer, the social media manager for the event, has arranged them into an n\times n square. Be... | 2
1 3
4 2
| 0 | 2 seconds | 512 megabytes | ['combinatorics', 'math', 'sortings'] |
M. Bottle Arrangementstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGabriella has been instructed to organize a renowned wine tasting event which will be attended by m critics. On display, there will be n different varieties of wine, each of which can either be a ... | 35 31 03 22 24 32 11 10 33 20 20 3 | RWRRW IMPOSSIBLE WWW | 2 seconds | 256 megabytes | ['constructive algorithms'] |
L. Il Derby della Madonninatime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe derby between Milan and Inter is happening soon, and you have been chosen as the assistant referee for the match, also known as linesman. Your task is to move along the touch-line, namely... | 3 2
5 10 15
7 17 29
| 2 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'math'] |
K. Pandemic Restrictionstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter a long time living abroad, you have decided to move back to Italy and have to find a place to live, but things are not so easy due to the ongoing global pandemic.Your three friends Fabio, ... | 0 0
5 0
3 3
| 5.0686143166 | 4 seconds | 256 megabytes | ['geometry', 'ternary search'] |
J. Training Camptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are organizing a training camp to teach algorithms to young kids. There are n^2 kids, organized in an n by n grid. Each kid is between 1 and n years old (inclusive) and any two kids who are in the s... | 3
1 2 3
3 1 2
2 3 1
1 0 0
0 0 1
0 0 0
| 1 | 2 seconds | 256 megabytes | ['flows', 'graphs'] |
I. Ice Cream Shoptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn a beach there are n huts in a perfect line, hut 1 being at the left and hut i+1 being 100 meters to the right of hut i, for all 1 \le i \le n - 1. In hut i there are p_i people.There are m ice cream... | 3 1
2 5 6
169
| 7 | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'sortings'] |
H. Boundarytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBethany would like to tile her bathroom. The bathroom has width w centimeters and length l centimeters. If Bethany simply used the basic tiles of size 1 \times 1 centimeters, she would use w \cdot l of them.... | 33 512 12314159265 358979323 | 3 1 2 3 3 1 2 11 2 1 2 | 2 seconds | 256 megabytes | ['brute force', 'math'] |
G. Gastronomic Eventtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSWERC organizers want to hold a gastronomic event.The location of the event is a building with n rooms connected by n-1 corridors (each corridor connects two rooms) so that it is possible to go from... | 5
1 2 2 2
| 13 | 2 seconds | 512 megabytes | ['dp', 'greedy', 'trees'] |
F. Antennastime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n equidistant antennas on a line, numbered from 1 to n. Each antenna has a power rating, the power of the i-th antenna is p_i. The i-th and the j-th antenna can communicate directly if and only if ... | 310 2 94 1 1 1 5 1 1 1 1 51 1 113 1 33 3 1 | 4 0 2 | 4 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'graphs', 'graphs', 'implementation', 'implementation', 'shortest paths', 'shortest paths'] |
E. Round Tabletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n people, numbered from 1 to n, sitting at a round table. Person i+1 is sitting to the right of person i (with person 1 sitting to the right of person n).You have come up with a better seating a... | 342 3 1 455 4 3 2 174 1 6 5 3 7 2 | 1 10 22 | 2 seconds | 256 megabytes | ['math'] |
D. Evolution of Weaselstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA wild basilisk just appeared at your doorstep. You are not entirely sure what a basilisk is and you wonder whether it evolved from your favorite animal, the weasel. How can you find out whether ... | 8ABBCCAAABBBBCCCCAAABABBCBCABCCBA | NO NO NO YES YES YES YES NO | 2 seconds | 256 megabytes | ['greedy', 'implementation', 'strings'] |
C. European Triptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe map of Europe can be represented by a set of n cities, numbered from 1 through n, which are connected by m bidirectional roads, each of which connects two distinct cities. A trip of length k is a se... | 4 5 2
4 1
2 3
3 1
4 3
2 4
| 0 | 2 seconds | 256 megabytes | ['dp', 'graphs', 'math', 'matrices'] |
B. Toystime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVittorio has three favorite toys: a teddy bear, an owl, and a raccoon. Each of them has a name. Vittorio takes several sheets of paper and writes a letter on each side of every sheet so that it is possible to sp... | AA
GA
MA
| 2 AG AM | 2 seconds | 256 megabytes | ['greedy', 'strings'] |
A. Organizing SWERCtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGianni, SWERC's chief judge, received a huge amount of high quality problems from the judges and now he has to choose a problem set for SWERC.He received n problems and he assigned a beauty score and... | 238 49 36 7123 1010 110 210 310 43 1010 510 610 710 810 91 10 | MOREPROBLEMS 93 | 2 seconds | 256 megabytes | ['brute force', 'implementation'] |
F. Teleporterstime limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n+1 teleporters on a straight line, located in points 0, a_1, a_2, a_3, ..., a_n. It's possible to teleport from point x to point y if there are teleporters in both of those points, and it costs... | 2
1 5
7
| 2 | 7 seconds | 512 megabytes | ['binary search', 'greedy', '*2600'] |
E. Narrow Componentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a matrix a, consisting of 3 rows and n columns. Each cell of the matrix is either free or taken.A free cell y is reachable from a free cell x if at least one of these conditions hold: ... | 12
100101011101
110110010110
010001011101
8
1 12
1 1
1 2
9 9
8 11
9 12
11 12
4 6
| 7 1 1 2 1 3 3 3 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'dp', 'dsu', 'math', 'trees', '*2500'] |
D. Progressions Coveringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays: an array a consisting of n zeros and an array b consisting of n integers.You can apply the following operation to the array a an arbitrary number of times: choose some ... | 3 3
5 4 6
| 5 | 2 seconds | 256 megabytes | ['data structures', 'greedy', '*1900'] |
C. Water the Treestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n trees in a park, numbered from 1 to n. The initial height of the i-th tree is h_i.You want to water these trees, so they all grow to the same height.The watering process goes as follows. Y... | 3
3
1 2 4
5
4 4 3 5 5
7
2 5 4 8 3 7 4
| 4 3 16 | 3 seconds | 256 megabytes | ['binary search', 'greedy', 'math', '*1700'] |
B. Getting Zerotime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you have an integer v. In one operation, you can: either set v = (v + 1) \bmod 32768 or set v = (2 \cdot v) \bmod 32768. You are given n integers a_1, a_2, \dots, a_n. What is the minimum numb... | 4
19 32764 10240 49
| 14 4 4 15 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dfs and similar', 'dp', 'graphs', 'greedy', 'shortest paths', '*1300'] |
A. Array Balancingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays of length n: a_1, a_2, \dots, a_n and b_1, b_2, \dots, b_n.You can perform the following operation any number of times: Choose integer index i (1 \le i \le n); Swap a_i and... | 3
4
3 3 10 10
10 10 3 3
5
1 2 3 4 5
6 7 8 9 10
6
72 101 108 108 111 44
10 87 111 114 108 100
| 0 8 218 | 2 seconds | 256 megabytes | ['greedy', 'math', '*800'] |
F2. Promising String (hard version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of Problem F. The only difference between the easy version and the hard version is the constraints.We will call a non-empty string balanced if it contains the... | 5
3
+-+
5
-+---
4
----
7
--+---+
6
+++---
| 2 4 2 7 4 | 2 seconds | 256 megabytes | ['data structures', 'implementation', 'math', 'strings', '*2100'] |
F1. Promising String (easy version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of Problem F. The only difference between the easy version and the hard version is the constraints.We will call a non-empty string balanced if it contains the... | 5
3
+-+
5
-+---
4
----
7
--+---+
6
+++---
| 2 4 2 7 4 | 3 seconds | 256 megabytes | ['brute force', 'implementation', 'math', 'strings', '*1700'] |
E. Matrix and Shiftstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary matrix A of size n \times n. Rows are numbered from top to bottom from 1 to n, columns are numbered from left to right from 1 to n. The element located at the intersection of ... | 4
3
010
011
100
5
00010
00001
10000
01000
00100
2
10
10
4
1111
1011
1111
1111
| 1 0 2 11 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'implementation', '*1600'] |
D. Maximum Product Strikes Backtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers. For each i (1 \le i \le n) the following inequality is true: -2 \le a_i \le 2.You can remove any number (possibly 0) of elements from th... | 5
4
1 2 -1 2
3
1 1 -2
5
2 0 -2 2 -1
3
-2 -1 -1
3
-1 -2 -2
| 0 2 3 0 2 0 0 1 1 0 | 2 seconds | 256 megabytes | ['brute force', 'implementation', 'math', 'two pointers', '*1600'] |
C. Get an Even Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA string a=a_1a_2\dots a_n is called even if it consists of a concatenation (joining) of strings of length 2 consisting of the same characters. In other words, a string a is even if two conditions a... | 6
aabbdabdccc
zyx
aaababbb
aabbcc
oaoaaaoo
bmefbmuyw
| 3 3 2 0 2 7 | 1 second | 256 megabytes | ['dp', 'greedy', 'strings', '*1300'] |
B. Vlad and Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNot so long ago, Vlad had a birthday, for which he was presented with a package of candies. There were n types of candies, there are a_i candies of the type i (1 \le i \le n).Vlad decided to eat exact... | 6
2
2 3
1
2
5
1 6 2 4 3
4
2 2 2 1
3
1 1000000000 999999999
1
1
| YES NO NO YES YES YES | 1 second | 256 megabytes | ['math', '*800'] |
A. Vasya and Coinstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVasya decided to go to the grocery store. He found in his wallet a coins of 1 burle and b coins of 2 burles. He does not yet know the total cost of all goods, so help him find out s (s > 0): the minimu... | 5
1 1
4 0
0 2
0 0
2314 2374
| 4 5 1 1 7063 | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
F. Tree and Permutation Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a tree of n vertices and a permutation p of size n. A token is present on vertex x of the tree.Alice and Bob are playing a game. Alice is in control of the permutation p, and Bob is ... | 3
6 3
1 3
3 2
4 3
3 6
5 3
2 1 3 6 4 5
3 2
1 2
3 2
1 3 2
3 2
1 2
3 2
1 2 3
| Alice Bob Alice | 1 second | 256 megabytes | ['dfs and similar', 'games', 'graphs', 'trees', '*3000'] |
E. AND-MEX Walktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an undirected, connected graph with n vertices and m weighted edges. A walk from vertex u to vertex v is defined as a sequence of vertices p_1,p_2,\ldots,p_k (which are not necessarily distinct)... | 6 7
1 2 1
2 3 3
3 1 5
4 5 2
5 6 4
6 4 6
3 4 1
3
1 5
1 2
5 3
| 2 0 1 | 3 seconds | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dfs and similar', 'dsu', 'graphs', '*2200'] |
D. Reverse Sort Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you had an array A of n elements, each of which is 0 or 1.Let us define a function f(k,A) which returns another array B, the result of sorting the first k elements of A in non-decreasing orde... | 5
4
2 4 2 4
7
0 3 4 2 3 2 7
3
0 0 0
4
0 0 0 4
3
1 2 3
| 1 1 0 1 0 1 1 0 0 0 1 0 0 0 0 0 0 1 1 0 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', 'implementation', 'math', 'two pointers', '*1900'] |
C. Line Empiretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are an ambitious king who wants to be the Emperor of The Reals. But to do that, you must first become Emperor of The Integers.Consider a number axis. The capital of your empire is initially at 0. There... | 4
5 2 7
3 5 12 13 21
5 6 3
1 5 6 21 30
2 9 3
10 15
11 27182 31415
16 18 33 98 874 989 4848 20458 34365 38117 72030
| 173 171 75 3298918744 | 1 second | 256 megabytes | ['binary search', 'brute force', 'dp', 'greedy', 'implementation', 'math', '*1500'] |
B. Bit Flippingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a binary string of length n. You have exactly k moves. In one move, you must select a single bit. The state of all bits except that bit will get flipped (0 becomes 1, 1 becomes 0). You need ... | 6
6 3
100001
6 4
100011
6 0
000000
6 1
111001
6 11
101100
6 12
001110
| 111110 1 0 0 2 0 0 111110 0 1 1 1 0 1 000000 0 0 0 0 0 0 100110 1 0 0 0 0 0 111111 1 2 1 3 0 4 111110 1 1 4 2 0 4 | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'greedy', 'strings', '*1300'] |
A. Red Versus Bluetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTeam Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of n matches.In the end, it turned out Team Red won r times and Team Blue won b tim... | 3
7 4 3
6 5 1
19 13 6
| RBRBRBR RRRBRR RRBRRBRRBRRBRRBRRBR | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'math', '*1000'] |
F. Juju and Binary Stringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe cuteness of a binary string is the number of \texttt{1}s divided by the length of the string. For example, the cuteness of \texttt{01101} is \frac{3}{5}.Juju has a binary string s of length ... | 4
4 2
0011
8 6
11000011
4 3
0101
5 5
11111
| 1 2 3 2 2 3 5 8 -1 1 1 5 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'greedy', 'math', '*2700'] |
E. Gojou and Matrix Gametime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMarin feels exhausted after a long day of cosplay, so Gojou invites her to play a game!Marin and Gojou take turns to place one of their tokens on an n \times n grid with Marin starting first. Th... | 3 1
1 2 4
6 8 3
9 5 7
| GGG MGG MGG | 4 seconds | 256 megabytes | ['data structures', 'dp', 'games', 'hashing', 'implementation', 'math', 'number theory', 'sortings', '*2500'] |
D2. 388535 (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference in the constraints between both versions are colored below in red. You can make hacks only if all versions of the problem are solved.Marin... | 3
4 7
3 2 1 0
4 7
4 7 6 5
1 3
0 2 1
| 4 0 3 | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'data structures', 'math', '*2300'] |
D1. 388535 (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference in the constraints between both versions is colored below in red. You can make hacks only if all versions of the problem are solved.Marin ... | 3
0 3
3 2 1 0
0 3
4 7 6 5
0 2
1 2 3
| 0 4 3 | 1 second | 256 megabytes | ['bitmasks', 'math', '*1600'] |
C. Shinju and the Lost Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputShinju loves permutations very much! Today, she has borrowed a permutation p from Juju to play with.The i-th cyclic shift of a permutation p is a transformation on the permutation such ... | 6
1
1
2
1 2
2
2 2
6
1 2 4 6 3 5
6
2 3 1 2 3 4
3
3 2 1
| YES YES NO NO YES NO | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1700'] |
B. Marin and Anti-coprime Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMarin wants you to count number of permutations that are beautiful. A beautiful permutation of length n is a permutation that has the following property: \gcd (1 \cdot p_1, \, 2 \cd... | 7
1
2
3
4
5
6
1000
| 0 1 0 4 0 36 665702330 | 1 second | 256 megabytes | ['combinatorics', 'math', 'number theory', '*800'] |
A. Marin and Photoshoottime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputToday, Marin is at a cosplay exhibition and is preparing for a group photoshoot!For the group picture, the cosplayers form a horizontal line. A group picture is considered beautiful if for every c... | 9
3
000
3
001
3
010
3
011
3
100
3
101
3
110
3
111
19
1010110000100000101
| 4 2 1 0 2 0 0 0 17 | 1 second | 256 megabytes | ['constructive algorithms', 'implementation', 'math', '*800'] |
F. Words on Treetime limit per test9 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices, and q triples (x_i, y_i, s_i), where x_i and y_i are integers from 1 to n, and s_i is a string with length equal to the number of vertices on the simple p... | 3 2
2 3
2 1
2 1 ab
2 3 bc
| YES abc | 9 seconds | 1024 megabytes | ['2-sat', 'dfs and similar', 'dsu', 'graphs', 'trees', '*2600'] |
E. Star MSTtime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn this problem, we will consider complete undirected graphs consisting of n vertices with weighted edges. The weight of each edge is an integer from 1 to k.An undirected graph is considered beautiful if the... | 3 2
| 5 | 6 seconds | 512 megabytes | ['combinatorics', 'dp', 'graph matchings', 'math', '*2200'] |
D. For Gamers. By Gamers.time limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMonocarp is playing a strategy game. In the game, he recruits a squad to fight monsters. Before each battle, Monocarp has C coins to spend on his squad.Before each battle starts, his squad is e... | 3 10
3 4 6
5 5 5
10 3 4
3
8 3
5 4
10 15
| 5 3 -1 | 4 seconds | 256 megabytes | ['binary search', 'brute force', 'greedy', 'math', 'sortings', '*2000'] |
C. Bracket Sequence Deletiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a bracket sequence consisting of n characters '(' and/or )'. You perform several operations with it.During one operation, you choose the shortest prefix of this string (some am... | 5
2
()
3
())
4
((((
5
)((()
6
)((()(
| 1 0 1 1 2 0 1 0 1 1 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1200'] |
B. XY Sequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given four integers n, B, x and y. You should build a sequence a_0, a_1, a_2, \dots, a_n where a_0 = 0 and for each i \ge 1 you can choose: either a_i = a_{i - 1} + x or a_i = a_{i - 1} - y. Yo... | 3
5 100 1 30
7 1000000000 1000000000 1000000000
4 1 7 3
| 15 4000000000 -10 | 2 seconds | 256 megabytes | ['greedy', '*800'] |
A. Integer Movestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere's a chip in the point (0, 0) of the coordinate plane. In one operation, you can move the chip from some point (x_1, y_1) to some point (x_2, y_2) if the Euclidean distance between these two points... | 3
8 6
0 0
9 15
| 1 0 2 | 2 seconds | 256 megabytes | ['brute force', 'math', '*800'] |
I. Neighbour Orderingtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an undirected graph G, we say that a neighbour ordering is an ordered list of all the neighbours of a vertex for each of the vertices of G. Consider a given neighbour ordering of G and three ... | 3
5 6
0 1
0 2
1 2
2 3
3 4
4 1
2 1
0 1
6 10
0 1
2 0
0 3
0 4
1 2
1 4
2 3
2 5
3 5
4 5
| YES 1 2 4 2 0 0 1 3 2 4 3 1 YES 1 0 NO | 5 seconds | 256 megabytes | ['constructive algorithms', 'graphs', '*3500'] |
H. Equal LCM Subsetstime limit per test10 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given two sets of positive integers A and B. You have to find two non-empty subsets S_A \subseteq A, S_B \subseteq B so that the least common multiple (LCM) of the elements of S_A is equal ... | 4
3 4
5 6 7
2 8 9 10
4 4
5 6 7 8
2 3 4 9
1 3
1
1 2 3
5 6
3 4 9 7 8
2 15 11 14 20 12
| NO YES 1 2 6 2 3 YES 1 1 1 1 YES 3 2 3 7 4 12 14 | 10 seconds | 512 megabytes | ['data structures', 'math', 'number theory', '*3200'] |
G. Cycle Palindrometime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe say that a sequence of n integers a_1, a_2, \ldots, a_n is a palindrome if for all 1 \leq i \leq n, a_i = a_{n-i+1}. You are given a sequence of n integers a_1, a_2, \ldots, a_n and you have to fin... | 3
4
1 2 2 1
3
1 2 1
7
1 3 3 3 1 2 2
| YES 3 1 4 2 NO YES 5 3 7 2 6 4 1 | 1 second | 256 megabytes | ['constructive algorithms', 'graphs', 'math', '*3200'] |
F. Parametric MSTtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a_1, a_2, \ldots, a_n. For any real number t, consider the complete weighted graph on n vertices K_n(t) with weight of the edge between vertices i and j equal to w_{ij}(t) = a_i... | 5
2
1 0
2
-1 1
3
1 -1 -2
3
3 -1 -2
4
1 2 3 -4
| INF -1 INF -6 -18 | 1 second | 256 megabytes | ['binary search', 'constructive algorithms', 'graphs', 'greedy', 'math', 'sortings', '*2600'] |
E. Equal Tree Sumstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected unrooted tree, i.e. a connected undirected graph without cycles.You must assign a nonzero integer weight to each vertex so that the following is satisfied: if any vertex of ... | 2
5
1 2
1 3
3 4
3 5
3
1 2
1 3
| -3 5 1 2 2 1 1 1 | 1 second | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'math', 'trees', '*2200'] |
D. K-goodtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe say that a positive integer n is k-good for some positive integer k if n can be expressed as a sum of k positive integers which give k distinct remainders when divided by k.Given a positive integer n, find ... | 5
2
4
6
15
20
| -1 -1 3 3 5 | 3 seconds | 256 megabytes | ['constructive algorithms', 'math', 'number theory', '*1900'] |
C. Make Equal With Modtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of n non-negative integers a_1, a_2, \ldots, a_n. You can make the following operation: choose an integer x \geq 2 and replace each number of the array by the remainder when... | 4
4
2 5 6 8
3
1 1 1
5
4 1 7 0 8
4
5 9 17 5
| YES YES NO YES | 2 seconds | 256 megabytes | ['constructive algorithms', 'math', 'number theory', 'sortings', '*1200'] |
B. Subtract Operationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a list of n integers. You can perform the following operation: you choose an element x from the list, erase x from the list, and subtract the value of x from all the remaining elements... | 4
4 5
4 2 2 7
5 4
1 9 1 3 4
2 17
17 0
2 17
18 18
| YES NO YES NO | 1 second | 256 megabytes | ['data structures', 'greedy', 'math', 'two pointers', '*1100'] |
A. Good Pairstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \ldots, a_n of positive integers. A good pair is a pair of indices (i, j) with 1 \leq i, j \leq n such that, for all 1 \leq k \leq n, the following equality holds: |a_i - a_... | 3
3
5 2 7
5
1 4 2 2 3
1
2
| 2 3 1 2 1 1 | 1 second | 256 megabytes | ['math', 'sortings', '*800'] |
H. Three Minimumstime limit per test8 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputGiven a list of distinct values, we denote with first minimum, second minimum, and third minimum the three smallest values (in increasing order).A permutation p_1, p_2, \dots, p_n is good if the follo... | 5 3
>>>
| 5 | 8 seconds | 1024 megabytes | ['combinatorics', 'constructive algorithms', 'divide and conquer', 'dp', 'fft', 'math', '*3500'] |
G. Snowy Mountaintime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThere are n locations on a snowy mountain range (numbered from 1 to n), connected by n-1 trails in the shape of a tree. Each trail has length 1. Some of the locations are base lodges. The height h_i o... | 6
1 1 0 0 0 0
1 3
2 4
3 4
4 5
5 6
| 0 0 1 1 3 5 | 5 seconds | 1024 megabytes | ['data structures', 'dfs and similar', 'graphs', 'greedy', 'shortest paths', 'trees', '*2900'] |
F. Minimal String Xorationtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an integer n and a string s consisting of 2^n lowercase letters of the English alphabet. The characters of the string s are s_0s_1s_2\cdots s_{2^n-1}.A string t of length 2^n (wh... | 2
acba
| abca | 3 seconds | 512 megabytes | ['bitmasks', 'data structures', 'divide and conquer', 'greedy', 'hashing', 'sortings', 'strings', '*2800'] |
E. Arithmetic Operationstime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou are given an array of integers a_1, a_2, \ldots, a_n.You can do the following operation any number of times (possibly zero): Choose any index i and set a_i to any integer (positive, negat... | 9
3 2 7 8 6 9 5 4 1
| 6 | 5 seconds | 1024 megabytes | ['brute force', 'data structures', 'graphs', 'math', '*2300'] |
D. Potion Brewing Classtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice's potion making professor gave the following assignment to his students: brew a potion using n ingredients, such that the proportion of ingredient i in the final potion is r_i > 0 (and r_1 ... | 3
4
3 2 3 4
1 2 4 3
1 4 2 4
8
5 4 2 3
6 4 5 4
1 3 5 2
6 8 2 1
3 5 3 4
3 2 2 5
6 7 4 3
17
8 7 4 16
9 17 4 5
5 14 13 12
11 1 17 14
6 13 8 9
2 11 3 11
4 17 7 2
17 16 8 6
15 5 1 14
16 7 1 10
12 17 13 10
11 16 7 2
10 11 6 4
13 17 14 6
3 11 15 8
15 6 12 8
| 69 359 573672453 | 3 seconds | 256 megabytes | ['dfs and similar', 'math', 'number theory', 'trees', '*2100'] |
C. Alice and the Caketime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice has a cake, and she is going to cut it. She will perform the following operation n-1 times: choose a piece of the cake (initially, the cake is all one piece) with weight w\ge 2 and cut it int... | 14
1
327
2
869 541
2
985214736 985214737
3
2 3 1
3
2 3 3
6
1 1 1 1 1 1
6
100 100 100 100 100 100
8
100 100 100 100 100 100 100 100
8
2 16 1 8 64 1 4 32
10
1 2 4 7 1 1 1 1 7 2
10
7 1 1 1 3 1 3 3 2 3
10
1 4 4 1 1 1 3 3 3 1
10
2 3 2 2 1 2 2 2 2 2
4
999999999 999999999 999999999 999999999
| YES NO YES YES NO YES NO YES YES YES YES NO NO YES | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'implementation', 'sortings', '*1400'] |
B. Prefix Removalstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of lowercase letters of the English alphabet. You must perform the following algorithm on s: Let x be the length of the longest prefix of s which occurs somewhere ... | 6
abcabdc
a
bbbbbbbbbb
codeforces
cffcfccffccfcffcfccfcffccffcfccf
zyzyzwxxyyxxyyzzyzzxxwzxwywxwzxxyzzw
| abdc a b deforces cf xyzzw | 2 seconds | 256 megabytes | ['strings', '*800'] |
A. Maximum Cake Tastinesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n pieces of cake on a line. The i-th piece of cake has weight a_i (1 \leq i \leq n).The tastiness of the cake is the maximum total weight of two adjacent pieces of cake (i. e., \max(a... | 5
6
5 2 1 4 7 3
3
32 78 78
3
69 54 91
8
999021 999021 999021 999021 999652 999021 999021 999021
2
1000000000 1000000000
| 12 156 160 1998673 2000000000 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', 'sortings', '*800'] |
F. Tower Defensetime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMonocarp is playing a tower defense game. A level in the game can be represented as an OX axis, where each lattice point from 1 to n contains a tower in it.The tower in the i-th point has c_i mana capac... | 3
5 1
7 4
4 2
4
0 14
1 10
3 16
10 16
| 4 | 4 seconds | 512 megabytes | ['binary search', 'brute force', 'data structures', '*3000'] |
E. Sum of Matchingstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLet's denote the size of the maximum matching in a graph G as \mathit{MM}(G).You are given a bipartite graph. The vertices of the first part are numbered from 1 to n, the vertices of the second part ... | 5
4 6
4 9
2 6
3 9
1 8
5 10
2 7
3 7
1 10
5 8
| 314 | 4 seconds | 512 megabytes | ['brute force', 'combinatorics', 'constructive algorithms', 'dfs and similar', 'graph matchings', 'greedy', 'math', '*2600'] |
D. Nearest Excluded Pointstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n distinct points on a plane. The coordinates of the i-th point are (x_i, y_i).For each point i, find the nearest (in terms of Manhattan distance) point with integer coordinates ... | 6
2 2
1 2
2 1
3 2
2 3
5 5
| 1 1 1 1 2 0 3 1 2 4 5 4 | 4 seconds | 256 megabytes | ['binary search', 'data structures', 'dfs and similar', 'graphs', 'shortest paths', '*1900'] |
C. Fault-tolerant Networktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a classroom with two rows of computers. There are n computers in each row and each computer has its own grade. Computers in the first row has grades a_1, a_2, \dots, a_n and in the sec... | 231 10 120 4 2541 1 1 11000000000 1000000000 1000000000 1000000000 | 31 1999999998 | 2 seconds | 256 megabytes | ['brute force', 'data structures', 'implementation', '*1500'] |
B. Prove Him Wrongtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, your friend discovered one special operation on an integer array a: Choose two indices i and j (i \neq j); Set a_i = a_j = |a_i - a_j|. After playing with this operation for a while, he c... | 3
2
512
3
| YES 1 337 NO YES 31 4 159 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*800'] |
A. Playofftime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputConsider a playoff tournament where 2^n athletes compete. The athletes are numbered from 1 to 2^n.The tournament is held in n stages. In each stage, the athletes are split into pairs in such a way that each a... | 2
3
1
| 7 1 | 2 seconds | 512 megabytes | ['implementation', '*800'] |
G. Counting Shortcutstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven an undirected connected graph with n vertices and m edges. The graph contains no loops (edges from a vertex to itself) and multiple edges (i.e. no more than one edge between each pair of vert... | 4
4 4
1 4
1 2
3 4
2 3
2 4
6 8
6 1
1 4
1 6
1 5
1 2
5 6
4 6
6 3
2 6
5 6
1 3
3 5
5 4
3 1
4 2
2 1
1 4
8 18
5 1
2 1
3 1
4 2
5 2
6 5
7 3
8 4
6 4
8 7
1 4
4 7
1 6
6 7
3 8
8 5
4 5
4 3
8 2
| 2 4 1 11 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'dp', 'graphs', 'shortest paths', '*2100'] |
F. Vitaly and Advanced Useless Algorithmstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVitaly enrolled in the course Advanced Useless Algorithms. The course consists of n tasks. Vitaly calculated that he has a_i hours to do the task i from the day he enrolled in t... | 5
3 5
5 7 8
1 1 30
2 3 50
2 3 100
1 1 80
3 3 100
1 5
51
1 36 91
1 8 40
1 42 83
1 3 45
1 13 40
2 9
9 20
2 8 64
2 7 64
1 20 56
2 8 76
2 20 48
1 2 89
1 3 38
2 18 66
1 7 51
3 2
7 18 33
1 5 80
3 4 37
2 5
569452312 703565975
1 928391659 66
1 915310 82
2 87017081 92
1 415310 54
2 567745964 82
| 4 1 4 3 5 3 2 4 5 4 6 7 1 2 -1 4 2 4 3 5 | 2 seconds | 256 megabytes | ['dp', 'greedy', 'implementation', '*2200'] |
E. Rescheduling the Examtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNow Dmitry has a session, and he has to pass n exams. The session starts on day 1 and lasts d days. The ith exam will take place on the day of a_i (1 \le a_i \le d), all a_i — are different. Sa... | 9
3 12
3 5 9
2 5
1 5
2 100
1 2
5 15
3 6 9 12 15
3 1000000000
1 400000000 500000000
2 10
3 4
2 2
1 2
4 15
6 11 12 13
2 20
17 20
| 2 1 1 2 99999999 3 0 1 9 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'greedy', 'implementation', 'math', 'sortings', '*1900'] |
D. Twist the Permutationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya got an array a of numbers from 1 to n, where a[i]=i.He performed n operations sequentially. In the end, he received a new state of the a array.At the i-th operation, Petya chose the first ... | 3
6
3 2 5 6 1 4
3
3 1 2
8
5 8 1 3 2 6 4 7
| 0 1 1 2 0 4 0 0 1 0 1 2 0 2 5 6 2 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', 'math', '*1300'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.