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
F. Squarestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n squares drawn from left to right on the floor. The i-th square has three integers p_i,a_i,b_i, written on it. The sequence p_1,p_2,\dots,p_n forms a permutation.Each round you will start from the ...
3 2 2 1 3 10 -5 4 3 -2 3 1 2
6 8
2 seconds
256 megabytes
['constructive algorithms', 'data structures', 'dp', 'graphs', 'trees', '*3300']
E. Qingshan and Danieltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputQingshan and Daniel are going to play a card game. But it will be so boring if only two persons play this. So they will make n robots in total to play this game automatically. Robots made by Qings...
3 3 1 5 2 3 2 7 1 2 3 2 1 1
100
2 seconds
256 megabytes
['brute force', 'data structures', 'greedy', 'implementation', '*3200']
D. BFS Treestime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWe define a spanning tree of a graph to be a BFS tree rooted at vertex s if and only if for every node t the shortest distance between s and t in the graph is equal to the shortest distance between s and ...
4 4 1 2 2 3 3 4 1 4
2 1 0 1 1 2 1 0 0 1 2 1 1 0 1 2
2.5 seconds
512 megabytes
['combinatorics', 'dfs and similar', 'graphs', 'math', 'shortest paths', 'trees', '*2600']
C. Garden of the Suntime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are many sunflowers in the Garden of the Sun.Garden of the Sun is a rectangular table with n rows and m columns, where the cells of the table are farmlands. All of the cells grow a sunflower on...
5 3 3 X.X ... X.X 4 4 .... .X.X .... .X.X 5 5 .X... ....X .X... ..... X.X.X 1 10 ....X.X.X. 2 2 .. ..
XXX ..X XXX XXXX .X.X .X.. .XXX .X... .XXXX .X... .X... XXXXX XXXXXXXXXX .. ..
1 second
256 megabytes
['constructive algorithms', 'graphs', '*2300']
B. Let's Go Hikingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOn a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper.A permutation p is written from ...
5 1 2 5 4 3
1
1 second
256 megabytes
['games', 'greedy', '*1900']
A. Diamond Minertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDiamond Miner is a game that is similar to Gold Miner, but there are n miners instead of 1 in this game.The mining area can be described as a plane. The n miners can be regarded as n points on the y-axis...
3 2 0 1 1 0 0 -1 -2 0 4 1 0 3 0 -5 0 6 0 0 3 0 1 0 2 0 4 5 3 0 0 4 0 -3 4 0 2 0 1 0 -3 0 0 -10 0 -2 0 -10
3.650281539872885 18.061819283610362 32.052255376143336
1 second
256 megabytes
['geometry', 'greedy', 'math', 'sortings', '*1200']
F. Delete The Edgestime limit per test8 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an undirected connected graph consisting of n vertices and m edges. Your goal is to destroy all edges of the given graph.You may choose any vertex as the starting one and begin walking ...
3 3 1 2 2 3 3 1
4 1 2 3 1
8 seconds
512 megabytes
['brute force', 'constructive algorithms', 'dfs and similar', 'graphs', 'implementation', '*2900']
E. A-Z Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a directed graph consisting of n vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty.You should process m queries with it. Each query is one of...
3 11 + 1 2 a + 2 3 b + 3 2 a + 2 1 b ? 3 ? 2 - 2 1 - 3 2 + 2 1 c + 3 2 d ? 5
YES NO YES
2 seconds
256 megabytes
['constructive algorithms', 'data structures', 'graphs', 'hashing', '*2400']
D. Dogeforcestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Dogeforces company has k employees. Each employee, except for lower-level employees, has at least 2 subordinates. Lower-level employees have no subordinates. Each employee, except for the head of the c...
3 2 5 7 5 1 7 7 7 4
5 2 1 4 7 5 4 1 5 2 5 5 4 3 4
2 seconds
256 megabytes
['constructive algorithms', 'data structures', 'dfs and similar', 'divide and conquer', 'dsu', 'greedy', 'sortings', 'trees', '*2300']
C. 1D Sokobantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are playing a game similar to Sokoban on an infinite number line. The game is discrete, so you only consider integer positions on the line.You start on a position 0. There are n boxes, the i-th box is ...
5 5 6 -1 1 5 11 15 -4 -3 -2 6 7 15 2 2 -1 1 -1000000000 1000000000 2 2 -1000000000 1000000000 -1 1 3 5 -1 1 2 -2 -1 1 2 5 2 1 1 2 10
4 2 0 3 1
2 seconds
256 megabytes
['binary search', 'dp', 'greedy', 'implementation', 'two pointers', '*1900']
B. Berland Crosswordtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland crossword is a puzzle that is solved on a square grid with n rows and n columns. Initially all the cells are white.To solve the puzzle one has to color some cells on the border of the grid b...
4 5 2 5 3 1 3 0 0 0 0 4 4 1 4 0 2 1 1 1 1
YES YES NO YES
2 seconds
256 megabytes
['bitmasks', 'brute force', 'greedy', 'implementation', '*1400']
A. ABC Stringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string a, consisting of n characters, n is even. For each i from 1 to n a_i is one of 'A', 'B' or 'C'.A bracket sequence is a string containing only characters "(" and ")". A regular bracke...
4 AABBAC CACA BBBBAC ABCA
YES YES NO NO
2 seconds
256 megabytes
['bitmasks', 'brute force', 'implementation', '*900']
F. Enchanted Matrixtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.There exists a matrix a of size n \times m (n rows and m columns), you know only numbers n and m. The rows of the matrix are numbered from 1 to n from top to bottom, and...
3 4 1 1 1 0
? 1 2 1 1 1 3 ? 1 2 2 1 2 3 ? 1 2 3 1 3 3 ? 1 1 1 1 1 2 ! 2
1 second
256 megabytes
['bitmasks', 'interactive', 'number theory', '*2600']
E. Enormous XORtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers l and r in binary representation. Let g(x, y) be equal to the bitwise XOR of all integers from x to y inclusive (that is x \oplus (x+1) \oplus \dots \oplus (y-1) \oplus y). Let'...
7 0010011 1111010
1111111
1 second
256 megabytes
['bitmasks', 'constructive algorithms', 'greedy', 'math', 'strings', 'two pointers', '*2600']
D. GCD of an Arraytime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n. You are asked to process q queries of the following format: given integers i and x, multiply a_i by x.After processing each query you need to output the greates...
4 3 1 6 8 12 1 12 2 3 3 3
2 2 6
2.5 seconds
256 megabytes
['brute force', 'data structures', 'hashing', 'implementation', 'math', 'number theory', 'sortings', 'two pointers', '*2100']
C. K-beautiful Stringstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string s consisting of lowercase English letters and a number k. Let's call a string consisting of lowercase English letters beautiful if the number of occurrences of each letter i...
4 4 2 abcd 3 1 abc 4 3 aaaa 9 3 abaabaaaa
acac abc -1 abaabaaab
2 seconds
256 megabytes
['binary search', 'brute force', 'constructive algorithms', 'greedy', 'strings', '*2000']
B. Planet Lapitulettitime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones....
5 24 60 12:21 24 60 23:59 90 80 52:26 1 100 00:01 10 10 04:04
12:21 00:00 52:28 00:00 00:00
2 seconds
256 megabytes
['brute force', 'implementation', '*1300']
A. Anti-knapsacktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two integers n and k. You are asked to choose maximum number of distinct integers from 1 to n so that there is no subset of chosen numbers with sum equal to k.A subset of a set is a set tha...
3 3 2 5 3 1 1
2 3 1 3 4 5 2 0
1 second
256 megabytes
['constructive algorithms', 'greedy', '*800']
E. Almost Fault-Tolerant Databasetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are storing an integer array of length m in a database. To maintain internal integrity and protect data, the database stores n copies of this array.Unfortunately, the recent inciden...
3 4 1 10 10 100 1 1 1 100 10 100 1 100
Yes 1 10 1 100
2 seconds
512 megabytes
['brute force', 'constructive algorithms', 'dfs and similar', 'greedy', 'implementation', '*2500']
D. Genius's Gambittime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given three integers a, b, k.Find two binary integers x and y (x \ge y) such that both x and y consist of a zeroes and b ones; x - y (also written in binary form) has exactly k ones. You a...
4 2 3
Yes 101000 100001
2 seconds
512 megabytes
['bitmasks', 'constructive algorithms', 'greedy', 'math', '*1900']
C. Maximum widthtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYour classmate, whom you do not like because he is boring, but whom you respect for his intellect, has two strings: s of length n and t of length m.A sequence p_1, p_2, \ldots, p_m, where 1 \leq p_1 < p...
5 3 abbbc abc
3
2 seconds
512 megabytes
['binary search', 'data structures', 'dp', 'greedy', 'two pointers', '*1500']
B. Card Decktime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have a deck of n cards, and you'd like to reorder it to a new one.Each card has a value between 1 and n equal to p_i. All p_i are pairwise distinct. Cards in a deck are numbered from bottom to top, i. e....
4 4 1 2 3 4 5 1 5 2 4 3 6 4 2 5 3 6 1 1 1
4 3 2 1 5 2 4 3 1 6 1 5 3 4 2 1
1 second
512 megabytes
['data structures', 'greedy', 'math', '*1100']
A. Three swimmerstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputThree swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.It takes the first swimmer exactly a minutes to swim across the entire pool ...
4 9 5 4 8 2 6 10 9 10 2 5 10 10 9 9 9
1 4 0 8
1 second
512 megabytes
['math', '*800']
I. Ruler Of The Zootime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter realizing that Zookeeper is just a duck, the animals have overthrown Zookeeper. They now have to decide a new ruler among themselves through a fighting tournament of the following format:Initia...
4 5 1 2 10 8 11 9 0 3 7 4 6
-1 -1
3 seconds
256 megabytes
['brute force', 'data structures', '*3500']
H. Yuezheng Ling and Dynamic Treetime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYuezheng Ling gives Luo Tianyi a tree which has n nodes, rooted at 1. Luo Tianyi will tell you that the parent of the i-th node is a_i (1 \leq a_i<i for 2 \le i \le n), and she will a...
6 4 1 2 3 3 4 2 3 4 1 2 3 1 2 5 6 2 2 3
3 3 1
1.5 seconds
256 megabytes
['data structures', 'trees', '*3400']
G. Switch and Fliptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n coins labeled from 1 to n. Initially, coin c_i is on position i and is facing upwards ((c_1, c_2, \dots, c_n) is a permutation of numbers from 1 to n). You can do some operations on these c...
3 2 1 3
3 1 3 3 2 3 1
1 second
256 megabytes
['constructive algorithms', 'graphs', 'math', '*2800']
F. Magnetstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Kochiya Sanae is playing with magnets. Realizing that some of those magnets are demagnetized, she is curious to find them out.There are n magnets, which can be of the following 3...
1 4 0 1 0 0
? 1 1 3 4 ? 1 2 1 2 3 ? 1 1 1 4 ? 1 1 1 3 ! 2 3 4
1 second
256 megabytes
['binary search', 'constructive algorithms', 'interactive', '*2700']
E. Fib-treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet F_k denote the k-th term of Fibonacci sequence, defined as below: F_0 = F_1 = 1 for any integer n \geq 0, F_{n+2} = F_{n+1} + F_nYou are given a tree with n vertices. Recall that a tree is a connected und...
3 1 2 2 3
YES
1 second
256 megabytes
['brute force', 'dfs and similar', 'divide and conquer', 'number theory', 'trees', '*2400']
D. Zookeeper and The Infinite Zootime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a new attraction in Singapore Zoo: The Infinite Zoo.The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled 1,2,3,\ldots. There is a directed...
5 1 4 3 6 1 6 6 2 5 5
YES YES NO NO YES
3 seconds
256 megabytes
['bitmasks', 'constructive algorithms', 'dp', 'greedy', 'math', '*1800']
C. Pekora and Trampolinetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a trampoline park with n trampolines in a line. The i-th of which has strength S_i.Pekora can jump on trampolines in multiple passes. She starts the pass by jumping on any trampoline of...
3 7 1 4 2 2 2 2 2 2 2 3 5 1 1 1 1 1
4 3 0
2 seconds
256 megabytes
['brute force', 'data structures', 'dp', 'greedy', 'implementation', '*1700']
B. Minimal Costtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a graph of n rows and 10^6 + 2 columns, where rows are numbered from 1 to n and columns from 0 to 10^6 + 1: Let's denote the node in the row i and column j by (i, j).Initially for each i the i-...
3 2 3 4 2 2 2 3 4 3 2 2 4 3 3 2
7 3 3
2 seconds
256 megabytes
['brute force', 'math', '*1200']
A. K-th Largest Valuetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a consisting of n integers. Initially all elements of a are either 0 or 1. You need to process q queries of two kinds: 1 x : Assign to a_x the value 1 - a_x. 2 k : Print the...
5 5 1 1 0 1 0 2 3 1 2 2 3 2 1 2 5
1 0 1 0
1 second
256 megabytes
['brute force', 'greedy', 'implementation', '*800']
G. Old Floppy Drive time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp was dismantling his attic and found an old floppy drive on it. A round disc was inserted into the drive with n integers written on it.Polycarp wrote the numbers from the disk into the a arr...
3 3 3 1 -3 4 1 5 2 2 2 -2 0 1 2 2 2 0 1 1 2
0 6 2 -1 -1 1 3
2 seconds
256 megabytes
['binary search', 'data structures', 'math', '*1900']
F. Equalize the Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp was gifted an array a of length n. Polycarp considers an array beautiful if there exists a number C, such that each number in the array occurs either zero or C times. Polycarp wants to rem...
3 6 1 3 2 1 4 2 4 100 100 4 100 8 1 2 3 3 3 2 6 6
2 1 2
2 seconds
256 megabytes
['binary search', 'data structures', 'greedy', 'math', 'sortings', '*1500']
E. Accidental Victorytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA championship is held in Berland, in which n players participate. The player with the number i has a_i (a_i \ge 1) tokens.The championship consists of n-1 games, which are played according to the ...
2 4 1 2 4 3 5 1 1 1 1 1
3 2 3 4 5 1 2 3 4 5
2 seconds
256 megabytes
['binary search', 'data structures', 'greedy', '*1400']
D. Permutation Transformationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA permutation — is a sequence of length n integers from 1 to n, in which all the numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] — permutations, and [2, 3, 2], [4, ...
3 5 3 5 2 1 4 1 1 4 4 3 1 2
1 0 2 3 1 0 0 1 3 2
2 seconds
256 megabytes
['dfs and similar', 'divide and conquer', 'implementation', '*1200']
C. Sum of Cubestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive integer x. Check whether the number x is representable as the sum of the cubes of two positive integers.Formally, you need to check if there are two integers a and b (1 \le a, b)...
7 1 2 4 34 35 16 703657519796
NO YES NO NO YES YES YES
2 seconds
256 megabytes
['binary search', 'brute force', 'brute force', 'math', '*1100']
B. Balanced Remainderstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a number n (divisible by 3) and an array a[1 \dots n]. In one move, you can increase any of the array elements by one. Formally, you choose the index i (1 \le i \le n) and replace a_...
4 6 0 2 5 5 4 8 6 2 0 2 1 0 0 9 7 1 3 4 2 10 3 9 6 6 0 1 2 3 4 5
3 1 3 0
2 seconds
256 megabytes
['brute force', 'constructive algorithms', 'math', '*1000']
A. Dense Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formally, for any i (1 \le i \le n-1), this condition must be satisfied: \fra...
6 4 4 2 10 1 2 1 3 2 6 1 3 1 4 2 5 1 2 3 4 3 12 4 31 25 50 30 20 34 46 42 16 15 16
5 1 2 1 0 3
2 seconds
256 megabytes
['greedy', 'math', '*800']
J. Flower Shoptime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friend is running a flower shop. In order to be prepared for the next holidays (when, as usual, sales skyrocket) she asked you to write her a special program that will help to analyze the stocks she ...
5 12 1 2 3 2 1 1 1 5 1 2 3 1 3 1 3 1 5 10 3 4 5 100 1 4 4 1 5 1 3 2 5 7 3 1 1 3 3 1 5 100 2 1 5 3 1 5 100
40 0 28 3 479 79
5 seconds
256 megabytes
['*special problem', 'data structures', 'fft', 'math', '*3100']
I. Demonic Invasiontime limit per test8 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDalaran is a flying city of magic. It consists of n floating islands connected by m bridges (each bridge can be traversed in both directions). Every island is reachable from every other along these b...
4 4 1 1 2 2 3 3 4 4 1
1
8 seconds
512 megabytes
['*special problem', 'flows', '*3100']
H. Build From Suffixestime limit per test10 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an integer n and a sequence a of n-1 integers, each element is either 0 or 1.You are asked to build a string of length n such that: each letter is one of "abcd"; if a_i=1, then t...
2 2 0 1 1
6 10
10 seconds
512 megabytes
['*special problem', 'combinatorics', 'data structures', '*2800']
G. Painting Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n integers, each integer is from 1 to n, all of them are pairwise distinct. You have to paint them red and blue (each integer should have exactly one color).The cost of painting is the ...
6
3 5 6 6 5 0
2 seconds
256 megabytes
['*special problem', 'data structures', 'greedy', 'number theory', '*2500']
F. Dogecointime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, cryptocurrencies have become increasingly popular. Ann decided that it was about time she started mining the Dogecoin cryptocurrency. Ann's computer is not very powerful, so Ann mines exactly 1 Dog...
5 4 1 2 3 2 4 1 5 2 4 3 5 5 5
15 9 8 2
2 seconds
256 megabytes
['*special problem', '*special problem', 'binary search', 'data structures', '*2300']
E. Palindromic Doublestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA subsequence is a sequence that can be obtained from another sequence by removing some elements without changing the order of the remaining elements.A palindromic sequence is a sequence that is e...
5 6 2 1 3 1 5 2 6 1 3 3 4 4 1 1 1 2 1 1 7 4 4 2 5 7 2 3
5 4 1 2 3
2 seconds
256 megabytes
['*special problem', 'data structures', 'dp', '*2200']
D. Problemsolving Marathontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp has decided to do a problemsolving marathon. He wants to solve s problems in n days. Let a_i be the number of problems he solves during the i-th day. He wants to find a distribution o...
3 1 15 3 9 2 6
15 4 4
2 seconds
256 megabytes
['*special problem', 'binary search', 'greedy', '*1900']
C. Two Policementime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a street that can be represented as an array of length n.There are two policemen patrolling a street: the first one is standing at the point x of the street and the second one is standing at th...
6 4 1 2 7 7 1 10 2 6 8 5 2 2 1 2 20 4 14
2 3 5 4 0 12
2 seconds
256 megabytes
['*special problem', 'binary search', 'brute force', 'math', '*1900']
B. RBS Deletiontime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence (or, shortly, an RBS) is a bracket sequence that can be transformed into a correct arithmetic expression ...
3 12 2 (()())((())) 6 3 ()()() 8 1 (((())))
4 3 2
3 seconds
512 megabytes
['*special problem', 'greedy', '*1800']
A. From Zero To Ytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two positive (greater than zero) integers x and y. There is a variable k initially set to 0.You can perform the following two types of operations: add 1 to k (i. e. assign k := k + 1); ...
3 2 7 3 42 25 1337
4 5 20
2 seconds
256 megabytes
['*special problem', 'math', '*900']
G. String Countingtime limit per test10 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputYou have c_1 letters 'a', c_2 letters 'b', ..., c_{26} letters 'z'. You want to build a beautiful string of length n from them (obviously, you cannot use the i-th letter more than c_i times). Each c...
4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
422500
10 seconds
1024 megabytes
['combinatorics', 'dp', 'fft', 'math', '*2700']
F. Onestime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a positive (greater than zero) integer n.You have to represent n as the sum of integers (possibly negative) consisting only of ones (digits '1'). For example, 24 = 11 + 11 + 1 + 1 and 102 = 111 - 1...
24
6
3 seconds
256 megabytes
['dp', 'greedy', 'shortest paths', '*2900']
E. Cheap Dinnertime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIvan wants to have a good dinner. A good dinner should consist of a first course, a second course, a drink, and a dessert.There are n_1 different types of first courses Ivan can buy (the i-th of them cos...
4 3 2 1 1 2 3 4 5 6 7 8 9 10 2 1 2 1 1 2 3 1 3 2 1 1 1
26
4 seconds
512 megabytes
['brute force', 'data structures', 'graphs', 'greedy', 'implementation', 'sortings', 'two pointers', '*2000']
D. Pythagorean Triplestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA Pythagorean triple is a triple of integer numbers (a, b, c) such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal...
3 3 6 9
0 1 1
2 seconds
256 megabytes
['binary search', 'brute force', 'math', 'number theory', '*1500']
C. Minimum Tiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA big football championship will occur soon! n teams will compete in it, and each pair of teams will play exactly one game against each other.There are two possible outcomes of a game: the game may resul...
2 2 3
0 1 -1 1
1 second
256 megabytes
['brute force', 'constructive algorithms', 'dfs and similar', 'graphs', 'greedy', 'implementation', 'math', '*1500']
B. Cat Cycletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSuppose you are living with two cats: A and B. There are n napping spots where both cats usually sleep.Your cats like to sleep and also like all these spots, so they change napping spot each hour cyclically:...
7 2 1 2 2 3 1 3 2 3 3 5 5 69 1337
1 2 1 3 2 2 65
1 second
256 megabytes
['math', 'number theory', '*1200']
A. Arenatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputn heroes fight against each other in the Arena. Initially, the i-th hero has level a_i.Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it...
3 3 3 2 2 2 5 5 4 1 3 3 7
1 0 3
1 second
256 megabytes
['implementation', 'sortings', '*800']
F. Pairs of Pathstime limit per test6 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a tree consisting of n vertices, and m simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number o...
5 1 2 1 3 1 4 3 5 4 2 3 2 4 3 4 3 5
2
6 seconds
512 megabytes
['combinatorics', 'data structures', 'dfs and similar', 'dp', 'trees', '*2600']
E. Paired Paymenttime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are n cities and m bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter w....
5 6 1 2 3 2 3 4 3 4 5 4 5 6 1 5 1 2 4 2
0 98 49 25 114
4 seconds
512 megabytes
['binary search', 'brute force', 'constructive algorithms', 'dp', 'flows', 'graphs', 'shortest paths', '*2200']
D. Max Mediantime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are a given an array a of length n. Find a subarray a[l..r] with length at least k with the largest median.A median in an array of length n is an element which occupies position number \lfloor \frac{n ...
5 3 1 2 3 2 1
2
2 seconds
256 megabytes
['binary search', 'data structures', 'dp', '*2100']
C2. Guessing the Greatest (hard version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array a of n different numbers. In one q...
5 3 4
? 1 5 ? 4 5 ! 1
1 second
256 megabytes
['binary search', 'interactive', '*1900']
C1. Guessing the Greatest (easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe only difference between the easy and the hard version is the limit to the number of queries.This is an interactive problem.There is an array a of n different numbers. In one q...
5 3 4
? 1 5 ? 4 5 ! 1
1 second
256 megabytes
['binary search', 'interactive', '*1600']
B. Eastern Exhibitiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou and your friends live in n houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be different houses located in the same point. The mayor of the city is a...
6 3 0 0 2 0 1 2 4 1 0 0 2 2 3 3 1 4 0 0 0 1 1 0 1 1 2 0 0 1 1 2 0 0 2 0 2 0 0 0 0
1 4 4 4 3 1
1 second
256 megabytes
['binary search', 'geometry', 'shortest paths', 'sortings', '*1500']
A. Shifting Stackstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have n stacks of blocks. The i-th stack contains h_i blocks and it's height is the number of blocks in it. In one move you can take a block from the i-th stack (if there is at least one block) and ...
6 2 1 2 2 1 0 3 4 4 4 2 0 0 3 0 1 0 4 1000000000 1000000000 1000000000 1000000000
YES YES YES NO NO YES
1 second
256 megabytes
['greedy', 'implementation', '*900']
F. Copy or Prefix Sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of integers b_1, b_2, \ldots, b_n.An array a_1, a_2, \ldots, a_n of integers is hybrid if for each i (1 \leq i \leq n) at least one of these conditions is true: b_i = a_i, ...
4 3 1 -1 1 4 1 2 3 4 10 2 -1 1 -2 2 3 -5 0 2 -1 4 0 0 0 1
3 8 223 1
2 seconds
256 megabytes
['combinatorics', 'data structures', 'dp', 'sortings', '*2400']
E. Move and Swaptime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n - 1 integers a_2, \dots, a_n and a tree with n vertices rooted at vertex 1. The leaves are all at the same distance d from the root. Recall that a tree is a connected undirected graph wi...
4 14 1 1 1 2 3 4 4 5 5 6 7 8 8 2 3 7 7 6 9 5 9 7 3 6 6 5 6 1 2 2 3 4 32 78 69 5 41 15 1 15 1 10 4 9 11 2 4 1 8 6 10 11 62 13 12 43 39 65 42 86 25 38 19 19 43 62 15 11 2 7 6 9 8 10 1 1 1 5 3 15 2 50 19 30 35 9 45 13 24 8 44 16 26 10 40
14 45 163 123
2 seconds
256 megabytes
['dfs and similar', 'dp', 'greedy', 'trees', '*2500']
D. Multiples and Power Differencestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a matrix a consisting of positive integers. It has n rows and m columns.Construct a matrix b consisting of positive integers. It should have the same size as a, and the f...
2 2 1 2 2 3
1 2 2 3
2 seconds
256 megabytes
['constructive algorithms', 'graphs', 'math', 'number theory', '*2200']
C. Floor and Modtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA pair of positive integers (a,b) is called special if \lfloor \frac{a}{b} \rfloor = a \bmod b. Here, \lfloor \frac{a}{b} \rfloor is the result of the integer division between a and b, while a \bmod b i...
9 3 4 2 100 4 3 50 3 12 4 69 420 12345 6789 123456 789 12345678 9
1 0 2 3 5 141 53384 160909 36
2 seconds
256 megabytes
['binary search', 'brute force', 'math', 'number theory', '*1700']
B. Replace and Keep Sortedtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven a positive integer k, two arrays are called k-similar if: they are strictly increasing; they have the same length; all their elements are positive integers between 1 and k (inclusive)...
4 2 5 1 2 4 5 2 3 3 4
4 3
2 seconds
256 megabytes
['dp', 'implementation', 'math', '*1200']
A. Add and Dividetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have two positive integers a and b.You can perform two kinds of operations: a = \lfloor \frac{a}{b} \rfloor (replace a with the integer part of the division between a and b) b=b+1 (increase b by 1...
6 9 2 1337 1 1 1 50000000 4 991026972 997 1234 5678
4 9 2 12 3 1
1 second
256 megabytes
['brute force', 'greedy', 'math', 'number theory', '*1000']
H. Examtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis year a Chunin Selection Exam is held again in Konoha, and taking part in it are n ninjas named s_1, s_2, ..., s_n. All names are distinct. One of the exam stages consists of fights between the participants....
5 hidan dan hanabi bi nabi
3
2 seconds
512 megabytes
['data structures', 'string suffix structures', 'trees', '*3400']
G. Vabanktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGustaw is the chief bank manager in a huge bank. He has unlimited access to the database system of the bank, in a few clicks he can move any amount of money from the bank's reserves to his own private account....
1 Lucky! Lucky! Lucky! Lucky! Lucky! Fraudster!
? 1 ? 2 ? 3 ? 4 ? 5 ? 6 ! 5
2 seconds
256 megabytes
['binary search', 'interactive', '*3200']
F. Useful Edgestime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given a weighted undirected graph on n vertices along with q triples (u, v, l), where in each triple u and v are vertices and l is a positive integer. An edge e is called useful if there is at le...
4 6 1 2 1 2 3 1 3 4 1 1 3 3 2 4 3 1 4 5 1 1 4 4
5
5 seconds
512 megabytes
['graphs', 'shortest paths', '*2400']
E. Skyline Phototime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give the set of photos as a present to Bob. However, she wants to find the set of photos with maxi...
5 1 2 3 5 4 1 5 3 2 4
15
2.5 seconds
256 megabytes
['data structures', 'divide and conquer', 'dp', '*2100']
D. Playlisttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputArkady has a playlist that initially consists of n songs, numerated from 1 to n in the order they appear in the playlist. Arkady starts listening to the songs in the playlist one by one, starting from song 1...
5 5 5 9 2 10 15 6 1 2 4 2 4 2 2 1 2 1 1 1 2
2 2 3 2 2 1 2 2 1 1 1 0
2 seconds
256 megabytes
['data structures', 'dsu', 'implementation', 'shortest paths', '*1900']
C. Basic Diplomacytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAleksey has n friends. He is also on a vacation right now, so he has m days to play this new viral cooperative game! But since it's cooperative, Aleksey will need one teammate in each of these m days....
2 4 6 1 1 2 1 2 3 1 2 3 4 1 2 3 4 2 2 3 1 3 2 2 1 1 1 1
YES 1 2 1 1 2 3 NO
2 seconds
512 megabytes
['brute force', 'constructive algorithms', 'greedy', 'implementation', '*1600']
B. Restore Modulotime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor the first place at the competition, Alex won many arrays of integers and was assured that these arrays are very expensive. After the award ceremony Alex decided to sell them. There is a rule in arra...
6 6 1 9 17 6 14 3 3 4 2 2 3 7 3 4 3 2 2 4 5 0 1000000000 0 1000000000 0 2 1 1
19 8 -1 -1 -1 2000000000 1000000000 0
1 second
256 megabytes
['implementation', 'math', '*1500']
A. Prison Breaktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMichael is accused of violating the social distancing rules and creating a risk of spreading coronavirus. He is now sent to prison. Luckily, Michael knows exactly what the prison looks like from the insid...
2 2 2 1 3
4 3
1 second
256 megabytes
['math', '*800']
F. AB Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputKilani and Abd are neighbors for 3000 years, but then the day came and Kilani decided to move to another house. As a farewell gift, Kilani is going to challenge Abd with a problem written by their other neigh...
9 3 1 2 2 4 4 4 3 1
4 aabbbbbba
2 seconds
256 megabytes
['dp', 'greedy', 'trees', '*3100']
E. Sorting Bookstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day you wanted to read something, so you went to your bookshelf to grab some book. But when you saw how messy the bookshelf was you decided to clean it up first. There are n books standing in a row...
5 1 2 2 1 3
2
2 seconds
256 megabytes
['data structures', 'dp', 'greedy', '*2500']
D. AB Graphtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour friend Salem is Warawreh's brother and only loves math and geometry problems. He has solved plenty of such problems, but according to Warawreh, in order to graduate from university he has to solve more ...
5 3 1 *ba b*b ab* 3 3 *ba b*b ab* 3 4 *ba b*b ab* 4 6 *aaa b*ba ab*a bba* 2 6 *a b*
YES 1 2 YES 2 1 3 2 YES 1 3 1 3 1 YES 1 2 1 3 4 1 4 NO
2 seconds
256 megabytes
['brute force', 'constructive algorithms', 'graphs', 'greedy', 'implementation', '*2000']
C. Fence Paintingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou finally woke up after this crazy dream and decided to walk around to clear your head. Outside you saw your house's fence — so plain and boring, that you'd like to repaint it. You have a fence cons...
6 1 1 1 1 1 5 2 1 2 2 1 1 1 2 2 1 1 1 2 3 3 2 2 2 2 2 2 2 3 2 10 5 7 3 2 1 7 9 4 2 7 9 9 9 2 1 4 9 4 2 3 9 9 9 7 4 3 5 2 1 2 2 1 1 1 2 2 1 1 3 3 6 4 3 4 2 4 1 2 2 3 1 3 1 1 2 2 3 4
YES 1 YES 2 2 YES 1 1 1 YES 2 1 9 5 9 NO NO
2 seconds
256 megabytes
['brute force', 'constructive algorithms', 'greedy', '*1600']
B. New Colonytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains u...
4 4 3 4 1 2 3 2 7 1 8 4 5 4 1 2 3 3 1 5 3 1
2 1 -1 -1
2 seconds
256 megabytes
['brute force', 'greedy', 'implementation', '*1100']
A. Space Navigation time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou were dreaming that you are traveling to a planet named Planetforces on your personal spaceship. Unfortunately, its piloting system was corrupted and now you need to fix it in order to reach Plan...
6 10 5 RRRRRRRRRRUUUUU 1 1 UDDDRLLL -3 -5 LDLDLDDDR 1 2 LLLLUU 3 -2 RDULRLLDR -1 6 RUDURUUUUR
YES YES YES NO YES NO
2 seconds
256 megabytes
['greedy', 'strings', '*800']
B. The Great Herotime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe great hero guards the country where Homer lives. The hero has attack power A and initial health value B. There are n monsters in front of the hero. The i-th monster has attack power a_i and initial...
5 3 17 1 2 16 10 999 3 10 20 30 100 50 30 1000 1000 4 200 300 400 500 1000 1000 1000 1000 999 999 1 1000 1000 999 999 1 1000000 999
YES YES YES NO YES
2 seconds
512 megabytes
['greedy', 'implementation', 'sortings', '*900']
A. Yet Another String Gametime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputHomer has two friends Alice and Bob. Both of them are string fans. One day, Alice and Bob decide to play a game on a string s = s_1 s_2 \dots s_n of length n consisting of lowercase English le...
3 a bbbb az
b azaz by
2 seconds
512 megabytes
['games', 'greedy', 'strings', '*800']
E. School Clubstime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn Homer's school, there are n students who love clubs. Initially, there are m clubs, and each of the n students is in exactly one club. In other words, there are a_i students in the i-th club for 1 \leq...
2 1 1
4
4 seconds
512 megabytes
['dp', 'fft', 'math', 'number theory', 'probabilities', '*3500']
D. Odd Mineral Resourcetime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputIn Homer's country, there are n cities numbered 1 to n and they form a tree. That is, there are (n-1) undirected roads between these n cities and every two cities can reach each other through th...
6 8 3 2 1 3 1 3 1 2 1 3 2 4 2 5 4 6 3 5 1 1 3 5 1 3 3 5 1 3 1 1 2 2 1 1 3 3 1 4 1 5 1 6 1 3 1 6 1 3
-1 2 3 -1 3 2 2 3
5 seconds
1024 megabytes
['binary search', 'bitmasks', 'brute force', 'data structures', 'probabilities', 'trees', '*2900']
C. Continuous Citytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSome time ago Homer lived in a beautiful city. There were n blocks numbered from 1 to n and m directed roads between them. Each road had a positive length, and each road went from the block with the s...
1 1
YES 2 1 1 2 1
2 seconds
512 megabytes
['bitmasks', 'constructive algorithms', '*2500']
B2. Painting the Array IItime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe only difference between the two versions is that this version asks the minimal possible answer.Homer likes arrays a lot. Today he is painting an array a_1, a_2, \dots, a_n with two kinds of...
6 1 2 3 1 2 2
4
2 seconds
512 megabytes
['constructive algorithms', 'data structures', 'dp', 'greedy', 'implementation', '*2100']
B1. Painting the Array Itime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe only difference between the two versions is that this version asks the maximal possible answer.Homer likes arrays a lot. Today he is painting an array a_1, a_2, \dots, a_n with two kinds of ...
7 1 1 2 2 3 3 3
6
2 seconds
512 megabytes
['constructive algorithms', 'data structures', 'dp', 'greedy', 'implementation', '*1900']
A. Searching Local Minimumtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Homer likes arrays a lot and he wants to play a game with you. Homer has hidden from you a permutation a_1, a_2, \dots, a_n of integers 1 to n. You are asked to ...
5 3 2 1 4 5
? 1 ? 2 ? 3 ? 4 ? 5 ! 3
2 seconds
512 megabytes
['binary search', 'interactive', 'ternary search', '*1700']
C. Nezzar and Symmetric Arraytime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputLong time ago there was a symmetric array a_1,a_2,\ldots,a_{2n} consisting of 2n distinct integers. Array a_1,a_2,\ldots,a_{2n} is called symmetric if for each integer 1 \le i \le 2n, there...
6 2 8 12 8 12 2 7 7 9 11 2 7 11 7 11 1 1 1 4 40 56 48 40 80 56 80 48 6 240 154 210 162 174 154 186 240 174 186 162 210
YES NO NO NO NO YES
2 seconds
512 megabytes
['implementation', 'math', 'sortings', '*1700']
B. Nezzar and Lucky Numbertime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputNezzar's favorite digit among 1,\ldots,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation. Given q integers a_1,a_2,\ldots,a_q, for each 1 \le i \...
2 3 7 24 25 27 10 7 51 52 53 54 55 56 57 58 59 60
YES NO YES YES YES NO YES YES YES YES YES YES NO
1 second
512 megabytes
['brute force', 'dp', 'greedy', 'math', '*1100']
A. Nezzar and Colorful Ballstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputNezzar has n balls, numbered with integers 1, 2, \ldots, n. Numbers a_1, a_2, \ldots, a_n are written on them, respectively. Numbers on those balls form a non-decreasing sequence, which means...
5 6 1 1 1 2 3 4 5 1 1 2 2 3 4 2 2 2 2 3 1 2 3 1 1
3 2 4 1 1
1 second
512 megabytes
['brute force', 'greedy', '*800']
F. Nezzar and Chocolate Barstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNezzar buys his favorite snack — n chocolate bars with lengths l_1,l_2,\ldots,l_n. However, chocolate bars might be too long to store them properly! In order to solve this problem, Nezzar de...
1 1 2
4
5 seconds
512 megabytes
['combinatorics', 'fft', 'math', 'probabilities', '*3500']
E. Nezzar and Tournamentstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn the famous Oh-Suit-United tournament, two teams are playing against each other for the grand prize of precious pepper points.The first team consists of n players, and the second team consist...
3 4 3 1 2 7 3 4 5 6 3 5 1 1 10 3 5
-4 9
5 seconds
512 megabytes
['data structures', 'greedy', '*3300']
D. Nezzar and Hidden Permutationstime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNezzar designs a brand new game "Hidden Permutations" and shares it with his best friend, Nanako.At the beginning of the game, Nanako and Nezzar both know integers n and m. The game goe...
3 4 2 1 2 3 4 6 4 1 2 1 3 3 5 3 6 2 1 1 2
1 2 3 4 3 4 1 2 2 3 4 1 6 5 1 4 3 2 5 6 1 2 1 2
5 seconds
512 megabytes
['constructive algorithms', 'dfs and similar', 'graphs', '*2800']
C. Nezzar and Nice Beatmaptime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNezzar loves the game osu!.osu! is played on beatmaps, which can be seen as an array consisting of distinct points on a plane. A beatmap is called nice if for any three consecutive points A,B,...
5 0 0 5 0 4 2 2 1 3 0
1 2 5 3 4
2 seconds
512 megabytes
['constructive algorithms', 'geometry', 'greedy', 'math', 'sortings', '*2200']
B. Nezzar and Binary Stringtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputNezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change t...
4 5 2 00000 00111 1 5 1 3 2 1 00 01 1 2 10 6 1111111111 0110001110 1 10 5 9 7 10 1 7 3 5 6 10 5 2 10000 11000 2 5 1 3
YES NO YES NO
2 seconds
512 megabytes
['data structures', 'greedy', '*1900']
A. Nezzar and Boardtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputn distinct integers x_1,x_2,\ldots,x_n are written on the board. Nezzar can perform the following operation multiple times. Select two integers x,y (not necessarily distinct) on the board, and write...
6 2 1 1 2 3 0 2 3 7 2 -1 31415926 27182818 2 1000000000000000000 1 1000000000000000000 2 -1000000000000000000 -1000000000000000000 123 6 80 -5 -20 13 -14 -2 -11
YES YES NO YES YES NO
2 seconds
512 megabytes
['constructive algorithms', 'math', 'number theory', '*1800']