problem_statement stringlengths 147 8.53k | input stringlengths 1 771 | output stringlengths 1 592 ⌀ | time_limit stringclasses 32
values | memory_limit stringclasses 21
values | tags stringlengths 6 168 |
|---|---|---|---|---|---|
B. Codeforces World Finalstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe king Copa often has been reported about the Codeforces site, which is rapidly getting more and more popular among the brightest minds of the humanity, who are using it for training and com... | Input01.01.9801.01.80 | OutputYES | 2 seconds | 256 megabytes | ['implementation', '*1700'] |
A. Accountingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself.The total income A of his kingdom during 0-th year is k... | Input2 18 2 | Output3 | 2 seconds | 256 megabytes | ['brute force', 'math', '*1400'] |
E. Quarreltime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFriends Alex and Bob live in Bertown. In this town there are n crossroads, some of them are connected by bidirectional roads of equal length. Bob lives in a house at the crossroads number 1, Alex — in a house ... | Input2 11 2 | Output11 2 2 1 | 1 second | 256 megabytes | ['graphs', 'shortest paths', '*2400'] |
D. Ant on the Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConnected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too.An ant stands at the root of some tree. He sees that t... | Input31 22 33 | Output1 2 3 2 1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'dfs and similar', 'trees', '*2000'] |
C. Mail Stampstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Bob got a letter in an envelope. Bob knows that when Berland's post officers send a letter directly from city «A» to city «B», they stamp it with «A B», or «B A». Unfortunately, often it is imposs... | Input21 100100 2 | Output2 100 1 | 2 seconds | 256 megabytes | ['data structures', 'dfs and similar', 'graphs', 'implementation', '*1700'] |
B. Traffic Lightstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA car moves from point A to point B at speed v meters per second. The action takes place on the X-axis. At the distance d meters from A there are traffic lights. Starting from time 0, for the first g s... | Input2 1 3 4 5 | Output0.66666667 | 2 seconds | 256 megabytes | ['implementation', '*1500'] |
A. Spit Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted... | Input20 11 -1 | OutputYES | 2 seconds | 256 megabytes | ['brute force', '*1000'] |
E. DravDe saves the worldtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputHow horrible! The empire of galactic chickens tries to conquer a beautiful city "Z", they have built a huge incubator that produces millions of chicken soldiers a day, and fenced it around. The ... | Input40 01 01 10 10 -11 0 1-10 1 -1 | Output1.00000000 0.00000000 | 1 second | 256 megabytes | ['geometry', 'math', '*2800'] |
D. Don't fear, DravDe is kindtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA motorcade of n trucks, driving from city «Z» to city «З», has approached a tunnel, known as Tunnel of Horror. Among truck drivers there were rumours about monster DravDe, who hunts for dr... | Input51 1 0 31 1 1 21 1 2 11 1 3 02 1 3 0 | Output41 2 3 5 | 2 seconds | 256 megabytes | ['binary search', 'data structures', 'dp', 'hashing', '*2400'] |
C. Bath Queuetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n students living in the campus. Every morning all students wake up at the same time and go to wash. There are m rooms with wash basins. The i-th of these rooms contains ai wash basins. Every stu... | Input1 12 | Output1.00000000000000000000 | 2 seconds | 256 megabytes | ['combinatorics', 'dp', 'probabilities', '*2200'] |
B. pSorttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. ... | Input55 4 3 2 11 1 1 1 1 | OutputYES | 2 seconds | 256 megabytes | ['dfs and similar', 'dsu', 'graphs', '*1600'] |
A. Bender Problemtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRobot Bender decided to make Fray a birthday present. He drove n nails and numbered them from 1 to n in some order. Bender decided to make a picture using metal rods. The picture is a closed polyline, ... | Input4 20 00 22 22 04 4 | OutputYES1 -1 2 -1 | 2 seconds | 256 megabytes | ['implementation', '*1600'] |
E. Number With The Given Amount Of Divisorstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018.InputThe first line ... | Input4 | Output6 | 2 seconds | 256 megabytes | ['brute force', 'dp', 'number theory', '*2000'] |
D. Ring Road 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is well known that Berland has n cities, which form the Silver ring — cities i and i + 1 (1 ≤ i < n) are connected by a road, as well as the cities n and 1. The goverment have decided to build m new ro... | Input4 21 32 4 | Outputio | 2 seconds | 256 megabytes | ['2-sat', 'dfs and similar', 'dsu', 'graphs', '*2200'] |
C. Unordered Subsequencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a... | Input567 499 600 42 23 | Output31 3 5 | 2 seconds | 256 megabytes | ['constructive algorithms', 'greedy', '*1900'] |
B. Tournamenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a ... | Input44 24 12 32 13 1 | Output4 3 | 2 seconds | 256 megabytes | ['bitmasks', 'brute force', 'dfs and similar', 'greedy', '*1300'] |
A. Next Testtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it i... | Input31 7 2 | Output3 | 2 seconds | 256 megabytes | ['implementation', 'sortings', '*1200'] |
E. Multithreadingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given the following concurrent program. There are N processes and the i-th process has the following pseudocode: repeat ni times yi := y y := yi + 1end repeatHere y is a shared variable. ... | Input1 1011 | OutputNo | 2 seconds | 256 megabytes | ['constructive algorithms', '*2400'] |
D. Ticketstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs a big fan of Formula One, Charlie is really happy with the fact that he has to organize ticket sells for the next Grand Prix race in his own city. Unfortunately, the finacial crisis is striking everywhere ... | Input5 3 1 | Output0.857143 | 2 seconds | 256 megabytes | ['combinatorics', 'math', 'probabilities', '*2400'] |
C. Parquettime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce Bob decided to lay a parquet floor in his living room. The living room is of size n × m metres. Bob had planks of three types: a planks 1 × 2 meters, b planks 2 × 1 meters, and c planks 2 × 2 meters. Hel... | Input2 6 2 2 1 | Outputaabccaaabdda | 2 seconds | 256 megabytes | ['combinatorics', 'constructive algorithms', 'greedy', 'implementation', '*2000'] |
B. Regular Bracket Sequencetime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» an... | Input(()))( | Output4 | 5 seconds | 256 megabytes | ['greedy', '*1400'] |
A. Almost Primetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which ar... | Input10 | Output2 | 2 seconds | 256 megabytes | ['number theory', '*900'] |
E. Testtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data to his problem is one string. Bob has 3 wrong solutions to this problem. The f... | Inputabbccd | Output4 | 2 seconds | 256 megabytes | ['hashing', 'strings', '*2200'] |
D. Roads not only in Berlandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBerland Government decided to improve relations with neighboring countries. First of all, it was decided to build new roads so that from each city of Berland and neighboring countries it bec... | Input21 2 | Output0 | 2 seconds | 256 megabytes | ['dsu', 'graphs', 'trees', '*1900'] |
C. Roads in Berlandtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities numbered from 1 to n in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is... | Input20 55 011 2 3 | Output3 | 2 seconds | 256 megabytes | ['graphs', 'shortest paths', '*1900'] |
B. Phone numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPhone number in Berland is a sequence of n digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to r... | Input6549871 | Output54-98-71 | 2 seconds | 256 megabytes | ['implementation', '*1100'] |
A. IQ testtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in e... | Input52 4 7 8 10 | Output3 | 2 seconds | 256 megabytes | ['brute force', '*1300'] |
E. Berland collidertime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently the construction of Berland collider has been completed. Collider can be represented as a long narrow tunnel that contains n particles. We associate with collider 1-dimensional coordinate ... | Input3-5 90 15 -1 | Output1.00000000000000000000 | 1.5 seconds | 256 megabytes | ['binary search', '*2300'] |
D. Broken robottime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken and behaves rather strangely (randomly). The board consists of N rows and M colu... | Input10 1010 4 | Output0.0000000000 | 2 seconds | 256 megabytes | ['dp', 'math', 'probabilities', '*2400'] |
C. Sequence of pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given the following points with integer coordinates on the plane: M0, A0, A1, ..., An - 1, where n is odd number. Now we define the following infinite sequence of points Mi: Mi is symmetric... | Input3 40 01 12 3-5 3 | Output14 0 | 2 seconds | 256 megabytes | ['geometry', 'implementation', 'math', '*1800'] |
B. F1 Championstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputFormula One championship consists of series of races called Grand Prix. After every race drivers receive points according to their final position. Only the top 10 drivers receive points in the following ... | Input33HamiltonVettelWebber2WebberVettel2HamiltonVettel | OutputVettelHamilton | 2 seconds | 256 megabytes | ['implementation', '*1500'] |
A. Ring roadtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Berland decided to keep up with new trends. Formerly all n cities ... | Input31 3 11 2 13 2 1 | Output1 | 2 seconds | 256 megabytes | ['graphs', '*1400'] |
E. Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputRecently Bob invented a new game with a tree (we should remind you, that a tree is a connected graph without cycles): he deletes any (possibly, zero) amount of edges of the tree, and counts the product of sizes ... | Input51 22 33 44 5 | Output6 | 2 seconds | 256 megabytes | ['dp', '*2500'] |
D. Tetragontime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're given the centers of three equal sides of a strictly convex tetragon. Your task is to restore the initial tetragon.InputThe first input line contains one number T — amount of tests (1 ≤ T ≤ 5·104). Ea... | Input31 1 2 2 3 30 1 1 0 2 29 3 7 9 9 8 | OutputNOYES3.5 1.5 0.5 2.5 -0.5 -0.5 2.5 0.5NO | 3 seconds | 256 megabytes | ['geometry', 'math', '*2600'] |
C. Oranges and Applestime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn 2N - 1 boxes there are apples and oranges. Your task is to choose N boxes so, that they will contain not less than half of all the apples and not less than half of all the oranges.InputThe fir... | Input2210 155 720 1810 0 | OutputYES1 3YES1 | 1.5 seconds | 256 megabytes | ['constructive algorithms', 'sortings', '*2500'] |
B. Partytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputn people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 ... | Input13 | Output1 | 2 seconds | 256 megabytes | ['constructive algorithms', 'graphs', 'math', '*1600'] |
A. You're Given a String...time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're given a string of lower-case Latin letters. Your task is to find the length of its longest substring that can be met in the string at least twice. These occurrences can overlap (see sa... | Inputabcd | Output0 | 2 seconds | 256 megabytes | ['brute force', 'greedy', '*1200'] |
E. Schemetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputTo learn as soon as possible the latest news about their favourite fundamentally new operating system, BolgenOS community from Nizhni Tagil decided to develop a scheme. According to this scheme a community mem... | Input33 3 2 | Output13 1 | 2 seconds | 256 megabytes | ['dfs and similar', 'graphs', 'trees', '*2300'] |
D. Segmentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through ... | Input20 22 5 | Output12 | 1 second | 256 megabytes | ['greedy', 'sortings', '*1900'] |
C. System Administratortime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBob got a job as a system administrator in X corporation. His first task was to connect n servers with the help of m two-way direct connection so that it becomes possible to transmit data from one... | Input5 6 3 | Output1 22 33 44 51 33 5 | 1 second | 256 megabytes | ['graphs', '*1700'] |
B. Bargaining Tabletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBob wants to put a new bargaining table in his office. To do so he measured the office room thoroughly and drew its plan: Bob's office room is a rectangular room n × m meters. Each square meter of th... | Input3 3000010000 | Output8 | 2 seconds | 256 megabytes | ['brute force', 'dp', '*1500'] |
A. Second Order Statisticstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is ... | Input41 2 2 -4 | Output1 | 2 seconds | 256 megabytes | ['brute force', '*800'] |
D. Traveling Graphtime limit per test0.5 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputYou are given undirected weighted graph. Find the length of the shortest cycle which starts from the vertex 1 and passes throught all the edges at least once. Graph may contain multiply edges between ... | Input3 31 2 12 3 13 1 1 | Output3 | 0.5 second | 64 megabytes | ['bitmasks', 'graph matchings', 'graphs', '*2400'] |
C. Stripe 2time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputOnce Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe in... | Input41 2 3 3 | Output1 | 1 second | 64 megabytes | ['binary search', 'dp', 'sortings', '*2000'] |
B. Intersectiontime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0.Write the program which finds the numbe... | Input1 1 02 2 0 | Output-1 | 1 second | 256 megabytes | ['implementation', 'math', '*2000'] |
A. Jabber IDtime limit per test0.5 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores character... | Input[email protected] | OutputYES | 0.5 second | 256 megabytes | ['implementation', 'strings', '*1900'] |
C. Dijkstra?time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputYou are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.InputThe first line contains two integers n and... | Input5 61 2 22 5 52 3 41 4 14 3 33 5 1 | Output1 4 3 5 | 1 second | 64 megabytes | ['graphs', 'shortest paths', '*1900'] |
B. Equationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order.InputThe first line contains three integer numbers A, B... | Input1 -5 6 | Output22.00000000003.0000000000 | 1 second | 256 megabytes | ['math', '*2000'] |
A. BerOS file systemtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputThe new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/... | Input//usr///local//nginx/sbin | Output/usr/local/nginx/sbin | 2 seconds | 64 megabytes | ['implementation', '*1700'] |
E. Fairytime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked into her magic ball and said that soon the fine young man will meet the mo... | Input4 41 21 32 43 4 | Output41 2 3 4 | 1.5 seconds | 256 megabytes | ['dfs and similar', 'divide and conquer', 'dsu', '*2900'] |
D. Pointstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPete and Bob invented a new interesting game. Bob takes a sheet of paper and locates a Cartesian coordinate system on it as follows: point (0, 0) is located in the bottom-left corner, Ox axis is directed right... | Input7add 1 1add 3 4find 0 0remove 1 1find 0 0add 1 1find 0 0 | Output1 13 41 1 | 2 seconds | 256 megabytes | ['data structures', '*2800'] |
C. Deletion of Repeatstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOnce Bob saw a string. It contained so many different letters, that the letters were marked by numbers, but at the same time each letter could be met in the string at most 10 times. Bob didn't lik... | Input61 2 3 1 2 3 | Output31 2 3 | 2 seconds | 256 megabytes | ['greedy', 'hashing', 'string suffix structures', '*2200'] |
B. Checkout Assistanttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputBob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spend... | Input42 100 201 51 3 | Output8 | 1 second | 256 megabytes | ['dp', '*1900'] |
A. World Football Cuptime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputEveryone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to ch... | Input4ABCDA-B 1:1A-C 2:2A-D 1:0B-C 1:0B-D 0:3C-D 0:3 | OutputAD | 2 seconds | 64 megabytes | ['implementation', '*1400'] |
E. Flag 2time limit per test2 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputAccording to a new ISO standard, a flag of every country should have, strangely enough, a chequered field n × m, each square should be wholly painted one of 26 colours. The following restrictions are set: In... | Input3 4aaaabbbbcccc | Output6ababbabaacac | 2 seconds | 128 megabytes | ['dp', '*2000'] |
D. Seller Bobtime limit per test2 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputLast year Bob earned by selling memory sticks. During each of n days of his work one of the two following events took place: A customer came to Bob and asked to sell him a 2x MB memory stick. If Bob had ... | Input7win 10win 5win 3sell 5sell 3win 10sell 10 | Output1056 | 2 seconds | 128 megabytes | ['brute force', 'dp', 'greedy', '*2000'] |
C. Stripetime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputOnce Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe int... | Input91 5 -6 7 9 -16 0 -2 2 | Output3 | 2 seconds | 64 megabytes | ['data structures', 'implementation', '*1200'] |
B. Platformstime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputIn one one-dimensional world there are n platforms. Platform with index k (platforms are numbered from 1) is a segment with coordinates [(k - 1)m, (k - 1)m + l], and l < m. Grasshopper Bob starts to jump alo... | Input2 2 5 3 | Output4 | 2 seconds | 64 megabytes | ['brute force', 'math', '*1700'] |
A. Triangletime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputAt a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three... | Input0 0 2 0 0 1 | OutputRIGHT | 2 seconds | 64 megabytes | ['brute force', 'geometry', '*1500'] |
E. Palisectiontime limit per test2 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputIn an English class Nick had nothing to do at all, and remembered about wonderful strings called palindromes. We should remind you that a string is called a palindrome if it can be read the same way both ... | Input4babb | Output6 | 2 seconds | 128 megabytes | ['strings', '*2900'] |
D. Notepadtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputNick is attracted by everything unconventional. He doesn't like decimal number system any more, and he decided to study other number systems. A number system with base b caught his attention. Before he starts ... | Input2 3 3 | Output1 | 2 seconds | 64 megabytes | ['number theory', '*2400'] |
C. Balancetime limit per test3 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputNick likes strings very much, he likes to rotate them, sort them, rearrange characters within a string... Once he wrote a random string of characters a, b, c on a piece of paper and began to perform the follo... | Input4abca | Output7 | 3 seconds | 128 megabytes | ['dp', '*2500'] |
B. Hierarchytime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputNick's company employed n people. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that each employee, except one, has exactly one supervisor). Th... | Input47 2 3 141 2 52 4 13 4 11 3 5 | Output11 | 2 seconds | 64 megabytes | ['dfs and similar', 'dsu', 'greedy', 'shortest paths', '*1500'] |
A. Noldbach problemtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputNick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he d... | Input27 2 | OutputYES | 2 seconds | 64 megabytes | ['brute force', 'math', 'number theory', '*1000'] |
E. Fishtime limit per test3 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputn fish, numbered from 1 to n, live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the s... | Input20 0.50.5 0 | Output0.500000 0.500000 | 3 seconds | 128 megabytes | ['bitmasks', 'dp', 'probabilities', '*1900'] |
D. Loggingtime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputThe main server of Gomble company received a log of one top-secret process, the name of which can't be revealed. The log was written in the following format: «[date:time]: message», where for each «[date:time]»... | Input5[05:00 a.m.]: Server is started[05:00 a.m.]: Rescan initialized[01:13 p.m.]: Request processed[01:10 p.m.]: Request processed[11:40 p.m.]: Rescan completed | Output2 | 1 second | 64 megabytes | ['implementation', 'strings', '*1900'] |
C. Monitortime limit per test0.5 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputReca company makes monitors, the most popular of their models is AB999 with the screen size a × b centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the sc... | Input800 600 4 3 | Output800 600 | 0.5 second | 64 megabytes | ['binary search', 'number theory', '*1800'] |
B. Burglar and Matchestime limit per test0.5 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputA burglar got into a matches warehouse and wants to steal as many matches as possible. In the warehouse there are m containers, in the i-th container there are ai matchboxes, and each matchbox con... | Input7 35 102 53 6 | Output62 | 0.5 second | 64 megabytes | ['greedy', 'implementation', 'sortings', '*900'] |
A. Flagtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputAccording to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should c... | Input3 3000111222 | OutputYES | 2 seconds | 64 megabytes | ['implementation', '*800'] |
E. Trianglestime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputLast summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He expla... | Input2 | Output10 | 1 second | 64 megabytes | ['combinatorics', 'dp', '*2600'] |
D. Maptime limit per test2 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard outputThere is an area map that is a rectangular matrix n × m, each cell of the matrix contains the average height of a corresponding area part. Peter works for a company that has to build several cities within this ar... | Input2 2 1 21 23 5 | Output21 1 12 1 2 | 2 seconds | 128 megabytes | ['data structures', 'implementation', 'sortings', '*2500'] |
C. Industrial Nimtime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputThere are n stone quarries in Petrograd.Each quarry owns mi dumpers (1 ≤ i ≤ n). It is known that the first dumper of the i-th quarry has xi stones in it, the second dumper has xi + 1 stones in it, the ... | Input22 13 2 | Outputtolik | 2 seconds | 64 megabytes | ['games', '*2000'] |
B. Lasertime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputPetya is the most responsible worker in the Research Institute. So he was asked to make a very important experiment: to melt the chocolate bar with a new laser device. The device consists of a rectangular field o... | Input24 4 1 1 3 34 3 1 1 2 2 | Output82 | 1 second | 64 megabytes | ['math', '*1800'] |
A. Cottage Villagetime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputA new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the... | Input2 20 46 2 | Output4 | 2 seconds | 64 megabytes | ['implementation', 'sortings', '*1200'] |
E. Camelstime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputBob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with t humps, representing them as polylines in th... | Input6 1 | Output6 | 2 seconds | 64 megabytes | ['dp', '*1900'] |
D. Two Pathstime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputAs you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the road... | Input41 22 33 4 | Output1 | 2 seconds | 64 megabytes | ['dfs and similar', 'dp', 'graphs', 'shortest paths', 'trees', 'two pointers', '*1900'] |
C. Four Segmentstime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputSeveral months later Alex finally got his brother Bob's creation by post. And now, in his turn, Alex wants to boast about something to his brother. He thought for a while, and came to the conclusion that... | Input1 1 6 11 0 6 06 0 6 11 1 1 0 | OutputYES | 2 seconds | 64 megabytes | ['brute force', 'constructive algorithms', 'geometry', 'implementation', 'math', '*1700'] |
B. Young Photographertime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputAmong other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready... | Input3 30 714 24 6 | Output1 | 2 seconds | 64 megabytes | ['implementation', '*1000'] |
A. Lettertime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputA boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sheet with n rows and m columns. Bob shaded some of the squares on the sheet. Having seen his masterpiece, he decided to share it wit... | Input6 7.........***....*......***....*......***.. | Output****..****..*** | 1 second | 64 megabytes | ['implementation', '*800'] |
E. Holestime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputLittle Petya likes to play a lot. Most of all he likes to play a game «Holes». This is a game for one person with following rules:There are N holes located in a single row and numbered from left to right with num... | Input8 51 1 1 1 1 2 8 21 10 1 31 10 3 41 2 | Output8 78 57 3 | 1 second | 64 megabytes | ['data structures', 'dsu', '*2700'] |
D. Trianglestime limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputLittle Petya likes to draw. He drew N red and M blue points on the plane in such a way that no three points lie on the same line. Now he wonders what is the number of distinct triangles with vertices in red ... | Input4 10 010 010 105 42 1 | Output2 | 2 seconds | 64 megabytes | ['dp', 'geometry', '*2600'] |
C. Sequencetime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputLittle Petya likes to play very much. And most of all he likes to play the following game:He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to ... | Input53 2 -1 2 11 | Output4 | 1 second | 64 megabytes | ['dp', 'sortings', '*2200'] |
B. Letter Atime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputLittle Petya learns how to write. The teacher gave pupils the task to write the letter A on the sheet of paper. It is required to check whether Petya really had written the letter A.You are given three segment... | Input34 4 6 04 1 5 24 0 4 40 0 0 60 6 2 -41 1 0 10 0 0 50 5 2 -11 2 0 1 | OutputYESNOYES | 1 second | 64 megabytes | ['geometry', 'implementation', '*2000'] |
A. Numberstime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputLittle Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.Now he wonders what is an... | Input5 | Output7/3 | 1 second | 64 megabytes | ['implementation', 'math', '*1000'] |
E. Start of the seasontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBefore the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never ... | Input2 | Output0 11 0 | 2 seconds | 256 megabytes | ['constructive algorithms', '*2100'] |
D. Balltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputN ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lad... | Input31 4 24 3 22 5 3 | Output1 | 2 seconds | 256 megabytes | ['data structures', 'sortings', '*2400'] |
C. Fruitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more tha... | Input5 34 2 1 10 5appleorangemango | Output7 19 | 1 second | 256 megabytes | ['greedy', 'implementation', 'sortings', '*1100'] |
B. Correct Solution?time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to... | Input33101033 | OutputOK | 2 seconds | 256 megabytes | ['implementation', 'sortings', '*1100'] |
A. Super Agenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission ... | InputXX.....XX | OutputYES | 2 seconds | 256 megabytes | ['implementation', '*800'] |
E. Forward, march!time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputJack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequ... | InputX | Output0.000000 | 1 second | 64 megabytes | ['binary search', 'dp', 'greedy', '*2800'] |
D. A Simple Tasktime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputGiven a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges.InputThe first line of input contains two integers n and m (1 ≤ n ≤ 19, 0 ≤ m... | Input4 61 21 31 42 32 43 4 | Output7 | 2 seconds | 256 megabytes | ['bitmasks', 'dp', 'graphs', '*2200'] |
C. How Many Squares?time limit per test2 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard outputYou are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only intere... | Input28 8000100010010100001000100100000100100010000101000110100111100001110 101111111000100000100010110010001011001010100000110110010010101010101000100100100010000010001111111000 | Output12 | 2 seconds | 64 megabytes | ['implementation', '*2200'] |
B. Jumping Jacktime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputJack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only... | Input2 | Output3 | 1 second | 64 megabytes | ['math', '*1600'] |
A. Increasing Sequencetime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputA sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.You are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one elemen... | Input4 21 3 3 2 | Output3 | 1 second | 64 megabytes | ['constructive algorithms', 'implementation', 'math', '*900'] |
E. Greedy Changetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputBilly investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amoun... | Input525 10 5 2 1 | Output-1 | 2 seconds | 256 megabytes | ['constructive algorithms', '*2600'] |
D. LCIStime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem differs from one which was on the online contest.The sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for i < n.The sequence s1, s2, ..., sk is called the subsequence of the sequence a1,... | Input72 3 1 6 5 4 641 3 5 6 | Output33 5 6 | 1 second | 256 megabytes | ['dp', '*2800'] |
C. Digital Roottime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputNot long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equation AB = C is correct. Recently Bi... | Input4 | Output2 | 2 seconds | 256 megabytes | ['number theory', '*2000'] |
B. Cinema Cashiertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAll cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tick... | Input2 11 1 | Output1 1 1-1 | 1 second | 256 megabytes | ['dp', 'implementation', '*1500'] |
A. Power Consumption Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputTom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touc... | Input1 3 2 1 5 100 10 | Output30 | 1 second | 256 megabytes | ['implementation', '*900'] |
E. Interesting Graph and Applestime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputHexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is ... | Input3 21 22 3 | OutputYES11 3 | 1 second | 64 megabytes | ['dfs and similar', 'dsu', 'graphs', '*2300'] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.