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. Monster Invaderstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputZiota found a video game called "Monster Invaders".Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns.For the sake of simplicity, we only cons... | 4 1 3 4 3
3 2 5 1
| 34 | 2 seconds | 512 megabytes | ['dp', 'greedy', 'implementation', '*2300'] |
B. Stoned Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputT is playing a game with his friend, HL.There are n piles of stones, the i-th pile initially has a_i stones. T and HL will take alternating turns, with T going first. In each turn, a player chooses a non-e... | 2
1
2
2
1 1
| T HL | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'games', 'greedy', '*1800'] |
A. Multiples of Lengthtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of n integers.You want to make all elements of a equal to zero by doing the following operation exactly three times: Select a segment, for each number in this segment we c... | 4
1 3 2 4
| 1 1 -1 3 4 4 2 2 4 -3 -6 -6 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'number theory', '*1600'] |
C. Boboniu and Bit Operationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBoboniu likes bit operations. He wants to play a game with you.Boboniu gives you two sequences of non-negative integers a_1,a_2,\ldots,a_n and b_1,b_2,\ldots,b_m.For each i (1\le i\le n), yo... | 4 2
2 6 4 0
2 4
| 2 | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'dp', 'greedy', '*1600'] |
B. Boboniu Plays Chesstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputBoboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.You are a new applicant for his company. Boboniu ... | 3 3 2 2
| 2 2 1 2 1 3 2 3 3 3 3 2 3 1 2 1 1 1 | 1 second | 512 megabytes | ['constructive algorithms', '*1100'] |
A. Boboniu Likes to Color Ballstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBoboniu gives you r red balls, g green balls, b blue balls, w white balls. He allows you to do the following operation as many times as you want: Pick a red ball, a green ball, and a... | 4
0 1 1 1
8 1 9 3
0 0 0 0
1000000000 1000000000 1000000000 1000000000
| No Yes Yes Yes | 1 second | 256 megabytes | ['brute force', 'math', '*1000'] |
E. Boboniu and Banknote Collectiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNo matter what trouble you're in, don't be afraid, but face it with a smile.I've made another billion dollars! — BoboniuBoboniu has issued his currencies, named Bobo Yuan. Bobo Yuan (BB... | 9
1 2 3 3 2 1 4 4 1
| 0 0 0 1 1 1 1 2 2 | 1 second | 256 megabytes | ['strings', '*3500'] |
D. Boboniu and Jianghutime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSince Boboniu finished building his Jianghu, he has been doing Kungfu on these mountains every day. Boboniu designs a map for his n mountains. He uses n-1 roads to connect all n mountains. Every pa... | 5
40 10 30 50 20
2 3 2 3 1
1 2
1 3
2 4
2 5
| 160 | 1 second | 256 megabytes | ['dp', 'greedy', 'sortings', 'trees', '*2800'] |
C. Boboniu and Stringtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBoboniu defines BN-string as a string s of characters 'B' and 'N'.You can perform the following operations on the BN-string s: Remove a character of s. Remove a substring "BN" or "NB" of s. Add ... | 3
B
N
BN
| 1 BN | 3 seconds | 256 megabytes | ['binary search', 'geometry', 'ternary search', '*2600'] |
B. Boboniu Walks on Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBoboniu has a directed graph with n vertices and m edges.The out-degree of each vertex is at most k.Each edge has an integer weight between 1 and m. No two edges have equal weights.Boboniu likes... | 4 6 3
4 2 1
1 2 2
2 4 3
4 1 4
4 3 5
3 1 6
| 2 | 1 second | 256 megabytes | ['brute force', 'dfs and similar', 'graphs', 'hashing', '*2300'] |
A. Boboniu Chats with Dutime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHave you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for days.In Boboniu's chat group, there's a person called Du Yi who likes to make fun of ... | 5 2 11
8 10 15 23 5
| 48 | 1 second | 256 megabytes | ['dp', 'greedy', 'sortings', 'two pointers', '*1800'] |
E2. Twilight and Ancient Scroll (harder version)time limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is a harder version of the problem E with larger constraints.Twilight Sparkle has received a new task from Princess Celestia. This time she asked to decipher the a... | 3
abcd
zaza
ataka
| 4 | 1.5 seconds | 256 megabytes | ['dp', 'hashing', 'implementation', 'string suffix structures', 'strings', 'two pointers', '*3200'] |
E1. Twilight and Ancient Scroll (easier version)time limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an easier version of the problem E with smaller constraints.Twilight Sparkle has received a new task from Princess Celestia. This time she asked to decipher the... | 3
abcd
zaza
ataka
| 4 | 1.5 seconds | 256 megabytes | ['dp', 'hashing', 'implementation', 'string suffix structures', 'strings', '*2800'] |
D. Rarity and New Dresstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCarousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of al... | 3 3
aaa
aaa
aaa
| 10 | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'implementation', 'shortest paths', '*2100'] |
C. Pinkie Pie Eats Patty-cakestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some pat... | 4
7
1 7 1 6 4 4 6
8
1 1 4 6 4 6 4 7
3
3 3 3
6
2 5 2 3 1 4
| 3 2 0 4 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', 'sortings', '*1700'] |
B. Applejack and Storagestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-z... | 6
1 1 1 2 1 1
6
+ 2
+ 1
- 1
+ 2
- 1
+ 2
| NO YES NO NO NO YES | 2 seconds | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', 'implementation', '*1400'] |
A. Rainbow Dash, Fluttershy and Chess Coloringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne evening Rainbow Dash and Fluttershy have come up with a game. Since the ponies are friends, they have decided not to compete in the game but to pursue a common goal. The... | 2
3
4
| 2 3 | 1 second | 256 megabytes | ['greedy', 'math', '*800'] |
I. Kevin and Gridtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs Kevin is in BigMan's house, suddenly a trap sends him onto a grid with n rows and m columns.BigMan's trap is configured by two arrays: an array a_1,a_2,\ldots,a_n and an array b_1,b_2,\ldots,b_m.In ... | 5 5 1
1 3 2 3 1
1 3 2 3 1
5
| -1 | 2 seconds | 256 megabytes | ['fft', 'graphs', 'math', '*3300'] |
H. ZS Shuffles Cardstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputzscoder has a deck of n+m custom-made cards, which consists of n cards labelled from 1 to n and m jokers. Since zscoder is lonely, he wants to play a game with himself using those cards. Initially, ... | 2 1
| 5 | 2 seconds | 512 megabytes | ['combinatorics', 'dp', 'math', 'probabilities', '*3000'] |
G. Omkar and Piestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar has a pie tray with k (2 \leq k \leq 20) spots. Each spot in the tray contains either a chocolate pie or a pumpkin pie. However, Omkar does not like the way that the pies are currently arranged, ... | 4 2 5
11000
00011
1 3
3 5
4 2
3 4
| 5 1 3 | 2 seconds | 256 megabytes | ['bitmasks', 'dfs and similar', 'dp', 'math', 'shortest paths', '*2900'] |
F. Omkar and Landslidetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar is standing at the foot of Celeste mountain. The summit is n meters away from him, and he can see all of the mountains up to the summit, so for all 1 \leq j \leq n he knows that the height o... | 4
2 6 7 8
| 5 5 6 7 | 2 seconds | 256 megabytes | ['binary search', 'constructive algorithms', 'data structures', 'greedy', 'math', '*2400'] |
E. Omkar and Ducktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Omkar has just come across a duck! The duck is walking on a grid with n rows and n columns (2 \leq n \leq 25) so that the grid contains a total of n^2 cells. Let's denote... | 4
3
23
26
27
| 1 2 3 6 4 6 2 10 9 0 7 3 2 8 8 2 1 1 1 2 1 3 2 3 2 4 3 4 4 4 1 1 2 1 3 1 3 2 3 3 3 4 4 4 1 1 1 2 1 3 1 4 2 4 3 4 4 4 | 2 seconds | 256 megabytes | ['bitmasks', 'constructive algorithms', 'interactive', 'math', '*2100'] |
D. Omkar and Bed Warstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar is playing his favorite pixelated video game, Bed Wars! In Bed Wars, there are n players arranged in a circle, so that for all j such that 2 \leq j \leq n, player j - 1 is to the left of the ... | 5
4
RLRL
6
LRRRRL
8
RLLRRRLL
12
LLLLRRLRRRLL
5
RRRRR
| 0 1 1 3 2 | 2 seconds | 256 megabytes | ['dp', 'greedy', '*1700'] |
C. Omkar and Waterslidetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar is building a waterslide in his water park, and he needs your help to ensure that he does it as efficiently as possible.Omkar currently has n supports arranged in a line, the i-th of which ... | 3
4
5 3 2 5
5
1 2 3 5 3
3
1 1 1
| 3 2 0 | 2 seconds | 256 megabytes | ['greedy', 'implementation', '*1200'] |
B. Omkar and Infinity Clocktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBeing stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve ... | 3
2 1
-199 192
5 19
5 -1 4 2 0
1 2
69
| 391 0 0 6 1 3 5 0 | 2 seconds | 256 megabytes | ['implementation', 'math', '*800'] |
A. Omkar and Passwordtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a password which you must interpret!A password is an array a of n positive integers. You app... | 2
4
2 1 3 1
2
420 420
| 1 2 | 2 seconds | 256 megabytes | ['greedy', 'math', '*800'] |
E. Pairs of Pairstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a simple and connected undirected graph consisting of n nodes and m edges.Consider any way to pair some subset of these n nodes such that no node is present in more than one pair. This pairing... | 4
6 5
1 4
2 5
3 6
1 5
3 5
6 5
1 4
2 5
3 6
1 5
3 5
12 14
1 2
2 3
3 4
4 1
1 5
1 12
2 6
2 7
3 8
3 9
4 10
4 11
2 4
1 3
12 14
1 2
2 3
3 4
4 1
1 5
1 12
2 6
2 7
3 8
3 9
4 10
4 11
2 4
1 3
| PATH 4 1 5 3 6 PAIRING 2 1 6 2 4 PAIRING 3 1 8 2 5 4 10 PAIRING 4 1 7 2 9 3 11 4 5 | 3 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', 'greedy', 'trees', '*2600'] |
D. 505time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA binary matrix is called good if every even length square sub-matrix has an odd number of ones. Given a binary matrix a consisting of n rows and m columns, determine the minimum number of cells you need to change... | 3 3
101
001
110
| 2 | 1 second | 256 megabytes | ['bitmasks', 'brute force', 'constructive algorithms', 'dp', 'greedy', 'implementation', '*2000'] |
C. Cyclic Permutations time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice... | 4
| 16 | 1 second | 256 megabytes | ['combinatorics', 'dp', 'graphs', 'math', '*1500'] |
B. Fix Youtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider a conveyor belt represented using a grid consisting of n rows and m columns. The cell in the i-th row from the top and the j-th column from the left is labelled (i,j). Every cell, except (n,m), has a ... | 4
3 3
RRD
DDR
RRC
1 4
DDDC
6 9
RDDDDDRRR
RRDDRRDDD
RRDRDRRDR
DDDDRDDRR
DRRDRDDDR
DDRDRRDDC
1 1
C
| 1 3 9 0 | 1 second | 256 megabytes | ['brute force', 'greedy', 'implementation', '*800'] |
A. Suborraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the arr... | 3
1
3
7
| 1 3 1 2 4 3 5 2 7 1 6 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*800'] |
G. Directing Edgestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an undirected connected graph consisting of n vertices and m edges. k vertices of this graph are special.You have to direct each edge of this graph or leave it undirected. If you leave t... | 3 2 2
1 3
11 1 5
10 10
1 2
2 3
| 11 2 5 | 4 seconds | 512 megabytes | ['dfs and similar', 'dp', 'graphs', 'trees', '*2800'] |
F. Bicolored Segmentstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n segments [l_1, r_1], [l_2, r_2], \dots, [l_n, r_n]. Each segment has one of two colors: the i-th segment's color is t_i.Let's call a pair of segments i and j bad if the following tw... | 3
1 3 1
4 6 2
2 5 1
| 2 | 2 seconds | 256 megabytes | ['data structures', 'dp', 'graph matchings', 'sortings', '*2600'] |
E. Calendar Ambiguitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland year consists of m months with d days each. Months are numbered from 1 to m. Berland week consists of w days. The first day of the year is also the first day of the week. Note that the last... | 5
6 7 4
10 7 12
12 30 7
1 1 1
3247834 10298779 625324
| 6 9 5 0 116461800 | 2 seconds | 256 megabytes | ['math', 'number theory', '*2200'] |
D. Segment Intersectionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two lists of segments [al_1, ar_1], [al_2, ar_2], \dots, [al_n, ar_n] and [bl_1, br_1], [bl_2, br_2], \dots, [bl_n, br_n].Initially, all segments [al_i, ar_i] are equal to [l_1, r_... | 3
3 5
1 2
3 4
2 1000000000
1 1
999999999 999999999
10 3
5 10
7 8
| 7 2000000000 0 | 2 seconds | 256 megabytes | ['brute force', 'greedy', 'implementation', 'math', '*2100'] |
C. Good Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call left cyclic shift of some string t_1 t_2 t_3 \dots t_{n - 1} t_n as string t_2 t_3 \dots t_{n - 1} t_n t_1.Analogically, let's call right cyclic shift of string t as string t_n t_1 t_2 t_3 \dot... | 3
95831
100120013
252525252525
| 3 5 0 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', 'two pointers', '*1500'] |
B. Array Walktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a_1, a_2, \dots, a_n, consisting of n positive integers. Initially you are standing at index 1 and have a score equal to a_1. You can perform two kinds of moves: move right — go fr... | 4
5 4 0
1 5 4 3 2
5 4 1
1 5 4 3 2
5 4 4
10 20 30 40 50
10 7 3
4 6 8 2 9 9 7 4 10 9
| 15 19 150 56 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', '*1600'] |
A. LCM Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet LCM(x, y) be the minimum positive integer that is divisible by both x and y. For example, LCM(13, 37) = 481, LCM(9, 6) = 18.You are given two integers l and r. Find two integers x and y such that l \l... | 4
1 1337
13 69
2 4
88 89
| 6 7 14 21 2 4 -1 -1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'math', 'number theory', '*800'] |
E. Uncle Bogdan and Projectionstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAfter returning to shore, uncle Bogdan usually visits the computer club "The Rock", to solve tasks in a pleasant company. One day, uncle Bogdan met his good old friend who told him one un... | 3
1 6 2
4 6 4
4 6 6
| 9.000000000 | 4 seconds | 512 megabytes | ['data structures', 'geometry', 'sortings', '*2700'] |
D. Captain Flint and Treasuretime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCaptain Fint is involved in another treasure hunt, but have found only one strange problem. The problem may be connected to the treasure's location or may not. That's why captain Flint deci... | 3
1 2 3
2 3 -1
| 10 1 2 3 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'graphs', 'greedy', 'implementation', 'trees', '*2000'] |
C. Uncle Bogdan and Country Happinesstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputUncle Bogdan is in captain Flint's crew for a long time and sometimes gets nostalgic for his homeland. Today he told you how his country introduced a happiness index.There are n cit... | 2
7 4
1 0 1 1 0 1 0
4 0 0 -1 0 -1 0
1 2
1 3
1 4
3 5
3 6
3 7
5 11
1 2 5 2 1
-11 -2 -6 -2 -1
1 2
1 3
1 4
3 5
| YES YES | 2 seconds | 256 megabytes | ['dfs and similar', 'greedy', 'math', 'trees', '*1800'] |
B. Captain Flint and a Long Voyagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCaptain Flint and his crew keep heading to a savage shore of Byteland for several months already, drinking rum and telling stories. In such moments uncle Bogdan often remembers his nep... | 2
1
3
| 8 998 | 2 seconds | 256 megabytes | ['greedy', 'math', '*1000'] |
A. Captain Flint and Crew Recruitmenttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDespite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peacefu... | 7
7
23
31
36
44
100
258
| NO NO YES 14 10 6 1 YES 5 6 10 15 YES 6 7 10 21 YES 2 10 33 55 YES 10 21 221 6 | 1 second | 256 megabytes | ['brute force', 'greedy', 'math', 'number theory', '*800'] |
C. Virusestime limit per test0.75 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Committee for Research on Binary Viruses discovered a method of replication for a large family of viruses whose genetic codes are sequences of zeros and ones. Each virus originates from a single gene; ... | 6 6 2
2 2 0 1
3 3 2 0 0
3 2 1 3
4 4 0 3 1 2
5 2 2 1
5 1 5
2 1 1
5 0 0 1 0 0
| NO 2 NO 4 NO 9 YES | 0.75 seconds | 256 megabytes | ['*special problem', 'dp', 'shortest paths', 'string suffix structures', '*2900'] |
B2. Village (Maximum)time limit per test0.75 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is split into two tasks. In this task, you are required to find the maximum possible answer. In the task Village (Minimum) you are required to find the minimum possible answer. Each... | 4
1 2
2 3
3 4
| 8 4 3 2 1 | 0.75 seconds | 256 megabytes | ['*special problem', 'dfs and similar', 'trees', '*2500'] |
B1. Village (Minimum)time limit per test0.75 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is split into two tasks. In this task, you are required to find the minimum possible answer. In the task Village (Maximum) you are required to find the maximum possible answer. Each... | 4
1 2
2 3
3 4
| 4 2 1 4 3 | 0.75 seconds | 256 megabytes | ['*special problem', 'dp', 'greedy', 'trees', '*2100'] |
A. Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an undirected graph where each edge has one of two colors: black or red.Your task is to assign a real number to each node so that: for each black edge the sum of values at its endpoints is 1; fo... | 4 4
1 2 1
2 3 2
1 3 2
3 4 1
| YES 0.5 0.5 1.5 -0.5 | 1 second | 256 megabytes | ['*special problem', 'binary search', 'dfs and similar', 'dp', 'math', 'ternary search', '*2100'] |
C. Jokertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJoker returns to Gotham City to execute another evil plan. In Gotham City, there are N street junctions (numbered from 1 to N) and M streets (numbered from 1 to M). Each street connects two distinct junctions, a... | 6 8 2
1 3
1 5
1 6
2 5
2 6
3 4
3 5
5 6
4 8
4 7
| NO YES | 1 second | 256 megabytes | ['*special problem', 'bitmasks', 'data structures', 'divide and conquer', 'dsu', '*2800'] |
B. Mixturetime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSerge, the chef of the famous restaurant "Salt, Pepper & Garlic" is trying to obtain his first Michelin star. He has been informed that a secret expert plans to visit his restaurant this evening.Even though... | 1 2 3
6
A 5 6 7
A 3 10 17
R 1
A 15 18 21
A 5 10 15
R 3
| 0 2 0 2 1 1 | 2.5 seconds | 256 megabytes | ['*special problem', 'data structures', 'geometry', 'math', 'sortings', '*2900'] |
A. Colorstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLinda likes to change her hair color from time to time, and would be pleased if her boyfriend Archie would notice the difference between the previous and the new color. Archie always comments on Linda's hair co... | 1
7
1
1
0
0
1
| ? 2 ? 7 ? 4 ? 1 ? 5 = 4 | 1 second | 256 megabytes | ['*special problem', 'binary search', 'constructive algorithms', 'interactive', '*2700'] |
G. Columns Swapstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a table a of size 2 \times n (i.e. two rows and n columns) consisting of integers from 1 to n.In one move, you can choose some column j (1 \le j \le n) and swap values a_{1, j} and a_{2, j... | 6
4
1 2 3 4
2 3 1 4
5
5 3 5 1 4
1 2 3 2 4
3
1 2 1
3 3 2
4
1 2 2 1
3 4 3 4
4
4 3 1 4
3 2 2 1
3
1 1 2
3 2 2
| 0 2 2 3 1 1 2 3 4 2 3 4 -1 | 2 seconds | 256 megabytes | ['2-sat', 'dfs and similar', 'dsu', 'graphs', 'implementation', '*2300'] |
F. Removing Leavestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree (connected graph without cycles) consisting of n vertices. The tree is unrooted — it is just a connected undirected graph without cycles.In one move, you can choose exactly k leav... | 4
8 3
1 2
1 5
7 6
6 8
3 1
6 4
6 1
10 3
1 2
1 10
2 3
1 5
1 6
2 4
7 10
10 9
8 10
7 2
3 1
4 5
3 6
7 4
1 2
1 4
5 1
1 2
2 3
4 3
5 3
| 2 3 3 4 | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'implementation', 'trees', '*2300'] |
E. Directing Edgestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a graph consisting of n vertices and m edges. It is not guaranteed that the given graph is connected. Some edges are already directed and you can't change their direction. Other edges ar... | 43 10 1 35 50 2 11 1 51 5 40 5 21 3 54 51 1 20 4 31 3 10 2 31 2 44 51 4 11 1 30 1 21 2 41 3 2 | YES 3 1 YES 2 1 1 5 5 4 2 5 3 5 YES 1 2 3 4 3 1 3 2 2 4 NO | 3 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'graphs', '*2000'] |
D. a-Good Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s[1 \dots n] consisting of lowercase Latin letters. It is guaranteed that n = 2^k for some integer k \ge 0.The string s[1 \dots n] is called c-good if at least one of the followin... | 6
8
bbdcaaaa
8
asdfghjk
8
ceaaaabb
8
bbaaddcc
1
z
2
ac
| 0 7 4 5 1 1 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'divide and conquer', 'dp', 'implementation', '*1500'] |
C. Make It Goodtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers. You have to find the length of the smallest (shortest) prefix of elements you need to erase from a to make it a good array. Recall that the prefix of the... | 5
4
1 2 3 4
7
4 3 3 8 4 5 2
3
1 1 1
7
1 3 1 4 5 3 2
5
5 4 3 2 3
| 0 4 0 2 3 | 1 second | 256 megabytes | ['greedy', '*1200'] |
B. Restore the Permutation by Mergertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1,... | 5
2
1 1 2 2
4
1 3 1 4 3 4 2 2
5
1 2 1 2 3 4 3 5 4 5
3
1 2 3 1 2 3
4
2 3 2 4 1 3 4 1
| 1 2 1 3 4 2 1 2 3 4 5 1 2 3 2 3 4 1 | 1 second | 256 megabytes | ['greedy', '*800'] |
A. Three Pairwise Maximumstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three positive (i.e. strictly greater than zero) integers x, y and z.Your task is to find positive integers a, b and c such that x = \max(a, b), y = \max(a, c) and z = \max(b, c),... | 5
3 2 3
100 100 100
50 49 49
10 30 20
1 1000000000 1000000000
| YES 3 2 1 YES 100 100 100 NO NO YES 1 1 1000000000 | 1 second | 256 megabytes | ['math', '*800'] |
B2. Koa and the Beach (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is on constraints. In this version constraints are higher. You can make hacks only if all versions of the problem are solved.Koa the... | 7
2 1 1
1 0
5 2 3
1 2 3 2 2
4 3 4
0 2 4 3
2 3 5
3 0
7 2 3
3 0 2 1 3 0 1
7 1 4
4 4 3 0 2 4 2
5 2 3
1 2 3 2 2
| Yes No Yes Yes Yes No No | 1 second | 256 megabytes | ['constructive algorithms', 'dp', 'greedy', 'implementation', '*2200'] |
B1. Koa and the Beach (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between easy and hard versions is on constraints. In this version constraints are lower. You can make hacks only if all versions of the problem are solved.Koa the ... | 7
2 1 1
1 0
5 2 3
1 2 3 2 2
4 3 4
0 2 4 3
2 3 5
3 0
7 2 3
3 0 2 1 3 0 1
7 1 4
4 4 3 0 2 4 2
5 2 3
1 2 3 2 2
| Yes No Yes Yes Yes No No | 1 second | 256 megabytes | ['brute force', 'dp', 'greedy', '*1900'] |
A. Common Prefixestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe length of the longest common prefix of two strings s = s_1 s_2 \ldots s_n and t = t_1 t_2 \ldots t_m is defined as the maximum integer k (0 \le k \le min(n,m)) such that s_1 s_2 \ldots s_k equals t... | 4
4
1 2 4 2
2
5 3
3
1 3 1
3
0 0 0
| aeren ari arousal around ari monogon monogamy monthly kevinvu kuroni kurioni korone anton loves adhoc problems | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', 'strings', '*1200'] |
F. Special Edgestime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKoa the Koala has a directed graph G with n nodes and m edges. Each edge has a capacity associated with it. Exactly k edges of the graph, numbered from 1 to k, are special, such edges initially have a c... | 2 1 1 3
1 2 0
0
1
2
| 0 1 2 | 5 seconds | 256 megabytes | ['flows', 'graphs', '*3200'] |
E. Strange Operationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKoa the Koala has a binary string s of length n. Koa can perform no more than n-1 (possibly zero) operations of the following form:In one operation Koa selects positions i and i+1 for some i with 1 \... | 000
| 3 | 1 second | 256 megabytes | ['combinatorics', 'data structures', 'dp', '*2800'] |
D. Rearrangetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKoa the Koala has a matrix A of n rows and m columns. Elements of this matrix are distinct integers from 1 to n \cdot m (each number from 1 to n \cdot m appears exactly once in the matrix).For any matrix M o... | 3 3
3 5 6
1 7 9
4 8 2
| 9 5 1 7 8 2 3 6 4 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'graphs', 'greedy', 'sortings', '*2800'] |
C. String Transformation 2time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNote that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects can be any letter from the first 20 ... | 5
3
aab
bcc
4
cabc
abcb
3
abc
tsr
4
aabd
cccd
5
abcbd
bcdda
| 2 3 3 2 4 | 3 seconds | 256 megabytes | ['bitmasks', 'dp', 'graphs', 'trees', '*3100'] |
B. GameGametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKoa the Koala and her best friend want to play a game.The game starts with an array a of length n consisting of non-negative integers. Koa and her best friend move in turns and each have initially a score equ... | 3
3
1 2 2
3
2 2 3
5
0 0 0 2 2
| WIN LOSE DRAW | 1 second | 256 megabytes | ['bitmasks', 'constructive algorithms', 'dp', 'games', 'greedy', 'math', '*1900'] |
A. String Transformation 1time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNote that the only difference between String Transformation 1 and String Transformation 2 is in the move Koa does. In this version the letter y Koa selects must be strictly greater alphabetical... | 5
3
aab
bcc
4
cabc
abcb
3
abc
tsr
4
aabd
cccd
5
abcbd
bcdda
| 2 -1 3 2 -1 | 1 second | 256 megabytes | ['dsu', 'graphs', 'greedy', 'sortings', 'strings', 'trees', 'two pointers', '*1700'] |
B. Sequential Nimtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n piles of stones, where the i-th pile has a_i stones. Two people play a game, where they take alternating turns removing stones.In a move, a player may remove a positive number of stones from... | 7
3
2 5 4
8
1 1 1 1 1 1 1 1
6
1 2 3 4 5 6
6
1 1 2 1 2 2
1
1000000000
5
1 2 2 1 1
3
1 1 1
| First Second Second First First Second First | 1 second | 256 megabytes | ['dp', 'games', '*1100'] |
A. Common Subsequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays of integers a_1,\ldots,a_n and b_1,\ldots,b_m.Your task is to find a non-empty array c_1,\ldots,c_k that is a subsequence of a_1,\ldots,a_n, and also a subsequence of b_1,\l... | 5
4 5
10 8 6 4
1 2 3 4 5
1 1
3
3
1 1
3
2
5 3
1000 2 2 2 3
3 1 5
5 5
1 2 3 4 5
1 2 3 4 5
| YES 1 4 YES 1 3 NO YES 1 3 YES 1 2 | 1 second | 256 megabytes | ['brute force', '*800'] |
E. Origamitime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter being discouraged by 13 time-limit-exceeded verdicts on an ugly geometry problem, you decided to take a relaxing break for arts and crafts.There is a piece of paper in the shape of a simple polygon with... | 4 7
0 10
10 0
0 -10
-10 0
-9
-5
-1
0
1
5
9
| 199.0000000000 175.0000000000 119.0000000000 100.0000000000 119.0000000000 175.0000000000 199.0000000000 | 4 seconds | 256 megabytes | ['geometry', 'math', 'sortings', '*3300'] |
D. The Majestic Brown Tree Snaketime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The ... | 4
8 4 7
1 2
2 3
1 4
4 5
4 6
1 7
7 8
4 3 2
4 3
1 2
2 3
9 3 5
1 2
2 3
3 4
1 5
5 6
6 7
1 8
8 9
16 15 12
1 2
2 3
1 4
4 5
5 6
6 7
4 8
8 9
8 10
10 11
11 12
11 13
13 14
10 15
15 16
| YES NO NO YES | 1 second | 256 megabytes | ['dfs and similar', 'dp', 'greedy', 'trees', 'two pointers', '*3000'] |
C. Mastermindtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn the game of Mastermind, there are two players — Alice and Bob. Alice has a secret code, which Bob tries to guess. Here, a code is defined as a sequence of n colors. There are exactly n+1 colors in the e... | 7
5 2 4
3 1 1 2 5
5 3 4
1 1 2 1 2
4 0 4
5 5 3 3
4 1 4
2 3 2 3
6 1 2
3 2 1 1 1 1
6 2 4
3 3 2 1 1 1
6 2 6
1 1 3 2 1 1
| YES 3 1 6 1 2 YES 3 1 1 1 2 YES 3 3 5 5 NO YES 4 4 4 4 3 1 YES 3 1 3 1 7 7 YES 2 3 1 1 1 1 | 1 second | 256 megabytes | ['constructive algorithms', 'graph matchings', 'greedy', 'implementation', 'sortings', 'two pointers', '*2500'] |
B. Unmergetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet a and b be two arrays of lengths n and m, respectively, with no elements in common. We can define a new array \mathrm{merge}(a,b) of length n+m recursively as follows: If one of the arrays is empty, the r... | 6
2
2 3 1 4
2
3 1 2 4
4
3 2 6 1 5 7 8 4
3
1 2 3 4 5 6
4
6 1 3 7 4 5 8 2
6
4 3 2 5 1 11 9 12 8 6 10 7
| YES NO YES YES NO NO | 1 second | 256 megabytes | ['dp', '*1800'] |
A2. Prefix Flip (Hard Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the hard version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the pro... | 5
2
01
10
5
01011
11100
2
01
01
10
0110011011
1000110100
1
0
1
| 3 1 2 1 6 5 2 5 3 1 2 0 9 4 1 2 10 4 1 2 1 5 1 1 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'implementation', 'strings', 'two pointers', '*1700'] |
A1. Prefix Flip (Easy Version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is the easy version of the problem. The difference between the versions is the constraint on n and the required number of operations. You can make hacks only if all versions of the pro... | 5
2
01
10
5
01011
11100
2
01
01
10
0110011011
1000110100
1
0
1
| 3 1 2 1 6 5 2 5 3 1 2 0 9 4 1 2 10 4 1 2 1 5 1 1 | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'strings', '*1300'] |
G. Circular Dungeontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are creating a level for a video game. The level consists of n rooms placed in a circle. The rooms are numbered 1 through n. Each room contains exactly one exit: completing the j-th room allows y... | 2
1 2
| 499122177 0 | 2 seconds | 256 megabytes | ['greedy', 'math', 'probabilities', '*2600'] |
F. Strange Additiontime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet a and b be some non-negative integers. Let's define strange addition of a and b as following: write down the numbers one under another and align them by their least significant digit; add them ... | 2 3
14
2 4
2 1
1 0
| 15 12 2 | 5 seconds | 256 megabytes | ['data structures', 'dp', 'matrices', '*2600'] |
E. Merging Towerstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have a set of n discs, the i-th disc has radius i. Initially, these discs are split among m towers: each tower contains at least one disc, and the discs in each tower are sorted in descending order... | 7 4
1 2 3 3 1 4 3
3 1
2 3
2 4
| 5 4 2 0 | 2 seconds | 512 megabytes | ['data structures', 'dsu', 'implementation', 'trees', '*2300'] |
D. Berserk And Fireballtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n warriors in a row. The power of the i-th warrior is a_i. All powers are pairwise distinct.You have two types of spells which you may cast: Fireball: you spend x mana and destroy exa... | 5 2
5 2 3
3 1 4 5 2
3 5
| 8 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'implementation', 'math', 'two pointers', '*2000'] |
C. Create The Teamstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n programmers that you want to split into several non-empty teams. The skill of the i-th programmer is a_i. You want to assemble the maximum number of teams from them. There is a restrictio... | 3
5 10
7 11 2 9 5
4 8
2 4 2 3
4 11
1 3 3 7
| 2 1 0 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'greedy', 'implementation', 'sortings', '*1400'] |
B. Universal Solutiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string s = s_1 s_2 \dots s_{n} of length n where each letter is ... | 3
RRRR
RSP
S
| PPPP RSP R | 2 seconds | 256 megabytes | ['greedy', '*1400'] |
A. Three Indicestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation p_1, p_2, \dots, p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.Find three indices i, j and k such that:... | 3
4
2 1 4 3
6
4 6 1 2 5 3
5
5 3 1 2 4
| YES 2 3 4 YES 3 5 6 NO | 2 seconds | 256 megabytes | ['brute force', 'data structures', '*900'] |
F2. Chess Strikes Back (hard version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNote that the difference between easy and hard versions is that in hard version unavailable cells can become available again and in easy version can't. You can make hacks only if al... | 1 3 3
1 1
1 5
2 4
| YES YES NO | 2 seconds | 512 megabytes | ['data structures', 'divide and conquer', '*2800'] |
F1. Chess Strikes Back (easy version)time limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNote that the difference between easy and hard versions is that in hard version unavailable cells can become available again and in easy version can't. You can make hacks only if al... | 1 3 3
1 1
1 5
2 4
| YES YES NO | 2 seconds | 512 megabytes | ['binary search', 'data structures', '*2700'] |
E. Inverse Genealogytime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputIvan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Addi... | 3 0
| YES 0 1 1 | 1 second | 512 megabytes | ['constructive algorithms', 'divide and conquer', 'dp', 'math', 'trees', '*2800'] |
D. New Passenger Tramstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are many freight trains departing from Kirnes planet every day. One day on that planet consists of h hours, and each hour consists of m minutes, where m is an even number. Currently, there a... | 2 24 60 15
16 0
17 15
| 0 0 | 2 seconds | 512 megabytes | ['binary search', 'brute force', 'data structures', 'sortings', 'two pointers', '*2300'] |
C. Choosing flowerstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputVladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly n flowers.Vladimir went to a flower shop, and he was amazed to see that there are m types... | 2
4 3
5 0
1 4
2 2
5 3
5 2
4 2
3 1
| 14 16 | 1 second | 512 megabytes | ['binary search', 'brute force', 'data structures', 'dfs and similar', 'dp', 'greedy', 'sortings', 'two pointers', '*2000'] |
B. Dubious Cyrptotime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputPasha loves to send strictly positive integers to his friends. Pasha cares about security, therefore when he wants to send an integer n, he encrypts it in the following way: he picks three integers a, b... | 2
4 6 13
2 3 1
| 4 6 5 2 2 3 | 1 second | 512 megabytes | ['binary search', 'brute force', 'math', 'number theory', '*1500'] |
A. Acacius and Stringtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputAcacius is studying strings theory. Today he came with the following problem.You are given a string s of length n consisting of lowercase English letters and question marks. It is possible to replac... | 6
7
abacaba
7
???????
11
aba?abacaba
11
abacaba?aba
15
asdf???f???qwer
11
abacabacaba
| Yes abacaba Yes abacaba Yes abadabacaba Yes abacabadaba No No | 1 second | 512 megabytes | ['brute force', 'implementation', 'strings', '*1500'] |
I. Cubic Latticetime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA cubic lattice L in 3-dimensional euclidean space is a set of points defined in the following way: L=\{u \cdot \vec r_1 + v \cdot \vec r_2 + w \cdot \vec r_3\}_{u, v, w \in \mathbb Z} Where \vec r_1, \... | 2
1 2 3
1 2 1
| 1 1 0 0 0 1 0 0 0 1 | 4 seconds | 256 megabytes | ['geometry', 'math', 'matrices', 'number theory', '*3500'] |
H. Set Mergingtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a permutation a_1, a_2, \dots, a_n of numbers from 1 to n. Also, you have n sets S_1,S_2,\dots, S_n, where S_i=\{a_i\}. Lastly, you have a variable cnt, representing the current number of se... | 3 2
1 3 2
2 3
1 3
| 6 3 2 1 3 5 2 4 6 | 4 seconds | 256 megabytes | ['constructive algorithms', 'divide and conquer', '*3300'] |
G. Tree Modificationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation: Choose three vertices a, b, and c such that b is adjacent to bot... | 6
4 5
2 6
3 2
1 2
2 4
| 1 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'dfs and similar', 'graph matchings', 'graphs', 'trees', '*2800'] |
F. Integer Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Anton and Harris are playing a game to decide which of them is the king of problemsetting.There are three piles of stones, initially containing a, b, and c stones, where a, ... | 5 2 6
3
0 | First 2 3 | 1 second | 256 megabytes | ['constructive algorithms', 'games', 'interactive', 'math', '*2600'] |
E. Inversion SwapSorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMadeline has an array a of n integers. A pair (u, v) of integers forms an inversion in a if: 1 \le u < v \le n. a_u > a_v. Madeline recently found a magical paper, which allows her to write two i... | 3
3 1 2
| 2 1 3 1 2 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', 'sortings', '*2500'] |
D. Replace by MEXtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're given an array of n integers between 0 and n inclusive.In one operation, you can choose any element of the array and replace it by the MEX of the elements of the array (which may change after the... | 5
3
2 2 3
3
2 1 0
7
0 7 3 1 3 7 7
9
2 0 1 1 2 4 4 2 0
9
8 4 7 6 1 2 3 0 5
| 0 2 3 1 4 2 5 5 4 11 3 8 9 7 8 5 9 6 4 1 2 10 1 8 1 9 5 2 4 6 3 7 | 1 second | 256 megabytes | ['brute force', 'constructive algorithms', 'sortings', '*1900'] |
C. Element Exterminationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n, which initially is a permutation of numbers from 1 to n. In one operation, you can choose an index i (1 \leq i < n) such that a_i < a_{i + 1}, and remove eit... | 4
3
1 2 3
4
3 1 2 4
3
2 3 1
6
2 4 6 1 3 5
| YES YES NO YES | 1 second | 256 megabytes | ['constructive algorithms', 'data structures', 'greedy', '*1400'] |
B. Neighbor Gridtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a grid with n rows and m columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number k > 0 ... | 5
3 4
0 0 0 0
0 1 0 0
0 0 0 0
2 2
3 0
0 0
2 2
0 0
0 0
2 3
0 0 0
0 4 0
4 4
0 0 0 0
0 2 0 1
0 0 0 0
0 0 0 0
| YES 0 0 0 0 0 1 1 0 0 0 0 0 NO YES 0 0 0 0 NO YES 0 1 0 0 1 4 2 1 0 2 0 0 1 3 1 0 | 1 second | 256 megabytes | ['constructive algorithms', 'greedy', '*1200'] |
A. Sign Flippingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers a_1, a_2, \dots, a_n, where n is odd. You are allowed to flip the sign of some (possibly all or none) of them. You wish to perform these flips in such a way that the following co... | 5
3
-2 4 3
5
1 1 1 1 1
5
-2 4 7 -6 4
9
9 7 -4 -2 1 -3 9 -4 -5
9
-4 1 9 4 8 9 5 1 -9
| -2 -4 3 1 1 1 1 1 -2 -4 7 -6 4 -9 -7 -4 2 1 -3 -9 -4 -5 4 -1 -9 -4 -8 -9 -5 -1 9 | 1 second | 256 megabytes | ['constructive algorithms', 'math', '*1100'] |
F. Cyclic Shifts Sortingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers.In one move, you can choose some index i (1 \le i \le n - 2) and shift the segment [a_i, a_{i + 1}, a_{i + 2}] cyclically to the right (i.e. rep... | 5
5
1 2 3 4 5
5
5 4 3 2 1
8
8 4 5 2 3 6 7 3
7
5 2 1 6 4 7 3
6
1 2 3 3 6 4
| 0 6 3 1 3 2 2 3 13 2 1 1 6 4 2 4 3 3 4 4 6 6 -1 4 3 3 4 4 | 2 seconds | 256 megabytes | ['brute force', 'constructive algorithms', 'implementation', 'sortings', '*2400'] |
E2. Reading Books (hard version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEasy and hard versions are actually different problems, so read statements of both problems completely and carefully.Summer vacation has started so Alice and Bob want to play and joy, bu... | Input6 3 16 0 011 1 09 0 121 1 110 1 08 0 1 | Output246 5 1 | 3 seconds | 256 megabytes | ['data structures', 'greedy', 'implementation', 'sortings', 'ternary search', 'two pointers', '*2500'] |
E1. Reading Books (easy version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEasy and hard versions are actually different problems, so read statements of both problems completely and carefully.Summer vacation has started so Alice and Bob want to play and joy, bu... | Input8 47 1 12 1 14 0 18 1 11 0 11 1 11 0 13 0 0 | Output18 | 2 seconds | 256 megabytes | ['data structures', 'greedy', 'sortings', '*1600'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.