contestId int64 0 1.01k | name stringlengths 2 58 | tags listlengths 0 11 | title stringclasses 523
values | time-limit stringclasses 8
values | memory-limit stringclasses 8
values | problem-description stringlengths 0 7.15k | input-specification stringlengths 0 2.05k | output-specification stringlengths 0 1.5k | demo-input listlengths 0 7 | demo-output listlengths 0 7 | note stringlengths 0 5.24k | test_cases listlengths 0 402 | timeConsumedMillis int64 0 8k | memoryConsumedBytes int64 0 537M | score float64 -1 3.99 | __index_level_0__ int64 0 621k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
603 | Pastoral Oddities | [
"data structures",
"divide and conquer",
"dsu",
"math",
"trees"
] | null | null | In the land of Bovinia there are *n* pastures, but no paths connecting the pastures. Of course, this is a terrible situation, so Kevin Sun is planning to rectify it by constructing *m* undirected paths connecting pairs of distinct pastures. To make transportation more efficient, he also plans to pave some of these new ... | The first line contains two integers *n* (2<=≤<=*n*<=≤<=100<=000) and *m* (1<=≤<=*m*<=≤<=300<=000), denoting the number of pastures and paths, respectively. The next *m* lines each contain three integers *a**i*, *b**i* and *l**i*, describing the *i*-th path. The *i*-th path connects pastures *a**i* and *b**i* (1<=≤<=*a... | Output *m* lines. The *i*-th line should contain a single integer denoting the minimum possible length of the longest path (maximum-weight edge) in a sunny paving using only the first *i* paths. If Kevin cannot pave a set of paths so that each pasture is incident to an odd number of paved paths, output <=-<=1.
Note th... | [
"4 4\n1 3 4\n2 4 8\n1 2 2\n3 4 3\n",
"3 2\n1 2 3\n2 3 4\n",
"4 10\n2 1 987\n3 2 829\n4 1 768\n4 2 608\n3 4 593\n3 2 488\n4 2 334\n2 1 204\n1 3 114\n1 4 39\n"
] | [
"-1\n8\n8\n3\n",
"-1\n-1\n",
"-1\n-1\n829\n829\n768\n768\n768\n488\n334\n204\n"
] | For the first sample, these are the paths that Kevin should pave after building the *i*-th path:
1. No set of paths works. 1. Paths 1 (length 4) and 2 (length 8). 1. Paths 1 (length 4) and 2 (length 8). 1. Paths 3 (length 2) and 4 (length 3).
In the second sample, there never exists a paving that makes Kevin hap... | [] | 46 | 0 | 0 | 571,006 | |
464 | World of Darkraft - 2 | [
"dp",
"probabilities"
] | null | null | Roma found a new character in the game "World of Darkraft - 2". In this game the character fights monsters, finds the more and more advanced stuff that lets him fight stronger monsters.
The character can equip himself with *k* distinct types of items. Power of each item depends on its level (positive integer number). ... | The first line contains two integers, *n* and *k* (1<=≤<=*n*<=≤<=105; 1<=≤<=*k*<=≤<=100). | Print a real number — expected number of earned coins after victory over *n* monsters. The answer is considered correct if its relative or absolute error doesn't exceed 10<=-<=9. | [
"1 3\n",
"2 1\n",
"10 2\n"
] | [
"1.0000000000\n",
"2.3333333333\n",
"15.9380768924\n"
] | none | [] | 30 | 0 | 0 | 571,350 | |
935 | Fafa and Array | [
"data structures",
"greedy"
] | null | null | Fafa has an array *A* of *n* positive integers, the function *f*(*A*) is defined as . He wants to do *q* queries of two types:
- 1<=*l*<=*r*<=*x* — find the maximum possible value of *f*(*A*), if *x* is to be added to one element in the range [*l*,<=<=*r*]. You can choose to which element to add *x*. - 2<=*l*<=*r*<=... | The first line contains one integer *n* (3<=≤<=*n*<=≤<=105) — the length of the array.
The second line contains *n* positive integers *a*1,<=*a*2,<=...,<=*a**n* (0<=<<=*a**i*<=≤<=109) — the array elements.
The third line contains an integer *q* (1<=≤<=*q*<=≤<=105) — the number of queries.
Then *q* lines follow, ... | For each query of type 1, print the answer to the query. | [
"5\n1 1 1 1 1\n5\n1 2 4 1\n2 2 3 1\n2 4 4 2\n2 3 4 1\n1 3 3 2\n",
"5\n1 2 3 4 5\n4\n1 2 4 2\n2 2 4 1\n2 3 4 1\n1 2 4 2\n"
] | [
"2\n8\n",
"6\n10\n"
] | none | [
{
"input": "5\n1 1 1 1 1\n5\n1 2 4 1\n2 2 3 1\n2 4 4 2\n2 3 4 1\n1 3 3 2",
"output": "2\n8"
},
{
"input": "5\n1 2 3 4 5\n4\n1 2 4 2\n2 2 4 1\n2 3 4 1\n1 2 4 2",
"output": "6\n10"
},
{
"input": "5\n1000 100 1 100 10000\n4\n1 2 4 10\n1 2 4 1000\n1 2 4 100\n1 2 4 59",
"output": "10998\n... | 46 | 0 | 0 | 571,708 | |
681 | Runaway to a Shadow | [
"geometry",
"sortings"
] | null | null | Dima is living in a dormitory, as well as some cockroaches.
At the moment 0 Dima saw a cockroach running on a table and decided to kill it. Dima needs exactly *T* seconds for aiming, and after that he will precisely strike the cockroach and finish it.
To survive the cockroach has to run into a shadow, cast by round p... | In the first line of the input the four integers *x*0, *y*0, *v*, *T* (|*x*0|,<=|*y*0|<=≤<=109, 0<=≤<=*v*,<=*T*<=≤<=109) are given — the cockroach initial position on the table in the Cartesian system at the moment 0, the cockroach's constant speed and the time in seconds Dima needs for aiming respectively.
In the nex... | Print the only real number *p* — the probability of that the cockroach will stay alive.
Your answer will be considered correct if its absolute or relative error does not exceed 10<=-<=4. | [
"0 0 1 1\n3\n1 1 1\n-1 -1 1\n-2 2 1\n",
"0 0 1 0\n1\n1 0 1\n"
] | [
"0.50000000000",
"1.00000000000"
] | The picture for the first sample is given below.
Red color stands for points which being chosen as the cockroach's running direction will cause him being killed, green color for those standing for survival directions. Please note that despite containing a circle centered in ( - 2, 2) a part of zone is colored red bec... | [] | 46 | 0 | 0 | 574,384 | |
150 | Mission Impassable | [
"dp",
"strings"
] | null | null | Market stalls now have the long-awaited game The Colder Scrools V: Nvodsk. The game turned out to be difficult as hell and most students can't complete the last quest ("We don't go to Nvodsk..."). That threatened winter exams. The rector already started to wonder whether he should postpone the winter exams till April (... | The first line contains an integer *l* (1<=≤<=*l*<=≤<=150) — the length of the string.
The second line contains exactly *l* integers *a**k* (<=-<=1<=≤<=*a**k*<=≤<=105) — the points a player gains for deleting.
The third line contains exactly *l* lowercase Latin letters — the original string from which a player can de... | Print a single number — the maximum number of points one can gain if he plays on the given string. | [
"7\n-1 -1 -1 -1 -1 -1 -1\nabacaba\n",
"7\n1 -1 -1 -1 -1 -1 -1\nabacaba\n",
"7\n1 5 -1 -1 -1 -1 10\nabacaba\n"
] | [
"0\n",
"7\n",
"16\n"
] | In the first sample we cannot delete any substring, so the best result is 0. In the second sample we are allowed to delete only those palindromes whose length equals 1, thus, if we delete the whole string, we get 7 points. In the third sample the optimal strategy is: first we delete character c, then string aa, then bb... | [] | 92 | 0 | 0 | 576,509 | |
292 | Beautiful IP Addresses | [
"brute force"
] | null | null | The problem uses a simplified TCP/IP address model, please read the statement carefully.
An IP address is a 32-bit integer, represented as a group of four decimal 8-bit integers (without leading zeroes), separated by commas. For example, record 0.255.1.123 shows a correct IP address and records 0.256.1.123 and 0.255.1... | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=10) — the number of digits in the set. The second line contains the set of integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=≤<=9). It is guaranteed that all digits in the set are distinct. | In the first line print a single integer *k* — the number of beautiful IP addresses that contain the given set of digits. In the following *k* lines print the IP addresses, one per line in the arbitrary order. | [
"6\n0 1 2 9 8 7\n",
"1\n4\n"
] | [
"6\n78.190.209.187\n79.180.208.197\n87.190.209.178\n89.170.207.198\n97.180.208.179\n98.170.207.189\n",
"16\n4.4.4.4\n4.4.4.44\n4.4.44.4\n4.4.44.44\n4.44.4.4\n4.44.4.44\n4.44.44.4\n4.44.44.44\n44.4.4.4\n44.4.4.44\n44.4.44.4\n44.4.44.44\n44.44.4.4\n44.44.4.44\n44.44.44.4\n44.44.44.44\n"
] | none | [
{
"input": "6\n0 1 2 9 8 7",
"output": "6\n78.190.209.187\n79.180.208.197\n87.190.209.178\n89.170.207.198\n97.180.208.179\n98.170.207.189"
},
{
"input": "1\n4",
"output": "16\n4.4.4.4\n4.4.4.44\n4.4.44.4\n4.4.44.44\n4.44.4.4\n4.44.4.44\n4.44.44.4\n4.44.44.44\n44.4.4.4\n44.4.4.44\n44.4.44.4\n44.4... | 310 | 268,390,400 | 0 | 576,881 | |
282 | Yet Another Number Game | [
"dp",
"games"
] | null | null | Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!
Since you are so curious about Bitland, I'll give you the chance of peeking at one of these games.
BitLGM and Bi... | The first line contains an integer *n* (1<=≤<=*n*<=≤<=3).
The next line contains *n* integers *a*1,<=*a*2,<=...,<=*a**n* (0<=≤<=*a**i*<=<<=300). | Write the name of the winner (provided that both players play optimally well). Either "BitLGM" or "BitAryo" (without the quotes). | [
"2\n1 1\n",
"2\n1 2\n",
"3\n1 2 1\n"
] | [
"BitLGM\n",
"BitAryo\n",
"BitLGM\n"
] | none | [
{
"input": "2\n1 1",
"output": "BitLGM"
},
{
"input": "2\n1 2",
"output": "BitAryo"
},
{
"input": "3\n1 2 1",
"output": "BitLGM"
},
{
"input": "2\n1 3",
"output": "BitLGM"
},
{
"input": "2\n3 5",
"output": "BitAryo"
},
{
"input": "2\n9 10",
"output... | 1,058 | 3,993,600 | 3 | 579,295 | |
730 | Award Ceremony | [
"greedy",
"implementation"
] | null | null | All-Berland programming contest comes to an end. In total, *n* teams participated in it. Like in ACM-ICPC, current results stopped refreshing one hour before the contest ends. So at the Award Ceremony, results are partially known. For each team the value *a**i* is given — the number of points the *i*-th team has earned... | The first line of the input file contains a single integer *n* (1<=≤<=*n*<=≤<=100) — the number of teams.
Each of the next *n* lines contains two integers *a**i* and *d**i* (1<=≤<=*a**i*<=≤<=100, <=-<=100<=≤<=*d**i*<=≤<=100) — the number of points the *i*-th team has earned before the last hour of the contest and the ... | Print the only integer — maximal total applause duration in seconds if the Jury can choose any order of the teams to unfreeze. | [
"4\n17 -14\n52 -5\n1 52\n6 0\n",
"5\n4 5\n3 2\n5 -3\n6 -2\n4 3\n"
] | [
"4\n",
"14\n"
] | In the first example the initial standings are:
1. Team 2, 52 points 1. Team 1, 17 points 1. Team 4, 6 points 1. Team 3, 1 point
Here any order of unfreezing the teams leads to 4 seconds of applause in total. For example, let's unfreeze teams in their order from the Team 1 to the Team 4.
After the Team 1 became ... | [
{
"input": "4\n17 -14\n52 -5\n1 52\n6 0",
"output": "4"
},
{
"input": "5\n4 5\n3 2\n5 -3\n6 -2\n4 3",
"output": "14"
},
{
"input": "3\n2 1\n1 -1\n1 2",
"output": "3"
},
{
"input": "5\n4 1\n5 4\n3 5\n4 5\n5 2",
"output": "16"
},
{
"input": "10\n3 3\n1 1\n1 2\n2 2\n... | 108 | 4,608,000 | 3 | 582,353 | |
176 | Hyper String | [
"dp"
] | null | null | Paul Erdős's prediction came true. Finally an alien force landed on the Earth. In contrary to our expectation they didn't asked the humans to compute the value of a Ramsey number (maybe they had solved it themselves). They asked another question which seemed as hard as calculating Ramsey numbers. Aliens threatened that... | The first line of input contains the single integer *n* (1<=≤<=*n*<=≤<=2000) — the number of base strings.
The next *n* lines contains values of base strings. Each base string is made of lowercase Latin letters. A base string cannot be empty string and the sum of lengths of all *n* base strings doesn't exceed 106.
... | Print the length of longest common sub-sequence of Hyper String *t* and string *s*. If there is no common sub-sequence print 0. | [
"2\ncba\ndgh\n2\n1 2\naedfhr\n",
"2\nb\na\n5\n1 2 1 2 1\naaa\n"
] | [
"3\n",
"2\n"
] | The length of string *s* is the number of characters in it. If the length of string *s* is marked as |*s*|, then string *s* can be represented as *s* = *s*<sub class="lower-index">1</sub>*s*<sub class="lower-index">2</sub>... *s*<sub class="lower-index">|*s*|</sub>.
A non-empty string *y* = *s*[*p*<sub class="lower-in... | [] | 92 | 0 | 0 | 583,163 | |
850 | Random Elections | [
"bitmasks",
"brute force",
"divide and conquer",
"fft",
"math"
] | null | null | The presidential election is coming in Bearland next year! Everybody is so excited about this!
So far, there are three candidates, Alice, Bob, and Charlie.
There are *n* citizens in Bearland. The election result will determine the life of all citizens of Bearland for many years. Because of this great responsibility,... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=20).
The next line contains a string of length 2*n* of zeros and ones, representing function *f*. Let *b**k*(*x*) the *k*-th bit in binary representation of *x*, *i*-th (0-based) digit of this string shows the return value of *f*(*b*1(*i*),<=*b*2(*i*),<=...,<=*b**... | Output one integer — answer to the problem. | [
"3\n01010101\n",
"3\n01101001\n"
] | [
"216\n",
"168\n"
] | In first sample, result is always fully determined by the first voter. In other words, *f*(*x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, *x*<sub class="lower-index">3</sub>) = *x*<sub class="lower-index">1</sub>. Thus, any no matter what happens, there will be a candidate who won two rounds ... | [] | 46 | 0 | 0 | 583,648 | |
0 | none | [
"none"
] | null | null | After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of *n* bullet slots able to contain exactly *k* bullets, now the boys have a chance to resolve the problem once and for all.
Sash... | The first line contains three integers *n*, *k* and *p* (1<=≤<=*n*<=≤<=1018,<=0<=≤<=*k*<=≤<=*n*,<=1<=≤<=*p*<=≤<=1000) — the number of slots in the cylinder, the number of bullets and the number of queries. Then follow *p* lines; they are the queries. Each line contains one integer *x**i* (1<=≤<=*x**i*<=≤<=*n*) the numb... | For each query print "." if the slot should be empty and "X" if the slot should be charged. | [
"3 1 3\n1\n2\n3\n",
"6 3 6\n1\n2\n3\n4\n5\n6\n",
"5 2 5\n1\n2\n3\n4\n5\n"
] | [
"..X",
".X.X.X",
"...XX"
] | The lexicographical comparison of is performed by the < operator in modern programming languages. The *a* string is lexicographically less that the *b* string, if there exists such *i* (1 ≤ *i* ≤ *n*), that *a*<sub class="lower-index">*i*</sub> < *b*<sub class="lower-index">*i*</sub>, and for any *j* (1 ≤ *j* <... | [
{
"input": "3 1 3\n1\n2\n3",
"output": "..X"
},
{
"input": "6 3 6\n1\n2\n3\n4\n5\n6",
"output": ".X.X.X"
},
{
"input": "5 2 5\n1\n2\n3\n4\n5",
"output": "...XX"
},
{
"input": "4 2 8\n1\n3\n4\n2\n3\n4\n1\n2",
"output": "..XX.X.X"
},
{
"input": "4 0 4\n1\n2\n3\n4",
... | 60 | 0 | 0 | 585,387 | |
958 | Death Stars (hard) | [] | null | null | The stardate is 2015, and Death Stars are bigger than ever! This time, two rebel spies have yet again given Heidi two maps with the possible locations of the Death Stars.
Heidi has now received two maps with possible locations of *N* Death Stars. She knows that each of the maps is possibly corrupted, and may contain s... | The first line of the input contains an integer *N* (1000<=≤<=*N*<=≤<=50000) – the number of Death Stars. The second line of the input contains an integer *N*1 (*N*<=≤<=*N*1<=≤<=1.5·*N*) – the number of stars in the first map. The next *N*1 lines specify the coordinates of the stars in the first map. The *i*-th line co... | You should output exactly *N* lines, each containing a space-separated pair of integers *i*1 and *i*2. Each such line should indicate that the star numbered *i*1 in the first map corresponds to the star numbered *i*2 in the second map. Your answer will be considered correct if over 90% of the distinct pairs listed in y... | [] | [] | The tests are generated in the following way:
- The number of Death Stars *N* is pre-selected in some way. - The numbers of stars on the first and on the second map, *N*<sub class="lower-index">1</sub> and *N*<sub class="lower-index">2</sub>, are selected uniformly at random between 1.0 × *N* and 1.5 × *N*. - *N* ... | [] | 1,279 | 512,000 | 0 | 585,668 | |
626 | Raffles | [
"data structures",
"dp",
"greedy",
"math"
] | null | null | Johnny is at a carnival which has *n* raffles. Raffle *i* has a prize with value *p**i*. Each participant can put tickets in whichever raffles they choose (they may have more than one ticket in a single raffle). At the end of the carnival, one ticket is selected at random from each raffle, and the owner of the ticket w... | The first line contains two integers *n*, *t*, and *q* (1<=≤<=*n*,<=*t*,<=*q*<=≤<=200 000) — the number of raffles, the number of tickets Johnny has, and the total number of updates, respectively.
The second line contains *n* space-separated integers *p**i* (1<=≤<=*p**i*<=≤<=1000) — the value of the *i*-th prize.
The... | Print *q* lines, each containing a single real number — the maximum expected value of Johnny's winnings after the *k*-th update. Your answer will be considered correct if its absolute or relative error does not exceed 10<=-<=6.
Namely: let's assume that your answer is *a*, and the answer of the jury is *b*. The check... | [
"2 1 3\n4 5\n1 2\n1 1\n1 2\n2 1\n",
"3 20 5\n6 8 10\n6 6 6\n1 1\n1 2\n1 3\n2 3\n2 3\n"
] | [
"1.666666667\n1.333333333\n2.000000000\n",
"12.000000000\n12.000000000\n11.769230769\n12.000000000\n12.000000000\n"
] | In the first case, Johnny only has one ticket to distribute. The prizes are worth 4 and 5, and the raffles initially have 1 and 2 tickets, respectively. After the first update, each raffle has 2 tickets, so Johnny has expected value <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/436bcf2181... | [] | 30 | 0 | 0 | 594,361 | |
286 | Tourists | [
"data structures",
"sortings"
] | null | null | A double tourist path, located at a park in Ultima Thule, is working by the following principle:
- We introduce the Cartesian coordinate system. - At some points of time there are two tourists going (for a walk) from points (<=-<=1,<=0) and (1,<=0) simultaneously. The first one is walking from (<=-<=1,<=0), the seco... | The first line contains two space-separated integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=105) — the number of pairs of tourists and the number of built walls. The next *m* lines contain three space-separated integers *l**i*, *r**i* and *t**i* each (0<=≤<=*l**i*<=<<=*r**i*<=≤<=109, 0<=≤<=*t**i*<=≤<=109) — the wall ends ... | For each pair of tourists print on a single line a single integer — the time in seconds when the two tourists from the corresponding pair won't see each other. Print the numbers in the order in which the they go in the input. | [
"2 2\n1 4 3\n3 6 5\n0 1\n",
"3 3\n0 3 4\n0 1 2\n2 4 0\n1 3 4\n"
] | [
"2\n4\n",
"2\n4\n4\n"
] | none | [] | 46 | 0 | 0 | 594,586 | |
154 | Martian Colony | [
"geometry"
] | null | null | The first ship with the Earth settlers landed on Mars. The colonists managed to build *n* necessary structures on the surface of the planet (which can be regarded as a plane, and the construction can be regarded as points on it). But one day the scanners recorded suspicious activity on the outskirts of the colony. It w... | The first line contains two integers *n* and *r* (1<=≤<=*n*<=≤<=105, 1<=≤<=*r*<=≤<=50000) — the number of buildings and the active ranges of the generators, correspondingly.
Next *n* lines contains the buildings' coordinates. The *i*<=+<=1-th (1<=≤<=*i*<=≤<=*n*) line contains two real numbers with at most three digits... | Print the single real number — the minimum area of the protected part containing all the buildings. The answer is accepted if absolute or relative error doesn't exceed 10<=-<=4. | [
"3 5\n0.00 0.000\n0.0 8.00\n6 8.00\n",
"4 1000\n0.0 0.0\n0 2.00\n2.00 2\n2.0 0.00\n",
"4 5\n3.00 0.0\n-3 0.00\n0.000 1\n0.0 -1.00\n"
] | [
"78.5398163397\n",
"4.0026666140\n",
"8.1750554397\n"
] | In the first sample the given radius equals the radius of the circle circumscribed around the given points. That's why the circle that corresponds to it is the sought area. The answer is 25π.
In the second sample the area nearly coincides with the square which has vertexes in the given points.
The area for the third ... | [] | 92 | 0 | 0 | 602,696 | |
418 | Big Problems for Organizers | [
"data structures",
"graphs",
"trees"
] | null | null | The 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 accommodate the participants. The hotels are connected by *n*<=-<=1 roads, you can get from any hotel to any other one.
The organiz... | The first line contains an integer *n* (2<=≤<=*n*<=≤<=100000) — the number of hotels. The next *n*<=-<=1 lines contain two integers each — the numbers of the hotels that have a road between them. Consider hotels are numbered from 1 to *n*.
The next line contains an integer *m* (1<=≤<=*m*<=≤<=100000) — the number of q... | For each request of the organizers print a single integer — the time that all participants need to reach the main hotels. | [
"3\n2 3\n3 1\n3\n2 1\n2 3\n3 1\n",
"4\n1 4\n1 2\n2 3\n3\n1 4\n1 3\n2 3\n"
] | [
"1\n1\n1\n",
"2\n1\n2\n"
] | none | [] | 30 | 0 | 0 | 609,800 | |
0 | none | [
"none"
] | null | null | A new bus route is opened in the city . The route is a closed polygon line in the place, with all segments parallel to one of the axes. *m* buses will operate on the route. All buses move in a loop along the route in the same direction with equal constant velocities (stopping times are negligible in this problem).
Bus... | The first line contains two integers *n* and *m* (2<=≤<=*n*,<=*m*<=≤<=105) — the number of vertices of the polygonal line, and the number of buses respectively.
Next *n* lines describe the vertices of the route in the traversing order. Each of these lines contains two integers *x**i*, *y**i* (<=-<=1000<=≤<=*x**i*,<=*y... | Print one real number — the answer to the problem. Your answer will be accepted if the relative or the absolute error doesn't exceed 10<=-<=6. | [
"4 2\n0 0\n0 1\n1 1\n1 0\n",
"2 2\n0 0\n1 0\n"
] | [
"1.000000000\n",
"0.000000000"
] | Suppose that each bus travel 1 distance unit per second.
In the first sample case, in 0.5 seconds buses will be at distance 1, hence we can choose *D* = 1.
In the second sample case, in 0.5 seconds both buses will be at (0.5, 0), hence we can choose *D* = 0. | [] | 46 | 0 | 0 | 610,863 | |
741 | Arpa’s abnormal DNA and Mehrdad’s deep interest | [
"data structures",
"string suffix structures"
] | null | null | All of us know that girls in Arpa’s land are... ok, you’ve got the idea :D
Anyone knows that Arpa isn't a normal man, he is ... well, sorry, I can't explain it more. Mehrdad is interested about the reason, so he asked Sipa, one of the best biology scientists in Arpa's land, for help. Sipa has a DNA editor.
Sipa put A... | The first line contains strings *S*, *T* and integer *q* (1<=≤<=|*S*|,<=|*T*|,<=*q*<=≤<=105) — Arpa's DNA, the DNA of a normal man, and the number of Mehrdad's questions. The strings *S* and *T* consist only of small English letters.
Next *q* lines describe the Mehrdad's questions. Each of these lines contain five int... | Print *q* integers. The *j*-th of them should be the number *i* of the most interesting option among those that satisfy the conditions of the *j*-th question. If there is no option *i* satisfying the conditions in some question, print -1. | [
"abc d 4\n0 3 2 0 0\n0 3 1 0 0\n1 2 1 0 0\n0 1 3 2 2\n",
"abbbbbbaaa baababaaab 10\n1 2 1 0 0\n2 7 8 4 7\n2 3 9 2 8\n3 4 6 1 1\n0 8 5 2 4\n2 8 10 4 7\n7 10 1 0 0\n1 4 6 0 2\n0 9 8 0 6\n4 8 5 0 1\n"
] | [
"2 3 2 -1 \n",
"1 4 2 -1 2 4 10 1 1 5 \n"
] | Explanation of first sample case:
In the first question Sipa has two options: dabc (*i* = 0) and abdc (*i* = 2). The latter (abcd) is better than abdc, so answer is 2.
In the last question there is no *i* such that 0 ≤ *i* ≤ 1 and <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/7cc85c61d9... | [] | 46 | 0 | 0 | 614,284 | |
580 | Kefa and Watch | [
"data structures",
"hashing",
"strings"
] | null | null | One day Kefa the parrot was walking down the street as he was on the way home from the restaurant when he saw something glittering by the road. As he came nearer he understood that it was a watch. He decided to take it to the pawnbroker to earn some money.
The pawnbroker said that each watch contains a serial number ... | The first line of the input contains three positive integers *n*, *m* and *k* (1<=≤<=*n*<=≤<=105, 1<=≤<=*m*<=+<=*k*<=≤<=105) — the length of the serial number, the number of change made by Kefa and the number of quality checks.
The second line contains a serial number consisting of *n* digits.
Then *m*<=+<=*k* lines ... | For each check on a single line print "YES" if the watch passed it, otherwise print "NO". | [
"3 1 2\n112\n2 2 3 1\n1 1 3 8\n2 1 2 1\n",
"6 2 3\n334934\n2 2 5 2\n1 4 4 3\n2 1 6 3\n1 2 3 8\n2 3 6 1\n"
] | [
"NO\nYES\n",
"NO\nYES\nNO\n"
] | In the first sample test two checks will be made. In the first one substring "12" is checked on whether or not it has period 1, so the answer is "NO". In the second one substring "88", is checked on whether or not it has period 1, and it has this period, so the answer is "YES".
In the second statement test three check... | [
{
"input": "3 1 2\n112\n2 2 3 1\n1 1 3 8\n2 1 2 1",
"output": "NO\nYES"
},
{
"input": "6 2 3\n334934\n2 2 5 2\n1 4 4 3\n2 1 6 3\n1 2 3 8\n2 3 6 1",
"output": "NO\nYES\nNO"
},
{
"input": "1 0 1\n5\n2 1 1 1",
"output": "YES"
},
{
"input": "20 1 2\n34075930750342906718\n2 1 20 2... | 763 | 23,449,600 | 3 | 618,245 | |
933 | A Preponderant Reunion | [
"constructive algorithms",
"dp"
] | null | null | East or west, home is best. That's why family reunion, the indispensable necessity of Lunar New Year celebration, is put in such a position.
After the reunion dinner, Little Tommy plays a game with the family. Here is a concise introduction to this game:
1. There is a sequence of *n* non-negative integers *p*1,<=*p... | The first line contains one integer *n* (1<=≤<=*n*<=≤<=3·105).
The second line contains *n* space-separated integers *p*1,<=*p*2,<=...,<=*p**n* (0<=≤<=*p**i*<=≤<=109,<=*i*<==<=1,<=2,<=...,<=*n*). | In the first line print one integer as the number of descensions *m* (0<=≤<=*m*<=≤<=*n*<=-<=1).
In the next *m* lines print the descensions chronologically. More precisely, in each line of the next *m* lines print one integer *i* (1<=≤<=*i*<=<<=*n*) representing a descension would operate on *p**i* and *p**i*<=+<=1... | [
"4\n2 1 3 1\n",
"5\n2 2 1 3 1\n"
] | [
"2\n1\n3\n",
"3\n2\n1\n4\n"
] | In the first sample, one possible best solution is <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/9248227dd2a5fa16d275273b9219a6e5a3560846.png" style="max-width: 100.0%;max-height: 100.0%;"/>, of which the cost is 1 + 1 = 2.
In the second sample, one possible best solution is <img align="... | [] | 46 | 0 | 0 | 618,390 | |
837 | Functions On The Segments | [
"data structures"
] | null | null | You have an array *f* of *n* functions.The function *f**i*(*x*) (1<=≤<=*i*<=≤<=*n*) is characterized by parameters: *x*1,<=*x*2,<=*y*1,<=*a*,<=*b*,<=*y*2 and take values:
- *y*1, if *x*<=≤<=*x*1. - *a*·*x*<=+<=*b*, if *x*1<=<<=*x*<=≤<=*x*2. - *y*2, if *x*<=><=*x*2.
There are *m* queries. Each query is deter... | First line contains one integer number *n* (1<=≤<=*n*<=≤<=75000).
Each of the next *n* lines contains six integer numbers: *x*1,<=*x*2,<=*y*1,<=*a*,<=*b*,<=*y*2 (0<=≤<=*x*1<=<<=*x*2<=≤<=2·105, 0<=≤<=*y*1,<=*y*2<=≤<=109, 0<=≤<=*a*,<=*b*<=≤<=104).
Next line contains one integer number *m* (1<=≤<=*m*<=≤<=500000).
Ea... | none | [
"1\n1 2 1 4 5 10\n1\n1 1 2\n",
"3\n2 5 1 1 1 4\n3 6 8 2 5 7\n1 3 5 1 4 10\n3\n1 3 3\n2 3 2\n1 2 5\n"
] | [
"13\n",
"19\n17\n11\n"
] | none | [
{
"input": "1\n1 2 1 4 5 10\n1\n1 1 2",
"output": "13"
},
{
"input": "3\n2 5 1 1 1 4\n3 6 8 2 5 7\n1 3 5 1 4 10\n3\n1 3 3\n2 3 2\n1 2 5",
"output": "19\n17\n11"
},
{
"input": "7\n4 8 562244866 6 8 140807945\n5 7 415374420 7 6 596093578\n3 4 766370993 3 7 973128805\n4 6 841321398 3 2 8931... | 46 | 0 | 0 | 620,486 | |
856 | Satellites | [] | null | null | Real Cosmic Communications is the largest telecommunication company on a far far away planet, located at the very edge of the universe. RCC launches communication satellites.
The planet is at the very edge of the universe, so its form is half of a circle. Its radius is *r*, the ends of its diameter are points *A* and ... | The first line of input data contains integers *r* and *n* — radius of the planet and the number of events (1<=≤<=*r*<=≤<=109, 1<=≤<=*n*<=≤<=5·105).
Each of the following *n* lines describe events in the specified format.
Satellite coordinates are integer, the satisfy the following constraints |*x*|<=≤<=109, 0<=<<... | For each event of type 3 print «YES» on a separate line, if it is possible to create a communication channel, or «NO» if it is impossible. | [
"5 8\n1 -5 8\n1 -4 8\n1 -3 8\n1 2 7\n3 1 3\n2 2\n3 1 3\n3 3 4\n"
] | [
"NO\nYES\nYES\n"
] | none | [] | 30 | 0 | 0 | 620,554 | |
736 | Chess Championship | [
"constructive algorithms",
"flows",
"greedy",
"math"
] | null | null | Ostap is preparing to play chess again and this time he is about to prepare. Thus, he was closely monitoring one recent chess tournament. There were *m* players participating and each pair of players played exactly one game. The victory gives 2 points, draw — 1 points, lose — 0 points.
Ostap is lazy, so he never tries... | The first line of the input contains two integers *m* and *n* (1<=≤<=*n*<=≤<=*m*<=≤<=3000) — the number of participants of the tournament and the number of top results Ostap remembers.
The second line contains *n* integers, provided in non-ascending order — the number of points earned by top participants as Ostap reme... | If there is no tournament such that Ostap can obtain the given set of integers using the procedure described in the statement, then print "no" in the only line of the output. Otherwise, the first line of the output should contain the word "yes". Next *m* lines should provide the description of any valid tournament. Eac... | [
"5 5\n8 6 4 2 0\n",
"5 1\n9\n"
] | [
"yes\nXWWWW\nLXWWW\nLLXWW\nLLLXW\nLLLLX\n",
"no\n"
] | none | [] | 31 | 0 | 0 | 621,337 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.