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. Save More Micetime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are one cat, k mice, and one hole on a coordinate line. The cat is located at the point 0, the hole is located at the point n. All mice are located between the cat and the hole: the i-th mouse is...
3 10 6 8 7 5 4 9 4 2 8 1 1 1 1 1 1 1 1 12 11 1 2 3 4 5 6 7 8 9 10 11
3 1 4
4 seconds
256 megabytes
['binary search', 'greedy', 'greedy', '*1000']
B. Make it Divisible by 25time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is given a positive integer n. In 1 move, one can select any single digit and remove it (i.e. one selects some position in the number and removes the digit located at this position). The ope...
5 100 71345 3259 50555 2050047
0 3 1 3 2
1 second
256 megabytes
['dfs and similar', 'dp', 'greedy', 'math', 'math', '*900']
A. Electionstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe elections in which three candidates participated have recently ended. The first candidate received a votes, the second one received b votes, the third one received c votes. For each candidate, solve the ...
5 0 0 0 10 75 15 13 13 17 1000 0 0 0 1000000000 0
1 1 1 66 0 61 5 5 0 0 1001 1001 1000000001 0 1000000001
1 second
256 megabytes
['math', '*800']
F2. Alice and Recoloring 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe difference between the versions is in the costs of operations. Solution for one version won't work for another!Alice has a grid of size n \times m, initially all its cells are colored whit...
3 3 WWW WBB WBB
2
2 seconds
256 megabytes
['constructive algorithms', 'flows', 'graph matchings', 'greedy', '*2800']
F1. Alice and Recoloring 1time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe difference between the versions is in the costs of operations. Solution for one version won't work for another!Alice has a grid of size n \times m, initially all its cells are colored whit...
3 3 WWW WBB WBB
3
2 seconds
256 megabytes
['constructive algorithms', 'greedy', '*2600']
E. Bored Bakrytime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBakry got bored of solving problems related to xor, so he asked you to solve this problem for him.You are given an array a of n integers [a_1, a_2, \ldots, a_n].Let's call a subarray a_{l}, a_{l+1}, a_{l+...
2 5 6
2
4 seconds
256 megabytes
['bitmasks', 'greedy', 'math', 'two pointers', '*2400']
D. Hemose in ICPC ?time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem!In the last regional contest Hemose, ZeyadKhattab and YahiaSherif — members of the team Carpe Diem — did not qualify to ICPC because of some unknown reasons. Hemose was ...
6 1 2 2 3 2 4 1 5 5 6 10 2 10
? 6 1 2 3 4 5 6 ? 3 3 1 5 ? 2 1 2 ! 1 2
1 second
256 megabytes
['binary search', 'dfs and similar', 'implementation', 'interactive', 'math', 'number theory', 'trees', '*2300']
C. Bakry and Partitioningtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBakry faced a problem, but since he's lazy to solve it, he asks for your help.You are given a tree of n nodes, the i-th node has value a_i assigned to it for each i from 1 to n. As a reminder, a...
5 2 2 1 3 1 2 5 5 3 3 3 3 3 1 2 2 3 1 4 4 5 5 2 1 7 2 3 5 1 2 2 3 1 4 4 5 5 3 1 6 4 1 2 1 2 2 3 1 4 4 5 3 3 1 7 4 1 2 2 3
NO YES NO YES NO
1 second
256 megabytes
['bitmasks', 'constructive algorithms', 'dfs and similar', 'dp', 'graphs', 'trees', '*1700']
B. Hemose Shoppingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHemose was shopping with his friends Samez, AhmedZ, AshrafEzz, TheSawan and O_E in Germany. As you know, Hemose and his friends are problem solvers, so they are very clever. Therefore, they will go to ...
4 3 3 3 2 1 4 3 1 2 3 4 5 2 5 1 2 3 4 5 4 1 2 3 4 4
NO YES YES YES
1 second
256 megabytes
['constructive algorithms', 'dsu', 'math', 'sortings', '*1200']
A. Gamer Hemosetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, Ahmed_Hossam went to Hemose and said "Let's solve a gym contest!". Hemose didn't want to do that, as he was playing Valorant, so he came up with a problem and told it to Ahmed to distract him. Sa...
3 2 4 3 7 2 6 4 2 3 11 2 1 7
1 2 3
1 second
256 megabytes
['binary search', 'greedy', 'math', 'sortings', '*800']
F. Jumping Through the Arraytime limit per test8 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array of integers a of size n and a permutation p of size n. There are q queries of three types coming to you: For given numbers l and r, calculate the sum in array a on th...
5 6 9 -5 3 0 2 3 1 5 4 6 1 1 5 2 1 1 1 1 5 3 1 5 2 1 -1 1 1 5
13 16 11
8 seconds
512 megabytes
['binary search', 'data structures', 'graphs', 'two pointers', '*3500']
I. Omkar and Mosaictime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOmkar is creating a mosaic using colored square tiles, which he places in an n \times n grid. When the mosaic is complete, each cell in the grid will have either a glaucous or sinoper tile. However, ...
4 S... ..G. .... ...S
MULTIPLE
2 seconds
256 megabytes
['combinatorics', 'constructive algorithms', 'math', '*3500']
G. Poacherstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice and Bob are two poachers who cut trees in a forest.A forest is a set of zero or more trees. A tree is a connected graph without cycles. A rooted tree has a special vertex called the root. The parent ...
4 4 0 1 0 3 7 0 1 2 0 4 5 6 4 0 1 1 2 7 0 1 1 2 2 3 3
NO YES NO YES
1.5 seconds
256 megabytes
['dp', 'games', 'graphs', 'trees', '*2500']
F. Non-equal Neighbourstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou are given an array of n positive integers a_1, a_2, \ldots, a_n. Your task is to calculate the number of arrays of n positive integers b_1, b_2, \ldots, b_n such that: 1 \le b_i \le a_i for...
3 2 2 2
2
3 seconds
512 megabytes
['combinatorics', 'dp', 'math', '*2400']
E. Frequency Queriestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPetya has a rooted tree with an integer written on each vertex. The vertex 1 is the root. You are to answer some questions about the tree.A tree is a connected graph without cycles. A rooted tree ha...
2 3 3 1 1 1 1 2 3 1 1 3 1 2 3 2 1 5 5 1 2 1 1 2 1 1 2 2 3 1 1 2 1 2 4 1 1 4 2 1 4 2 2
1 -1 1 1 1 2 1 -1
4 seconds
512 megabytes
['data structures', 'dfs and similar', 'trees', '*2400']
D. Yet Another Sorting Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya has an array of integers a_1, a_2, \ldots, a_n. He only likes sorted arrays. Unfortunately, the given array could be arbitrary, so Petya wants to sort it.Petya likes to challenge him...
7 1 1 2 2 2 2 2 1 3 1 2 3 3 2 1 3 3 3 1 2 4 2 1 4 3
YES YES NO YES NO YES YES
2 seconds
256 megabytes
['data structures', 'math', '*1900']
C. Minimize Distancetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA total of n depots are located on a number line. Depot i lies at the point x_i for 1 \le i \le n.You are a salesman with n bags of goods, attempting to deliver one bag to each of the n depots. You a...
4 5 1 1 2 3 4 5 9 3 -5 -10 -15 6 5 8 3 7 4 5 3 2 2 3 3 3 4 2 1000000000 1000000000 1000000000 1000000000
25 41 7 3000000000
1 second
256 megabytes
['greedy', '*1300']
B. Array Eversiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a of length n.Let's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not g...
3 5 2 4 1 5 3 5 5 3 2 4 1 4 1 1 1 1
1 2 0
1 second
256 megabytes
['greedy', '*900']
A. Life of a Flowertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya has got an interesting flower. Petya is a busy person, so he sometimes forgets to water it. You are given n days from Petya's live and you have to determine what happened with his flower in the ...
4 3 1 0 1 3 0 1 1 4 1 0 0 1 1 0
3 7 -1 1
1 second
256 megabytes
['implementation', '*800']
G. Eligible Segmentstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n distinct points p_1, p_2, \ldots, p_n on the plane and a positive integer R. Find the number of pairs of indices (i, j) such that 1 \le i < j \le n, and for every possible k (1 \le k...
4 2 0 1 0 -1 3 0 -3 0
1
3 seconds
256 megabytes
['geometry', '*3200']
F. Strange LCStime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n strings s_1, s_2, \ldots, s_n, each consisting of lowercase and uppercase English letters. In addition, it's guaranteed that each character occurs in each string at most twice. Find the lo...
4 2 ABC CBA 2 bacab defed 3 abcde aBcDe ace 2 codeforces technocup
1 A 0 3 ace 3 coc
2 seconds
256 megabytes
['bitmasks', 'dp', 'graphs', 'greedy', 'strings', '*2600']
E. Game with Stonestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBob decided to take a break from calculus homework and designed a game for himself. The game is played on a sequence of piles of stones, which can be described with a sequence of integers s_1, \ldots...
6 2 2 2 3 1 2 3 4 1 1 1 1 4 1 2 2 1 4 1 2 1 2 8 1 2 1 2 1 2 1 2
1 0 4 2 1 3
2 seconds
256 megabytes
['binary search', 'data structures', 'games', 'greedy', '*2300']
D. Guess the Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Jury initially had a sequence a of length n, such that a_i = i.The jury chose three integers i, j, k, such that 1 \leq i < j < k \leq n, j - i > 1. After that, Jury...
2 5 4 3 3 5 2 2 1
? 1 5 ? 2 5 ? 3 5 ! 1 3 5 ? 1 5 ? 2 5 ? 3 5 ! 2 4 5
1 second
256 megabytes
['binary search', 'combinatorics', 'interactive', 'math', '*2000']
C. Two Arraystime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two arrays of integers a_1, a_2, \ldots, a_n and b_1, b_2, \ldots, b_n.Let's define a transformation of the array a: Choose any non-negative integer k such that 0 \le k \le n. Choose k disti...
3 3 -1 1 0 0 0 2 1 0 2 5 1 2 3 4 5 1 2 3 4 5
YES NO YES
1 second
256 megabytes
['greedy', 'math', 'sortings', '*900']
B. Coloring Rectanglestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDavid was given a red checkered rectangle of size n \times m. But he doesn't like it. So David cuts the original or any other rectangle piece obtained during the cutting into two new pieces along t...
4 1 3 2 2 2 5 3 5
1 2 4 5
1 second
256 megabytes
['greedy', 'math', '*1000']
A. Mathematical Additiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIvan decided to prepare for the test on solving integer equations. He noticed that all tasks in the test have the following form: You are given two positive integers u and v, find any pair of in...
4 1 1 2 3 3 5 6 9
-1 1 -4 9 -18 50 -4 9
1 second
256 megabytes
['math', '*800']
H. Omkar and Tourstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputOmkar is hosting tours of his country, Omkarland! There are n cities in Omkarland, and, rather curiously, there are exactly n-1 bidirectional roads connecting the cities to each other. It is guarantee...
5 3 2 2 3 3 3 1 2 4 7 1 3 2 8 2 4 8 2 2 5 1 1 1 3 9 5 6 2
3 8 3 0 3 2
3 seconds
512 megabytes
['data structures', 'divide and conquer', 'sortings', 'trees', '*3300']
G. Omkar and Time Traveltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEl Psy Kongroo.Omkar is watching Steins;Gate.In Steins;Gate, Okabe Rintarou needs to complete n tasks (1 \leq n \leq 2 \cdot 10^5). Unfortunately, he doesn't know when he needs to complete the t...
2 1 4 2 3 2 1 2
3
2 seconds
256 megabytes
['data structures', 'math', '*3000']
F. Defender of Childhood Dreamstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputEven if you just leave them be, they will fall to pieces all by themselves. So, someone has to protect them, right?You find yourself playing with Teucer again in the city of Liyue. As you...
5 3
2 1 2 2 2 2 2 2 1 1 1
3 seconds
512 megabytes
['bitmasks', 'constructive algorithms', 'divide and conquer', '*2500']
E. Moment of Bloomtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputShe does her utmost to flawlessly carry out a person's last rites and preserve the world's balance of yin and yang.Hu Tao, being the little prankster she is, has tried to scare you with this graph pro...
6 7 2 1 2 3 3 5 1 4 6 1 5 6 4 5 3 1 4 5 1 4 5
YES 2 1 4 4 5 3 2 1 5 4 1 2 3 5
3 seconds
512 megabytes
['constructive algorithms', 'dfs and similar', 'graph matchings', 'graphs', 'greedy', 'trees', '*2200']
D. Omkar and the Meaning of Lifetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt turns out that the meaning of life is a permutation p_1, p_2, \ldots, p_n of the integers 1, 2, \ldots, n (2 \leq n \leq 100). Omkar, having created all life, knows this permutation, ...
5 2 0 1
? 4 4 2 3 2 ? 3 5 1 5 5 ? 5 2 4 3 1 ! 3 2 1 5 4
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'interactive', '*1800']
C. Omkar and Determinationtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe problem statement looms below, filling you with determination.Consider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at tha...
4 5 ..XXX ...X. ...X. ...X. 5 1 3 3 3 4 5 5 5 1 5
YES YES NO YES NO
2 seconds
256 megabytes
['data structures', 'dp', '*1700']
B. Omkar and Heavenly Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLord Omkar would like to have a tree with n nodes (3 \le n \le 10^5) and has asked his disciples to construct the tree. However, Lord Omkar has created m (\mathbf{1 \le m < n}) restrictions to...
2 7 4 1 2 3 3 4 5 5 6 7 6 5 4 5 3 1 2 3 2 3 4 3 4 5
1 2 1 3 3 5 3 4 2 7 7 6 5 1 1 3 3 2 2 4
2 seconds
256 megabytes
['constructive algorithms', 'trees', '*1200']
A. Windblume Odetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.You have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n \g...
4 3 8 1 2 4 6 9 4 2 9 1 2 3 4 5 6 7 8 9 3 200 199 198
2 2 1 4 2 1 4 3 9 6 9 1 2 3 4 5 7 8 3 1 2 3
1 second
256 megabytes
['math', 'number theory', '*800']
G. Kuzya and Homeworktime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputKuzya started going to school. He was given math homework in which he was given an array a of length n and an array of symbols b of length n, consisting of symbols '*' and '/'.Let's denote a path o...
3 1 2 3 */*
2
2 seconds
512 megabytes
['data structures', 'number theory', '*2600']
F2. Korney Korneevich and XOR (hard version)time limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is a harder version of the problem with bigger constraints.Korney Korneevich dag up an array a of length n. Korney Korneevich has recently read about the operation bit...
4 4 2 2 4
4 0 2 4 6
1.5 seconds
512 megabytes
['binary search', 'brute force', 'dp', 'greedy', 'two pointers', '*2400']
F1. Korney Korneevich and XOR (easy version)time limit per test1.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThis is an easier version of the problem with smaller constraints.Korney Korneevich dag up an array a of length n. Korney Korneevich has recently read about the operation b...
4 4 2 2 4
4 0 2 4 6
1.5 seconds
512 megabytes
['bitmasks', 'dp', 'greedy', '*1800']
E. Pchelyonok and Segmentstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputPchelyonok decided to give Mila a gift. Pchelenok has already bought an array a of length n, but gifting an array is too common. Instead of that, he decided to gift Mila the segments of that a...
5 1 1 3 1 2 3 5 1 1 2 2 3 7 1 2 1 1 3 2 6 5 9 6 7 9 7
1 1 2 3 1
2 seconds
512 megabytes
['binary search', 'data structures', 'dp', 'greedy', 'math', '*2000']
D. Vupsen, Pupsen and 0time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputVupsen and Pupsen were gifted an integer array. Since Vupsen doesn't like the number 0, he threw away all numbers equal to 0 from the array. As a result, he got an array a of length n.Pupsen, on t...
3 2 5 5 5 5 -2 10 -9 4 7 1 2 3 4 5 6 7
1 -1 -1 5 1 -1 -1 -10 2 2 -3 5 -1 -1
1 second
256 megabytes
['constructive algorithms', 'math', '*1600']
C. Grandma Capa Knits a Scarftime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGrandma Capa has decided to knit a scarf and asked Grandpa Sher to make a pattern for it, a pattern is a string consisting of lowercase English letters. Grandpa Sher wrote a string s of leng...
5 8 abcaacab 6 xyzxyz 4 abba 8 rprarlap 10 khyyhhyhky
2 -1 0 3 2
1 second
256 megabytes
['brute force', 'data structures', 'greedy', 'strings', 'two pointers', '*1200']
B. Luntik and Subsequencestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuntik came out for a morning stroll and found an array a of length n. He calculated the sum s of the elements of the array (s= \sum_{i=1}^{n} a_i). Luntik calls a subsequence of the array a ne...
5 5 1 2 3 4 5 2 1000 1000 2 1 0 5 3 0 2 1 1 5 2 1 0 3 0
1 0 2 4 4
1 second
256 megabytes
['combinatorics', 'math', '*900']
A. Luntik and Concertstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLuntik has decided to try singing. He has a one-minute songs, b two-minute songs and c three-minute songs. He wants to distribute all songs into two concerts such that every song should be included...
4 1 1 1 2 1 3 5 5 5 1 1 2
0 1 0 1
1 second
256 megabytes
['math', '*800']
B. Diameter of Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCQXYM wants to create a connected undirected graph with n nodes and m edges, and the diameter of the graph must be strictly less than k-1. Also, CQXYM doesn't want a graph that contains self-loops or...
5 1 0 3 4 5 3 4 6 3 5 4 1 2 1 1
YES NO YES NO NO
1 second
256 megabytes
['constructive algorithms', 'graphs', 'greedy', 'math', '*1200']
A. CQXYM Count Permutationstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCQXYM is counting permutations length of 2n.A permutation is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] i...
4 1 2 9 91234
1 12 830455698 890287984
1 second
256 megabytes
['combinatorics', 'math', 'number theory', '*800']
F. Problems for Codeforcestime limit per test8 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputXYMXYM and CQXYM will prepare n problems for Codeforces. The difficulty of the problem i will be an integer a_i, where a_i \geq 0. The difficulty of the problems must satisfy a_i+a_{i+1}<m (1 ...
3 2
4
8 seconds
256 megabytes
['combinatorics', 'fft', 'math', '*3300']
E. Railway Constructiontime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputBecause the railway system in Gensokyo is often congested, as an enthusiastic engineer, Kawasiro Nitori plans to construct more railway to ease the congestion.There are n stations numbered from...
5 5 1 1 1 1 1 1 1 2 1 2 3 1 2 4 1 3 5 1 4 5 1 1 2
3 9
2.5 seconds
512 megabytes
['brute force', 'constructive algorithms', 'data structures', 'graphs', 'shortest paths', '*3400']
D. Subsequencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice has an integer sequence a of length n and all elements are different. She will choose a subsequence of a of length m, and defines the value of a subsequence a_{b_1},a_{b_2},\ldots,a_{b_m} as \sum_{i ...
6 4 15 2 18 12 13 4
100
1 second
256 megabytes
['brute force', 'divide and conquer', 'dp', 'greedy', 'trees', '*2900']
C. Train Maintenancetime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputKawasiro Nitori is excellent in engineering. Thus she has been appointed to help maintain trains.There are n models of trains, and Nitori's department will only have at most one train of each model a...
3 4 10 15 12 10 1 1 1 3 1 1 2 1 2 3
0 1 0 0
1 second
512 megabytes
['brute force', 'data structures', 'implementation', '*2200']
B. Mathematics Curriculumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet c_1, c_2, \ldots, c_n be a permutation of integers 1, 2, \ldots, n. Consider all subsegments of this permutation containing an integer x. Given an integer m, we call the integer x good if t...
4 3 2 10007
4
2 seconds
256 megabytes
['brute force', 'combinatorics', 'dp', 'trees', '*2600']
A. Portaltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputCQXYM found a rectangle A of size n \times m. There are n rows and m columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empt...
1 5 4 1000 0000 0110 0000 0001
12
1 second
256 megabytes
['brute force', 'data structures', 'dp', 'greedy', 'implementation', '*1700']
G. Minimal Coveragetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n lengths of segments that need to be placed on an infinite axis with coordinates.The first segment is placed on the axis so that one of its endpoints lies at the point with coordinate 0...
6 2 1 3 3 1 2 3 4 6 2 3 9 4 6 8 4 5 7 1 2 4 6 7 7 3 8 8 6 5 1 2 2 3 6
3 3 9 9 7 8
1 second
256 megabytes
['dp', '*2200']
F. Array Stabilization (AND version)time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array a[0 \ldots n - 1] = [a_0, a_1, \ldots, a_{n - 1}] of zeroes and ones only. Note that in this problem, unlike the others, the array indexes are numbered from ze...
5 2 1 0 1 3 2 0 1 0 5 2 1 1 0 1 0 4 2 0 1 0 1 1 1 0
1 1 3 -1 0
2 seconds
256 megabytes
['brute force', 'graphs', 'math', 'number theory', 'shortest paths', '*1700']
E2. Array Optimization by Dequetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn fact, the problems E1 and E2 do not have much in common. You should probably think of them as two separate problems.You are given an integer array a[1 \ldots n] = [a_1, a_2, \ldots, a_...
6 4 3 7 5 5 3 3 2 1 3 3 1 2 4 -1 2 2 -1 4 4 5 1 3 5 1 3 1 3 2
2 0 1 0 1 2
2 seconds
256 megabytes
['data structures', 'greedy', '*1700']
E1. Permutation Minimization by Dequetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn fact, the problems E1 and E2 do not have much in common. You should probably think of them as two separate problems.A permutation p of size n is given. A permutation of size n is...
5 4 3 1 2 4 3 3 2 1 3 3 1 2 2 1 2 2 2 1
1 3 2 4 1 2 3 1 3 2 1 2 1 2
2 seconds
256 megabytes
['constructive algorithms', 'greedy', 'math', '*1000']
D. Productive Meetingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAn important meeting is to be held and there are exactly n people invited. At any moment, any two people can step back and talk in private. The same two people can talk several (as many as they wan...
8 2 2 3 3 1 2 3 4 1 2 3 4 3 0 0 2 2 6 2 3 0 0 2 5 8 2 0 1 1 5 0 1 0 0 6
2 1 2 1 2 3 1 3 2 3 2 3 5 1 3 2 4 2 4 3 4 3 4 0 2 1 2 1 2 0 4 1 2 1 5 1 4 1 2 1 5 2
2 seconds
256 megabytes
['constructive algorithms', 'graphs', 'greedy', '*1400']
C. Tickstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCasimir has a rectangular piece of paper with a checkered field of size n \times m. Initially, all cells of the field are white.Let us denote the cell with coordinates i vertically and j horizontally by (i, j)....
8 2 3 1 *.* ... 4 9 2 *.*.*...* .*.*...*. ..*.*.*.. .....*... 4 4 1 *.*. **** .**. .... 5 5 1 ..... *...* .*.*. ..*.* ...*. 5 5 2 ..... *...* .*.*. ..*.* ...*. 4 7 1 *.....* .....*. ..*.*.. ...*... 3 3 1 *** *** *** 3 5 1 *...* .***. .**..
NO YES YES YES NO NO NO NO
2 seconds
256 megabytes
['greedy', 'implementation', '*1500']
B. Shifting Sorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe new generation external memory contains an array of integers a[1 \ldots n] = [a_1, a_2, \ldots, a_n].This type of memory does not support changing the value of an arbitrary element. Instead, it allo...
4 2 2 1 3 1 2 1 4 2 4 1 3 5 2 5 1 4 3
1 1 2 1 1 1 3 2 3 2 4 1 2 3 1 1 3 2 4 2 4 2 1 5 3 1 2 1 1 3 1
2 seconds
256 megabytes
['implementation', 'sortings', '*1100']
A. Casimir's String Solitairetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCasimir has a string s which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions: he can either erase exactly one lette...
6 ABACAB ABBA AC ABC CABCBB BCBCBCBCBCBCBCBC
NO YES NO NO YES YES
2 seconds
256 megabytes
['math', 'strings', '*800']
M. The Mindtime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.In this problem, you need to come up with a strategy for a cooperative game. This game is played by two players. Each player receives 5 cards. Each card has a random integer b...
2 2 12 27 71 100 22 29 39 68 90
0.8 0.2 0.0 0.0 0.0 0.0 0.2 0.2 0.2 0.3
2 seconds
1024 megabytes
['constructive algorithms', 'interactive', 'probabilities', '*2700']
L. Labyrinthtime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputIn a dream, Lucy found herself in a labyrinth. This labyrinth consists of n rooms, connected by m passages (i-th passage is w_i cm wide). Each passage can be traversed in both directions. It is guaranteed ...
3 3 1 2 3 1 2 4 1 3 4 2 3 6
3
2 seconds
1024 megabytes
['binary search', 'dsu', 'greedy', '*2400']
K. Kingdom of Islandstime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThe Kingdom of Islands consists of p islands. As the king, you rule over the whole kingdom, while each island is ruled over by one or several jarls under your rule. In total, there are n jarls und...
4 4 1 2 3 4 1 2 3
3 1 4 2
2 seconds
1024 megabytes
['brute force', 'graphs', 'implementation', '*2800']
J. Just Kingdomtime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThe Just Kingdom is ruled by a king and his n lords, numbered 1 to n. Each of the lords is a vassal of some overlord, who might be the king himself, or a different lord closer to the king. The king, and...
5 0 2 1 2 0 1 1 1 0 5
11 7 3 5 11
5 seconds
1024 megabytes
['brute force', 'data structures', 'dfs and similar', '*3100']
I. Interactive Raystime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThis is an interactive problem.Your goal is to find a circle on a plane by shooting rays and getting the distance to the circle as a result. Interactor has three hidden integer parameters that are d...
? 0 -10 ? 10 -10 ? 10 0 ? 10 10 ? 10 20 ? 10 30 ! 20 10 10
12.360679775 11.2132034356 0.0 0.0 3.416407865 5.8113883008
2 seconds
1024 megabytes
['geometry', 'interactive', '*3300']
H. Higher Order Functionstime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputHelen studies functional programming and she is fascinated with a concept of higher order functions — functions that are taking other functions as parameters. She decides to generalize the con...
()
0
2 seconds
1024 megabytes
['implementation', 'strings', '*1700']
G. Game of Chancetime limit per test6 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThe King wants to marry off his daughter, and he wants her husband to have the greatest innate luckiness possible. To find such a person he decided to hold a heads-or-tails tournament. If person A wit...
5 1 4 1 1 4
0.026 0.3584 0.0676 0.0616 0.4864
6 seconds
1024 megabytes
['math', 'probabilities', '*3500']
F. Framing Picturestime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputLife has been discovered on Venus! What is more, the life forms appear to be convex polygons. An international consortium is designing a probe to send to Venus to take pictures, but they need to est...
4 0 0 10 0 10 10 0 10
163.661977237
2 seconds
1024 megabytes
['geometry', '*2900']
E. Easy Schedulingtime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputEonathan Eostar decided to learn the magic of multiprocessor systems. He has a full binary tree of tasks with height h. In the beginning, there is only one ready task in the tree — the task in the ro...
3 3 1 3 2 10 6
7 4 173
2 seconds
1024 megabytes
['implementation', 'math', '*1200']
D. Dragon Curvetime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputA dragon curve is a self-similar fractal curve. In this problem, it is a curve that consists of straight-line segments of the same length connected at right angles. A simple way to construct a dragon cu...
5 0 0 -2 0 -7 -7 5 -9 9 9
1 1 2 2 3 189 4 186 2 68
5 seconds
1024 megabytes
['*3200']
C. Cactus Lady and her Cingtime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputCactus lady loves her cactuses very much. Especially she likes a small cactus named Cing. Cing can be seen as a connected undirected graph in which every vertex lies on at most one simple cy...
5 4 3 1 2 2 3 3 4 8 7 1 2 3 2 2 4 4 5 4 6 6 7 6 8 5 4 1 2 1 3 1 4 1 5 8 9 1 2 2 3 3 4 1 4 4 5 5 6 6 7 7 8 5 8 10 10 1 2 2 3 3 4 4 5 5 6 6 1 3 7 4 8 1 9 6 10
Yes 0 0 0 1 1 1 1 2 Yes 0 3 1 3 1 4 1 2 0 2 1 1 0 1 1 0 No Yes 0 0 1 0 1 1 0 1 0 2 0 3 1 3 1 2 Yes 1 1 1 2 1 3 0 3 0 2 0 1 1 4 0 4 1 0 0 0
5 seconds
1024 megabytes
['*3500']
B. Building Forest Trailstime limit per test3 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThere are n villages lying equidistant on a circle in the middle of a thick, impassable forest. From ancient times, it was impossible to move from one village to another, but technical progres...
6 9 1 1 3 1 4 6 2 3 4 1 2 4 2 1 2 2 1 3 2 1 4 2 6 1 2 5 3
011110
3 seconds
1024 megabytes
['data structures', 'dsu', '*2800']
A. Anti-Tetristime limit per test2 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputLet us consider the game "Sticky Tetris". In this game, there is a field of n \times m squares. Tiles appear on the field and the player can move the tiles. Each tile is a 4-connected set of at most 7 sq...
3 2 aa ab aa
2 2 DS 1 S
2 seconds
1024 megabytes
['constructive algorithms', 'graphs', 'shortest paths', '*2800']
A. Communication Routing Challengetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn optical communication networks, appropriate path planning can improve the utilization of communication resources and bring a smooth communication experience to users. The following ...
8 15 3 1 0 0 0 1 100 1050 1 1 0 1 200 2200 2 1 0 1 200 99400 3 2 0 3 100 450 4 3 0 3 500 1120 5 4 1 2 1000 40000 6 5 2 3 600 10000 7 5 2 3 600 10000 8 6 1 4 120 2500 9 6 1 4 120 450 10 7 1 5 170 1250 11 8 2 5 200 2500 12 9 3 5 100 1250 13 10 3 6 300 1150 14 11 3 7 300 1100 2 5 7 2 6 7 2 6 11 0 4 6 100
1 0 8 0 3 13
2 seconds
512 megabytes
['*special problem']
M. Managing Telephone Polestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek's city can be represented as a plane. He wants to build a housing complex in the city.There are some telephone poles on the plane, which is represented by a grid a of size (n + 1) ...
2 2 101 000 000
18
2 seconds
512 megabytes
['data structures', 'geometry', '*2400']
L. Longest Array Deconstructiontime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek gives you a sequence a indexed from 1 to n. Define f(a) as the number of indices where a_i = i. You can pick an element from the current sequence and remove it, then concatenat...
7 2 1 4 2 5 3 7
3
2 seconds
512 megabytes
['data structures', 'divide and conquer', 'dp', 'sortings', '*2100']
K. Knitting Batiktime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek wants to knit a batik, a traditional cloth from Indonesia. The cloth forms a grid a with size n \times m. There are k colors, and each cell in the grid can be one of the k colors.Define a su...
3 3 2 2 2 1 1 2 2
32
2 seconds
512 megabytes
['implementation', 'math', '*2200']
J. Jeopardy of Dropped Ballstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek has a new game called Dropping Balls. Initially, Mr. Chanek has a grid a of size n \times mEach cell (x,y) contains an integer a_{x,y} denoting the direction of how the ball will ...
5 5 3 1 2 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1
2 2 1
2 seconds
512 megabytes
['binary search', 'brute force', 'dsu', 'implementation', '*1500']
I. Illusions of the Deserttime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputChanek Jones is back, helping his long-lost relative Indiana Jones, to find a secret treasure in a maze buried below a desert full of illusions.The map of the labyrinth forms a tree with n roo...
6 4 10 -9 2 -1 4 -6 1 5 5 4 5 6 6 2 6 3 2 1 2 1 1 -3 2 1 2 2 3 3
39 32 0
3 seconds
512 megabytes
['data structures', 'trees', '*2300']
H. Holiday Wall Ornamentstime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThe Winter holiday will be here soon. Mr. Chanek wants to decorate his house's wall with ornaments. The wall can be represented as a binary string a of length n. His favorite nephew has another...
9 3 100101011 101
1 1 0 1 6 -1 -1 -1
3 seconds
512 megabytes
['dp', 'strings', '*2200']
G. GCD Festivaltime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek has an array a of n integers. The prettiness value of a is denoted as:\sum_{i=1}^{n} {\sum_{j=1}^{n} {\gcd(a_i, a_j) \cdot \gcd(i, j)}}where \gcd(x, y) denotes the greatest common divisor (GCD...
5 3 6 2 1 4
77
3 seconds
512 megabytes
['math', 'number theory', '*2200']
F. Finding Expected Valuetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek opened a letter from his fellow, who is currently studying at Singanesia. Here is what it says.Define an array b (0 \leq b_i < k) with n integers. While there exists a pair (i, j) su...
2 2 0 1
2
3 seconds
512 megabytes
['math', '*2900']
E. Eye-Pleasing City Park Tourtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere is a city park represented as a tree with n attractions as its vertices and n - 1 rails as its edges. The i-th attraction has happiness value a_i.Each rail has a color. It is either ...
5 0 1 3 2 6 4 1 2 1 1 4 0 3 2 1 2 5 0
45
4 seconds
512 megabytes
['data structures', 'trees', '*2600']
D. Divisible by Twenty-Fivetime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek has an integer represented by a string s. Zero or more digits have been erased and are denoted by the character _. There are also zero or more digits marked by the character X, mea...
25
1
2 seconds
512 megabytes
['brute force', 'dfs and similar', 'dp', '*1800']
C. Cyclic Sumtime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputDenote a cyclic sequence of size n as an array s such that s_n is adjacent to s_1. The segment s[r, l] where l < r is the concatenation of s[r, n] and s[1, l].You are given an array a consisting of n integ...
5 1 5 1 2 3 4 3
4
3 seconds
512 megabytes
['data structures', 'fft', 'number theory', '*3000']
B. Building an Amusement Parktime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMr. Chanek lives in a city represented as a plane. He wants to build an amusement park in the shape of a circle of radius r. The circle must touch the origin (point (0, 0)).There are n bird...
8 4 -3 1 -4 4 1 5 2 2 2 -2 -2 -4 -1 -1 -6 0
3.1622776589
5 seconds
512 megabytes
['binary search', 'geometry', '*2300']
A. Another Sorting Problemtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAndi and Budi were given an assignment to tidy up their bookshelf of n books. Each book is represented by the book title — a string s_i numbered from 1 to n, each with length m. Andi really wa...
5 2 AA AB BB BA AZ
5 2 1 3 4
2 seconds
512 megabytes
['data structures', 'sortings', 'strings', '*1100']
F. Occurrencestime limit per test7 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA subarray of array a from index l to the index r is the array [a_l, a_{l+1}, \dots, a_{r}]. The number of occurrences of the array b in the array a is the number of subarrays of a such that they are equa...
2 4 3 2 1 2 1 3
5
7 seconds
512 megabytes
['combinatorics', 'dfs and similar', 'dp', 'dsu', 'fft', 'graphs', '*2700']
E. Coloringtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA matrix of size n \times m, such that each cell of it contains either 0 or 1, is considered beautiful if the sum in every contiguous submatrix of size 2 \times 2 is exactly 2, i. e. every "square" of size 2...
2 2 7 1 1 1 1 2 1 2 1 1 1 1 0 1 2 -1 2 1 -1 1 1 -1
3 1 0 1 2 3 6
2 seconds
256 megabytes
['combinatorics', 'constructive algorithms', 'implementation', 'math', '*2500']
D. The Strongest Buildtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIvan is playing yet another roguelike computer game. He controls a single hero in the game. The hero has n equipment slots. There is a list of c_i items for the i-th slot, the j-th of them increas...
3 3 1 2 3 2 1 5 3 2 4 6 2 3 2 3 3 2 2
2 2 3
3 seconds
256 megabytes
['binary search', 'brute force', 'data structures', 'dfs and similar', 'graphs', 'greedy', 'hashing', 'implementation', '*2000']
C. Slay the Dragontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, Petya learned about a new game "Slay the Dragon". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this...
4 3 6 2 3 5 3 12 7 9 4 14 1 10 8 7
1 2 4 0 2
2 seconds
256 megabytes
['binary search', 'greedy', 'sortings', 'ternary search', '*1300']
B. Combinatorics Homeworktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given four integer values a, b, c and m.Check if there exists a string that contains: a letters 'A'; b letters 'B'; c letters 'C'; no other letters; exactly m pairs of adjacent eq...
3 2 2 1 0 1 1 1 1 1 2 3 2
YES NO YES
2 seconds
256 megabytes
['combinatorics', 'greedy', 'math', '*1100']
A. Regular Bracket Sequencestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputA bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by insert...
3 3 1 3
()()() ((())) (()()) () ((())) (())() ()(())
2 seconds
512 megabytes
['constructive algorithms', '*800']
F. Stationstime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities in a row numbered from 1 to n.The cities will be building broadcasting stations. The station in the i-th city has height h_i and range w_i. It can broadcast information to city j if the ...
1 3 2 1 1 1 1 1 2 1 1
1 1
2.5 seconds
256 megabytes
['data structures', '*3400']
E. Polygontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a strictly convex polygon with n vertices.You will make k cuts that meet the following conditions: each cut is a segment that connects two different nonadjacent vertices; two cuts can interse...
8 4 -2 -4 2 -2 4 2 1 5 0 5 -4 4 -5 0 -5 -1
11
3 seconds
256 megabytes
['binary search', 'dp', 'geometry', '*3000']
D. Bridge Clubtime limit per test2.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputThere are currently n hot topics numbered from 0 to n-1 at your local bridge club and 2^n players numbered from 0 to 2^n-1. Each player holds a different set of views on those n topics, more specificall...
3 1 8 3 5 7 1 10 3 2
13
2.5 seconds
512 megabytes
['flows', 'graph matchings', 'graphs', 'greedy', '*2800']
C. Painttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a 1 by n pixel image. The i-th pixel of the image has color a_i. For each color, the number of pixels of that color is at most 20.You can perform the following operation, which works like the bucke...
3 5 1 2 3 2 1 4 1 1 2 2 5 1 2 1 4 2
2 1 3
1 second
256 megabytes
['dp', 'greedy', '*2700']
B. Xor of 3time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a sequence a of length n consisting of 0s and 1s.You can perform the following operation on this sequence: Pick an index i from 1 to n-2 (inclusive). Change all of a_{i}, a_{i+1}, a_{i+2} to ...
3 3 0 0 0 5 1 1 1 1 0 4 1 0 0 1
YES 0 YES 2 3 1 NO
1 second
256 megabytes
['brute force', 'constructive algorithms', 'greedy', 'two pointers', '*2500']
A. Booktime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a book with n chapters.Each chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you unde...
5 4 1 2 0 2 1 4 1 2 5 1 5 1 1 1 2 1 3 1 4 5 0 0 2 1 2 1 2 2 2 1 4 2 2 3 0 0 2 3 2 5 1 2 1 3 1 4 1 5 0
2 -1 1 2 5
1.5 seconds
256 megabytes
['binary search', 'brute force', 'data structures', 'dp', 'graphs', 'implementation', 'sortings', '*1800']
J. Two Railroadstime limit per test5 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard outputThere are n cities in Berland, and they are connected by two railroads — the Main railroad and the Auxiliary railroad. Each city has two railway stations, one connected to the Main railroad (called the...
5 3 4 7 4 8 5 3 5 10 5 3 4 10 4 1 4 1 2 3 4 2 4
9 8 10 9
5 seconds
1024 megabytes
['*special problem', '*3000']
I. Physical Examinationtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp plans to undergo a full physical examination at his local clinic. There are n doctors, numbered from 1 to n. The i-th doctor takes patients from minute L_i to minute R_i, so Polycarp can...
5 3 2 3 1 3 3 2 8 6 6 5 4 9 4 3 6 7 6 10 6 9 6 6 8 2 4 2 4 2 3 2 2 2 3 3 3 1 5 10
1 3 1 2 3 7 4 6 2 1 8 5 3 -1 -1 7 1
4 seconds
256 megabytes
['*special problem', 'binary search', 'data structures', '*3200']
H. Laser Beamstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIra is developing a computer game. This game features randomized generation and difficulty of levels. To achieve randomized difficulty, some enemies in each level are randomly replaced with stronger ones....
1 2 2 1 1 500000
6
2 seconds
512 megabytes
['*special problem', 'geometry', 'probabilities', '*2900']