name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p00082 Flying Jenny
<image> You know the merry-go-round in the amusement park. Vehicles such as horses and carriages are fixed on a large disk, and it is a standard playset that the vehicle swings up and down at the same time as the disk rotates. A merry-go-round in an amusement park has two four-seater carriages, two two-seater cars, f...
{ "input": [], "output": [] }
{ "input": [ "2 3 1 4 0 1 0 1\n4 2 3 2 2 2 1 1" ], "output": [ "1 4 1 4 1 2 1 2\n4 1 4 1 2 1 2 1" ] }
{ "input": [ "2 3 1 4 0 1 1 1\n4 2 3 2 2 2 1 1", "2 3 1 2 0 1 1 1\n4 2 3 2 2 2 1 1", "0 3 1 3 0 0 -1 2\n1 1 5 2 -1 3 0 0", "0 3 1 1 0 1 -1 2\n1 1 5 2 -1 3 0 0", "0 3 1 1 0 -1 -1 2\n1 1 5 3 -1 3 0 -1", "0 2 0 1 0 -1 -1 2\n1 1 5 3 -1 3 0 -1", "0 2 1 1 0 -1 -1 2\n1 1 5 3 -1 0 0 -1", "0 4 ...
p00214 Autumnal Illumination
In Square Town, where many people who love squares live, a festival is held to color the town with illuminations that combine square lightning boards. This electric board emits light when electricity is applied, and the plate in contact with the light emitting plate also emits light. Therefore, no matter how many elect...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n0 0 0 1 1 1 1 0\n2\n0 0 0 1 1 1 1 0\n100 100 100 200 200 200 200 100\n2\n0 0 0 100 100 100 100 0\n10 10 10 20 20 20 20 10\n2\n1\n30 40 40 50 40 20 20 10\n1\n30 40 40 50 40 20 20 10\n0" ], "output": [ "1\n2\n1\n1\n1" ] }
{ "input": [ "3\n1\n0 0 0 1 1 1 1 0\n2\n0 0 0 1 1 1 1 0\n100 100 100 200 200 200 200 100\n2\n0 0 0 100 100 100 100 0\n10 10 10 11 20 20 20 10\n2\n1\n30 40 40 50 40 20 20 10\n1\n30 40 40 50 40 20 20 10\n0", "3\n1\n0 0 0 1 1 1 1 -1\n0\n0 0 0 1 1 1 1 0\n100 100 100 200 200 111 200 000\n2\n0 0 0 100 100 100 100 0...
p00374 Iron Bars
A boy PCK had N straight iron bars, which were serially indexed. Unfortunately, the first M bars (0 ≤ M ≤ N) among them were bent during transportation. They all suffered a perpendicular bend at one point. He is planning to make a cube using a set of bars selected using the following rules: X bars from bent ones, Y ba...
{ "input": [], "output": [] }
{ "input": [ "18 8 3 6\n4\n3\n3\n3\n3\n2\n2\n2\n1\n1\n1\n1\n1\n2\n2\n3\n3\n3\n1\n1\n1\n1\n1\n1\n1\n1" ], "output": [ "3" ] }
{ "input": [ "18 8 3 6\n7\n3\n3\n3\n3\n2\n2\n2\n1\n1\n1\n1\n1\n2\n2\n3\n3\n3\n1\n1\n1\n1\n1\n1\n1\n1", "18 8 3 6\n7\n3\n3\n3\n3\n2\n2\n4\n1\n1\n2\n1\n1\n2\n2\n3\n3\n3\n1\n1\n1\n1\n1\n1\n1\n1", "18 8 3 6\n7\n3\n3\n3\n3\n2\n2\n4\n1\n1\n2\n1\n1\n2\n2\n3\n3\n3\n1\n1\n2\n1\n1\n2\n1\n1", "18 8 5 3\n4\n5\n3\...
p00591 Advanced Algorithm Class
In the advanced algorithm class, n2 students sit in n rows and n columns. One day, a professor who teaches this subject comes into the class, asks the shortest student in each row to lift up his left hand, and the tallest student in each column to lift up his right hand. What is the height of the student whose both han...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3\n4 5 6\n7 8 9\n3\n1 2 3\n7 8 9\n4 5 6\n0" ], "output": [ "7\n7" ] }
{ "input": [ "3\n1 2 3\n4 5 6\n7 10 9\n3\n1 2 3\n7 8 9\n4 5 6\n0", "3\n1 2 3\n4 5 6\n7 10 9\n3\n1 2 3\n7 8 6\n4 5 6\n0", "3\n1 2 3\n4 5 6\n7 10 9\n3\n1 2 3\n2 8 9\n4 5 6\n0", "3\n1 2 3\n4 5 6\n7 10 9\n3\n1 2 3\n7 8 6\n4 5 7\n0", "3\n1 2 3\n4 5 6\n12 10 9\n3\n1 4 3\n7 8 9\n4 8 6\n0", "3\n1 2 3\...
p00728 ICPC Score Totalizer Software
<image> The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business. One of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of judges may differ from one co...
{ "input": [], "output": [] }
{ "input": [ "3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0" ], "output": [ "342\n7\n300\n326" ] }
{ "input": [ "3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n708\n274\n283\n132\n402\n523\n0", "3\n1000\n342\n0\n5\n0\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0", "3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8...
p00868 Spherical Mirrors
A long time ago in a galaxy, far, far away, there were N spheres with various radii. Spheres were mirrors, that is, they had reflective surfaces . . . . You are standing at the origin of the galaxy (0, 0, 0), and emit a laser ray to the direction (u,v, w). The ray travels in a straight line. When the laser ray from I...
{ "input": [], "output": [] }
{ "input": [ "3\n-20 -20 -24\n100 100 100 30\n10 8 3 5\n-70 -70 -84 5\n4\n0 47 84\n-23 41 42 8\n45 -10 14 19\n-5 28 47 12\n-27 68 34 14\n0" ], "output": [ "79.0940 79.0940 94.9128\n-21.8647 54.9770 34.1761" ] }
{ "input": [ "3\n-20 -20 -24\n100 100 100 30\n10 8 3 5\n-70 -70 -84 5\n4\n0 47 74\n-23 41 42 8\n45 -10 14 19\n-5 28 47 12\n-27 68 34 14\n0", "3\n-20 -20 -24\n100 100 100 30\n10 8 3 5\n-70 -70 -84 5\n4\n0 47 74\n-23 41 42 8\n45 -10 14 19\n-5 9 47 12\n-27 68 34 14\n0", "3\n-20 -20 -24\n100 100 100 30\n10 8 ...
p00999 Rental DVD Shop NEO
Problem I started a part-time job at the rental DVD shop "NEO". First of all, I decided to study the fee system of this store. There are three types of rental DVDs, old, semi-new, and new, and the rental fee for one DVD is a yen, b yen, and c yen, respectively. The set rental shown below can be applied multiple times...
{ "input": [], "output": [] }
{ "input": [ "70 100 340 4 200\n1 1 4\n70 100 340 4 200\n0 1 3\n70 100 340 4 200\n1 1 2\n0 0 0 0 0" ], "output": [ "970\n800\n800" ] }
{ "input": [ "70 100 340 4 200\n1 1 4\n70 100 340 4 200\n0 1 3\n70 100 340 6 200\n1 1 2\n0 0 0 0 0", "135 100 340 4 200\n1 1 4\n70 100 340 4 200\n0 1 3\n70 100 340 6 200\n1 1 2\n0 0 0 0 0", "135 100 340 4 200\n1 1 4\n70 100 351 5 200\n0 1 3\n70 100 340 6 288\n1 1 2\n0 0 0 0 0", "70 100 340 4 200\n1 1 ...
p01131 Keitai Message
Alice wants to send an email to Miku on her mobile phone. The only buttons that can be used for input on mobile phones are number buttons. Therefore, in order to input characters, the number buttons are pressed several times to input characters. The following characters are assigned to the number buttons of the mobile...
{ "input": [], "output": [] }
{ "input": [ "5\n20\n220\n222220\n44033055505550666011011111090666077705550301110\n000555555550000330000444000080000200004440000" ], "output": [ "a\nb\nb\nhello, world!\nkeitai" ] }
{ "input": [ "5\n40\n220\n222220\n44033055505550666011011111090666077705550301110\n000555555550000330000444000080000200004440000", "5\n40\n30\n222220\n44033055505550666011011111090666077705550301110\n000555555550000330000444000080000200004440000", "5\n10\n220\n222220\n4403305550555066601101111109066607770...
p01270 Restrictive Filesystem
You are a programmer on the development team for new recording media. This recording medium can be randomly accessed for reading and erasing data. On the other hand, when writing data, access is always performed in order from the beginning, and only the first free space found can be written. You have begun to build a ...
{ "input": [], "output": [] }
{ "input": [ "6\nW 0 2\nW 1 2\nD 0\nW 2 4\nR 3\nR 1\n1\nR 1000000000\n0" ], "output": [ "1\n2\n\n-1" ] }
{ "input": [ "6\nW 0 2\nW 1 2\nD 0\nW 2 4\nR 3\nR 2\n1\nR 1000000000\n0", "6\nW 0 2\nW 0 2\nD 0\nW 2 4\nR 3\nR 2\n1\nR 1000000000\n0", "6\nW 0 2\nW 0 2\nD -1\nW 2 4\nR 2\nR 2\n1\nR 0000000000\n0", "6\nW 0 2\nW 1 2\nD 0\nW 2 4\nR 5\nR 2\n1\nR 1000000000\n0", "6\nW 0 2\nW 0 2\nD 0\nW 2 4\nR 3\nR 4\n...
p01440 Revenge of Champernowne Constant
Champernowne constant is an irrational number. Its decimal representation starts with "0.", followed by concatenation of all positive integers in the increasing order. You will be given a sequence S which consists of decimal digits. Your task is to write a program which computes the position of the first occurrence of...
{ "input": [], "output": [] }
{ "input": [ "45678\n67891011\n21\n314159265358979", "45678\n67891011\n21\n314159265358979\n#" ], "output": [ "4\n6\n15\n2012778692735799", "4\n6\n15\n2012778692735799" ] }
{ "input": [ "45678\n67891011\n28\n314159265358979", "45678\n67891011\n9\n314159265358979", "45678\n67891011\n9\n438894300035810", "45678\n48782446\n9\n438894300035810", "45678\n48782446\n9\n625210440910086", "45678\n91285515\n9\n625210440910086", "45678\n135768712\n9\n625210440910086", ...
p01589 Strange Currency System
The currency system in the Kingdom of Yoax-Musty is strange and fairly inefficient. Like other countries, the kingdom has its own currencty unit denoted by K $ (kingdom dollar). However, the Ministry of Finance issues bills for every value between 1 K $ and (231 - 1) K $ worth. On the other hand, this system often ena...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p01746 Directions
Sunuke cannot move in the initial state. The price of the i-th ticket is pi, which can be bought to move from (x, y) to (x + tai, y + tbi) for any (x, y) and any non-negative real number t. become able to. Find the minimum total amount of tickets that Sunuke must buy in order to be able to move between any two points o...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2 3\n4 5 6", "7\n0 3 1\n0 3 2\n1 -1 2\n0 0 1\n-2 4 1\n-4 0 1\n2 1 2" ], "output": [ "-1", "4" ] }
{ "input": [ "2\n1 2 3\n4 5 10", "7\n0 3 1\n0 3 2\n1 -1 2\n0 0 1\n-2 7 1\n-4 0 1\n2 1 2", "7\n0 3 0\n0 3 2\n1 -1 2\n0 1 1\n-2 7 1\n-2 0 1\n2 1 2", "7\n1 3 0\n0 2 2\n1 -1 1\n0 1 1\n-4 2 1\n-2 0 1\n2 1 2", "7\n1 3 0\n0 2 2\n1 -1 1\n0 1 1\n-4 2 1\n-2 0 0\n2 1 4", "7\n0 3 0\n0 3 2\n0 -1 2\n0 1 1\n...
p01886 Share the Ruins Preservation
Example Input 8 -10 0 -10 5 -5 5 -5 0 10 0 10 -5 5 -5 5 0 Output 50
{ "input": [], "output": [] }
{ "input": [ "8\n-10 0\n-10 5\n-5 5\n-5 0\n10 0\n10 -5\n5 -5\n5 0" ], "output": [ "50" ] }
{ "input": [ "8\n-10 0\n-10 5\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0", "8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0", "8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n4 -5\n5 -5\n5 0", "8\n-10 0\n-15 10\n-5 5\n-5 -1\n10 0\n4 -5\n5 -5\n5 0", "8\n-10 0\n-10 5\n-5 5\n-5 0\n10 0\n10 -5\n7 -5\n5 0", "...
p02023 Ravage
I: Ravage Santa Claus was caught in the illuminations of the city and broke it. There are N light bulbs in the illumination, and the $ i $ th light bulb only comes on when the voltage is above $ A_i $ and below $ B_i $. The voltage should be the same everywhere in the illumination. Find out how many light bulbs can...
{ "input": [], "output": [] }
{ "input": [ "4\n1 4\n3 6\n2 7\n5 8" ], "output": [ "3" ] }
{ "input": [ "4\n0 4\n3 6\n2 7\n5 8", "4\n0 4\n3 6\n2 9\n0 8", "4\n-1 2\n3 2\n3 7\n-1 8", "4\n-1 0\n1 2\n3 0\n1 12", "4\n0 4\n3 6\n2 9\n5 8", "4\n0 4\n3 6\n2 9\n1 8", "4\n0 4\n3 6\n2 7\n1 8", "4\n0 4\n3 6\n3 7\n1 8", "4\n0 4\n3 6\n3 7\n0 8", "4\n0 2\n3 6\n3 7\n0 8", "4\n0 2...
p02165 Blaster
Problem How, you have been trapped in a cave! Perhaps the wall had collapsed, and many rocks were in the way before we reached the only exit. But I realized that there was a bomb vending machine right next to you. In addition, it seems that some "blasters" have also fallen in the cave. If you use these two tools, it ...
{ "input": [], "output": [] }
{ "input": [ "4 5\n_####\nB##\n_####\n_###_", "4 5\n_#B##\n\nB##\n_", "8 5\n_###_\n_#_B#\n_####\n____#\n_#\n\n_#\n_", "8 5\n_###_\n_#_B#\n_####\n____#\n###_#\n#####\n###_#\n####_", "5 5\n_____\n_____\n_____\n_____\n_____" ], "output": [ "2", "1", "1", "1", "0" ] }
{ "input": [], "output": [] }
p02306 Incircle of a Triangle
Write a program which prints the central coordinate ($cx$,$cy$) and the radius $r$ of a incircle of a triangle which is constructed by three points ($x_1$, $y_1$), ($x_2$, $y_2$) and ($x_3$, $y_3$) on the plane surface. Constraints * $-10000 \leq x_i, y_i \leq 10000$ * The three points are not on the same straight li...
{ "input": [], "output": [] }
{ "input": [ "0 3\n4 0\n0 0", "1 -2\n3 2\n-2 0" ], "output": [ "1.00000000000000000000 1.00000000000000000000 1.00000000000000000000", "0.53907943898209422325 -0.26437392711448356856 1.18845545916395465278" ] }
{ "input": [ "0 3\n6 0\n0 0", "1 -2\n3 0\n-2 0", "0 3\n6 0\n0 1", "1 -2\n0 0\n-2 0", "0 3\n6 1\n0 1", "1 -2\n1 0\n-2 0", "0 3\n6 1\n0 2", "0 3\n4 1\n0 2", "1 3\n4 1\n0 2", "1 3\n4 2\n0 2", "1 3\n4 1\n-1 2", "1 3\n8 1\n-1 2", "1 3\n8 2\n-1 2", "1 3\n8 2\n-1 1", ...
p02453 Lower Bound
For a given sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ which is sorted by ascending order, find the lower bound for a specific value $k$ given as a query. * lower bound: the place pointing to the first element greater than or equal to a specific value, or $n$ if there is no such element. Constraints * $1 \leq n \le...
{ "input": [], "output": [] }
{ "input": [ "4\n1 2 2 4\n3\n2\n3\n5" ], "output": [ "1\n3\n4" ] }
{ "input": [ "4\n1 2 2 6\n3\n2\n3\n5", "4\n1 0 2 6\n3\n2\n3\n5", "4\n1 0 2 6\n4\n2\n3\n5", "4\n1 0 2 4\n3\n2\n3\n5", "4\n1 0 2 4\n3\n2\n6\n6", "4\n1 0 0 4\n3\n2\n6\n6", "4\n1 0 0 4\n3\n4\n12\n0", "4\n1 0 0 5\n3\n7\n23\n0", "4\n1 0 -1 5\n3\n7\n40\n0", "4\n0 0 -1 9\n3\n7\n40\n0",...
arhn04
Dhapu is a school girl who hacks and programs in free time. But right now she has to do her boring school homework. It's a few addition and subtraction problems. She has gotten bored with doing these repetitive questions. So, she wants to automate the entire process. Will you help her write a program to complete her ma...
{ "input": [], "output": [] }
{ "input": [ "4\n1+1\n1-2\n141654614141045641415616417161565497897981246+489748946511344946164879465416948465489426\n5467246752197212658296172941726172167-5467246752197212658296172941726172166" ], "output": [ "2\n-1\n142144363087556986361781296626982446363470672\n1\n" ] }
{ "input": [ "4\n1+1\n2-2\n141654614141045641415616417161565497897981246+489748946511344946164879465416948465489426\n5467246752197212658296172941726172167-5467246752197212658296172941726172166", "4\n1+1\n2-2\n141654614141045641415616417161565497897981246+489748946511344946164879465416948465489426\n66127162714...
clarissa
Problem description Clarissa Adele Fray (a.k.a Clary) has found out that she is a shadowhunter, a human with angelic qualities. She can create her own runes (magical spells). Last week, she created many powerful runes. Right now, she is facing several underworld demons, help her find the number of ways, such that th...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n100\n3\n80 90 90" ], "output": [ "1\n3" ] }
{ "input": [], "output": [] }
fcbarca
As we all know, F.C. Barcelona is the best soccer team of our era! Their entangling and mesmerizing game style usually translates into very high ball possession, consecutive counter-attack plays and goals. Lots of goals, thanks to the natural talent of their attacker and best player in history, Lionel Andres Messi. How...
{ "input": [], "output": [] }
{ "input": [ "2\n2 4\n4 2" ], "output": [ "4\n6\n" ] }
{ "input": [ "2\n3 4\n4 2", "2\n3 4\n4 3", "2\n3 1\n4 2", "2\n3 1\n4 3", "2\n6 1\n4 3", "2\n6 2\n4 3", "2\n6 2\n4 1", "2\n5 2\n4 1", "2\n5 2\n4 2", "2\n3 2\n4 2", "2\n3 4\n4 1", "2\n3 1\n4 5", "2\n3 1\n5 3", "2\n3 1\n8 3", "2\n5 4\n4 1", "2\n5 2\n4 3", ...
lealco
The Little Elephant and his friends from the Zoo of Lviv were returning from the party. But suddenly they were stopped by the policeman Big Hippo, who wanted to make an alcohol test for elephants. There were N elephants ordered from the left to the right in a row and numbered from 0 to N-1. Let R[i] to be the result of...
{ "input": [], "output": [] }
{ "input": [ "4\n5 3 2\n1 3 1 2 1\n5 3 3\n7 7 7 7 7\n5 3 3\n7 7 7 8 8\n4 3 1\n1 3 1 2" ], "output": [ "0\n1\n1\n-1" ] }
{ "input": [], "output": [] }
pinoch2
After confronting Pinocchio, Lampwick decided to further analyse his diary about Pinocchio. (You can find the details about the diary in Part 1 of this problem) Now he needs to find out the maximum number of days that passed by in which Pinocchio surely didn't lie. Can you help him out?   Input First line of input co...
{ "input": [], "output": [] }
{ "input": [ "1\n7\n1 2 2 3 4 5 5" ], "output": [ "1" ] }
{ "input": [ "1\n7\n1 2 2 3 8 5 5", "1\n2\n1 2 4 3 8 0 5", "1\n1\n2 2 2 6 8 0 1", "1\n7\n2 2 2 2 8 5 4", "1\n7\n1 2 2 3 8 0 5", "1\n2\n1 2 2 3 8 0 5", "1\n2\n1 2 2 3 8 0 1", "1\n2\n1 2 2 6 8 0 1", "1\n2\n0 2 2 6 8 0 1", "1\n2\n0 2 2 6 6 0 1", "1\n2\n0 2 2 6 6 1 1", "1\n...
strq
Chef likes strings a lot but moreover he likes good strings. Chef calls a string str a good string if str starts and ends at different characters. For eg : strings such as abab , baccba , abc are all good strings whereas strings like aba, baab , baacaab are not good at all . Today, Chef has a special string P consistin...
{ "input": [], "output": [] }
{ "input": [ "checfcheff\n5\nc h 1 10\nc f 1 10\ne c 1 10\nc f 1 5\nc f 6 10" ], "output": [ "4\n8\n2\n2\n2" ] }
{ "input": [ "checfcheff\n5\nc h 1 10\nc f 1 7\ne c 1 10\nc f 1 5\nc f 6 10", "checfcheff\n5\nc h 1 10\nc f 1 10\ne c 1 10\nc f 1 7\nc f 6 10", "checfcheff\n1\nc h 1 10\nc f 1 7\ne c 1 10\nc f 1 5\nc f 6 10", "checfcheff\n5\nc h 0 10\nc f 1 10\ne c 1 10\nc f 1 7\nc f 6 10", "checfcheff\n5\nc h 1 1...
1535_D. Playoff Tournament
2^k teams participate in a playoff tournament. The tournament consists of 2^k - 1 games. They are held as follows: first of all, the teams are split into pairs: team 1 plays against team 2, team 3 plays against team 4 (exactly in this order), and so on (so, 2^{k-1} games are played in that phase). When a team loses a g...
{ "input": [], "output": [] }
{ "input": [ "3\n0110?11\n6\n5 1\n6 ?\n7 ?\n1 ?\n5 ?\n1 1\n" ], "output": [ "\n1\n2\n3\n3\n5\n4\n" ] }
{ "input": [ "3\n0110?11\n6\n5 1\n6 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "3\n0110?11\n6\n5 1\n6 ?\n6 ?\n1 ?\n5 ?\n1 1\n", "3\n11?0110\n6\n5 1\n6 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "3\n0110?11\n6\n5 1\n7 ?\n7 ?\n2 ?\n5 ?\n1 1\n", "3\n0110?11\n1\n5 1\n6 ?\n7 @\n2 ?\n5 ?\n1 1\n", "3\n01101?1\n1\n5 1\n11 >\n11 @\n0 ?...
162_G. Non-decimal sum
You are given an array of integers written in base radix. Calculate their sum and output it written in the same base. Input The first line of the input contains an integer n (1 ≤ n ≤ 10) — the size of the array. The second line contains an integer radix (2 ≤ radix ≤ 36) — the base of the numeral system used. Next n l...
{ "input": [], "output": [] }
{ "input": [ "3\n16\nF0\n20B\n004\n", "2\n10\n12\n34\n" ], "output": [ "2FF\n", "46\n" ] }
{ "input": [], "output": [] }
841_C. Leha and Function
Leha like all kinds of strange things. Recently he liked the function F(n, k). Consider all possible k-element subsets of the set [1, 2, ..., n]. For subset find minimal element in it. F(n, k) — mathematical expectation of the minimal element among all k-element subsets. But only function does not interest him. He wan...
{ "input": [], "output": [] }
{ "input": [ "5\n7 3 5 3 4\n2 1 3 2 3\n", "7\n4 6 5 8 8 2 6\n2 1 2 2 1 1 2\n" ], "output": [ "5 7 3 4 3\n", "6 8 5 4 8 6 2\n" ] }
{ "input": [ "5\n7 3 5 3 4\n2 1 3 3 3\n", "7\n4 6 5 8 8 2 6\n2 1 2 1 1 1 2\n", "7\n4 12 5 8 8 2 6\n2 1 2 1 1 1 2\n", "7\n4 12 5 8 8 2 5\n2 1 2 1 1 1 2\n", "7\n4 12 5 8 8 2 5\n2 1 2 1 1 1 1\n", "7\n4 12 5 8 8 2 5\n2 1 2 0 1 1 1\n", "7\n4 12 5 8 8 2 5\n2 1 2 0 1 1 0\n", "7\n8 6 5 8 8 2 6...
brio-and-house-2-1
Brio got his house constructed near the National Highway. The Construction and Planning Committee has planned to construct a road near his house. Brio is worried about the Committee's plan as he fears that his house might come on the way of the road being constructed. In such a case, he needs to request the Committee m...
{ "input": [], "output": [] }
{ "input": [ "2\n5 5 -5 5 \n4\n1 2 3 4\n5\n\nSAMPLE" ], "output": [ "SAFE\nREPLANNING\n" ] }
{ "input": [ "2\n5 3 -5 5 \n4\n1 2 3 4\n5\n\nSAMPLE", "2\n5 4 -5 5 \n4\n1 2 0 4\n5\n\nSAMPLE", "2\n5 8 -9 5 \n1\n1 2 0 4\n1\n\nSAMPLE", "2\n13 8 -9 5 \n1\n0 1 0 6\n0\n\nSAMPLE", "2\n31 1 -1 1 \n1\n0 1 1 6\n0\n\nRAMPME", "2\n31 1 -1 0 \n1\n-1 1 1 2\n0\n\nEMPMAR", "2\n10 1 -1 0 \n1\n2 1 0 0\...
game-of-bots
There are two kind of bots in the game BOT A and BOT B. Both are designed so as to move only in one direction in a 1-D array. Bot A can move towards left whereas bot B is constrained to move rightwards. Both are constrained to move only to the empty elements and one cannot jump over another bot. Now, a particular state...
{ "input": [], "output": [] }
{ "input": [ "2\n#A#B#B# A###B#B\n#A#B# #B#A#\n\nSAMPLE" ], "output": [ "Yes\nNo\n" ] }
{ "input": [ "2\n#A#B#A# A###B#B\n#A#B# #B#A#\n\nSAMPLE", "2\n#A#B#B# A###B#B\n#A#B# #B#A#\n\nS@MPLE", "2\n#A#B#A# A###B#B\n#@#B# #B#A#\n\nSAMPLE", "2\n#A#B#A# A#$#B#B\n#@#B# #B#A#\n\nSAMPLE", "2\n#A#B#A# A#$#B#B\n#@#B# #B#A\"\n\nSAMPLE", "2\n#A#B#A# A#$#C#B\n#@#B# #B#A\"\n\nSAMPLE", "2\n#...
karan-and-his-sticker-collection
The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime. Karan likes stickers. All his stickers are rect...
{ "input": [], "output": [] }
{ "input": [ "2\n18 400000000\n\nSAMPLE" ], "output": [ "1\n" ] }
{ "input": [ "2\n18 757482671\n\nSAMPLE", "2\n8 120919901\n\nFAMPMR", "2\n4 757482671\n\nSAMPLE", "2\n4 535383490\n\nSAMPLE", "2\n4 535383490\n\nSAMPLF", "2\n4 804643187\n\nSAMPLF", "2\n8 804643187\n\nSAMPLF", "2\n8 804643187\n\nRAMPLF", "2\n0 804643187\n\nRAMPLF", "2\n0 482804...
starting-game-development
Every one is now a days playing games on their smartphones for passing free time. Because of which there are number of game developing companies growing in the market. Not only that, each company is now flooding the market with a lot of games. With such a huge number of games in the market, for each company, with milli...
{ "input": [], "output": [] }
{ "input": [ "2 3 3\n10 20 30\n7 14 100\n11 7\n35 13\n100 1002\n\nSAMPLE" ], "output": [ "1\n1\n3\n" ] }
{ "input": [ "2 3 3\n10 20 30\n3 14 100\n11 7\n35 13\n100 1002\n\nSAMPLE", "2 3 1\n10 20 18\n3 14 100\n11 7\n45 7\n100 1002\n\nSAMQLE", "2 3 2\n10 20 30\n7 14 100\n11 7\n35 13\n100 1002\n\nSAMPLE", "2 3 3\n10 20 30\n7 14 100\n11 7\n35 24\n100 1002\n\nSAMPLE", "2 3 3\n10 20 38\n3 4 110\n22 10\n16 5...
p02584 AtCoder Beginner Contest 175 - Walking Takahashi
Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so that the absolute value of the coordinate of the destination wil...
{ "input": [], "output": [] }
{ "input": [ "1000000000000000 1000000000000000 1000000000000000", "6 2 4", "10 1 2", "7 4 3" ], "output": [ "1000000000000000", "2", "8", "1" ] }
{ "input": [ "1000000000000000 1000100000000000 1000000000000000", "3 2 4", "10 1 4", "7 6 3", "7 0 3", "13 0 3", "1000100000000000 1000101000000000 1000000001000000", "13 1 3", "1000100100000000 1000101000000000 1000000001000000", "15 1 3", "15 1 4", "1000100100000000 ...
p02715 AtCoder Beginner Contest 162 - Sum of gcd of Tuples (Hard)
Consider sequences \\{A_1,...,A_N\\} of length N consisting of integers between 1 and K (inclusive). There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them. Since this sum can be enormous, print the value modulo (10^9+7). Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1...
{ "input": [], "output": [] }
{ "input": [ "100000 100000", "3 200", "3 2" ], "output": [ "742202979", "10813692", "9" ] }
{ "input": [ "101000 100000", "3 224", "5 2", "101010 100000", "4 224", "5 1", "4 169", "4 227", "4 64", "7 2", "8 64", "5 0", "8 80", "8 5", "3 214", "3 3", "3 190", "14 2", "2 224", "4 168", "4 55", "4 82", "1 2", "8 44"...
p02844 Sumitomo Mitsui Trust Bank Programming Contest 2019 - Lucky PIN
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? ...
{ "input": [], "output": [] }
{ "input": [ "4\n0224", "6\n123123", "19\n3141592653589793238" ], "output": [ "3", "17", "329" ] }
{ "input": [ "19\n5546189040285140044", "19\n4753841743850076999", "19\n9039528710159876563", "19\n3616863455241776042", "19\n2785343766571511696", "19\n2922045480066417189", "19\n7230040539071200180", "19\n1036710694297327965", "19\n1455506616048969060", "19\n33565210068211285...
p02981 AtCoder Beginner Contest 133 - T or T
N of us are going on a trip, by train or taxi. The train will cost each of us A yen (the currency of Japan). The taxi will cost us a total of B yen. How much is our minimum total travel expense? Constraints * All values in input are integers. * 1 \leq N \leq 20 * 1 \leq A \leq 50 * 1 \leq B \leq 50 Input Input i...
{ "input": [], "output": [] }
{ "input": [ "4 2 7", "4 2 9", "4 2 8" ], "output": [ "7", "8", "8" ] }
{ "input": [ "6 2 7", "4 4 9", "3 2 8", "6 1 0", "7 6 12", "6 4 1", "7 4 2", "12 2 20", "11 4 4", "5 2 5", "5 2 8", "1 2 -1", "50 0 -2", "5 -1 4", "50 -1 -2", "87 -1 -2", "5 -2 1", "42 -1 -2", "45 -1 -2", "5 -3 0", "3 -1 4", "5 -5...
p03122 World Tour Finals 2019 - Triangular Lamps Hard
Red bold fonts show the difference from C1. There is an infinitely large triangular grid, as shown below. Each point with integer coordinates contains a lamp. <image> Initially, only the lamp at (X, Y) was on, and all other lamps were off. Then, Snuke performed the following operation zero or more times: * Choose t...
{ "input": [], "output": [] }
{ "input": [ "4\n-2 1\n-2 2\n0 1\n1 0" ], "output": [ "-1 0" ] }
{ "input": [ "4\n-2 1\n-2 0\n0 1\n1 0", "4\n-2 1\n-2 0\n0 1\n2 0", "4\n-2 1\n-2 0\n-1 1\n2 0", "4\n-2 1\n-2 0\n-1 2\n2 0", "4\n-2 1\n-2 1\n0 1\n1 0", "4\n-2 1\n-2 0\n1 1\n2 0", "4\n-2 1\n-2 -1\n0 1\n2 0", "4\n-2 1\n-2 0\n-1 2\n1 1", "4\n-2 2\n-2 0\n0 1\n1 -1", "4\n-2 1\n-2 0\n-...
p03264 AtCoder Beginner Contest 108 - Pair
Find the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter. Constraints * 2\leq K\leq 100 * K is an integer. Input Input is given from Standard Input in the following format: K Output Print the number of ways to...
{ "input": [], "output": [] }
{ "input": [ "6", "50", "11", "3" ], "output": [ "9", "625", "30", "2" ] }
{ "input": [ "2", "59", "14", "0", "104", "7", "4", "51", "5", "10", "89", "-3", "17", "118", "20", "84", "-9", "35", "13", "-6", "8", "26", "27", "-12", "36", "42", "-11", "67", "-29", "105", "...
p03422 AtCoder Regular Contest 091 - Strange Nim
Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i. Starting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation: * Choose a pile. If the i-th pile is selected and th...
{ "input": [], "output": [] }
{ "input": [ "4\n3141 59\n26535 897\n93 23\n8462 64", "3\n28 3\n16 4\n19 2", "3\n3 2\n4 3\n5 1", "2\n5 2\n3 3" ], "output": [ "Takahashi", "Aoki", "Takahashi", "Aoki" ] }
{ "input": [ "4\n3141 59\n26535 897\n73 23\n8462 64", "2\n7 2\n3 6", "3\n28 3\n16 4\n22 2", "3\n3 2\n4 3\n6 1", "4\n3141 59\n51840 897\n73 23\n8462 64", "3\n28 3\n21 4\n22 2", "3\n3 2\n5 3\n6 1", "4\n3141 59\n51840 897\n73 23\n3930 64", "3\n28 3\n21 1\n22 2", "3\n0 2\n5 3\n6 1"...
p03580 CODE FESTIVAL 2017 qual B - 101 to 010
N cells are arranged in a row. Some of them may contain tokens. You are given a string s that consists of `0`s and `1`s. If the i-th character of s is `1`, the i-th cell (from left) contains a token. Otherwise, it doesn't contain a token. Snuke wants to perform the following operation as many times as possible. In eac...
{ "input": [], "output": [] }
{ "input": [ "7\n1010101", "50\n10101000010011011110001001111110000101010111100110" ], "output": [ "2", "10" ] }
{ "input": [ "7\n1010001", "50\n10101000010011011110001001111110001101010111100110", "7\n1000001", "50\n10101000010011011010001001111110001101010111100100", "50\n10101000010011011010001001111110001101010111000100", "50\n10101000010011010010001001111110001101010111000100", "7\n1101001", ...
p03737 AtCoder Beginner Contest 059 - Three-letter acronym
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Stan...
{ "input": [], "output": [] }
{ "input": [ "resident register number", "async layered coding", "k nearest neighbor", "atcoder beginner contest" ], "output": [ "RRN", "ALC", "KNN", "ABC" ] }
{ "input": [ "resident retsiger number", "asymc layered coding", "k nearest robhgien", "atcoder beginner contdst", "ysamc layered coding", "k tseraen robhgien", "resident setsiger nuebmr", "ysamc layered gnidoc", "resident setsiger rmbeun", "ysamc kayered gnidoc", "l tserae...
p03899 CODE FESTIVAL 2016 Tournament Round 3 (Parallel) - Struck Out
There are N panels arranged in a row in Takahashi's house, numbered 1 through N. The i-th panel has a number A_i written on it. Takahashi is playing by throwing balls at these panels. Takahashi threw a ball K times. Let the panel hit by a boll in the i-th throw be panel p_i. He set the score for the i-th throw as i \t...
{ "input": [], "output": [] }
{ "input": [ "5 2 3\n10 2 8 10 2", "10 3 5\n3 7 2 6 9 4 8 5 1 1000000000", "5 5 2\n5 2 10 5 9" ], "output": [ "56", "5000000078", "28" ] }
{ "input": [ "5 2 3\n10 2 11 10 2", "10 3 5\n0 7 2 6 9 4 8 5 1 1000000000", "5 5 2\n1 2 10 5 9", "10 3 5\n0 7 2 6 9 4 2 5 1 1000000000", "5 5 2\n1 2 5 5 9", "5 2 2\n10 2 11 10 1", "5 2 2\n5 2 11 10 1", "5 5 2\n2 2 5 8 9", "5 2 2\n5 2 11 6 1", "5 5 2\n2 2 5 8 6", "5 2 2\n2 2...
p00005 GCD and LCM
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b. Constraints * 0 < a, b ≤ 2,000,000,000 * LCM(a, b) ≤ 2,000,000,000 * The number of data sets ≤ 50 Input Input consists of several data sets. Each data set contains a and b separated by a single spa...
{ "input": [], "output": [] }
{ "input": [ "8 6\n50000000 30000000" ], "output": [ "2 24\n10000000 150000000" ] }
{ "input": [ "8 6\n50000000 24597532", "8 6\n88904261 24597532", "14 6\n88904261 24597532", "14 6\n88904261 49076254", "14 4\n88904261 49076254", "8 6\n50000000 25142724", "8 6\n50000000 42267576", "8 6\n162089565 24597532", "14 4\n88904261 24597532", "14 8\n88904261 49076254",...
p00137 Middle-Square Method
Create a program of the square picking method, which is one of the classical random number generation methods. The square harvesting method was proposed by von Neumann in the mid-1940s. In the square picking method, when the number of digits of the generated random number is n, the square of the initial value s is cal...
{ "input": [], "output": [] }
{ "input": [ "2\n123\n567" ], "output": [ "Case 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082" ] }
{ "input": [ "2\n210\n567", "2\n210\n225", "2\n272\n225", "2\n272\n153", "2\n499\n153", "2\n711\n153", "2\n390\n153", "2\n390\n297", "2\n191\n297", "2\n191\n461", "2\n289\n461", "2\n289\n615", "2\n242\n615", "2\n387\n615", "2\n38\n615", "2\n16\n615", ...
p00270 Railroad
We have decided to introduce an automatic ticket gate to the railway network of a certain country. One of the difficult issues to implement is determining whether a given ticket can move between designated stations. Each ticket has a boarding station and a getting-off station. With this ticket, you can not only "get on...
{ "input": [], "output": [] }
{ "input": [ "6 7\n1 2 3\n1 4 1\n2 3 5\n4 3 1\n3 6 2\n4 5 2\n5 6 1\n1 6 6\n1 6\n4 3\n4 6\n5 6\n2 6\n2 5" ], "output": [ "Yes\nYes\nYes\nYes\nNo\nNo" ] }
{ "input": [ "6 3\n1 2 3\n1 4 1\n2 3 5\n4 3 1\n3 6 2\n4 5 2\n5 6 1\n1 6 6\n1 6\n4 3\n4 6\n5 6\n2 6\n2 5", "6 3\n1 2 3\n1 4 1\n2 3 5\n4 3 2\n3 1 2\n1 5 2\n5 6 1\n1 6 6\n1 6\n4 3\n4 6\n8 6\n2 6\n2 5", "6 0\n1 2 5\n1 4 2\n2 3 5\n4 3 1\n3 0 2\n1 5 2\n5 2 1\n1 4 6\n1 2\n4 3\n4 0\n5 6\n1 11\n2 5", "6 2\n1 1...
p00458 Crossing Black Ice
problem One day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In addition, there are sections with and without thin ice. JOI Taro decided ...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 0 0\n1 0 0 0 1\n0\n0" ], "output": [ "5\n5" ] }
{ "input": [ "3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0", "3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0", "3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 1 1 0 1\n0\n0", "3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 0 1 0 1\n1 1 0 1 0\n1 0 0 0 1\n...
p00648 Watchin' TVA
Animation is one of methods for making movies and in Japan, it is popular to broadcast as a television program or perform as a movie. Many people, especially the young, love one. And here is an anime lover called Jack. We say he is an mysterious guy with uncertain age. He likes anime which are broadcasted in midnight a...
{ "input": [], "output": [] }
{ "input": [ "1\ngalaxy_angel 0 600\n1\ngalaxy_angel\n11\nA 0 600\nB 0 610\nC 0 610\nD 0 610\nE 0 640\nEE 0 700\nF 0 710\nG 0 710\nH 0 710\nI 0 740\nJ 0 750\n2\nB\nH\n42\nnchj 6 2620\nanhnnnmewbktthsrn 4 2515\ngntmdsh 1 1800\nachnnl 4 2540\nhnskirh 0 2200\naonexrcst 0 1700\ndgdys 6 2330\nhdnnara 4 2525\ndnpaonnts...
{ "input": [ "1\ngalaxy_angel 0 600\n1\ngalaxy_angel\n11\nA 0 600\nB 0 610\nC 0 610\nD 0 610\nE 0 640\nEE 0 700\nF 0 710\nG 0 710\nH 0 710\nI 0 740\nJ 0 750\n2\nB\nH\n42\nnchj 6 2620\nanhnnnmewbktthsrn 4 2515\ngntmdsh 1 1800\nachnnl 4 2540\nhnskirh 0 2200\naonexrcst 0 1700\ndgdys 6 2330\nhdnnara 4 2525\ndnpaonnts...
p00792 Mirror Illusion
A rich man has a square room with mirrors for security or just for fun. Each side of the room is eight meters wide. The floor, the ceiling and the walls are not special; however, the room can be equipped with a lot of mirrors on the walls or as vertical partitions. Every mirror is one meter wide, as tall as the wall, ...
{ "input": [], "output": [] }
{ "input": [ "0\n1\ny 8 7\n4\ny 8 7\nx 7 8\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 2\ny 0 0\nx 0 0\n-1" ], "output": [ "800 750\n750 800\n75 25\n75 25" ] }
{ "input": [ "0\n1\ny 1 7\n4\ny 8 7\nx 7 8\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 2\ny 0 0\nx 0 0\n-1", "0\n1\ny 1 7\n4\ny 8 7\nx 7 8\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 4\ny 0 0\nx 0 0\n-1", "0\n1\ny 1 7\n4\ny 8 7\nx 7 7\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 2\ny 0 0\nx 0 0\n-1", "0\n1\ny 1 7\n4\ny 8 7\nx 7 7\ny 0 0\nx 0 0\n4...
p00924 Bit String Reordering
Example Input 6 3 1 0 0 1 0 1 1 3 2 Output 1
{ "input": [], "output": [] }
{ "input": [ "6 3\n1 0 0 1 0 1\n1 3 2" ], "output": [ "1" ] }
{ "input": [ "1 3\n1 0 0 1 0 1\n1 3 2", "6 3\n1 0 1 0 0 1\n1 3 2", "6 3\n1 0 0 1 0 1\n0 3 3", "6 3\n0 1 0 1 0 1\n0 3 3", "6 3\n1 0 1 1 0 0\n1 3 2", "1 3\n1 0 0 1 0 1\n2 3 2", "1 3\n1 0 0 1 0 1\n2 3 1", "1 3\n1 0 0 1 0 1\n2 0 1", "1 3\n1 0 0 1 0 1\n1 3 1", "1 3\n1 0 -1 1 0 1\n1 ...
p01057 String Crossing
Problem N strings {S1, S2, ..., SN} are given. Then Q queries are given. There are two types of queries: 1. When a, b, c, d are input, the substring from the bth character of Sa is connected after the substring up to the d-1 character of Sc. Let this be the new Sc. Concatenate the substring from the dth character of ...
{ "input": [], "output": [] }
{ "input": [ "2 1\nabcd\nefgh\n1 1 2 2 3", "2 3\nabcd\nefgh\n1 1 2 2 3\n2 1 3 x\n2 2 4 x", "10 10\nsjcvpauokb\nfmeaowomscy\nsepeqqfcosrjmonfsv\nzapc\naromazjzqoeiqswvcaf\nclifpa\ndusudcz\nqeqdzdtdzlkhc\ngkpsjvdvadmf\nxrtyxnkolluagwxp\n1 4 4 6 3\n1 7 1 8 1\n2 2 6 o\n1 4 4 3 7\n2 1 2 i\n1 6 3 3 2\n1 6 5 1 9...
{ "input": [ "2 1\nabcd\nefgh\n1 1 1 2 3", "2 3\nabcd\nefgh\n1 1 2 2 3\n2 1 3 y\n2 2 4 x", "10 10\nsjcvpauokb\nfmesowomacy\nsepeqqfcosrjmonfsv\nzapc\naromazjzqoeiqswvcaf\nclifpa\ndusudcz\nqeqdzdtdzlkhc\ngkpsjvdvadmf\nxrtyxnkolluagwxp\n1 4 4 6 3\n1 7 1 8 1\n2 2 6 o\n1 4 4 3 7\n2 1 2 i\n1 6 3 3 2\n1 6 5 1 9...
p01189 Roads in a City
Roads in a city play important roles in development of the city. Once a road is built, people start their living around the road. A broader road has a bigger capacity, that is, people can live on a wider area around the road. Interstellar Conglomerate of Plantation and Colonization (ICPC) is now planning to develop ro...
{ "input": [], "output": [] }
{ "input": [ "2\n0 -12 0 0 2\n0 0 12 0 2\n0" ], "output": [ "39.14159" ] }
{ "input": [], "output": [] }
p01326 UTF-8
UTF-8 is one of the methods for coding multibyte characters. Characters are treated as bytes on the computer. If it is only English, it can be expressed in 1 byte even if the Latin alphabet, numbers and symbols are combined, but unfortunately it is not possible to express the characters used all over the world in 1 by...
{ "input": [], "output": [] }
{ "input": [ "1\nxxxxxxxx", "1\nxxxxxxxx\n3\n11100000\n10x00000\n10111111\n3\n11100000\n10000000\n10111111\n4\nxxxxxxxx\nxxxxxxxx\nxxxxxxxx\nxxxxxxxx\n0", "3\n11100000\n10000000\n10111111", "3\n11100000\n10x00000\n10111111", "4\nxxxxxxxx\nxxxxxxxx\nxxxxxxxx\nxxxxxxxx" ], "output": [ "128",...
{ "input": [ "3\n11100000\n10100000\n10111111", "3\n11100000\n00x00001\n10111111", "3\n11000100\n10000x00\n00111111", "3\n11100000\n10100000\n10110111", "3\n11100000\n00x00001\n00111111", "3\n11100000\n00100000\n10110111", "3\n11100100\n00x00001\n00111111", "3\n11100000\n00100000\n1111...
p01494 ThreeRooks
Example Input 3 3 1 0 0 Output 4
{ "input": [], "output": [] }
{ "input": [ "3 3 1\n0 0" ], "output": [ "4" ] }
{ "input": [ "3 5 1\n0 0", "3 1 1\n0 0", "3 4 1\n0 0", "3 5 1\n0 1", "3 6 1\n0 0", "3 7 1\n0 1", "3 6 0\n0 0", "3 6 1\n0 1", "3 6 1\n0 2", "3 6 1\n1 2", "4 4 1\n0 0", "4 5 1\n0 1", "4 7 1\n0 1", "3 6 1\n1 1", "2 6 -1\n0 0", "4 5 1\n0 0", "3 2 1\n1 0"...
p01660 Sugoroku
E-Sugoroku Bob, a fox with no friends, decided to spend his time playing sugoroku alone today. A 6-sided die with integers a_1, a_2, a_3, a_4, a_5, a_6 written on each side, a piece, and M squares on a straight line, and numbers from 1 to M are assigned in order from the left. I decided to use a board. Instructions ar...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p01807 Stamp Rally
Stamp Rally Stamp Rally The Japan Amusement Group (JAG) is planning an event at a theme park that imitates an island country. In this event, each time a participant crosses a bridge, the stamps decided for each bridge are stamped in order on the stamp book. The prepared stamp is one of the following seven types. a ...
{ "input": [], "output": [] }
{ "input": [ "4 5 1 4\n1 2 (\n1 3 a\n2 4 a\n3 4 )\n3 2 +\n4 4 1 2\n1 3 (\n3 4 a\n4 1 +\n3 2 a\n3 4 1 1\n1 2 a\n2 2 +\n2 3 a\n3 1 a\n5 8 1 5\n1 1 [\n1 2 (\n2 1 *\n2 2 a\n2 3 a\n3 3 )\n3 4 ]\n4 5 )\n2 14 1 1\n1 2 a\n1 2 (\n1 2 )\n1 2 [\n1 2 ]\n1 2 +\n1 2 *\n2 1 a\n2 1 (\n2 1 )\n2 1 [\n2 1 ]\n2 1 +\n2 1 *\n0 0 0 0" ...
{ "input": [ "4 5 1 4\n1 2 (\n1 3 a\n2 4 a\n3 4 )\n3 2 +\n4 4 1 1\n1 3 (\n3 4 a\n4 1 +\n3 2 a\n3 4 1 1\n1 2 a\n2 2 +\n2 3 a\n3 1 a\n5 8 1 5\n1 1 [\n1 2 (\n2 1 *\n2 2 a\n2 3 a\n3 3 )\n3 4 ]\n4 5 )\n2 14 1 1\n1 2 a\n1 2 (\n1 2 )\n1 2 [\n1 2 ]\n1 2 +\n1 2 *\n2 1 a\n2 1 (\n2 1 )\n2 1 [\n2 1 ]\n2 1 +\n2 1 *\n0 0 0 0",...
p01942 Taiyaki-Master and Eater
E: Taiyaki-Master and Eater story Tsuta is very good at making Taiyaki. Ebi-chan loves Taiyaki made by Tsuta-san. The two are happy to make and eat Taiyaki every week, but Tsuta-san's recent worries are that Ebi-chan, who is in the middle of eating, eats the food while making Taiyaki. Mr. Tsuta, who decided to make ...
{ "input": [], "output": [] }
{ "input": [ "3 3 3 6\n1 0 1 1\n2 2 1 1 2 2\n3 1 1 1\n4 0 2 1\n5 2 1 1 2 2\n6 2 2 1 3 3" ], "output": [ "0 1\n1 1\n0 1" ] }
{ "input": [ "3 3 3 6\n1 0 1 1\n2 2 1 1 2 2\n3 1 1 1\n4 0 2 1\n5 2 2 1 2 2\n6 2 2 1 3 3", "3 3 3 6\n1 0 1 1\n2 2 1 1 2 2\n3 1 1 1\n4 0 2 1\n5 2 2 1 2 2\n6 2 3 1 3 3", "3 3 3 6\n1 0 1 1\n2 2 1 0 2 2\n3 1 1 1\n4 0 2 1\n5 2 1 1 2 2\n6 2 2 1 3 3", "3 3 3 6\n1 0 1 1\n2 2 1 1 0 2\n3 1 1 1\n4 0 2 1\n5 2 2 1 ...
p02091 XORANDORBAN
D: XORANDORBAN Problem Statement You are given a positive integer N. Your task is to determine a set S of 2^N integers satisfying the following conditions: * All the integers in S are at least 0 and less than 2^{N+1}. * All the integers in S are distinct. * You are also given three integers X, A, and O, where 0 \le...
{ "input": [], "output": [] }
{ "input": [ "2 6 1 5" ], "output": [ "Yes\n0 3 4 7" ] }
{ "input": [ "2 6 0 5", "2 6 0 6", "2 5 0 4", "2 5 1 1", "2 5 1 0", "2 4 1 4", "2 4 0 3", "3 5 1 1", "3 5 1 0", "2 4 2 4", "3 4 0 3", "2 4 2 0", "4 4 2 0", "4 4 2 1", "4 7 2 1", "4 11 2 1", "4 11 3 1", "4 11 1 1", "9 2 0 1", "9 1 0 2", ...
p02223 String Set
Problem statement Of the string set $ S $ that meets the following conditions, configure $ 1 $ with the largest number of elements. * The length of the string contained in $ S $ is $ 1 $ or more and $ N $ or less. * The lengths of the strings contained in $ S $ are different. * The string contained in $ S $ consists ...
{ "input": [], "output": [] }
{ "input": [ "2" ], "output": [ "2\n0\n11" ] }
{ "input": [], "output": [] }
p02375 Range Query on a Tree II
Write a program which manipulates a weighted rooted tree $T$ with the following operations: * $add(v,w)$: add $w$ to all edges from the root to node $u$ * $getSum(u)$: report the sum of weights of all edges from the root to node $u$ The given tree $T$ consists of $n$ nodes and every node has a unique ID from $0$ t...
{ "input": [], "output": [] }
{ "input": [ "4\n1 1\n1 2\n1 3\n0\n6\n0 3 1000\n0 2 1000\n0 1 1000\n1 1\n1 2\n1 3", "6\n2 1 2\n2 3 5\n0\n0\n0\n1 4\n7\n1 1\n0 3 10\n1 2\n0 4 20\n1 3\n0 5 40\n1 4" ], "output": [ "3000\n5000\n6000", "0\n0\n40\n150" ] }
{ "input": [ "4\n1 1\n1 2\n1 3\n0\n6\n0 3 1000\n0 2 1000\n0 1 1001\n1 1\n1 2\n1 3", "4\n1 1\n1 2\n1 3\n0\n6\n0 3 1000\n0 2 1000\n0 1 1001\n1 0\n1 2\n1 3", "6\n2 1 2\n2 3 5\n0\n0\n0\n1 4\n7\n1 1\n0 3 6\n1 2\n0 4 20\n1 3\n0 5 40\n1 4", "4\n1 1\n1 2\n1 3\n0\n6\n0 0 1000\n0 2 1000\n0 1 1001\n1 1\n1 2\n1 3...
cds002
There are n children who have landed up in an unknown place where they find just some jar of cookies to eat. They also have a dog with them. The children gather all the cookies and put them in a big jar. Exhausted, they agree to go and wait until the next morning to divide up the cookies. At one o'clock in the morning,...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n6" ], "output": [ "15621\n279931" ] }
{ "input": [], "output": [] }
cw5
With her new hair-style, Penny has to listen to all the comments of Sheldon Cooper. She (God knows why) challenged Sheldon Cooper for a match of Chess. Penny wants to defeat Dr. Sheldon Cooper in the game of chess. Although, she tried very hard, she is in a situation and wants your help. It is your duty to help Penny. ...
{ "input": [], "output": [] }
{ "input": [ "____B___\n________\n__Q_____\n________\n____P_S_\n_R______\n________\n________" ], "output": [ "NOT YET!" ] }
{ "input": [], "output": [] }
icq2
Prats is learning to count.But this is not a usual counting.He has been given the task to count number of trailing 0s in a binary representation of a number.   Input First line of input contains T, number of test cases. Each of the next T lines contains a number N.   Output Output the number of trailing 0s in binary ...
{ "input": [], "output": [] }
{ "input": [ "2\n4\n7" ], "output": [ "2\n0" ] }
{ "input": [ "2\n2\n7", "2\n2\n6", "2\n1\n1", "2\n4\n12", "2\n4\n6", "2\n4\n1", "2\n1\n2", "2\n8\n1", "2\n1\n12", "2\n2\n12", "2\n16\n7", "2\n2\n16", "2\n4\n8", "2\n2\n8", "2\n3\n16", "2\n4\n16", "2\n3\n8", "2\n16\n4", "2\n16\n6", "2\n5\n...
mriu2
A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its (base 10) digits will be prime.[1][2] For example 1193 is a circular prime, since 1931, 9311 and 3119 all are also prime Input First line contains an integer N, number of inputs. Seco...
{ "input": [], "output": [] }
{ "input": [ "10\n88 11 2 5 6 9 100 121 233 79" ], "output": [ "0 1 1 1 0 0 0 0 0 1" ] }
{ "input": [], "output": [] }
rgame
Princess Rupsa saw one of her friends playing a special game. The game goes as follows: N+1 numbers occur sequentially (one at a time) from A0 to AN. You must write the numbers on a sheet of paper, such that A0 is written first. The other numbers are written according to an inductive rule — after Ai-1 numbers have bee...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n1 2\n2\n1 2 1" ], "output": [ "4\n14\n" ] }
{ "input": [ "2\n1\n1 2\n2\n2 2 1", "2\n1\n1 2\n2\n2 2 0", "2\n1\n1 0\n2\n2 2 0", "2\n1\n1 0\n2\n3 2 0", "2\n1\n1 0\n2\n3 2 -1", "2\n1\n1 0\n2\n3 4 -1", "2\n1\n1 2\n2\n1 2 2", "2\n1\n1 2\n2\n2 3 1", "2\n1\n1 2\n2\n2 1 0", "2\n1\n1 0\n2\n6 2 -1", "2\n1\n1 0\n2\n3 4 -2", ...
uaseq
You are given an array that consists of n integer numbers. You have to change at most K elements of this array, so that the resulting array will be a arithmetic progression. From all the possible arithmetic progressions, you should choose most beautiful. You can uniquely define the arithmetic progression by two number...
{ "input": [], "output": [] }
{ "input": [ "4 2\n1 2 1 4" ], "output": [ "-5 -2 1 4\n" ] }
{ "input": [ "4 2\n1 0 1 4", "4 2\n1 2 0 4", "4 2\n1 0 1 8", "4 2\n1 1 1 2", "4 2\n1 1 2 2", "4 2\n1 1 2 4", "4 2\n1 1 2 8", "4 2\n1 -1 2 4", "4 2\n-1 0 0 2", "4 2\n1 2 0 6", "4 2\n1 0 0 8", "4 2\n1 1 4 4", "4 2\n1 -1 -1 4", "4 2\n0 0 0 7", "4 2\n1 0 -1 8", ...
1211_D. Teams
There are n table bowling players, the rating of the i-th player equals r_i. Compose a maximum number of teams in a such way that: * each player belongs to at most one team; * each team contains exactly a+b players; * each team contains a group of a players with the same rating and a group of b players with an...
{ "input": [], "output": [] }
{ "input": [ "12 1 2 2\n1 1 2 2 2 2 2 3 3 4 6 6\n", "14 1 1 3\n3 3 1 1 9 9 2 3 6 6 3 18 3 18\n", "1 2 3 10\n1000000\n" ], "output": [ "\n3\n", "\n6\n", "\n0\n" ] }
{ "input": [], "output": [] }
1360_H. Binary Median
Consider all binary strings of length m (1 ≤ m ≤ 60). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly 2^m such strings in total. The string s is lexicographically smaller than the string t (both have the sam...
{ "input": [], "output": [] }
{ "input": [ "5\n3 3\n010\n001\n111\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n" ], "output": [ "100\n010\n0\n1\n11\n" ] }
{ "input": [ "5\n3 3\n010\n001\n110\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "5\n3 3\n010\n001\n101\n4 3\n000\n111\n100\n011\n1 1\n1\n1 1\n1\n3 2\n00\n01\n10\n", "5\n3 3\n010\n101\n110\n4 3\n000\n110\n100\n011\n1 1\n1\n1 1\n0\n3 2\n00\n01\n10\n", "5\n3 3\n010\n001\n111\n4 3\n000\n...
1496_A. Split it!
Kawashiro Nitori is a girl who loves competitive programming. One day she found a string and an integer. As an advanced problem setter, she quickly thought of a problem. Given a string s and a parameter k, you need to check if there exist k+1 non-empty strings a_1,a_2...,a_{k+1}, such that $$$s=a_1+a_2+… +a_k+a_{k+1}...
{ "input": [], "output": [] }
{ "input": [ "7\n5 1\nqwqwq\n2 1\nab\n3 1\nioi\n4 2\nicpc\n22 0\ndokidokiliteratureclub\n19 8\nimteamshanghaialice\n6 3\naaaaaa\n" ], "output": [ "\nYES\nNO\nYES\nNO\nYES\nNO\nNO\n" ] }
{ "input": [ "7\n5 1\nqwqwq\n2 1\nab\n3 1\nioi\n4 2\nipcc\n22 0\ndokidokiliteratureclub\n19 8\nimteamshanghaialice\n6 3\naaaaaa\n", "7\n5 1\nqwqwq\n2 1\nab\n3 1\nioi\n4 2\nipcc\n22 0\ndokidokiliteratureclub\n19 0\necilaiahgnahsmaetmi\n6 3\naaaaaa\n", "7\n5 1\nqwqwq\n2 1\nab\n3 1\nioi\n4 2\nipcc\n22 0\ndok...
241_E. Flights
LiLand is a country, consisting of n cities. The cities are numbered from 1 to n. The country is well known because it has a very strange transportation system. There are many one-way flights that make it possible to travel between the cities, but the flights are arranged in a way that once you leave a city you will ne...
{ "input": [], "output": [] }
{ "input": [ "5 6\n1 2\n2 3\n3 5\n1 4\n4 5\n1 3\n", "3 3\n1 2\n2 3\n1 3\n", "4 4\n1 2\n2 3\n3 4\n1 4\n" ], "output": [ "Yes\n1\n1\n2\n2\n2\n2\n", "Yes\n1\n1\n2\n", "No" ] }
{ "input": [ "4 3\n1 2\n2 3\n3 4\n1 4\n", "4 4\n1 2\n2 3\n3 4\n1 3\n", "4 2\n1 2\n2 4\n3 4\n1 4\n", "4 3\n1 2\n2 3\n3 4\n1 3\n", "4 3\n1 2\n2 3\n3 4\n2 3\n", "4 3\n1 2\n2 3\n3 4\n1 5\n", "4 3\n1 2\n2 3\n3 4\n0 3\n", "4 3\n1 2\n2 3\n3 4\n0 5\n", "4 3\n1 2\n2 3\n3 4\n1 2\n", "4 3...
690_F2. Tree of Life (medium)
Heidi got tired of deciphering the prophecy hidden in the Tree of Life and decided to go back to her headquarters, rest a little and try there. Of course, she cannot uproot the Tree and take it with her, so she made a drawing of the Tree on a piece of paper. On second thought, she made more identical drawings so as to ...
{ "input": [], "output": [] }
{ "input": [ "1\n5 5\n2\n4 1\n2 1\n1\n3 1\n3\n4 1\n4 3\n2 1\n3\n3 1\n3 2\n4 1\n3\n2 1\n3 2\n4 2\n" ], "output": [ "YES\n1 2\n1 4\n3 4\n1 5\n" ] }
{ "input": [ "1\n5 5\n2\n4 1\n2 1\n1\n3 1\n3\n4 1\n4 3\n2 1\n3\n3 1\n3 1\n4 1\n3\n2 1\n3 2\n4 2\n", "1\n5 5\n2\n4 1\n2 1\n1\n3 1\n3\n4 1\n5 3\n2 1\n3\n3 1\n3 1\n4 1\n3\n2 1\n3 2\n4 2\n", "1\n5 5\n0\n4 1\n2 1\n1\n3 1\n3\n4 1\n5 3\n2 1\n3\n3 1\n3 1\n4 1\n3\n2 1\n3 2\n4 2\n", "1\n5 5\n0\n4 1\n2 1\n1\n3 1...
help-ashu-1
Ashu and Shanu are best buddies. One day Shanu gives Ashu a problem to test his intelligence.He gives him an array of N natural numbers and asks him to solve the following queries:- Query 0:- modify the element present at index i to x. Query 1:- count the number of even numbers in range l to r inclusive. Query 2:- cou...
{ "input": [], "output": [] }
{ "input": [ "6\n1 2 3 4 5 6\n4\n1 2 5\n2 1 4\n0 5 4\n1 1 6\n\nSAMPLE" ], "output": [ "2\n2\n4\n" ] }
{ "input": [ "6\n1 2 3 4 5 6\n4\n1 2 5\n2 1 3\n0 5 4\n1 1 6\n\nSAMPLE", "6\n1 2 6 4 5 6\n4\n1 1 5\n2 1 4\n0 5 4\n1 1 6\n\nSAMPLE", "6\n1 2 3 4 5 0\n4\n1 2 4\n2 1 3\n0 4 4\n1 2 6\n\nSAMPLE", "6\n1 2 2 4 5 12\n4\n1 1 5\n2 1 4\n0 5 5\n1 1 6\n\nSAMPLE", "6\n1 2 3 4 7 -1\n4\n1 2 4\n2 1 3\n0 4 4\n1 2 6\...
lucky-string-1
Lucky numbers are those numbers which contain only "4" and/or "5". For example 4, 5, 44, 54,55,444 are lucky numbers while 457, 987 ,154 are not. Lucky number sequence is one in which all lucky numbers exist in increasing order for example 4,5,44,45,54,55,444,445,454,455... Now we concatenate all the lucky number...
{ "input": [], "output": [] }
{ "input": [ "4\n1\n2\n3\n9\n\nSAMPLE" ], "output": [ "Hacker\nEarth\nHacker\nEarth\n" ] }
{ "input": [ "4\n1\n2\n3\n8\n\nSAMPLE", "4\n1\n1\n3\n8\n\nSAMPLE", "4\n1\n2\n1\n9\n\nSAMPLE", "4\n2\n2\n3\n8\n\nSAMPLE", "4\n4\n2\n7\n8\n\nSAMPLE", "4\n2\n2\n7\n4\n\nSPMBLE", "4\n4\n1\n4\n2\n\nSPMBLE", "4\n8\n1\n2\n4\n\nELBMPT", "4\n7\n1\n4\n2\n\nELBMPT", "4\n8\n1\n2\n2\n\nELBM...
navi-and-his-company-3
Navi is a CEO of a famous IT based software company. He is hiring some new developers to work in his company. He already know the number of new projects and number of hirings at particular timestamp. He will assign one project to one developer and that developer will work alone on that project . Your task is to help Na...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n1\nNew Project\nNew Project\n\nSAMPLE" ], "output": [ "1\n" ] }
{ "input": [ "1\n3\n2\nNew Project\nNew Project\n\nSAMPLE", "1\n3\n0\nNew Project\nNew Project\n\nSAMPLE", "1\n3\n1\nNew Project\nNew Project\n\nS@MPLE", "1\n3\n0\nNew Project\nNew Project\n\nSAMPME", "1\n3\n2\nNew Project\nNew Project\n\nSALPME", "1\n3\n0\nNew Project\nNew Project\n\nS@MPLE",...
sharpen-the-pencils-2
Madhav and Riya were getting bored. So they decided to play a game. They placed N pencils in a line. Madhav starts to sharpen pencil from left to right, and Riya from right to left. For each pencil, its length is known. Madhav sharpens with speed twice that of Riya. If a player starts to sharpen the pencil, other pla...
{ "input": [], "output": [] }
{ "input": [ "1\n5\n2 9 8 2 7\n\nSAMPLE" ], "output": [ "3 2\n" ] }
{ "input": [ "1\n5\n2 9 8 2 7\n\nSAMPLD", "1\n5\n2 9 8 4 0\n\nSAMPLD", "1\n5\n2 9 8 2 13\n\nSAMPLD", "1\n5\n2 7 1 2 -3\n\nSAMPLD", "1\n5\n2 9 8 4 7\n\nSAMPLD", "1\n5\n2 9 8 1 0\n\nSAMPLD", "1\n5\n2 9 6 1 0\n\nSAMPLD", "1\n5\n2 9 8 4 2\n\nSAMPLD", "1\n5\n0 9 8 1 0\n\nSAMPLD", "1...
the-blessing-1
In a village far far away, lived a farmer named Zico. He was finding it difficult to make his two ends meet and hence, approached the god of grains, Azure. Azure granted him a blessing: "I shall grant thou P units of food initially . After every year, thou shall come to me and the food units shall increase by a valu...
{ "input": [], "output": [] }
{ "input": [ "3\n0 1 \n0 3\n2 9\n\nSAMPLE" ], "output": [ "2\n6\n22\n" ] }
{ "input": [ "3\n0 1 \n0 6\n2 9\n\nSAMPLE", "3\n1 1 \n0 6\n2 9\n\nSAMPLE", "3\n1 2 \n0 6\n2 9\n\nSAMPLE", "3\n1 2 \n0 6\n0 9\n\nSAMPLE", "3\n1 2 \n1 6\n0 9\n\nSAMPLE", "3\n1 2 \n1 6\n-1 9\n\nSAMPLE", "3\n1 4 \n1 6\n-1 9\n\nPAMSLE", "3\n1 4 \n1 6\n-1 6\n\nPAMSLE", "3\n1 4 \n1 6\n-1 ...
p02647 Tokio Marine & Nichido Fire Insurance Programming Contest 2020 - Lamps
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity o...
{ "input": [], "output": [] }
{ "input": [ "5 1\n1 0 0 1 0", "5 2\n1 0 0 1 0" ], "output": [ "1 2 2 1 2", "3 3 4 4 3" ] }
{ "input": [ "5 1\n0 0 0 1 0", "5 2\n0 0 0 1 0", "5 2\n0 0 0 0 0", "5 2\n1 0 0 0 0", "5 2\n0 0 0 0 1", "5 0\n0 0 0 0 1", "5 2\n1 0 0 2 0", "5 2\n0 0 0 2 0", "5 3\n0 0 0 0 0", "5 2\n0 1 0 0 1", "5 0\n0 1 0 0 1", "5 2\n0 2 0 0 2", "5 2\n0 4 0 0 2", "5 2\n1 0 0 1 1...
p02776 AtCoder Beginner Contest 155 - Perils in Parallel
After being invaded by the Kingdom of AlDebaran, bombs are planted throughout our country, AtCoder Kingdom. Fortunately, our military team called ABC has managed to obtain a device that is a part of the system controlling the bombs. There are N bombs, numbered 1 to N, planted in our country. Bomb i is planted at the ...
{ "input": [], "output": [] }
{ "input": [ "4 2\n2 0\n3 1\n5 1\n7 0\n1 4\n4 7", "3 2\n5 0\n10 0\n8 0\n6 9\n66 99", "3 4\n5 1\n10 1\n8 0\n1 10\n4 5\n6 7\n8 9", "12 20\n536130100 1\n150049660 1\n79245447 1\n132551741 0\n89484841 1\n328129089 0\n623467741 0\n248785745 0\n421631475 0\n498966877 0\n43768791 1\n112237273 0\n21499042 142...
{ "input": [ "4 2\n2 0\n3 1\n5 1\n7 0\n2 4\n4 7", "3 0\n5 0\n10 0\n8 0\n6 9\n66 99", "12 20\n536130100 1\n230886416 1\n79245447 1\n132551741 0\n89484841 1\n328129089 0\n623467741 0\n248785745 0\n421631475 0\n498966877 0\n43768791 1\n112237273 0\n21499042 142460201\n58176487 384985131\n88563042 144788076\n...
p02911 AtCoder Beginner Contest 141 - Attack Survival
Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows. A game is played by N players, numbered 1 to N. At the beginning of a game, each player has K poi...
{ "input": [], "output": [] }
{ "input": [ "6 5 4\n3\n1\n3\n2", "10 13 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9", "6 3 4\n3\n1\n3\n2" ], "output": [ "Yes\nYes\nYes\nYes\nYes\nYes", "No\nNo\nNo\nNo\nYes\nNo\nNo\nNo\nYes\nNo", "No\nNo\nYes\nNo\nNo\nNo" ] }
{ "input": [ "6 1 4\n3\n1\n3\n2", "10 8 15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9", "6 3 4\n3\n1\n3\n4", "19 8 15\n3\n1\n4\n1\n5\n0\n2\n6\n5\n3\n5\n8\n9\n7\n9", "37 8 15\n3\n0\n4\n1\n5\n0\n2\n6\n5\n6\n5\n8\n1\n7\n13", "6 5 4\n3\n0\n3\n2", "8 1 4\n3\n1\n0\n2", "10 1 1\n3\n1\n0\n2"...
p03047 diverta 2019 Programming Contest - Consecutive Integers
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? Constraints * All values in input are integers. * 1 \leq K \leq N \leq 50 Input Input is given from Standard Input in the following format: N K Output Print the a...
{ "input": [], "output": [] }
{ "input": [ "13 3", "3 2" ], "output": [ "11", "2" ] }
{ "input": [ "13 6", "6 2", "13 1", "13 0", "23 1", "19 1", "2 1", "2 0", "2 -1", "0 0", "0 1", "15 1", "13 2", "6 1", "19 2", "30 1", "11 1", "9 0", "6 0", "24 1", "32 1", "17 1", "32 0", "6 -2", "26 1", "63 0", ...
p03188 AtCoder Grand Contest 030 - Coloring Torus
For an n \times n grid, let (r, c) denote the square at the (r+1)-th row from the top and the (c+1)-th column from the left. A good coloring of this grid using K colors is a coloring that satisfies the following: * Each square is painted in one of the K colors. * Each of the K colors is used for some squares. * Let us...
{ "input": [], "output": [] }
{ "input": [ "9", "2" ], "output": [ "3\n1 2 3\n4 5 6\n7 8 9", "3\n1 1 1\n1 1 1\n2 2 2" ] }
{ "input": [ "4", "0", "7", "3", "6", "10", "8", "19", "5", "13", "26", "11", "29", "15", "14", "12", "22", "32", "-7", "-11", "-15", "-19", "27", "21", "20", "31", "18", "24", "36", "17", "40",...
p03335 AtCoder Grand Contest 025 - Walking on a Tree
Takahashi loves walking on a tree. The tree where Takahashi walks has N vertices numbered 1 through N. The i-th of the N-1 edges connects Vertex a_i and Vertex b_i. Takahashi has scheduled M walks. The i-th walk is done as follows: * The walk involves two vertices u_i and v_i that are fixed beforehand. * Takahashi wi...
{ "input": [], "output": [] }
{ "input": [ "5 3\n1 2\n1 3\n3 4\n3 5\n2 4\n3 5\n1 5", "6 4\n1 2\n2 3\n1 4\n4 5\n4 6\n2 4\n3 6\n5 6\n4 5", "4 3\n2 1\n3 1\n4 1\n2 3\n3 4\n4 2" ], "output": [ "6\n2 4\n3 5\n5 1", "9\n2 4\n6 3\n5 6\n4 5", "6\n2 3\n3 4\n4 2" ] }
{ "input": [ "4 1\n2 1\n3 1\n4 1\n2 3\n3 4\n4 2", "4 0\n2 1\n3 1\n4 0\n2 3\n3 4\n4 2", "4 1\n2 1\n3 1\n5 -1\n3 3\n3 4\n4 2", "4 1\n2 1\n3 1\n4 0\n2 3\n3 4\n4 2", "4 1\n2 1\n3 1\n6 0\n2 3\n3 4\n4 2", "4 1\n2 1\n3 1\n5 0\n2 3\n3 4\n4 2", "4 1\n2 1\n3 1\n5 0\n2 3\n3 4\n4 4", "4 1\n2 1\n3 ...
p03496 AtCoder Beginner Contest 081 - Non-decreasing
Snuke has an integer sequence, a, of length N. The i-th element of a (1-indexed) is a_{i}. He can perform the following operation any number of times: * Operation: Choose integers x and y between 1 and N (inclusive), and add a_x to a_y. He would like to perform this operation between 0 and 2N times (inclusive) so ...
{ "input": [], "output": [] }
{ "input": [ "3\n-2 5 -1", "2\n-1 -3", "5\n0 0 0 0 0" ], "output": [ "2\n2 3\n3 3", "1\n2 1", "0" ] }
{ "input": [ "2\n-2 -3", "2\n1 -11", "3\n-3 5 -1", "2\n0 0", "2\n1 0", "2\n2 -1", "3\n-2 5 0", "2\n0 -3", "2\n0 -4", "2\n0 -7", "2\n0 -14", "2\n0 -27", "2\n0 -22", "2\n-1 -22", "2\n0 -11", "2\n1 -19", "2\n1 -32", "2\n1 -39", "2\n2 -39", "...
p03656 AtCoder Grand Contest 018 - Two Trees
There are two rooted trees, each with N vertices. The vertices of each tree are numbered 1 through N. In the first tree, the parent of Vertex i is Vertex A_i. Here, A_i=-1 if Vertex i is the root of the first tree. In the second tree, the parent of Vertex i is Vertex B_i. Here, B_i=-1 if Vertex i is the root of the sec...
{ "input": [], "output": [] }
{ "input": [ "6\n-1 5 1 5 1 3\n6 5 5 3 -1 3", "5\n3 3 4 -1 4\n4 4 1 -1 1", "8\n2 7 1 2 2 1 -1 4\n4 -1 4 7 4 4 2 4" ], "output": [ "IMPOSSIBLE", "POSSIBLE\n1 -1 -1 3 -1", "POSSIBLE\n1 2 -1 0 -1 1 0 -1" ] }
{ "input": [ "6\n-1 5 1 5 1 3\n6 3 5 3 -1 3", "8\n2 7 1 2 2 1 -1 4\n8 -1 8 7 4 4 2 4", "5\n-1 0 1 0 0\n1 2 2 -1 6", "5\n3 0 4 -1 4\n4 4 1 -1 1", "8\n2 7 1 2 2 1 -1 4\n4 -1 8 7 4 4 2 4", "5\n3 0 4 -1 4\n4 4 1 0 1", "8\n2 7 1 2 2 1 -1 4\n2 -1 8 7 4 4 2 4", "5\n3 0 4 -1 4\n4 4 0 0 1", ...
p03812 AtCoder Grand Contest 010 - Tree Game
There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i. Currently, there are A_i stones placed on vertex i. Takahashi and Aoki will play a game using this tree. First, Takahashi will select a vertex and place a piece on it. Then, starting from Takahashi, they wi...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3\n1 2\n2 3", "5\n5 4 1 2 3\n1 2\n1 3\n2 4\n2 5", "3\n1 1 1\n1 2\n2 3" ], "output": [ "2", "1 2", "" ] }
{ "input": [ "5\n2 4 1 2 3\n1 2\n1 3\n2 4\n2 5", "3\n1 2 1\n1 2\n2 3", "3\n1 2 3\n1 2\n1 3", "5\n5 4 1 2 3\n1 2\n1 3\n1 4\n3 5", "3\n1 2 2\n1 4\n1 3", "3\n0 1 1\n1 0\n1 3", "5\n1 1 1 3 3\n1 2\n1 3\n2 1\n2 5", "5\n2 12 -2 4 3\n1 2\n1 3\n2 8\n4 5", "5\n2 1 1 2 5\n1 2\n1 3\n2 4\n2 5",...
p03981 Kyoto University Programming Contest 2016 - Exam
You are going to take the entrance examination of Kyoto University tomorrow and have decided to memorize a set of strings S that is expected to appear in the examination. Since it is really tough to memorize S as it is, you have decided to memorize a single string T that efficiently contains all the strings in S. You ...
{ "input": [], "output": [] }
{ "input": [ "abcbabbcabbc", "abcabc", "abracadabra", "bbcacbcbcabbabacccbbcacbaaababbacabaaccbccabcaabba" ], "output": [ "8", "3", "7", "44" ] }
{ "input": [ "cbbacbbabcba", "cbacba", "arbadacarba", "bbcacbcbcabaabacccbbcacbaaababbacabaaccbccabcaabba", "cbbacbbbbcba", "cb`cba", "bbcacbcbcabaabaccdbbcacaaaababbacabaaccbccabcabbba", "abbbacbaccbdcabbacabbbbaaaacacbbdccabaacacbbbcacbb", "dbcadbbaaabc", "accabc", "abbba...
p00069 Drawing Lots II
There are n vertical lines in the Amidakuji. This Amidakuji meets the following conditions. * Draw a horizontal line right next to it. Do not pull diagonally. * Horizontal lines always connect adjacent vertical lines. In other words, the horizontal line does not cross the vertical line. * For any vertical line, horizo...
{ "input": [], "output": [] }
{ "input": [ "5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0100\n0101\n1010\n0" ], "output": [ "6 4" ] }
{ "input": [ "5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0000\n0101\n1010\n0", "5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0000\n0101\n1000\n0", "5\n2\n3\n9\n1010\n1001\n0000\n1001\n0010\n1000\n0000\n0101\n1001\n0", "5\n2\n3\n9\n1010\n1001\n1000\n1001\n0010\n1000\n0000\n0101\n1001\n0", "...
p00201 Wrought Gold Master
You finally got a magic pot, an alchemy pot. You can create a new item by putting multiple items in the alchemy pot. Newly created items can also be placed in alchemy pots to make other items. A list of items needed to make an item will be called an alchemy recipe. The following three are examples of alchemy recipes. ...
{ "input": [], "output": [] }
{ "input": [ "8\nwood 3000\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophone 9800\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 racket microphone onigiri\nguitar\n1\ncomputer 300000\n0\ncomputer\n0" ], "output": [ "13636\n300000" ] }
{ "input": [ "8\nwood 3000\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophone 4961\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 racket microphone onigiri\nguitar\n1\ncomputer 300000\n0\ncomputer\n0", "8\nwood 5003\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophon...
p00356 Wire
I am a craftsman specialized in interior works. A customer asked me to perform wiring work on a wall whose entire rectangular surface is tightly pasted with pieces of panels. The panels are all of the same size (2 m in width, 1 m in height) and the wall is filled with an x (horizontal) by y (vertical) array of the pane...
{ "input": [], "output": [] }
{ "input": [ "4 6", "4 4" ], "output": [ "9", "5" ] }
{ "input": [ "2 4", "1 8", "5 6", "1 0", "9 6", "4 13", "9 3", "6 1", "2 13", "7 1", "2 29", "17 2", "20 2", "21 1", "1 3", "2 2", "2 22", "17 1", "15 1", "33 1", "27 1", "11 1", "2 25", "1 1", "29 1", "61 1", ...
p00562 Soccer
You are a manager of a prestigious soccer team in the JOI league. The team has $N$ players numbered from 1 to $N$. The players are practicing hard in order to win the tournament game. The field is a rectangle whose height is $H$ meters and width is $W$ meters. The vertical line of the field is in the north-south direc...
{ "input": [], "output": [] }
{ "input": [ "6 5\n1 3 6\n3\n1 1\n0 4\n6 5" ], "output": [ "26" ] }
{ "input": [ "6 5\n1 3 6\n3\n1 1\n0 4\n2 5", "6 5\n2 3 6\n3\n1 1\n0 4\n2 5", "6 5\n2 3 6\n3\n1 0\n0 4\n2 5", "6 5\n0 3 6\n3\n1 1\n0 5\n2 5", "2 5\n0 3 1\n3\n1 1\n0 5\n0 3", "6 5\n1 2 6\n3\n1 1\n0 4\n6 5", "6 5\n1 6 6\n3\n1 1\n0 4\n2 5", "6 5\n2 3 6\n3\n1 0\n0 4\n3 5", "6 5\n1 2 6\n...
p00715 Name the Crossing
The city of Kyoto is well-known for its Chinese plan: streets are either North-South or East-West. Some streets are numbered, but most of them have real names. Crossings are named after the two streets crossing there, e.g. Kawaramachi-Sanjo is the crossing of Kawaramachi street and Sanjo street. But there is a problem:...
{ "input": [], "output": [] }
{ "input": [ "7\nShijo-Kawaramachi\nKarasuma-Imadegawa\nKawaramachi-Imadegawa\nNishioji-Shijo\nKarasuma-Gojo\nTorimaru-Rokujo\nRokujo-Karasuma\n6\nShijo-Karasuma\nImadegawa-Nishioji\nNishioji-Gojo\nShijo-Torimaru\nTorimaru-Gojo\nShijo-Kawabata\n4\n1jo-Midosuji\nMidosuji-2jo\n2jo-Omotesando\nOmotesando-1jo\n4\nMid...
{ "input": [ "7\nShijo-Kawaramachi\nKbrasuma-Imadegawa\nKawaramachi-Imadegawa\nNishioji-Shijo\nKarasuma-Gojo\nTorimaru-Rokujo\nRokujo-Karasuma\n6\nShijo-Karasuma\nImadegawa-Nishioji\nNishioji-Gojo\nShijo-Torimaru\nTorimaru-Gojo\nShijo-Kawabata\n4\n1jo-Midosuji\nMidosuji-2jo\n2jo-Omotesando\nOmotesando-1jo\n4\nMid...
p00855 Prime Gap
The sequence of n - 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a prime gap of length n. For example, (24, 25, 26, 27, 28) between 23 and 29 is a prime gap of length 6. Your mission is to write a program to c...
{ "input": [], "output": [] }
{ "input": [ "10\n11\n27\n2\n492170\n0" ], "output": [ "4\n0\n6\n0\n114" ] }
{ "input": [ "10\n11\n27\n2\n296421\n0", "10\n11\n27\n2\n338424\n0", "10\n11\n27\n2\n525306\n0", "10\n11\n27\n2\n245198\n0", "10\n11\n27\n2\n199792\n0", "10\n11\n47\n2\n199792\n0", "10\n15\n55\n2\n199792\n0", "10\n15\n55\n2\n76071\n0", "10\n11\n53\n2\n338424\n0", "10\n0\n27\n2\...
p00986 Parentheses Editor
Parentheses Editor You are working with a strange text editor for texts consisting only of open and close parentheses. The editor accepts the following three keys as editing commands to modify the text kept in it. * ‘(’ appends an open parenthesis (‘(’) to the end of the text. * ‘)’ appends a close parenthesis (‘)’) ...
{ "input": [], "output": [] }
{ "input": [ "(()())---)" ], "output": [ "0\n0\n1\n1\n3\n4\n3\n1\n1\n2" ] }
{ "input": [ ")()(()---)", ")()(-)--()", "(()())---(", ")()((---))", "())((---))", "())()---()", "())())---)", ")))(-)--()", "))))-)--((", ")()-()--()", "(()())-(--", ")()-))--((", "()(())---(", ")()--))-((", ")-)(()-(-)", ")(()(---))", "()(())---)",...
p01118 On-Screen Keyboard
<!-- Problem B --> On-Screen Keyboard You are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum number of button presses required to input a given string with the given OSK. <image> Fig. B-1 Remote control...
{ "input": [], "output": [] }
{ "input": [ "3 9\nABCDEFGHI\nJKLMNOPQR\nSTUVWXYZ_\nICPC\n5 11\n___________\n____A______\n________M__\n___________\n_C_________\nACM\n4 21\n1_2_3_4_5_6_7_8_9_0_-\nQqWwEeRrTtYyUuIiOoPp@\nAaSsDdFfGgHhJjKkLl;_:\nZzXxCcVvBbNnMm,_._/__\nICPC2019,AsiaYokohamaRegional,QualificationRound\n0 0" ], "output": [ "28\...
{ "input": [ "3 9\nABCDEFGHI\nJKLMNOPQR\nSTUVWXYZ_\nICPC\n5 11\n___________\n____A______\n________M__\n___________\n_C_________\nACM\n4 21\n1_2_3_4_5_6_7_8_9_0_-\nQqWwEeRrTtYyUuIiOoPp@\nAaSsDdFfGgHhJjKkLl;^:\nZzXxCcVvBbNnMm,_._/__\nICPC2019,AsiaYokohamaRegional,QualificationRound\n0 0", "3 9\nABCDEFGHI\nJKLMN...
p01256 Time Trial
Some people like finishing computer games in an extremely short time. Terry A. Smith is one of such and prefers role playing games particularly. He is now trying to find a shorter play for one of the key events in a role playing game. In this event, a player is presented a kind of puzzle on a grid map with three rocks...
{ "input": [], "output": [] }
{ "input": [ "7 6\n\n.._..#\n.*.*.#\n.@.*.#\n_..._#\n\n10 13\n\n___###\n...###\n...###\n.####\n.....#..#\n.#*.*.*.#\n...###..#\n.#.#.##\n.#.#.##\n.....##\n..@..##\n\n0 0", "7 6\n#######\n#.._..#\n#.*.*.#\n#.@.*.#\n#_..._#\n#######\n10 13\n##########\n####___###\n####...###\n####...###\n#####.####\n#.....#..#\...
{ "input": [ "7 6\n#######\n#.._..#\n#.*.*.#\n#.@.*.#\n#_..._#\n#######\n10 13\n##########\n#\"##___###\n####...###\n####...###\n#####.####\n#.....#..#\n#.#*.*.*.#\n#...###..#\n###.#.#.##\n###.#.#.##\n###.....##\n###..@..##\n##########\n0 0", "7 6\n\n.._..#\n#*.*..\n.@.*.#\n_..._#\n\n10 13\n\n___###\n...###\n...
p01417 Calender Colors
Taro is a member of a programming contest circle. In this circle, the members manage their schedules in the system called Great Web Calender. Taro has just added some of his friends to his calendar so that he can browse their schedule on his calendar. Then he noticed that the system currently displays all the schedule...
{ "input": [], "output": [] }
{ "input": [ "2 1\n1.0 1.0 1.0\n0.0 0.0 0.0", "5 3\n12.0 15.0 9.0\n10.0 -3.0 2.2\n3.5 6.8 9.0\n2.1 4.4 5.9\n1.2 4.0 -5.4", "3 2\n0 0 0\n10 10 10\n100 100 100" ], "output": [ "0.00000000000000000000", "1003.44000000000005456968", "30000.00000000000000000000" ] }
{ "input": [ "2 1\n1.0 1.0 1.0\n0.6914210799445369 0.0 0.0", "5 3\n12.0 15.0 9.0\n10.0 -3.0 2.2\n3.5 6.8 9.0\n2.1 4.4 5.9\n1.5075343707499678 4.0 -5.4", "3 2\n0 0 1\n10 10 10\n100 100 100", "5 3\n12.0 15.0 9.0\n10.0 -2.853485636048826 2.2\n3.5 6.8 9.0\n2.1 4.4 5.9\n1.5075343707499678 4.0 -5.4", "2...
p01571 Adhoc Translation
One day, during daily web surfing, you encountered a web page which was written in a language you've never seen. The character set of the language was the same as your native language; moreover, the grammar and words seemed almost the same. Excitedly, you started to "decipher" the web page. The first approach you tried...
{ "input": [], "output": [] }
{ "input": [ "1 5\nqwerty asdf zxcv\nqwert\nasf\ntyui\nzxcvb\nghjk" ], "output": [ "3" ] }
{ "input": [ "1 10\nqwerty asdf zxcv\nqwert\nasf\ntyui\nzxcvb\nghjk", "1 10\nqwerty asdf zcxv\nqwert\nasf\ntxui\nzxcvb\nghjk", "1 10\nqwerty ascf xczv\nqwert\nasf\ntxui\nbvcxz\nghjk", "1 10\nytrewq ascf xczv\nqwert\nasf\ntxui\nbvcxz\nghjk", "1 15\nqwerty fcsa xczv\nqwert\nasf\ntxui\nzxcvb\ngijk", ...
p01733 Fox Observation
Ievan Ritola is a researcher of behavioral ecology. Her group visited a forest to analyze an ecological system of some kinds of foxes. The forest can be expressed as a two-dimensional plane. With her previous research, foxes in the forest are known to live at lattice points. Here, lattice points are the points whose x...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1 2\n2 2 3" ], "output": [ "5 / 1" ] }
{ "input": [ "2\n1 1 4\n2 2 3", "2\n1 1 3\n2 2 3", "2\n1 1 4\n2 0 0", "2\n0 1 1\n2 0 0", "2\n1 1 2\n2 0 0", "2\n1 1 0\n3 0 0", "2\n1 1 2\n3 2 3", "2\n1 1 4\n2 2 5", "2\n1 0 5\n2 1 3", "2\n1 1 4\n4 2 5", "2\n1 0 8\n1 -1 3", "2\n1 1 7\n2 2 6", "2\n1 2 7\n2 3 12", ...
p01872 My Number
A: My Number-My Number- problem I'm sorry! Late late! Ah! I'm starting to work for this company I've been longing for today! Even so, I've been oversleeping since the first day ...! ?? Today is an important day when I have to tell my number to the company ...! I think everyone knows, but I'll explain my number fo...
{ "input": [], "output": [] }
{ "input": [ "?12345678901" ], "output": [ "4" ] }
{ "input": [ "?123456789/1", "1/987654321?", "1.987654321?", "1.687954321?", "1/587954321?", "1/687954321?", "6/478851321?", "?1/315887426", "634788413/1?", "?12345678900", "?123456789.1", "1.587954321?", "4/687951321?", "4/678951321?", "6/478951321?", "...
p02009 Nim without Zero
Alice: "Hi, Bob! Let's play Nim!" Bob: "Are you serious? I don't want to play it. I know how to win the game." Alice: "Right, there is an algorithm to calculate the optimal move using XOR. How about changing the rule so that a player loses a game if he or she makes the XOR to $0$?" Bob: "It sounds much better now, but ...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n1", "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10", "5\n1\n2\n3\n4\n5" ], "output": [ "Alice", "Alice", "Bob" ] }
{ "input": [ "2\n0\n1", "10\n1\n2\n3\n4\n5\n6\n7\n9\n9\n10", "5\n1\n2\n3\n4\n4", "10\n2\n2\n3\n4\n5\n6\n7\n9\n9\n10", "5\n1\n2\n3\n6\n4", "10\n3\n2\n3\n4\n5\n6\n7\n9\n9\n10", "5\n0\n2\n3\n6\n4", "10\n3\n2\n3\n4\n5\n6\n7\n9\n11\n10", "5\n0\n2\n2\n6\n4", "10\n3\n2\n3\n4\n5\n6\n7\...
p02152 Tunnel
Problem There are $ n $ rectangles on the $ xy $ plane with $ x $ on the horizontal axis and $ y $ on the vertical axis. The $ i $ th rectangle is $ h_i $ in height and $ 1 $ in width, and the vertices are point $ (i-1, 0) $, point $ (i-1, h_i) $, and point $ (i, h_i). ) $, Point $ (i, 0) $. You choose $ n $ positive ...
{ "input": [], "output": [] }
{ "input": [ "7\n3 1 9 2 2 5 1", "3\n6 1 4", "2\n5 3" ], "output": [ "12.37500000", "6.25000000", "2.83333333" ] }
{ "input": [ "7\n2 1 9 2 2 5 1", "3\n1 1 4", "2\n0 3", "7\n2 1 9 2 1 5 1", "3\n0 1 4", "2\n0 1", "7\n4 1 9 2 1 5 1", "3\n0 1 7", "2\n0 0", "7\n4 1 9 2 1 5 2", "3\n0 1 8", "2\n0 -1", "7\n8 1 9 2 1 5 2", "3\n0 0 8", "7\n8 1 9 0 1 5 2", "3\n0 -1 8", "3\...
p02293 Parallel/Orthogonal
For given two lines s1 and s2, print "2" if they are parallel, "1" if they are orthogonal, or "0" otherwise. s1 crosses points p0 and p1, and s2 crosses points p2 and p3. Constraints * 1 ≤ q ≤ 1000 * -10000 ≤ xpi, ypi ≤ 10000 * p0 ≠ p1 and p2 ≠ p3. Input The entire input looks like: q (the number of queries) 1st...
{ "input": [], "output": [] }
{ "input": [ "3\n0 0 3 0 0 2 3 2\n0 0 3 0 1 1 1 4\n0 0 3 0 1 1 2 2" ], "output": [ "2\n1\n0" ] }
{ "input": [ "3\n0 0 3 0 0 2 3 2\n0 0 3 0 1 1 1 7\n0 0 3 0 1 1 2 2", "3\n0 0 3 1 0 2 3 2\n0 0 3 0 1 1 1 7\n0 0 3 0 1 1 2 2", "3\n0 0 3 0 0 2 3 2\n0 0 3 -1 1 1 1 4\n0 0 3 0 1 1 2 2", "3\n0 0 3 1 0 2 3 2\n0 1 3 0 1 1 1 7\n0 0 3 0 1 1 2 2", "3\n0 0 3 1 0 2 3 2\n0 1 3 0 1 0 1 7\n0 0 3 0 1 1 2 1", ...
p02440 Min-Max Element
Write a program which manipulates a sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ by the following operations: * min($b, e$): report the minimum element in $a_b, a_{b+1}, ..., a_{e-1}$ * max($b, e$): report the maximum element in $a_b, a_{b+1}, ..., a_{e-1}$ Constraints * $1 \leq n \leq 1,000$ * $-1,000,000,000 \leq a...
{ "input": [], "output": [] }
{ "input": [ "7\n8 3 7 1 9 1 4\n3\n0 0 3\n0 1 5\n1 0 7" ], "output": [ "3\n1\n9" ] }
{ "input": [ "7\n8 3 0 1 9 1 4\n3\n0 0 3\n0 1 5\n1 0 7", "7\n8 3 0 0 9 1 4\n3\n0 0 3\n1 1 5\n1 0 7", "7\n8 3 0 0 9 1 4\n6\n0 0 3\n1 1 5\n1 0 7", "7\n8 3 0 1 14 1 4\n3\n0 1 3\n0 1 5\n1 0 7", "7\n2 2 -1 2 9 1 0\n3\n0 0 3\n0 1 5\n1 0 7", "7\n8 3 7 1 9 1 4\n3\n1 0 3\n0 1 5\n1 0 7", "7\n8 3 0 -...