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. k-Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputQuite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.A k-tree is an infinite rooted tree where: eac...
Input3 3 2
Output3
1 second
256 megabytes
['dp', 'implementation', 'trees', '*1600']
B. Shower Linetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMany students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its drawbacks. There is only one shower and there are multiple students who wish t...
Input0 0 0 0 90 0 0 0 00 0 0 0 00 0 0 0 07 0 0 0 0
Output32
1 second
256 megabytes
['brute force', 'implementation', '*1200']
A. Black Squaretime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputQuite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.In this game, the phone's screen is divi...
Input1 2 3 4123214
Output13
1 second
256 megabytes
['implementation', '*800']
B. Balls Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub is training for the IOI. What is a better way to train than playing a Zuma-like game? There are n balls put in a row. Each ball is colored in one of k colors. Initially the row doesn't contain three o...
Input6 2 21 1 2 2 1 1
Output6
1 second
256 megabytes
['brute force', 'two pointers', '*1400']
A. Points and Segments (easy)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement a...
Input3 33 7 141 56 1011 15
Output0 0 0
1 second
256 megabytes
['constructive algorithms', 'sortings', '*1600']
E. Points and Segmentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and star...
Input20 22 3
Output0 1
1 second
256 megabytes
['graphs', '*3000']
D. Tricky Functiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag,...
Input41 0 0 -1
Output1
2 seconds
256 megabytes
['data structures', 'divide and conquer', 'geometry', '*2200']
C. Guess the Treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve...
Input41 1 1 4
OutputYES
1 second
256 megabytes
['bitmasks', 'constructive algorithms', 'dp', 'greedy', 'trees', '*2300']
B. Working outtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSummer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents th...
Input3 3100 100 100100 1 100100 100 100
Output800
2 seconds
256 megabytes
['dp', '*1600']
A. Xor-treetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees.The...
Input102 13 14 25 16 27 58 69 810 51 0 1 1 0 1 0 1 0 11 0 1 0 0 1 1 1 0 1
Output247
1 second
256 megabytes
['dfs and similar', 'trees', '*1300']
E. Police Patroltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputImagine that your city is an infinite 2D plane with Cartesian coordinate system. The only crime-affected road of your city is the x-axis. Currently, there are n criminals along the road. No police statio...
Input3 61 2 3
Output4
1 second
256 megabytes
['greedy', 'implementation', 'math', 'ternary search', '*2000']
D. Match & Catchtime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputPolice headquarter is monitoring signal on different frequency levels. They have got two suspiciously encoded strings s1 and s2 from two different frequencies as signals. They are suspecting that these t...
Inputapplepepperoni
Output2
1 second
512 megabytes
['dp', 'string suffix structures', 'strings', '*2200']
C. Checkpoststime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYour city has n junctions. There are m one-way roads between the junctions. As a mayor of the city, you have to ensure the security of all the junctions.To ensure the security, you have to build some polic...
Input31 2 331 22 33 2
Output3 1
2 seconds
256 megabytes
['dfs and similar', 'graphs', 'two pointers', '*1700']
B. Prison Transfertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of the prisoners to a prison located in another city.For this reason, he m...
Input4 3 32 3 1 1
Output2
1 second
256 megabytes
['data structures', 'implementation', '*1100']
A. Police Recruitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.Meanwhile, crimes keeps occurring within the cit...
Input3-1 -1 1
Output2
1 second
256 megabytes
['implementation', '*800']
B. Sereja and Mirroringtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties: th...
Input4 30 0 11 1 01 1 00 0 1
Output2
1 second
256 megabytes
['implementation', '*1300']
A. Sereja and Mugstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and n water mugs on it. Then all players take turns to move. During a move, a pl...
Input3 41 1 1
OutputYES
1 second
256 megabytes
['implementation', '*800']
E. Sereja and Setstime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's assume that set S consists of m distinct intervals [l1, r1], [l2, r2], ..., [lm, rm] (1 ≤ li ≤ ri ≤ n; li, ri are integers).Let's assume that f(S) is the maximum number of intervals that you c...
Input3 1
Output23
1.5 seconds
256 megabytes
['dp', '*2500']
D. Sereja and Squarestime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSereja has painted n distinct points on the plane. The coordinates of each point are integers. Now he is wondering: how many squares are there with sides parallel to the coordinate axes and with po...
Input50 00 22 02 21 1
Output1
2 seconds
512 megabytes
['binary search', 'data structures', 'hashing', '*2300']
C. Sereja and Two Sequencestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputSereja has two sequences a1, a2, ..., an and b1, b2, ..., bm, consisting of integers. One day Sereja got bored and he decided two play with them. The rules of the game was very simple. Sereja...
Input5 5 100000 10001 2 3 4 53 2 4 5 1
Output3
4 seconds
512 megabytes
['data structures', 'dp', '*2300']
B. Sereja and Table time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSereja has an n × m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values ...
Input5 5 21 1 1 1 11 1 1 1 11 1 0 1 11 1 1 1 11 1 1 1 1
Output1
1 second
256 megabytes
['bitmasks', 'greedy', '*2200']
A. Sereja and Swapstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:A swap operation is the following sequence of actions: choose two indexes i, j (i ≠ j); perfo...
Input10 210 -1 2 2 2 2 2 2 -1 10
Output32
1 second
256 megabytes
['brute force', 'sortings', '*1500']
E. Colored Jengatime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCold winter evenings in Tomsk are very boring — nobody wants be on the streets at such a time. Residents of Tomsk while away the time sitting in warm apartments, inventing a lot of different games. One ...
Input6RGBGRGBBBGGRBRGBRB
Output17.119213696601992
5 seconds
256 megabytes
['dfs and similar', 'dp', 'probabilities', '*2500']
D. Biathlon Tracktime limit per test4.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently an official statement of the world Olympic Committee said that the Olympic Winter Games 2030 will be held in Tomsk. The city officials decided to prepare for the Olympics thoroughly and to b...
Input6 7 483 6 25 4 8 3 3 7 94 1 6 8 7 1 11 6 4 6 4 8 67 2 6 1 6 9 41 9 8 6 3 9 24 5 6 8 4 3 7
Output4 3 6 7
4.5 seconds
256 megabytes
['binary search', 'brute force', 'constructive algorithms', 'data structures', 'dp', '*2300']
C. Magic Formulastime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPeople in the Tomskaya region like magic formulas very much. You can see some of them below.Imagine you are given a sequence of positive integer numbers p1, p2, ..., pn. Lets write down some magic form...
Input31 2 3
Output3
2 seconds
256 megabytes
['math', '*1600']
B. Megacitytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve it...
Input4 9999981 1 12 2 13 3 12 -2 1
Output2.8284271
2 seconds
256 megabytes
['binary search', 'greedy', 'implementation', 'sortings', '*1200']
A. Squatstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.For another exercise, Pasha needs exactly ...
Input4xxXx
Output1XxXx
1 second
256 megabytes
['implementation', '*900']
D. Bug in Codetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code...
Input4 22 31 41 42 1
Output6
1 second
256 megabytes
['binary search', 'data structures', 'sortings', '*1900']
A. Pasha and Hamsterstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any ...
Input4 2 31 22 3 4
Output1 1 2 2
1 second
256 megabytes
['constructive algorithms', 'implementation', '*800']
E. Playing the balltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA coder cannot sit and code all day. Sometimes it is a good idea to rise from the desk, have a rest, have small talk with colleagues and even play. The coders of the F company have their favorite bal...
Input2 51 1 15 0 1
Output1
2 seconds
256 megabytes
['geometry', '*2600']
D. Cup Tricktime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.The point is to trick the spectator's attentio...
Input2 12 1
Output2 1
3 seconds
256 megabytes
['data structures', '*2200']
C. Bug in Codetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code...
Input4 22 31 41 42 1
Output6
1 second
256 megabytes
['data structures', 'graphs', 'implementation', 'two pointers', '*1900']
B. Online Meetingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the ...
Input5 4+ 1+ 2- 2- 1
Output41 3 4 5
1 second
256 megabytes
['implementation', '*1800']
A. Start Uptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?The market analysts came up with a very smart pl...
InputAHA
OutputYES
1 second
256 megabytes
['implementation', '*1000']
E. Tricky Passwordtime limit per test3.5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputIn order to ensure confidentiality, the access to the "Russian Code Cup" problems is password protected during the problem development process.To select a password, the jury can generate a special t...
Input61 2 2 2 3 132 2 31 3 32 3 4
Output21
3.5 seconds
512 megabytes
['data structures', '*3100']
D. Big Problems for Organizerstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Finals of the "Russian Code Cup" 2214 will be held in n hotels. Two hotels (let's assume that they are the main hotels), will host all sorts of events, and the remaining hotels will ac...
Input32 33 132 12 33 1
Output111
2 seconds
256 megabytes
['data structures', 'graphs', 'trees', '*2800']
E. Square Tabletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile resting on the ship after the "Russian Code Cup" a boy named Misha invented an interesting game. He promised to give his quadrocopter to whoever will be the first one to make a rectangular table of ...
Input1 1
Output1
1 second
256 megabytes
['constructive algorithms', 'math', 'probabilities', '*2400']
D. Cunning Genatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solv...
Input2 2 1100 1 12100 2 11
Output202
1 second
256 megabytes
['bitmasks', 'dp', 'greedy', 'sortings', '*1900']
C. Footballtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against ...
Input3 1
Output31 22 33 1
1 second
256 megabytes
['constructive algorithms', 'graphs', 'implementation', '*1400']
B. Crashtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring the "Russian Code Cup" programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent se...
Input20 11 1
OutputYES
1 second
256 megabytes
['implementation', '*1400']
A. Eliminationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe finalists of the "Russian Code Cup" competition in 2214 will be the participants who win in one of the elimination rounds.The elimination rounds are divided into main and additional. Each of the main e...
Input1 107 21
Output2
1 second
256 megabytes
['dp', 'implementation', 'math', '*1500']
E. President's Pathtime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGood old Berland has n cities and m roads. Each road connects a pair of distinct cities and is bidirectional. Between any pair of cities, there is at most one road. For each road, we know its length....
Input5 61 2 12 3 13 4 14 1 12 4 24 5 4
Output1 4 1 2 1 5 6 1 2 1
4 seconds
256 megabytes
['dp', 'graphs', 'shortest paths', '*2500']
D. Population Sizetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarpus develops an interesting theory about the interrelation of arithmetic progressions with just everything in the world. His current idea is that the population of the capital of Berland changes...
Input98 6 4 2 1 4 7 10 2
Output3
1 second
256 megabytes
['greedy', 'implementation', 'math', '*2400']
C. Booking Systemtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInnovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!A restaurant called "Dijkstra's Place" has started thinking about optimizing the bo...
Input310 502 1005 3034 6 9
Output2 1302 13 2
1 second
256 megabytes
['binary search', 'dp', 'greedy', 'implementation', '*1600']
B. Art Uniontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA well-known art union called "Kalevich is Alive!" manufactures objects d'art (pictures). The union consists of n painters who decided to organize their work as follows.Each painter uses only the color that ...
Input5 112345
Output1 3 6 10 15
1 second
256 megabytes
['brute force', 'dp', 'implementation', '*1300']
A. Guess a number!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.The rules are simple. The host thinks of an integer y and the participants gu...
Input4>= 1 Y< 3 N<= -3 N> 55 N
Output17
1 second
256 megabytes
['greedy', 'implementation', 'two pointers', '*1400']
B. Mashmokh and Tokenstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end ...
Input5 1 412 6 11 9 1
Output0 2 3 1 1
1 second
256 megabytes
['binary search', 'greedy', 'implementation', 'math', '*1500']
A. Mashmokh and Lightstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n...
Input5 44 3 1 2
Output1 1 3 4 4
1 second
256 megabytes
['implementation', '*900']
E. Mashmokh's Designed Problemtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputAfter a lot of trying, Mashmokh designed a problem and it's your job to solve it.You have a tree T with n vertices. Each vertex has a unique index from 1 to n. The root of T has index 1. F...
Input4 91 21 31 401 1 42 4 21 3 43 13 22 3 21 1 23 13 2
Output3224134
4 seconds
512 megabytes
['data structures', '*3200']
D. Mashmokh and Water Tankstime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard outputMashmokh is playing a new game. In the beginning he has k liters of water and p coins. Additionally he has a rooted tree (an undirected connected acyclic graph) that consists of m vertices. Ea...
Input10 2 11 21 33 43 52 66 86 79 88 10
Output2
1 second
512 megabytes
['binary search', 'data structures', 'greedy', 'trees', 'two pointers', '*2300']
C. Mashmokh and Reverse Operationtime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputMashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of ...
Input22 1 4 341 2 0 2
Output0660
4 seconds
512 megabytes
['combinatorics', 'divide and conquer', '*2100']
B. Mashmokh and ACMtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. ...
Input3 2
Output5
1 second
256 megabytes
['combinatorics', 'dp', 'number theory', '*1400']
A. Mashmokh and Numberstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. In this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly...
Input5 2
Output1 2 3 4 5
1 second
256 megabytes
['constructive algorithms', 'number theory', '*1500']
E. Maze 2Dtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe last product of the R2 company in the 2D games' field is a new revolutionary algorithm of searching for the shortest path in a 2 × n maze.Imagine a maze that looks like a 2 × n rectangle, divided into uni...
Input4 7.X.....X5 11 37 71 46 14 75 7
Output1405222
2 seconds
256 megabytes
['data structures', 'divide and conquer', '*2200']
D. 2048time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe programmers from the R2 company love playing 2048. One day, they decided to invent their own simplified version of this game — 2k on a stripe.Imagine an infinite in one direction stripe, consisting of unit sq...
Input7 42 2 4 2 2 2 2
Output1
1 second
256 megabytes
['bitmasks', 'dp', '*2000']
C. Jeopardy!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals ...
Input4 11 3 7 53
Output18
1 second
256 megabytes
['greedy', 'math', '*1400']
B. Spyke Chattingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program...
Input3 4 51 1 1 11 0 1 11 1 0 01 13 11 32 43 2
Output3 3 1
1 second
256 megabytes
['implementation', '*1300']
A. Data Recoverytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputNot so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.The testing goes in n s...
Input2 1 1 21
OutputCorrect
1 second
256 megabytes
['implementation', '*1200']
E. E-mail Addressestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne of the most important products of the R1 company is a popular @r1.com mail service. The R1 mailboxes receive and send millions of emails every day.Today, the online news thundered with terrible in...
Input[email protected]
Output18
1 second
256 megabytes
['implementation', '*1900']
D. Giving Awardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe employees of the R1 company often spend time together: they watch football, they go camping, they solve contests. So, it's no big deal that sometimes someone pays for someone else.Today is the day of...
Input2 11 2
Output2 1
1 second
256 megabytes
['dfs and similar', '*2000']
C. Patterntime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDevelopers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often u...
Input2?ab??b
Outputxab
1 second
256 megabytes
['implementation', 'strings', '*1200']
B. Network Configurationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer ...
Input3 240 20 30
Output30
1 second
256 megabytes
['greedy', 'sortings', '*900']
A. Postertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the ma...
Input2 2R1
OutputPRINT 1LEFTPRINT R
1 second
256 megabytes
['greedy', 'implementation', '*900']
C. Kickertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one ...
Input1 100100 199 9999 99
OutputTeam 1
1 second
256 megabytes
['implementation', '*1700']
B. Multi-core Processortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.At each cycle each core of th...
Input4 3 51 0 01 0 22 3 13 2 0
Output1130
1 second
256 megabytes
['implementation', '*1600']
A. Password Checktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have probably registered on Internet sites many times. And each time you should enter your invented password. Usually the registration form automatically checks the password's crypt resistance. If t...
Inputabacaba
OutputToo weak
1 second
256 megabytes
['*special problem', 'implementation', '*800']
I. Feed the Golorptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputGolorps are mysterious creatures who feed on variables. Golorp's name is a program in some programming language. Some scientists believe that this language is Befunge; golorps are tantalizingly silent....
Input?(_-_/___*__):-___>__.
Output0010
1 second
256 megabytes
['*special problem', '*2400']
H. A + B Strikes Backtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Wa...
Input5 14
Output19
1 second
256 megabytes
['*special problem', 'brute force', 'constructive algorithms', 'dsu', 'implementation', '*1500']
G. On a planetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInputThe first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane.Each of the next n lines contains two real coordinates xi and yi of the point, specified with exactly 2 frac...
Input8-2.14 2.06-1.14 2.04-2.16 1.46-2.14 0.70-1.42 0.40-0.94 -0.48-1.42 -1.28-2.16 -1.62
Output5.410
1 second
256 megabytes
['*special problem', 'geometry', '*2200']
F. 000001time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputInputThe input contains a single integer a (1 ≤ a ≤ 64).OutputOutput a single integer.ExamplesInput2Output1Input4Output2Input27Output5Input42Output6
Input2
Output1
1 second
256 megabytes
['*special problem', '*1900']
E. Dometime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output InputThe input contains a single floating-point number x with exactly 6 decimal places (0 < x < 5).OutputOutput two integers separated by a single space. Each integer should be between 1 and 10, inclusive. If s...
Input1.200000
Output3 2
1 second
256 megabytes
['*special problem', '*1800']
D. Big Datatime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Petya wanted to give an April Fools Day present to some scientists. After some hesitation he decided to give them the array that he got as a present in Codeforces Round #153 (Div.2). The scientists rej...
Input1
Output1
1 second
256 megabytes
['*special problem', '*1700']
C. Magnum Opustime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputSalve, mi amice.Et tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.Rp:    I Aqua Fortis    I Aqua Regia    II Amalgama ...
Input2 4 6 8 10
Output1
1 second
256 megabytes
['*special problem', '*1700']
A. The Great Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTwo teams meet in The Game World Championship. Some scientists consider this game to be the most intellectually challenging game in the world. You are given two strings describing the teams' actions in ...
Input[]()[]8<8<[]()8<
OutputTEAM 2 WINS
1 second
256 megabytes
['*special problem', '*1700']
B. Garlandtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is...
Inputaaabbacaabbccac
Output6
1 second
256 megabytes
['implementation', '*1200']
A. Line to Cashiertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products...
Input111
Output20
1 second
256 megabytes
['implementation', '*900']
E. k-d-sequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWe'll call a sequence of integers a good k-d sequence if we can add to it at most k numbers in such a way that after the sorting the sequence will be an arithmetic progression with difference d.You got h...
Input6 1 24 3 2 8 6 2
Output3 5
2 seconds
256 megabytes
['data structures', '*3100']
D. Largest Submatrix 3time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given matrix a of size n × m, its elements are integers. We will assume that the rows of the matrix are numbered from top to bottom from 1 to n, the columns are numbered from left to right...
Input3 31 3 14 5 62 6 1
Output6
3 seconds
256 megabytes
['dp', 'hashing', '*2700']
C. Curious Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou've got an array consisting of n integers: a[1], a[2], ..., a[n]. Moreover, there are m queries, each query can be described by three integers li, ri, ki. Query li, ri, ki means that we should add t...
Input5 10 0 0 0 01 5 0
Output1 1 1 1 1
2 seconds
256 megabytes
['brute force', 'combinatorics', 'implementation', 'math', '*2500']
B. Long Pathtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one....
Input21 2
Output4
1 second
256 megabytes
['dp', 'implementation', '*1600']
A. Triangletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate a...
Input1 1
OutputNO
1 second
256 megabytes
['brute force', 'geometry', 'implementation', 'math', '*1600']
E. Hamming Triplestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Chris is having a nightmare. Even in dreams all he thinks about is math.Chris dreams about m binary strings of length n, indexed with numbers from 1 to m. The most horrifying part is that the bi...
Input5 40 30 51 41 5
Output3
1 second
256 megabytes
['implementation', 'math', 'two pointers', '*2800']
D. Hill Climbingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem has nothing to do with Little Chris. It is about hill climbers instead (and Chris definitely isn't one).There are n hills arranged on a line, each in the form of a vertical line segment with...
Input61 42 13 24 36 47 433 15 62 3
Output5 6 3
1 second
256 megabytes
['dfs and similar', 'geometry', 'trees', '*2200']
E. Graph Cuttingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Chris is participating in a graph cutting contest. He's a pro. The time has come to test his skills to the fullest.Chris is given a simple undirected connected graph with n vertices (numbered fro...
Input8 121 22 33 44 11 32 43 53 65 66 76 87 8
Output1 2 41 3 21 4 35 3 65 6 86 7 8
2 seconds
256 megabytes
['dfs and similar', 'graphs', '*2300']
D. Toy Sumtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris.There are exactly s blocks in Chris's set, each block has a unique ...
Input31 4 5
Output2999993 1000000
1 second
256 megabytes
['greedy', 'implementation', 'math', '*1700']
C. Unusual Producttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix.The dot product of two integer number vectors x and y of size n is the s...
Input31 1 10 1 11 0 01232 332 22 21 3331 22 11 13
Output01001
1 second
256 megabytes
['implementation', 'math', '*1600']
B. Domino Effecttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".Chris arranges n dominoe...
Input14.L.R...LR..L..
Output4
1 second
256 megabytes
['*1100']
A. Gravity Fliptime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLittle Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.There are n columns of toy c...
Input43 2 1 2
Output1 2 2 3
1 second
256 megabytes
['greedy', 'implementation', 'sortings', '*900']
E. Maze 1Dtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera has a strip infinite in both directions and consisting of cells. The cells are numbered by integers. The cell number 0 has a robot.The robot has instructions — the sequence of moves that he must perform...
InputRR
Output1
1 second
256 megabytes
['binary search', 'greedy', 'implementation', '*2200']
D. Minesweeper 1Dtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputGame "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contai...
Input?01???
Output4
2 seconds
512 megabytes
['dp', 'implementation', '*1900']
C. Restore Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera had an undirected connected graph without self-loops and multiple edges consisting of n vertices. The graph had an interesting property: there were at most k edges adjacent to each of its vertices...
Input3 20 1 1
Output31 21 33 2
1 second
256 megabytes
['dfs and similar', 'graphs', 'sortings', '*1800']
B. Marathontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0, 0) and the ...
Input2 52
Output1.0000000000 2.00000000002.0000000000 0.0000000000
1 second
256 megabytes
['implementation', 'math', '*1500']
A. Valera and Xtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher...
Input5xoooxoxoxosoxoooxoxoxooox
OutputNO
1 second
256 megabytes
['implementation', '*1000']
E. Two Rooted Treestime limit per test4 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputYou have two rooted undirected trees, each contains n vertices. Let's number the vertices of each tree with integers from 1 to n. The root of each tree is at vertex 1. The edges of the first tree are...
Input51 1 1 14 2 1 13
OutputBlue3Red1 3Blue1 2Red2
4 seconds
512 megabytes
['data structures', 'implementation', 'trees', '*2900']
D. Beautiful Pairs of Numberstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe sequence of integer pairs (a1, b1), (a2, b2), ..., (ak, bk) is beautiful, if the following statements are fulfilled: 1 ≤ a1 ≤ b1 < a2 ≤ b2 < ... < ak ≤ bk ≤ n, where n is a given posi...
Input61 12 12 23 13 23 3
Output130620
3 seconds
256 megabytes
['combinatorics', 'dp', '*2300']
E. Strictly Positive Matrixtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have matrix a of size n × n. Let's number the rows of the matrix from 1 to n from top to bottom, let's number the columns from 1 to n from left to right. Let's use aij to represent the ele...
Input21 00 1
OutputNO
1 second
256 megabytes
['graphs', 'math', '*2200']
D. Upgrading Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have an array of positive integers a[1], a[2], ..., a[n] and a set of bad prime numbers b1, b2, ..., bm. The prime numbers that do not occur in the set b are considered good. The beauty of array a ...
Input5 24 20 34 10 102 5
Output-2
1 second
256 megabytes
['dp', 'greedy', 'math', 'number theory', '*1800']
C. Searching for Graphtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLet's call an undirected graph of n vertices p-interesting, if the following conditions fulfill: the graph contains exactly 2n + p edges; the graph doesn't contain self-loops and multiple edges;...
Input16 0
Output1 21 31 41 51 62 32 42 52 63 43 53 6
1 second
256 megabytes
['brute force', 'constructive algorithms', 'graphs', '*1500']
B. Trees in a Rowtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height ai meters. Today the Queen decided to update the scenery of her garden. She w...
Input4 11 2 1 5
Output2+ 3 2- 4 1
1 second
256 megabytes
['brute force', 'implementation', '*1400']
A. Nutstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.You are minimalist. ...
Input3 10 3 3
Output2
1 second
256 megabytes
['greedy', 'math', '*1100']