name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p03625 AtCoder Beginner Contest 071 - Make a Rectangle
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. Constraints * 4 \leq N \leq 10^5 * 1 \leq A_i \leq ...
{ "input": [], "output": [] }
{ "input": [ "10\n3 3 3 3 4 4 4 5 5 5", "6\n3 1 2 4 2 1", "4\n1 2 3 4" ], "output": [ "20", "2", "0" ] }
{ "input": [ "10\n3 3 3 3 4 4 2 5 5 5", "6\n3 1 2 4 2 2", "6\n3 2 2 4 2 2", "6\n3 2 2 4 3 2", "10\n3 3 6 3 4 4 1 6 5 5", "10\n3 3 6 3 4 3 1 6 5 6", "6\n3 4 2 3 4 3", "10\n3 3 6 6 4 3 1 6 3 6", "10\n3 2 8 6 4 0 1 8 3 10", "6\n1 -1 1 7 8 7", "10\n0 2 12 13 3 1 0 18 3 1", ...
p03785 AtCoder Grand Contest 011 - Airport Bus
Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i. Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus that departs earlier than the airplane arrives at the airport. Also...
{ "input": [], "output": [] }
{ "input": [ "5 3 5\n1\n2\n3\n6\n12", "6 3 3\n7\n6\n2\n8\n10\n6" ], "output": [ "3", "3" ] }
{ "input": [ "5 3 5\n1\n4\n3\n6\n12", "5 5 5\n1\n4\n3\n6\n12", "6 3 3\n7\n6\n2\n13\n17\n5", "6 6 0\n7\n9\n8\n9\n19\n5", "6 6 0\n7\n3\n8\n9\n19\n5", "5 5 5\n1\n1\n4\n6\n4", "6 3 3\n7\n6\n2\n13\n10\n6", "6 3 6\n7\n6\n2\n13\n10\n6", "5 5 5\n1\n1\n3\n6\n12", "6 3 6\n7\n6\n2\n22\n10...
p03953 AtCoder Grand Contest 006 - Rabbit Exercise
There are N rabbits on a number line. The rabbits are conveniently numbered 1 through N. The coordinate of the initial position of rabbit i is x_i. The rabbits will now take exercise on the number line, by performing sets described below. A set consists of M jumps. The j-th jump of a set is performed by rabbit a_j (2≤...
{ "input": [], "output": [] }
{ "input": [ "3\n1 -1 1\n2 2\n2 2", "3\n-1 0 2\n1 1\n2", "5\n0 1 3 6 10\n3 10\n2 3 4" ], "output": [ "1.0\n-1.0\n1.0", "-1.0\n1.0\n2.0", "0.0\n3.0\n7.0\n8.0\n10.0" ] }
{ "input": [ "3\n1 0 1\n2 2\n2 2", "5\n0 1 3 6 17\n3 10\n2 3 4", "3\n2 0 1\n2 2\n2 2", "5\n0 1 3 6 17\n3 10\n3 3 4", "5\n0 1 3 6 17\n3 1\n3 3 4", "3\n1 -1 1\n2 3\n2 2", "3\n0 0 2\n1 1\n2", "5\n0 1 3 6 11\n3 10\n2 3 4", "5\n0 1 3 6 9\n3 10\n2 3 4", "3\n0 0 1\n2 2\n2 2", "5\n...
p00043 Puzzle
There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers. The conditions for completing the puzzle are * You must have one combination of the same numbers. * The remaining 12 numbers are 4 combinations of 3 numbers. The combination of three numbers i...
{ "input": [], "output": [] }
{ "input": [ "3649596966777\n6358665788577\n9118992346175\n9643871425498\n7755542764533\n1133557799246" ], "output": [ "2 3 5 8\n3 4\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0" ] }
{ "input": [ "3649596966777\n4672433573317\n9118992346175\n9643871425498\n7755542764533\n1133557799246", "3649596966777\n7685559208632\n9118992346175\n9643871425498\n7755542764533\n1133557799246", "3649596966777\n4672433573317\n9118992346175\n7133209108608\n7755542764533\n704120058101", "3649596966777...
p00175 Quaternary Notation
Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers. Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numbers. Only the four numbers 0, 1, 2, and 3 are used in quaternary n...
{ "input": [], "output": [] }
{ "input": [ "7\n4\n0\n12\n10\n10000\n-1" ], "output": [ "13\n10\n0\n30\n22\n2130100" ] }
{ "input": [ "7\n4\n0\n12\n10\n10010\n-1", "7\n4\n0\n12\n4\n10000\n-1", "7\n4\n0\n13\n10\n10010\n-1", "7\n4\n0\n12\n6\n10000\n-1", "7\n4\n0\n24\n10\n10010\n-1", "7\n4\n1\n12\n6\n10000\n-1", "7\n4\n1\n24\n10\n10010\n-1", "7\n6\n1\n12\n6\n10000\n-1", "7\n1\n1\n24\n10\n10010\n-1", ...
p00331 Sunrise and Sunset
The appearance of the sun is called "sunrise" and the hiding is called "sunset". What is the exact time when the sun is on the horizon? As shown in the figure below, we will represent the sun as a circle and the horizon as a straight line. At this time, the time of "sunrise" and "sunset" of the sun is the moment when ...
{ "input": [], "output": [] }
{ "input": [ "3 3", "-3 3", "-4 3" ], "output": [ "1", "0", "-1" ] }
{ "input": [ "3 0", "-6 3", "0 0", "-2 3", "5 0", "-1 3", "-12 3", "1 0", "-2 1", "-15 3", "-4 1", "-23 3", "0 1", "-4 0", "-5 3", "0 2", "-6 1", "-2 5", "0 4", "-9 1", "-2 8", "1 2", "-9 2", "-3 8", "1 3", "-9 3",...
p00504 Gifts
problem JOI, who came to Australia for a trip, enjoyed sightseeing in various places and finally returned to Japan. Now, JOI is in the town with the international airport where the return flight departs. The town is divided into north, south, east and west, and each section has roads, souvenir shops, houses, and an in...
{ "input": [], "output": [] }
{ "input": [ "5 4 2\n...#\n.#.#\n.#73\n8##.\n...." ], "output": [ "11" ] }
{ "input": [ "5 4 2\n...#\n.#/#\n.#73\n8##.\n....", "5 4 2\n.#-.\n.#.$\n37#.\n8##.\n....", "5 4 0\n.#-.\n.#.$\n.#73\n8##.\n....", "5 4 1\n.#,.\n.#.$\n.#73\n9##.\n....", "5 4 0\n.#-.\n.#.$\n37#.\n.##8\n....", "5 4 1\n..,#\n#..$\n38#.\n8##.\n....", "5 4 2\n.#..\n.#.$\n.#74\n8##.\n....", ...
p00688 Factorization of Quadratic Formula
As the first step in algebra, students learn quadratic formulas and their factorization. Often, the factorization is a severe burden for them. A large number of students cannot master the factorization; such students cannot be aware of the elegance of advanced algebra. It might be the case that the factorization increa...
{ "input": [], "output": [] }
{ "input": [ "2 5 2\n1 1 1\n10 -7 0\n1 0 -3\n0 0 0" ], "output": [ "2 1 1 2\nImpossible\n10 -7 1 0\nImpossible" ] }
{ "input": [ "2 5 4\n1 1 1\n10 -7 0\n1 0 -3\n0 0 0", "2 5 2\n1 1 1\n9 -7 0\n1 0 -3\n0 0 0", "2 5 4\n1 2 1\n10 -7 0\n1 0 -3\n0 0 0", "2 5 2\n1 1 1\n11 -7 0\n1 0 -3\n0 0 0", "2 5 4\n1 2 1\n10 -7 -1\n1 0 -3\n0 0 0", "2 5 2\n1 1 1\n10 -7 1\n1 0 -3\n0 0 0", "2 7 2\n1 1 1\n9 -7 0\n1 0 -3\n0 0 0"...
p00830 Pathological Paths
Professor Pathfinder is a distinguished authority on the structure of hyperlinks in the World Wide Web. For establishing his hypotheses, he has been developing software agents, which automatically traverse hyperlinks and analyze the structure of the Web. Today, he has gotten an intriguing idea to improve his software a...
{ "input": [], "output": [] }
{ "input": [ "5 6\n/home/ACM/index.html\n/ICPC/index.html\n/ICPC/general.html\n/ICPC/japanese/index.html\n/ICPC/secret/confidential/2005/index.html\n/home/ACM/\n/home/ICPC/../ACM/\n/ICPC/secret/\n/ICPC/secret/index.html\n/ICPC\n/ICPC/../ICPC/index.html\n/ICPC\n/ICPC/general.html\n/ICPC/japanese/.././\n/ICPC/japan...
{ "input": [ "5 6\n/home/ACM/index.html\n/ICPC/index.html\n/ICPC/general.html\n/ICPC/japanese/index.html\n/ICPC/secret/confidential/2005/index.html\n/home/ACM/\n/home/ICPC/../ACM/\n/ICPC/secret/\n/ICPC/secret/index.html\n/ICPC\n/ICPC/../ICPC/index.html\n/ICPC\n/ICPC/general.html\n/ICPC/japanese/.././\n/ICPC/japan...
p00961 Black or White
Problem E Black or White Here lies a row of a number of bricks each painted either black or white. With a single stroke of your brush, you can overpaint a part of the row of bricks at once with either black or white paint. Using white paint, all the black bricks in the painted part become white while originally white ...
{ "input": [], "output": [] }
{ "input": [ "4 4\nBWWB\nWBBW" ], "output": [ "2" ] }
{ "input": [ "4 5\nBWWB\nWBBW", "1 5\nBWWB\nWBBW", "0 5\nBWWB\nWBBW", "4 3\nBWWB\nWBBW", "1 10\nBWWB\nWBBW", "1 19\nBWWB\nWBBW", "1 35\nBWWB\nWBBW", "1 31\nBWWB\nWBBW", "3 4\nBWWB\nWBBW", "4 10\nBWWB\nWBBW", "1 10\nBWBW\nWBBW", "1 19\nBWWA\nWBBW", "1 35\nBWWB\nWBAW"...
p01094 Look for the Winner!
Look for the Winner! The citizens of TKB City are famous for their deep love in elections and vote counting. Today they hold an election for the next chairperson of the electoral commission. Now the voting has just been closed and the counting is going to start. The TKB citizens have strong desire to know the winner a...
{ "input": [], "output": [] }
{ "input": [ "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nA A A B A C A C C B\n10\nU U U U U V V W W W\n0" ], "output": [ "A 1\nTIE\nTIE\nK 4\nX 5\nA 7\nU 8" ] }
{ "input": [ "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nA A A B A C A C C B\n10\nV U U U U V V W W W\n0", "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nA A A B A C A C C B\n10\nV U U U U V V W V W\n0", "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X...
p01230 Can I go there?
At one point, there was a president who traveled around Japan to do business. One day he got a mysterious ticket. If you use the ticket, the train fare will be free regardless of the distance to the destination. However, when moving from the current station to the adjacent station is counted as one step, if the number ...
{ "input": [], "output": [] }
{ "input": [ "2 1 1\n1 2\n2 1 2\n1 2\n3 1 2\n1 2\n8 8 5778\n1 2\n2 3\n2 4\n3 5\n5 6\n6 7\n7 8\n4 8\n8 8 5777\n1 2\n2 3\n2 4\n3 5\n5 6\n6 7\n7 8\n4 8\n0 0 0" ], "output": [ "yes\nno\nno\nyes\nno" ] }
{ "input": [ "2 1 1\n1 2\n2 1 2\n1 4\n3 1 2\n1 2\n8 8 5778\n1 2\n2 3\n2 4\n3 5\n5 6\n6 7\n7 8\n4 8\n8 8 5777\n1 2\n2 3\n2 4\n3 5\n5 6\n6 7\n7 8\n4 8\n0 0 0", "2 1 1\n1 2\n2 1 2\n1 4\n3 1 2\n1 2\n11 8 5778\n1 2\n2 3\n2 4\n3 5\n5 6\n6 7\n7 8\n4 8\n8 8 5777\n1 2\n2 3\n2 4\n3 5\n5 6\n6 7\n7 8\n4 8\n0 0 0", "4...
p01364 Two-Wheel Buggy
International Car Production Company (ICPC), one of the largest automobile manufacturers in the world, is now developing a new vehicle called "Two-Wheel Buggy". As its name suggests, the vehicle has only two wheels. Quite simply, "Two-Wheel Buggy" is made up of two wheels (the left wheel and the right wheel) and a axle...
{ "input": [], "output": [] }
{ "input": [ "1 1\n180 90 2\n1 1\n180 180 20\n2 10\n360 -360 5\n-90 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225 5\n0 0" ], "output": [ "3.00000\n3.00000\n0.00000\n62.83185\n12.00000\n0.00000\n-2.44505\n13.12132" ] }
{ "input": [ "1 1\n180 90 2\n1 1\n180 180 20\n2 10\n360 -360 5\n-9 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225 5\n0 0", "1 1\n180 90 2\n1 1\n180 180 20\n2 13\n360 -360 5\n-9 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225 5\n0 0", "1 1\n180 90 2\n1 1\n180 180 20\n2 13\n143 -360 5\n-9 360 8\n3 2\n100 60 9\n-72 -...
p01546 Sports Days 2
The University of Aizu Elementary School (Aizu University and Small) is famous as one of Japan's leading competition programmer training schools. Of course, it is essential to practice the algorithm even when attending an athletic meet. Of course you, the director of the competitive programming department, want to win ...
{ "input": [], "output": [] }
{ "input": [ "7 8 4000\n0 1 1\n1 0 1\n1 2 2\n2 3 2\n3 4 2\n5 4 3\n3 5 4\n5 6 5", "2 0 1", "3 9 89\n2 0 2\n1 0 3\n2 0 1\n2 0 3\n0 1 1\n0 1 2\n1 2 3\n0 1 1\n1 0 2" ], "output": [ "3991", "-1", "34\n1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 0" ] }
{ "input": [ "2 0 2", "3 9 89\n2 0 2\n1 0 3\n2 1 1\n2 0 3\n0 1 1\n0 1 2\n1 2 3\n0 1 1\n1 0 2", "7 8 4000\n0 1 1\n1 0 1\n1 2 2\n2 3 2\n3 4 2\n5 4 3\n3 5 4\n3 6 5", "3 9 89\n2 0 2\n1 0 5\n2 1 1\n2 0 3\n0 1 1\n0 1 2\n1 2 3\n0 1 1\n1 0 0", "7 8 4000\n0 1 1\n1 0 1\n1 2 2\n2 3 2\n3 5 2\n5 3 3\n3 5 4\n3 ...
p01702 Unknown Switches
Problem Statement In the headquarter building of ICPC (International Company of Plugs & Connectors), there are $M$ light bulbs and they are controlled by $N$ switches. Each light bulb can be turned on or off by exactly one switch. Each switch may control multiple light bulbs. When you operate a switch, all the light b...
{ "input": [], "output": [] }
{ "input": [ "3 10 3\n000 0000000000\n110 0000001111\n101 1111111100\n2 2 0\n1 1 0\n2 1 1\n01 1\n11 11 10\n10000000000 10000000000\n11000000000 01000000000\n01100000000 00100000000\n00110000000 00010000000\n00011000000 00001000000\n00001100000 00000100000\n00000110000 00000010000\n00000011000 00000001000\n0000000...
{ "input": [ "3 10 3\n000 0000000000\n110 0000101111\n101 1111111100\n2 2 0\n1 1 0\n2 1 1\n01 1\n11 11 10\n10000000000 10000000000\n11000000000 01000000000\n01100000000 00100000000\n00110000000 00010000000\n00011000000 00001000000\n00001100000 00000100000\n00000110000 00000010000\n00000011000 00000001000\n0000000...
p01846 jfen
jfen There is a one-person game to play on the H × W board. This game is a game to move 0 or 1 balls in each cell. You were playing this game and found it difficult to move the ball accurately from cell to cell because the ball is so round. So you decided to make a robot that would move the ball as instructed. Here, t...
{ "input": [], "output": [] }
{ "input": [ "b1/1b\n1 1 1 2\nb5/bbbbbb\n2 4 1 4\nb2b2b/7\n1 4 2 4\n#" ], "output": [ "1b/1b\nb2b2/bbb1bb\nb5b/3b3" ] }
{ "input": [ "b1/1b\n1 1 1 2\nb5/bbbbbb\n2 4 1 4\nb2b2b/7\n1 4 2 6\n#", "b1/1b\n1 1 1 2\nb5/bbbbbb\n2 4 1 5\nb2b2b/7\n1 4 2 4\n#", "b1/1b\n1 1 1 2\nb5/bbbbbb\n2 4 1 4\nb2b2b/7\n1 4 1 4\n#", "b1/1b\n1 1 1 2\nb5/bbbbbb\n2 4 0 5\nb2b2b/7\n1 4 2 4\n#", "b1/1b\n1 1 1 2\nb5/bbbbbb\n2 4 1 4\nb2b2b/7\n1 4...
p01982 Generalized Leap Years
Generalized leap year Normally, whether or not the year x is a leap year is defined as follows. 1. If x is a multiple of 400, it is a leap year. 2. Otherwise, if x is a multiple of 100, it is not a leap year. 3. Otherwise, if x is a multiple of 4, it is a leap year. 4. If not, it is not a leap year. This can be ge...
{ "input": [], "output": [] }
{ "input": [ "3 1988 2014\n400\n100\n4\n1 1000 1999\n1\n2 1111 3333\n2\n2\n6 2000 3000\n5\n7\n11\n9\n3\n13\n0 0 0" ], "output": [ "7\n1000\n2223\n785" ] }
{ "input": [ "3 1988 2014\n400\n100\n4\n1 1000 1999\n1\n2 1111 3333\n2\n2\n6 2000 3000\n5\n7\n21\n9\n3\n13\n0 0 0", "3 1988 2014\n400\n100\n4\n1 1000 1999\n1\n2 1111 4526\n2\n2\n6 2000 3000\n5\n7\n21\n9\n3\n13\n0 0 0", "3 1988 2014\n400\n100\n4\n1 1000 1999\n1\n2 0111 4526\n2\n2\n6 2000 3000\n5\n7\n21\n9\...
p02128 Light
Problem There are $ N $ streetlights on a two-dimensional square of $ W \ times H $. Gaccho wants to start with $ (1,1) $ and go to $ (W, H) $. Gaccho is afraid of dark places, so he only wants to walk in the squares that are brightened by the streetlights. Initially, all streetlights only brighten the squares with th...
{ "input": [], "output": [] }
{ "input": [ "1 1 1\n1 1", "5 10 3\n3 9\n2 8\n5 1", "10 10 1\n6 6" ], "output": [ "0", "8", "10" ] }
{ "input": [ "5 10 3\n3 9\n2 8\n2 1", "8 10 1\n6 6", "5 10 3\n3 9\n2 8\n1 1", "10 10 3\n3 9\n2 8\n1 1", "5 10 3\n1 9\n2 8\n5 1", "10 10 1\n6 2", "13 10 3\n3 9\n2 6\n1 1", "5 19 3\n2 9\n2 8\n1 1", "26 10 3\n3 9\n2 6\n1 1", "10 19 3\n1 9\n0 4\n1 1", "24 4 1\n6 2", "10 19 ...
p02269 Dictionary
Your task is to write a program of a simple dictionary which implements the following instructions: * insert str: insert a string str in to the dictionary * find str: if the distionary contains str, then print 'yes', otherwise print 'no' Notes Template in C Constraints * A string consists of 'A', 'C', 'G', or 'T' ...
{ "input": [], "output": [] }
{ "input": [ "5\ninsert A\ninsert T\ninsert C\nfind G\nfind A", "13\ninsert AAA\ninsert AAC\ninsert AGA\ninsert AGG\ninsert TTT\nfind AAA\nfind CCC\nfind CCC\ninsert CCC\nfind CCC\ninsert T\nfind TTT\nfind T" ], "output": [ "no\nyes", "yes\nno\nno\nyes\nyes\nyes" ] }
{ "input": [ "5\ninsert A\ninsert U\ninsert C\nfind G\nfind A", "13\ninsert AAA\ninsert AAC\ninsert AGA\ninsert AGF\ninsert TTT\nfind AAA\nfind CCC\nfind CCC\ninsert CCC\nfind CCC\ninsert T\nfind TTT\nfind T", "5\ninsert B\ninsert T\ninsert C\nfind G\nfind A", "13\ninsert AAA\ninsert AAC\ninsert AGA\n...
p02416 Sum of Numbers
Write a program which reads an integer and prints sum of its digits. Input The input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including single zero. Your program should not process for this terminal ...
{ "input": [], "output": [] }
{ "input": [ "123\n55\n1000\n0" ], "output": [ "6\n10\n1" ] }
{ "input": [ "123\n55\n1001\n0", "123\n69\n1000\n0", "123\n69\n1010\n0", "123\n69\n1110\n0", "123\n55\n0001\n0", "123\n55\n1101\n0", "123\n69\n1111\n0", "123\n23\n1001\n0", "123\n65\n0001\n0", "123\n151\n1101\n0", "123\n132\n1000\n0", "123\n45\n1100\n0", "123\n20\n1...
btreat
Its Chef's Birthday and his friends are demanding him for treat. So he went to the shop to buy N gift packets (one for each friend). Each gift packet bought from shop contains some number of chocolates in it. Chef believes in equality i.e. all gift packets should contain equal number of chocolates in it. So Chef thou...
{ "input": [], "output": [] }
{ "input": [ "2\n4\n5 2 4 5\n6\n5 2 4 1 7 5" ], "output": [ "2\n5" ] }
{ "input": [], "output": [] }
compiler
Lira is now very keen on compiler development. :) She knows that one of the most important components of a compiler, is its parser. A parser is, in simple terms, a software component that processes text, and checks it's semantic correctness, or, if you prefer, if the text is properly built. As an example, in declaring...
{ "input": [], "output": [] }
{ "input": [ "3\n<<>>\n><\n<>>>" ], "output": [ "4\n0\n2\n" ] }
{ "input": [ "3\n<<>>\n<>\n<>>>", "3\n><<>\n<>\n<>>>", "3\n><<>\n><\n<>>>", "3\n<<>>\n><\n<>>?", "3\n><<>\n<>\n><>?", "3\n><<>\n><\n>><>", "3\n<<>>\n<>\n>>><", "3\n<<>>\n><\n>>><", "3\n<>><\n<>\n>>><", "3\n<>><\n<>\n<>>?", "3\n<>><\n><\n<>>?", "3\n<>>;\n><\n>>><", "...
gdog
Tuzik is a little dog. But despite the fact he is still a puppy he already knows about the pretty things that coins are. He knows that for every coin he can get very tasty bone from his master. He believes that some day he will find a treasure and have loads of bones. And finally he found something interesting. A woode...
{ "input": [], "output": [] }
{ "input": [ "2\n5 2\n11 3" ], "output": [ "1\n2\n" ] }
{ "input": [ "2\n5 4\n11 3", "2\n5 4\n11 6", "2\n5 4\n8 6", "2\n5 2\n5 3", "2\n5 8\n11 6", "2\n10 7\n8 6", "2\n1 4\n15 6", "2\n1 2\n15 2", "2\n9 4\n11 6", "2\n5 8\n11 4", "2\n10 4\n1 6", "2\n15 4\n15 6", "2\n10 7\n8 10", "2\n1 2\n14 6", "2\n6 7\n8 10", "...
m3
The new season of the Bytelandian Premier League (BPL) has started! In the BPL, any two soccer teams play with each other exactly once. In each match, the winner earns 3 points and the loser earns no point. There is no draw (if the match is level after the two halves, two teams will take part in a penalty shootout to d...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n0 0 0 \n1 0 1 \n1 0 0 \n4\n0 1 1 0 \n0 0 2 0 \n0 2 0 0 \n1 1 1 0 \n5\n0 2 2 1 0 \n2 0 1 1 0 \n2 0 0 1 0 \n0 0 0 0 1 \n1 1 1 0 0" ], "output": [ "010\n0001\n11001" ] }
{ "input": [], "output": [] }
prys01
Problem Statement N knights were sitting at a round table and having a serious talk. The knights are so tired, that they can’t even rotate their neck to talk to talk to the knights sitting on their sides. So, a knight can only talk to the knight sitting diametrically opposite to him on the table. Given the number of kn...
{ "input": [], "output": [] }
{ "input": [ "1\n6 2" ], "output": [ "5" ] }
{ "input": [ "1\n10 2", "1\n20 2", "1\n20 3", "1\n39 3", "1\n68 3", "1\n10 3", "1\n16 3", "1\n29 4", "1\n3 4", "1\n3 5", "1\n3 0", "1\n3 1", "1\n1 0", "1\n-1 4", "1\n-2 8", "1\n-1 -1", "1\n0 -1", "1\n17 -2", "1\n-4 -2", "1\n-1 -2", "1...
tidrice
Did you know that there are over 40,000 varieties of Rice in the world ? There are so many dishes that can be prepared with Rice too. A famous chef from Mumbai, Tid Gusto prepared a new dish and named it 'Tid Rice'. He posted the recipe in his newly designed blog for community voting, where a user can plus (+) or minus...
{ "input": [], "output": [] }
{ "input": [ "3\n4\ntilak +\ntilak +\ntilak -\ntilak +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -" ], "output": [ "1\n-2\n-1\n" ] }
{ "input": [ "3\n4\ntilak +\ntilak +\ntilak -\ntilaj +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -", "3\n4\ntilak +\nkalit +\ntilak -\ntilak +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -", "3\n4\nuilak +\ntilak +\ntilak -\ntilaj +\n3\nratna +\nshashi -\nratna ...
1101_C. Division and Union
There are n segments [l_i, r_i] for 1 ≤ i ≤ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize testing pr...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n5 5\n2 3\n3\n3 5\n2 3\n2 3\n3\n3 3\n4 4\n5 5\n" ], "output": [ "2 1 \n-1\n1 2 2 \n" ] }
{ "input": [ "3\n2\n5 5\n2 3\n3\n3 5\n1 3\n2 3\n3\n3 3\n4 4\n5 5\n", "3\n2\n3 5\n2 3\n3\n3 5\n1 5\n2 3\n3\n3 3\n4 4\n5 4\n", "3\n2\n5 5\n2 3\n3\n3 5\n1 3\n2 3\n2\n3 3\n4 4\n5 5\n", "3\n2\n5 5\n2 3\n3\n3 5\n1 3\n2 3\n2\n3 4\n4 4\n5 5\n", "3\n2\n3 5\n2 3\n3\n3 5\n1 5\n2 3\n3\n3 3\n4 4\n0 4\n", "...
1170_G. Graph Decomposition
You are given an undirected graph consisting of n vertices and m edges. Recall that a cycle is a path that starts and ends in the same vertex. A cycle in a graph is called simple if it contains each vertex (except the starting and ending one) no more than once (the starting and the ending one is contained always twice...
{ "input": [], "output": [] }
{ "input": [ "6 9\n1 2\n2 3\n1 3\n2 4\n2 5\n4 5\n3 5\n3 6\n5 6\n", "4 7\n1 1\n1 2\n2 3\n3 4\n4 1\n1 3\n1 3\n", "4 8\n1 1\n1 2\n2 3\n3 4\n4 1\n2 4\n1 3\n1 3\n" ], "output": [ "\nYES\n3\n4 2 5 4 2 \n4 3 6 5 3 \n4 1 3 2 1 \n", "\nYES\n3\n2 1 1 \n5 1 4 3 2 1 \n3 1 3 1 \n", "\nNO\n" ] }
{ "input": [], "output": [] }
1250_D. Conference Problem
A large-scale conference on unnatural sciences is going to be held soon in Berland! In total, n scientists from all around the world have applied. All of them have indicated a time segment when they will attend the conference: two integers l_i, r_i — day of arrival and day of departure. Also, some of the scientists ha...
{ "input": [], "output": [] }
{ "input": [ "2\n4\n1 10 30\n5 6 30\n6 12 0\n1 1 0\n4\n1 2 1\n2 3 0\n3 4 0\n4 5 2\n" ], "output": [ "\n4\n2\n" ] }
{ "input": [], "output": [] }
470_H. Array Sorting
Sorting arrays is traditionally associated with high-level languages. How hard can it be in FALSE? Sort the given array in non-descending order. Input The input consists of a single line of space-separated integers. The first number is n (1 ≤ n ≤ 10) — the size of the array. The following n numbers are the elements o...
{ "input": [], "output": [] }
{ "input": [ "3 3 1 2\n", "7 12 2 3 44 5 60 2\n" ], "output": [ "1 2 3 \n", "2 2 3 5 12 44 60 \n" ] }
{ "input": [], "output": [] }
aprileasy-the-one-with-the-queries-3
You are given a string S and Q query strings (q1, q2, ... , qQ). For each query string, report whether or not it is a subsequence of S. Input : The first line contains a string S. The next line contains a single integer, Q. The following Q lines each contain 1 query string qi. Output : Output Q lines. On the i^th...
{ "input": [], "output": [] }
{ "input": [ "hello\n5\nworld\nlo\nelo\nhl\nol\n\nSAMPLE" ], "output": [ "No\nYes\nYes\nYes\nNo\n" ] }
{ "input": [ "hello\n5\nworld\nln\nelo\nhl\nol\n\nSAMPLE", "hello\n5\nwolrd\nlo\nelo\nhl\nol\n\nSAMPLE", "hello\n5\nwolrd\nlo\nflo\nhl\nol\n\nSAMPLE", "olleh\n5\nworld\nnl\nelo\nhl\nol\n\nSAMPME", "olleh\n5\nworld\nnl\nelo\nlh\nol\n\nSAMMPE", "olleg\n5\ndlrow\nml\nleo\nlh\nlo\n\nSAMEPN", "...
power-matrix
You are given a square matrix M and a positive integer N. You will have to compute M raised to the power N. (that is, M multiplied with itself N times.) Input First line of input is T ( number of test-cases) . First line of each test-case contains two integer M , N where M is size of square array that you have to ex...
{ "input": [], "output": [] }
{ "input": [ "2\n2 3\n1 0 \n1 1 \n3 3\n1 0 4 \n1 2 2 \n0 4 4\n\nSAMPLE" ], "output": [ "1 0 \n3 1 \n17 112 116 \n15 88 100 \n28 144 160" ] }
{ "input": [], "output": [] }
p02615 AtCoder Beginner Contest 173 - Chat in a Circle
Quickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i. The N players will arrive at the place one by one in some order. To ma...
{ "input": [], "output": [] }
{ "input": [ "4\n2 2 1 3", "7\n1 1 1 1 1 1 1" ], "output": [ "7", "6" ] }
{ "input": [ "4\n1 2 1 3", "7\n1 1 1 1 1 0 1", "4\n1 3 1 3", "4\n1 5 1 3", "4\n1 4 1 3", "4\n1 10 1 3", "4\n0 10 1 2", "7\n1 2 2 -1 2 0 2", "4\n2 4 1 2", "7\n1 2 4 -3 2 0 0", "4\n2 4 1 10", "4\n1 5 1 10", "4\n1 7 1 8", "4\n1 7 1 13", "7\n-1 0 2 -6 0 0 0", ...
p02746 Panasonic Programming Contest 2020 - Fractal Shortest Path
For a non-negative integer K, we define a fractal of level K as follows: * A fractal of level 0 is a grid with just one white square. * When K > 0, a fractal of level K is a 3^K \times 3^K grid. If we divide this grid into nine 3^{K-1} \times 3^{K-1} subgrids: * The central subgrid consists of only black squares. * Ea...
{ "input": [], "output": [] }
{ "input": [ "2\n4 2 7 4\n9 9 1 9" ], "output": [ "5\n8" ] }
{ "input": [ "2\n3 2 7 4\n9 9 1 9", "2\n3 2 7 4\n9 3 1 9", "2\n3 2 7 4\n9 3 1 15", "2\n3 2 7 4\n7 3 1 15", "2\n3 2 4 4\n7 3 1 15", "2\n3 2 4 4\n7 3 1 9", "2\n3 2 6 4\n7 3 1 9", "2\n3 2 6 4\n4 3 1 9", "2\n3 2 6 4\n4 3 2 9", "2\n3 2 6 4\n4 3 2 4", "2\n3 4 6 4\n4 3 2 4", "...
p02881 AtCoder Beginner Contest 144 - Walk on Multiplication Table
Takahashi is standing on a multiplication table with infinitely many rows and columns. The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1). In one move, he can move from (i,j) to either (i+1,j) or (i,j+1). Given an integer N, find the minimum number of moves needed to reach a ...
{ "input": [], "output": [] }
{ "input": [ "10000000019", "50", "10" ], "output": [ "10000000018", "13", "5" ] }
{ "input": [ "6069423871", "83", "19", "605667865", "72", "33", "927082247", "40", "5", "223605823", "77", "1", "68324856", "2", "63407968", "28", "3", "65898355", "14", "26587698", "16", "21", "42496184", "11", "54734...
p03016 AtCoder Beginner Contest 129 - Takahashi's Basics in Education and Learning
There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}. The initial term is A, and the common difference is B. That is, s_i = A + B \times i holds. Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 woul...
{ "input": [], "output": [] }
{ "input": [ "4 8 1 1000000", "107 10000000000007 1000000000000007 998244353", "5 3 4 10007" ], "output": [ "891011", "39122908", "5563" ] }
{ "input": [ "6 8 1 1000000", "107 10000000000007 1000000000000007 1055093371", "5 5 4 10007", "4 8 1 1001000", "107 10000000000007 1000000000000007 498250141", "2 5 4 10007", "3 8 1 1001000", "107 17664785118816 1000000000000007 498250141", "2 1 4 10007", "3 7 1 1001000", ...
p03156 AISing Programming Contest 2019 - Contests
You have written N problems to hold programming contests. The i-th problem will have a score of P_i points if used in a contest. With these problems, you would like to hold as many contests as possible under the following condition: * A contest has three problems. The first problem has a score not greater than A poin...
{ "input": [], "output": [] }
{ "input": [ "3\n5 6\n5 6 10", "7\n5 15\n1 10 16 2 7 20 12", "8\n3 8\n5 5 5 10 10 10 15 20" ], "output": [ "1", "2", "0" ] }
{ "input": [ "3\n5 11\n5 6 10", "7\n5 15\n1 10 28 2 7 20 12", "8\n3 8\n5 5 5 2 10 10 15 20", "3\n5 11\n5 6 4", "7\n5 15\n1 13 28 2 7 20 12", "8\n3 8\n5 5 5 2 10 12 15 20", "3\n5 11\n5 6 3", "7\n5 21\n1 13 28 2 7 20 12", "8\n3 8\n5 5 5 2 9 12 15 20", "3\n6 11\n5 6 3", "7\n5 ...
p03299 AtCoder Grand Contest 026 - Histogram Coloring
Let us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i-th column (1 \leq i \leq N) from the left and j-th row (1 \leq j \leq 10^9) from the bottom. Snuke has cut out some part of the grid so that, for each i = 1, 2, ..., N, the bottom-most h_i squares are remaining in the i-t...
{ "input": [], "output": [] }
{ "input": [ "9\n2 3 5 4 1 2 4 2 1", "2\n2 2", "9\n27 18 28 18 28 45 90 45 23", "5\n2 1 2 1 2" ], "output": [ "12800", "6", "844733013", "256" ] }
{ "input": [ "9\n3 3 5 4 1 2 4 2 1", "9\n21 18 28 18 28 45 90 45 23", "9\n2 3 7 4 1 2 4 2 1", "9\n21 18 3 18 28 45 90 45 23", "9\n2 3 4 4 1 2 4 2 1", "9\n21 18 3 18 46 45 90 45 23", "9\n2 3 2 4 1 2 4 2 1", "9\n21 18 3 17 46 45 90 45 23", "9\n2 3 2 4 1 2 4 2 2", "9\n21 18 1 17 4...
p03457 AtCoder Beginner Contest 086 - Traveling
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1...
{ "input": [], "output": [] }
{ "input": [ "2\n3 1 2\n6 1 1", "2\n5 1 1\n100 1 1", "1\n2 100 100" ], "output": [ "Yes", "No", "No" ] }
{ "input": [ "2\n3 1 2\n6 0 1", "2\n5 2 3\n100 0 0", "2\n7 1 1\n100 1 1", "1\n2 100 101", "2\n7 1 1\n100 1 0", "1\n3 100 101", "2\n5 1 1\n100 1 0", "1\n3 100 001", "2\n5 2 1\n100 1 0", "1\n3 110 001", "2\n5 2 2\n100 1 0", "1\n3 111 001", "2\n5 2 2\n100 1 -1", "1...
p03618 AtCoder Grand Contest 019 - Reverse and Compare
You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters. You can choose any two indices i and j such that 1 \leq i \leq j \leq n and reverse substring A_i A_{i+1} ... A_j. You can perform this operation at most once. How many different strings can you obtain? Constraints * 1 \leq |A| \leq 200...
{ "input": [], "output": [] }
{ "input": [ "xxxxxxxxxx", "aatt", "abracadabra" ], "output": [ "1", "5", "44" ] }
{ "input": [ "yxxxxxxxxx", "aatu", "abracbdabra", "yxxxxxxxxw", "yxxxxxxyxw", "yxxxxxxzxw", "yxxxwxxzxw", "aaracbdaarb", "wxzxxxwxxz", "aarqabdaacb", "abrqabdaacb", "ttaa", "yxxxxyxxxx", "arbadbcbrca", "vxzxxwxxxy", "zxxwyxxzxw", "arbadbcbsca", "...
p03776 AtCoder Beginner Contest 057 - Maximum Average Sets
You are given N items. The value of the i-th item (1 \leq i \leq N) is v_i. Your have to select at least A and at most B of these items. Under this condition, find the maximum possible arithmetic mean of the values of selected items. Additionally, find the number of ways to select items so that the mean of the values o...
{ "input": [], "output": [] }
{ "input": [ "4 2 3\n10 20 10 10", "5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996", "5 2 2\n1 2 3 4 5" ], "output": [ "15.000000\n3", "1000000000000000.000000\n1", "4.500000\n1" ] }
{ "input": [ "4 2 6\n10 20 10 10", "5 2 2\n1 0 3 4 5", "4 2 6\n10 20 10 5", "4 2 6\n2 20 10 5", "5 1 5\n1000000000000000 999999999999999 999999999999998 455140417295801 999999999999996", "5 2 2\n1 2 3 3 5", "4 2 6\n10 28 10 10", "4 1 6\n2 20 10 5", "4 2 6\n2 20 11 4", "5 2 2\n1...
p03945 AtCoder Beginner Contest 047 - 1D Reversi
Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones b...
{ "input": [], "output": [] }
{ "input": [ "WWWWWW", "WBWBWBWBWB", "BBBWW" ], "output": [ "0", "9", "1" ] }
{ "input": [ "WWWXWW", "WBWBWBBBWW", "BWBBW", "WXWXWW", "WWBBCWBWBV", "XWBBCWBWBV", "XWVBCWBWCB", "WWBBB", "XWVWVX", "WWBBBWBWBW", "WBBWB", "WXVXWW", "WWBBBWBWBV", "WBBXB", "WWXVXW", "BXBBW", "WWXUXW", "BXBWB", "WXUXWW", "XWVBCWBWBB", ...
p00037 Path on a Grid
Seen from above, there is a grid-like square shaped like Figure 1. The presence or absence of "walls" on each side of this grid is represented by a sequence of 0s and 1s. Create a program that stands at point A, puts your right hand on the wall, keeps walking in the direction of the arrow, and outputs the route to retu...
{ "input": [], "output": [] }
{ "input": [ "1111\n00001\n0110\n01011\n0010\n01111\n0010\n01001\n0111" ], "output": [ "RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL" ] }
{ "input": [ "1111\n00001\n0110\n01011\n0010\n01111\n0010\n01011\n0111", "1111\n00001\n0110\n01011\n0010\n01111\n1010\n01011\n0111", "1111\n00001\n0110\n01111\n0010\n00011\n1010\n01011\n0111", "1111\n00001\n0110\n01111\n1010\n00011\n1010\n01011\n0111", "1111\n00001\n0110\n11111\n1010\n00011\n1010\...
p00169 Blackjack
Blackjack is a type of card game played in casinos, where the game is played using cards with numbers from 1 to 13. The score of each card is decided as follows. * 1 is 1 point or 11 points * From 2 to 9, the score is as written. * 10 points from 10 to 13 There are several participants in this game, including paren...
{ "input": [], "output": [] }
{ "input": [ "1\n7 7 7\n7 7 8\n12 1\n10 1 1\n0" ], "output": [ "11\n21\n0\n21\n12" ] }
{ "input": [ "1\n7 7 7\n7 7 8\n12 1\n10 1 2\n0", "1\n7 7 7\n7 7 8\n10 1\n10 1 1\n0", "1\n7 7 7\n7 7 8\n2 1\n10 2 1\n0", "1\n7 9 7\n7 7 8\n2 1\n10 2 1\n0", "1\n7 9 7\n1 9 8\n2 1\n10 2 1\n0", "1\n7 4 7\n1 9 8\n2 1\n10 2 1\n0", "1\n7 4 2\n1 9 8\n2 1\n10 2 1\n0", "1\n7 3 2\n1 9 8\n2 1\n10 ...
p00325 Halting Problem
Have you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it. Unfortunately, it is not possible to make such a decision for any program in the programming language you normally use. H...
{ "input": [], "output": [] }
{ "input": [ "3\n111 SET c 1\n12 SUB c c 2\n777 SET a 4", "3\n10 SET c 1\n120 IF c 10\n20 HALT", "6\n10 SET c 1\n20 SET i 5\n100 ADD s s i\n110 SUB i i c\n120 IF i 100\n200 HALT" ], "output": [ "a=0\nc=1", "inf", "c=1\ni=0\ns=15" ] }
{ "input": [ "3\n111 SET c 1\n12 SUB c c 4\n777 SET a 4", "3\n10 SET c 1\n193 IF c 10\n20 HALT", "6\n10 SET c 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n120 IF i 100\n200 HALT", "3\n10 SET c 1\n193 IF c 11\n20 HALT", "3\n10 SET c 0\n193 IF c 11\n20 HALT", "3\n111 SET c 1\n12 SUB c c 2\n777 S...
p00497 Nails
JOI is playing with a nail in the board. As shown in the figure below, JOI stabbed nails in the shape of an equilateral triangle with N sides. A nails are lined up in the ath line (1 ≤ a ≤ N) from the top. The bth nail (1 ≤ b ≤ a) from the left is represented by (a, b). <image> Figure 1: Arrangement of nails (when N =...
{ "input": [], "output": [] }
{ "input": [ "None", "5 2\n2 2 1\n2 1 3" ], "output": [ "None", "12" ] }
{ "input": [ "Npne", "5 2\n2 1 1\n2 1 3", "Nnpe", "9 2\n2 1 1\n2 1 3", "Nope", "1 2\n2 1 1\n2 1 3", "Nopd", "1 2\n2 1 1\n2 2 3", "dpoN", "1 2\n2 1 1\n2 2 0", "cpoN", "1 2\n2 1 0\n2 2 0", "cNop", "cNpo", "opNc", "opNd", "odNp", "npNd", "pnNd",...
p00682 Area of Polygons
Polygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd better try some programming exercises about basic operations on polygons. Your job in this problem is ...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 30\n0 40\n100 40\n100 0\n\n0" ], "output": [ "1 8.5\n2 3800.0" ] }
{ "input": [ "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 33\n0 40\n100 40\n100 0\n\n0", "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 33\n0 40\n110 40\n100 0\n\n0", "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n10 30\n0 40\n100 40\n100 1\n\n0", "3\n1 1\n3 4\n6 0\n\n7\n0 0\n10 10\n0 20\n3 33\n0 40\n100 40\...
p00824 Gap
Let’s play a card game called Gap. You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 to 7) represents the value of the card. First, you shuffle the cards and lay them face up on the table in four rows of seven cards, leaving a...
{ "input": [], "output": [] }
{ "input": [ "4\n\n12 13 14 15 16 17 21\n22 23 24 25 26 27 31\n32 33 34 35 36 37 41\n42 43 44 45 46 47 11\n\n26 31 13 44 21 24 42\n17 45 23 25 41 36 11\n46 34 14 12 37 32 47\n16 43 27 35 22 33 15\n\n17 12 16 13 15 14 11\n27 22 26 23 25 24 21\n37 32 36 33 35 34 31\n47 42 46 43 45 44 41\n\n27 14 22 35 32 46 33\n13 ...
{ "input": [ "4\n\n12 13 15 15 16 17 21\n22 23 24 25 26 27 31\n32 33 34 35 36 37 41\n42 43 44 45 46 47 11\n\n26 31 13 44 21 24 42\n17 45 23 25 41 36 11\n46 34 14 12 37 32 47\n16 43 27 35 22 33 15\n\n17 12 16 13 15 14 11\n27 22 26 23 25 24 21\n37 32 36 33 35 34 31\n47 42 46 43 45 44 41\n\n27 14 22 35 32 46 33\n13 ...
p00955 Cover the Polygon with Your Disk
Example Input 4 4 0 0 6 0 6 6 0 6 Output 35.759506
{ "input": [], "output": [] }
{ "input": [ "4 4\n0 0\n6 0\n6 6\n0 6" ], "output": [ "35.759506" ] }
{ "input": [ "4 2\n0 0\n6 0\n6 6\n0 6", "4 1\n0 0\n6 0\n6 6\n0 6", "4 1\n0 0\n6 0\n6 6\n0 9", "4 1\n0 -1\n6 0\n6 6\n0 9", "2 1\n0 -1\n6 0\n6 6\n0 9", "4 4\n0 1\n6 0\n6 6\n0 6", "4 2\n0 0\n6 0\n9 6\n0 6", "4 1\n0 0\n6 1\n6 6\n0 6", "4 4\n0 1\n6 -1\n6 6\n0 6", "4 2\n-1 0\n6 0\n9 ...
p01088 500-yen Saving
500-yen Saving "500-yen Saving" is one of Japanese famous methods to save money. The method is quite simple; whenever you receive a 500-yen coin in your change of shopping, put the coin to your 500-yen saving box. Typically, you will find more than one million yen in your saving box in ten years. Some Japanese people...
{ "input": [], "output": [] }
{ "input": [ "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n600\n4\n300\n700\n1600\n650\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n667\n876\n299\n0" ], "output": [ "2 2900\n3 2500\n3 3250\n1 500\n3 1500\n3 2217" ] }
{ "input": [ "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n30\n4\n300\n700\n1600\n650\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n667\n876\n299\n0", "4\n800\n700\n1600\n600\n4\n300\n700\n1600\n30\n4\n300\n700\n1600\n650\n3\n1000\n2000\n500\n3\n250\n250\n1000\n4\n1251\n1191\n876\n299\n0", "4\n800\n700\n...
p01224 Perfect Number
Let S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a program that determines whether a given integer is a perfect number, a missing number, or an abundant num...
{ "input": [], "output": [] }
{ "input": [ "1\n2\n3\n4\n6\n12\n16\n28\n33550336\n99999998\n99999999\n100000000\n0" ], "output": [ "deficient number\ndeficient number\ndeficient number\ndeficient number\nperfect number\nabundant number\ndeficient number\nperfect number\nperfect number\ndeficient number\ndeficient number\nabundant numbe...
{ "input": [ "1\n2\n3\n4\n6\n12\n16\n28\n33550336\n99999998\n99999999\n100001000\n0", "1\n2\n5\n4\n6\n12\n16\n28\n820514\n99999998\n99999999\n100001100\n0", "1\n2\n5\n4\n6\n12\n18\n28\n820514\n99999998\n99999999\n100001100\n0", "1\n1\n5\n0\n6\n12\n16\n28\n33550336\n99999998\n99999999\n100001100\n0", ...
p01358 Usaneko Matrix
Rabbits and cats are competing. The rules are as follows. First, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. Each time a card is drawn, the two will mark it if the same number a...
{ "input": [], "output": [] }
{ "input": [ "3 2 2 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8", "3 2 1 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8" ], "output": [ "USAGI", "DRAW" ] }
{ "input": [ "3 2 4 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8", "3 3 4 11\n1 2 3\n8 5 6\n7 8 9\n1 2 3\n8 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n3\n1\n3\n8", "3 5 4 11\n1 2 3\n8 5 6\n7 8 9\n1 2 3\n8 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n3\n1\n3\n8", "3 2 4 10\n1 2 3\n4 5 6\n7 8 9\...
p01540 Treasure Hunt
Taro came to a square to look for treasure. There are many treasures buried in this square, but Taro has the latest machines, so he knows everything about where the treasures are buried. Since the square is very wide Taro decided to look for the treasure to decide the area, but the treasure is what treasure does not kn...
{ "input": [], "output": [] }
{ "input": [ "5 5\n10 5\n-3 -8\n2 11\n6 0\n-1 3\n-3 1 3 13\n-1 -1 9 5\n-3 -8 10 11\n0 0 5 5\n-10 -9 15 10", "3 1\n1 1\n2 4\n5 3\n0 0 5 5", "4 2\n-1 1\n0 3\n4 0\n2 1\n-3 1 5 1\n4 0 4 0", "2 3\n0 0\n0 0\n-1 -1 1 1\n0 0 2 2\n1 1 4 4" ], "output": [ "2\n2\n5\n0\n4", "3", "2\n1", "2\n2\...
{ "input": [ "5 5\n10 5\n-3 -8\n2 11\n6 0\n-1 3\n-3 1 3 13\n-1 -1 9 9\n-3 -8 10 11\n0 0 5 5\n-10 -9 15 10", "3 1\n1 1\n2 4\n5 3\n-1 0 5 5", "4 2\n-1 1\n0 1\n4 0\n2 1\n-3 1 5 1\n4 0 4 0", "2 3\n0 0\n0 0\n-1 -1 1 1\n0 0 2 2\n1 2 4 4", "4 2\n-1 1\n0 1\n4 0\n2 1\n-3 1 5 1\n4 0 4 -1", "3 1\n1 1\n2 ...
p01696 Broken Cipher Generator
Broken crypto generator JAG (Japanese Alumni Group) is a mysterious organization composed of many programmers, and in order to enter the building where the headquarters of this organization is located, it is necessary to solve the ciphertext generated by a certain machine every time. This ciphertext consists of the sy...
{ "input": [], "output": [] }
{ "input": [ "A+A++A\nZ-Z--Z+-Z\n[ESREVER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n." ], "output": [ "ABC\nZYXZ\nREVERSE\nJAG\nICPC\nJAPAN" ] }
{ "input": [ "A+A++A\nZ-Z--Z+-Z\n[ESRVEER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.", "A+A++A\nZ-ZZ--+-Z\n[ESRVEER]\nJ---?---J\n++++++++A+++Z-----------A+++Z\n[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L\n.", "A+A++A\nZ-Z--Z+-Z\n[ESRVEER]\nJ---?---J\...
p01840 Delivery to a Luxurious House
B-Mansion and courier Problem Statement Taro lives alone in a mansion. Taro, who loves studying, intends to study in his study in the house today. Taro can't concentrate outside the study, so he always studies in the study. However, on this day, $ N $ of courier service to Taro arrived. $ i $ ($ 1 \ leq i \ leq N $)...
{ "input": [], "output": [] }
{ "input": [ "1 1 5\n3" ], "output": [ "3" ] }
{ "input": [ "1 1 5\n6", "1 1 10\n6", "1 2 10\n6", "1 0 10\n6", "1 1 10\n10", "1 2 9\n9", "1 1 5\n5", "1 1 19\n6", "1 2 20\n6", "1 0 19\n2", "1 1 5\n1", "1 1 33\n6", "1 1 20\n6", "1 1 58\n6", "1 2 37\n6", "1 1 101\n6", "1 2 62\n6", "1 1 15\n6", ...
p01976 Anagram
problem Given a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \ le K \ le N) $ that satisfy the following conditions. Condition: Well sorted $ a_1, \ cdots, a_K $ matches $ a_ {N-K + 1}, \ cdots, a_N $. Example Input 8 5 2 4 9 4 9 2 5 Output 1 2 4 6 7 8
{ "input": [], "output": [] }
{ "input": [ "8\n5 2 4 9 4 9 2 5" ], "output": [ "1 2 4 6 7 8" ] }
{ "input": [ "8\n5 2 4 4 4 9 2 5", "8\n5 2 4 4 4 14 2 0", "8\n-1 10 7 2 2 1 -1 -1", "8\n-1 0 3 32 0 4 -1 0", "8\n0 1 1 -16 -1 0 1 1", "8\n0 1 1 -24 -1 1 1 0", "8\n-1 1 0 -2 1 0 -1 -2", "8\n5 2 4 4 4 14 2 5", "8\n5 2 4 4 4 11 2 0", "8\n5 2 6 4 4 11 2 0", "8\n6 2 6 4 4 11 2 0...
p02122 RMQ 2
Problem Given two sequences of length $ N $, $ A $ and $ B $. First, the $ i $ item in the sequence $ A $ is $ a_i $, and the $ i $ item in the sequence $ B $ is $ b_i $. Since a total of $ Q $ of statements of the following format are given, create a program that processes in the given order. Each statement is repr...
{ "input": [], "output": [] }
{ "input": [ "5\n1 3 5 7 9\n6 2 3 2 6\n10\n1 3 4\n3 4 5\n4 2 3\n5 -1 -1\n2 3 8\n3 2 5\n4 3 3\n1 1 1\n6 -1 -1\n3 1 5" ], "output": [ "7\n2\n2\n8\n1" ] }
{ "input": [ "5\n1 3 5 7 9\n6 2 3 2 6\n10\n1 3 4\n3 4 5\n4 2 3\n5 -1 -1\n2 3 8\n3 2 5\n4 3 3\n2 1 1\n6 -1 -1\n3 1 5", "5\n1 3 5 7 9\n6 2 3 2 6\n10\n1 3 4\n3 4 5\n4 2 3\n5 -1 -1\n2 3 16\n3 2 5\n4 3 3\n1 1 1\n6 -1 -1\n3 1 5", "5\n1 3 5 7 9\n6 2 3 2 6\n10\n1 3 6\n3 4 5\n4 2 3\n5 -1 -1\n2 3 8\n6 2 5\n4 3 3\n2...
p02262 Shell Sort
Shell Sort Shell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g...
{ "input": [], "output": [] }
{ "input": [ "5\n5\n1\n4\n3\n2", "3\n3\n2\n1" ], "output": [ "2\n4 1\n3\n1\n2\n3\n4\n5", "1\n1\n3\n1\n2\n3" ] }
{ "input": [ "5\n5\n1\n4\n5\n2", "3\n6\n2\n1", "5\n6\n1\n4\n5\n2", "3\n0\n2\n1", "5\n6\n1\n4\n9\n2", "3\n-1\n2\n1", "5\n6\n1\n4\n6\n2", "3\n0\n2\n0", "5\n5\n1\n4\n9\n2", "3\n0\n1\n0", "5\n7\n1\n4\n9\n2", "3\n1\n1\n0", "5\n7\n1\n4\n9\n3", "3\n1\n1\n-1", "5\n7...
p02410 Matrix Vector Multiplication
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column ve...
{ "input": [], "output": [] }
{ "input": [ "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0" ], "output": [ "5\n6\n9" ] }
{ "input": [ "3 4\n1 4 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0", "3 4\n1 2 0 1\n0 3 0 1\n4 1 2 0\n1\n2\n3\n0", "3 4\n1 4 0 1\n0 3 1 1\n4 1 1 0\n1\n2\n3\n0", "3 4\n1 4 0 1\n0 3 1 1\n4 1 1 0\n1\n2\n0\n0", "3 4\n1 4 -1 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0", "3 4\n0 2 0 1\n0 3 0 1\n4 1 2 0\n1\n2\n3\n0", ...
arithm
Chef's encounters with sweets continue with this problem! This time, he wants to distribute chocolates to his N students sitting on a long bench. The students are ordered according to the scores they got from the last exam. Chef wants to give more chocolates to the higher-scoring students. He also has a few more restr...
{ "input": [], "output": [] }
{ "input": [ "2\n4 24\n2 2" ], "output": [ "Yes\nNo" ] }
{ "input": [], "output": [] }
clco03
Arush was not always poor at Mathematics but his recent performances had not been that good and he had lost his confidence. Now his elder brother was determined to bring back his confidence back in Mathematics. So he made a tricky question and made sure that Arush would be able to do solve it. The factorial of a non-ne...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n6\n3\n006" ], "output": [ "53\n53" ] }
{ "input": [], "output": [] }
fctrl2
A tutorial for this problem is now available on our blog. Click here to read it. You are asked to calculate factorials of some small positive integers. Input An integer t, 1 ≤ t ≤ 100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1 ≤ n ≤ 100. Output For each integer n ...
{ "input": [], "output": [] }
{ "input": [ "4\n1\n2\n5\n3" ], "output": [ "1\n2\n120\n6\n" ] }
{ "input": [ "4\n2\n2\n5\n3", "4\n2\n2\n5\n6", "4\n2\n2\n8\n6", "4\n2\n2\n2\n6", "4\n1\n2\n2\n6", "4\n1\n2\n2\n9", "4\n2\n2\n2\n9", "4\n2\n2\n4\n9", "4\n3\n2\n4\n9", "4\n3\n2\n4\n3", "4\n3\n2\n2\n3", "4\n1\n2\n4\n3", "4\n2\n2\n6\n3", "4\n1\n2\n5\n6", "4\n2\n...
lebamboo
Problem Statement Little Elephant from Zoo of Lviv likes bamboo very much. He currently has n stems of bamboo, Hi - height of i-th stem of bamboo (0-based numeration). Today inspector Andrii from World Bamboo Association is visiting the plantation. He doesn't like current situation. He wants the height of i-th stem t...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n1\n2\n2\n1 2\n2 1\n3\n3 2 2\n4 5 3" ], "output": [ "-1\n1\n5" ] }
{ "input": [ "3\n1\n1\n2\n2\n1 2\n2 1\n1\n3 2 2\n4 5 3", "3\n1\n1\n2\n2\n0 2\n2 1\n1\n3 2 2\n4 5 3", "3\n1\n1\n2\n2\n2 2\n2 1\n3\n3 2 2\n4 5 3", "3\n1\n0\n2\n2\n0 2\n2 0\n1\n3 2 2\n4 5 3", "3\n1\n2\n2\n2\n2 2\n2 1\n1\n3 2 2\n4 5 3", "3\n1\n1\n0\n2\n1 1\n2 0\n2\n3 0 7\n6 5 5", "3\n1\n1\n0\n...
plgrm
For Turbo C++ Users : Read the following document before attempting the question : Problem Description N-Boy is very eccentric when it comes to strings. These days, he spends most of his time studying palindromes and pangrams (for his IP assignment at IIITD). For those of you who don’t know, a palindrome is a word ...
{ "input": [], "output": [] }
{ "input": [ "3\nabba\nabcdefghijklmnopqrstuvwxyz\nqwerty" ], "output": [ "palindrome\npangram\nnone\n" ] }
{ "input": [ "3\nabba\nfbcdeaghijklmnopqrstuvwxyz\nqwerty", "3\nabba\ngbcdeaghijklmnopqrstuvwxyz\nqwerty", "3\naaba\ngbcdeaghijklmnopqrstuvwxyz\nqwerty", "3\nabab\nfbcdeaynijklmhopqrstuvwxgz\newqrty", "3\naaba\ngbcdeaghijklmnopqrstuvwxyz\nqwertz", "3\naaba\ngbcdeaghijklmnopqrstuvwxyz\nztrewq",...
sub_perm
A factory called 'IP Labs Pvt. Ltd.' has produced some material, which is in the form of blocks. Each block is labeled by an alphanumeric character. You've been recently hired as Packaging Manager, and your job is to rearrange the huge lot of manufactured blocks and then extract out the useful blocks from it which can ...
{ "input": [], "output": [] }
{ "input": [ "4\nareyouafoobarmember\nbarfoo\nfofoforabrabbbbbbfoooooooaaa\nfoobar\nthisisiplab\nsi\nababa\naa" ], "output": [ "1\n2\n2\n1" ] }
{ "input": [ "4\nareyouafoobarmember\nbarfoo\nfofoforabrabbbbbbfoooooooaaa\noofbar\nthisisiplab\nsi\nababa\naa", "4\nareyouafoobarmember\nbarfoo\ngofoforabrabbbbbbfoooooooaaa\noofbar\nthisisiplab\nsi\nababa\nab", "4\nareyouafoobarmember\nbargoo\ngofoforabrabbbbbbfooooonoaaa\noofbar\nthisisiplab\nsi\nababa...
1330_B. Dreamoon Likes Permutations
The sequence of m integers is called the permutation if it contains all integers from 1 to m exactly once. The number m is called the length of the permutation. Dreamoon has two permutations p_1 and p_2 of non-zero lengths l_1 and l_2. Now Dreamoon concatenates these two permutations into another sequence a of length...
{ "input": [], "output": [] }
{ "input": [ "6\n5\n1 4 3 2 1\n6\n2 4 1 3 2 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n1 1 1\n" ], "output": [ "2\n1 4\n4 1\n1\n4 2\n0\n0\n1\n2 10\n0\n" ] }
{ "input": [ "6\n5\n1 4 3 1 1\n6\n2 4 1 3 2 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n1 1 1\n", "6\n5\n1 4 3 2 1\n6\n2 4 1 3 3 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n1 1 1\n", "6\n5\n1 4 3 1 1\n6\n2 4 1 4 2 1\n4\n2 1 1 3\n4\n1 3 3 1\n12\n2 1 3 4 5 6 7 8 9 1 10 2\n3\n...
1485_D. Multiples and Power Differences
You are given a matrix a consisting of positive integers. It has n rows and m columns. Construct a matrix b consisting of positive integers. It should have the same size as a, and the following conditions should be met: * 1 ≤ b_{i,j} ≤ 10^6; * b_{i,j} is a multiple of a_{i,j}; * the absolute value of the dif...
{ "input": [], "output": [] }
{ "input": [ "2 3\n16 16 16\n16 16 16\n", "2 2\n1 2\n2 3\n", "2 2\n3 11\n12 8\n" ], "output": [ "\n16 32 48\n32 48 64\n", "\n1 2\n2 3\n", "\n327 583\n408 664\n" ] }
{ "input": [ "2 3\n16 16 11\n16 16 16\n", "2 2\n1 2\n3 3\n", "2 2\n6 11\n12 8\n", "2 2\n1 2\n2 5\n", "2 2\n1 2\n4 3\n", "2 2\n1 1\n4 3\n", "2 2\n1 1\n8 3\n", "2 2\n6 10\n12 8\n", "1 2\n1 2\n2 0\n", "2 3\n7 16 5\n9 7 16\n", "2 2\n0 3\n3 3\n", "2 2\n6 10\n14 8\n", "2 ...
162_I. Truncatable primes
A truncatable prime is a prime number which contains no zeros in decimal notation and all its suffixes are primes. 1 is considered to be not a prime. You are given a positive integer n. Figure out whether it is a truncatable prime. Input The only line of input contains an integer n (2 ≤ n ≤ 107). Output Output "YE...
{ "input": [], "output": [] }
{ "input": [ "19\n", "9137\n" ], "output": [ "NO\n", "YES\n" ] }
{ "input": [], "output": [] }
dawood-the-mathematician
Dr.Dawood is another mathematician who is more geekier than Osama (that's why, ++). Dawood deals with more complex problems than Osama usually deals with. He also recruits people to be his sub-ordinates. He usually gives them "trivial" problems as test for them to solve and earn their position to be his sub-ordinate. ...
{ "input": [], "output": [] }
{ "input": [ "4\n3\n1\n2\n5\n\nSAMPLE" ], "output": [ "2\n2\n4\n2" ] }
{ "input": [], "output": [] }
panda-and-combination
Panda loves solving problems which are deemed impossible by his fellow classmates. The current problem which he is working on is to express a number N as sum of powers of number X (Not necessarily distinct) such that the number of powers of number X used should be minimum. Note: The powers of a number can be 0, 1,...
{ "input": [], "output": [] }
{ "input": [ "3\n4 4\n5 3\n6 1\n\nSAMPLE" ], "output": [ "1\n3\n6\n" ] }
{ "input": [ "3\n4 4\n2 3\n6 1\n\nSAMPLE", "3\n4 4\n2 3\n11 1\n\nSAMPLE", "3\n8 4\n2 3\n11 1\n\nSAMPLE", "3\n8 5\n2 3\n11 1\n\nSAMPKE", "3\n11 5\n2 3\n11 1\n\nSAMPKE", "3\n11 5\n2 3\n6 1\n\nSAMPKE", "3\n11 5\n3 3\n6 1\n\nSAMPKE", "3\n4 3\n5 3\n6 1\n\nSAMPLE", "3\n7 9\n2 3\n11 1\n\n...
uncles-will-1
Ramu’s uncle has left him a stable in his Will. But the stable is not in a good condition. The roofs leak and need to be repaired. There are a number of stalls in the stable. A stall may or may not contain a horse. Ramu has to buy new cement sheets to cover these stalls. He has to cover atleast all those stalls that h...
{ "input": [], "output": [] }
{ "input": [ "1\n2 10 3\n2\n4\n10\n\nSAMPLE" ], "output": [ "4" ] }
{ "input": [], "output": [] }
p02586 AtCoder Beginner Contest 175 - Picking Goods
There are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column (1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i. Takahashi will begin at (1, 1), the start, and get to (R, C), the goal. When he is at (i, ...
{ "input": [], "output": [] }
{ "input": [ "2 5 5\n1 1 3\n2 4 20\n1 2 1\n1 3 4\n1 4 2", "2 2 3\n1 1 3\n2 1 4\n1 2 5", "4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10" ], "output": [ "29", "8", "142" ] }
{ "input": [ "2 5 5\n1 1 3\n2 4 20\n2 2 1\n1 3 4\n1 4 2", "4 5 3\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10", "4 5 3\n2 5 10\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10", "4 5 5\n2 5 10\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 ...
p02717 AtCoder Beginner Contest 161 - ABC Swap
We have three boxes A, B, and C, each of which contains an integer. Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively. We will now do the operations below in order. Find the content of each box afterward. * Swap the contents of the boxes A and B * Swap the contents of the boxes A and C C...
{ "input": [], "output": [] }
{ "input": [ "100 100 100", "41 59 31", "1 2 3" ], "output": [ "100 100 100", "31 41 59", "3 1 2" ] }
{ "input": [ "000 100 100", "41 82 31", "2 2 3", "010 100 100", "41 82 46", "2 2 5", "010 000 100", "41 18 46", "2 2 7", "010 000 110", "41 5 46", "3 2 7", "010 010 110", "41 5 7", "3 2 12", "011 010 110", "59 5 7", "2 2 12", "011 000 110", ...
p02846 Sumitomo Mitsui Trust Bank Programming Contest 2019 - Interval Running
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows towards the east: * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subse...
{ "input": [], "output": [] }
{ "input": [ "1 2\n10 10\n12 4", "100 1\n101 101\n102 1", "12000 15700\n3390000000 3810000000\n5550000000 2130000000" ], "output": [ "1", "infinity", "113" ] }
{ "input": [ "1 2\n10 10\n12 5", "100 1\n111 101\n102 1", "100 2\n100 101\n102 1", "1 1\n1 20\n12 5", "100 2\n100 101\n102 0", "1 1\n2 20\n12 5", "100 2\n100 111\n102 0", "1 1\n0 20\n12 5", "30901 15700\n2647944172 11366428589\n5864465524 4464634034", "1 -2\n-2 1\n1 3", "34...
p02983 AtCoder Beginner Contest 133 - Remainder Minimization 2019
You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019. Constraints * All values in input are integers. * 0 \leq L < R \leq 2 \times 10^9 Input Input is given from Standard Input in the fol...
{ "input": [], "output": [] }
{ "input": [ "4 5", "2020 2040" ], "output": [ "20", "2" ] }
{ "input": [ "3 5", "4 10", "2020 3053", "1 5", "8 10", "2845 3053", "2 5", "6 8", "5 12", "9 10", "543 3053", "1 8", "1022 3053", "0 8", "1022 2650", "-1 8", "1022 4340", "-1 15", "0 15", "-2 15", "-4 15", "-3 15", "0 13", ...
p03125 AtCoder Beginner Contest 118 - B +/- A
You are given positive integers A and B. If A is a divisor of B, print A + B; otherwise, print B - A. Constraints * All values in input are integers. * 1 \leq A \leq B \leq 20 Input Input is given from Standard Input in the following format: A B Output If A is a divisor of B, print A + B; otherwise, print B -...
{ "input": [], "output": [] }
{ "input": [ "4 12", "8 20", "1 1" ], "output": [ "16", "12", "2" ] }
{ "input": [ "1 12", "4 20", "1 0", "1 2", "4 24", "1 -1", "6 24", "6 36", "6 10", "6 17", "6 32", "5 32", "5 52", "5 10", "2 16", "1 16", "3 19", "5 19", "4 28", "8 28", "22 28", "22 14", "16 14", "16 3", "16 1", ...
p03267 AtCoder Beginner Contest 108 - All Your Paths are Different Lengths
You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists. * The number of vertices, N, is at most 20. The vertices are given ID numbers from 1 to N. * The number o...
{ "input": [], "output": [] }
{ "input": [ "4", "5" ], "output": [ "8 10\n1 2 0\n2 3 0\n3 4 0\n1 5 0\n2 6 0\n3 7 0\n4 8 0\n5 6 1\n6 7 1\n7 8 1", "5 7\n1 2 0\n2 3 1\n3 4 0\n4 5 0\n2 4 0\n1 3 3\n3 5 1" ] }
{ "input": [ "8", "2", "1", "9", "6", "3", "10", "17", "18", "33", "16", "12", "20", "40", "36", "32", "65", "24", "34", "66", "48", "68", "72", "129", "64", "130", "136", "80", "160", "96", "14...
p03425 AtCoder Beginner Contest 089 - March
There are N people. The name of the i-th person is S_i. We would like to choose three people so that the following conditions are met: * The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`. * There are no multiple people whose names begin with the same letter. How many such ways are there to choo...
{ "input": [], "output": [] }
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nHABORO\nHOROKANAI", "5\nCHOKUDAI\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZZ\nZZZ\nZ\nZZZZZZZZZZ" ], "output": [ "2", "7", "0" ] }
{ "input": [ "5\nMASHIKE\nRUMOI\nOBIRA\nOROBAH\nHOROKANAI", "5\nCHOKUD@I\nRNG\nMAKOTO\nAOKI\nRINGO", "4\nZY\nZZZ\nZ\nZZZZZZZZZZ", "5\nDHOKUD@I\nRNG\nMAKOTO\nAOKI\nRINGN", "5\nI@DUKOGE\nHNR\nMTAOKP\nAINK\nRINGN", "5\nMASHIKE\nIOMUR\nOBIRA\nOROBAH\nHOROKANAI", "5\nCHOKUD@I\nRNG\nMAKOTO\nAOKI...
p03582 CODE FESTIVAL 2017 qual B - Largest Smallest Cyclic Shift
For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = `babca`, f(S) = `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`). You are given three integers X, Y, and Z. You want to construct a string T that consists of exact...
{ "input": [], "output": [] }
{ "input": [ "2 2 0", "1 1 1" ], "output": [ "abab", "acb" ] }
{ "input": [ "2 1 0", "1 1 0", "0 2 0", "1 0 1", "2 0 0", "1 0 0", "2 2 1", "2 0 1", "3 2 0", "3 0 1", "3 3 0", "3 1 1", "6 3 0", "2 1 1", "6 3 1", "4 1 1", "6 3 2", "4 2 1", "6 0 2", "5 2 1", "6 0 1", "7 2 1", "7 4 1", "7...
p03739 AtCoder Beginner Contest 059 - Sequence
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-...
{ "input": [], "output": [] }
{ "input": [ "5\n3 -6 4 -5 7", "4\n1 -3 1 0", "6\n-1 4 3 2 -5 4" ], "output": [ "0", "4", "8" ] }
{ "input": [ "5\n3 -6 4 -8 7", "4\n1 -3 1 -1", "6\n-1 4 3 2 -5 0", "4\n1 -5 1 -1", "6\n-1 4 2 2 -5 0", "5\n3 -8 4 -12 7", "4\n1 -5 0 -1", "6\n-1 4 1 2 -5 0", "5\n3 -5 4 -12 7", "6\n-1 8 1 2 -5 0", "6\n-1 8 2 2 -5 0", "6\n-1 8 2 2 -5 -1", "6\n0 8 2 2 -5 -1", "5\n...
p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing!
Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki. Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneou...
{ "input": [], "output": [] }
{ "input": [ "6\n40", "101\n80", "3\n100" ], "output": [ "7.5000000", "63.7500000", "2.0000000" ] }
{ "input": [ "6\n36", "101\n141", "3\n101", "6\n38", "101\n233", "3\n111", "6\n59", "101\n416", "3\n001", "6\n106", "101\n221", "3\n011", "6\n174", "101\n27", "3\n010", "6\n95", "101\n37", "3\n110", "6\n180", "101\n67", "3\n000", ...
p00007 Debt Hell
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks. Input An integer n (0 ≤ n ≤ 100) is g...
{ "input": [], "output": [] }
{ "input": [ "5" ], "output": [ "130000" ] }
{ "input": [ "1", "4", "2", "3", "8", "11", "10", "7", "6", "12", "14", "9", "19", "16", "15", "13", "23", "32", "58", "99", "34", "54", "35", "40", "67", "41", "62", "49", "24", "17", "18", ...
p00139 Snakes
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
{ "input": [], "output": [] }
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~" ], "output": [ "A\nB\nNA" ] }
{ "input": [ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~", "3\n>(======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#==~>=", "3\n>'======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\...
p00272 Ticket Sales
Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well! Shortly after ...
{ "input": [], "output": [] }
{ "input": [ "3 10\n1 4\n4 1\n2 5" ], "output": [ "30000\n24000\n2000\n20000" ] }
{ "input": [ "3 10\n1 4\n4 1\n1 5", "3 13\n1 4\n4 1\n1 5", "3 13\n1 4\n1 1\n1 5", "3 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 5", "2 13\n1 4\n1 2\n1 3", "2 13\n1 6\n1 2\n1 3", "3 10\n1 0\n4 1\n2 5", "3 10\n1 4\n2 1\n1 5", "3 16\n1 4\n1 1\n1 5", "3 13\n2 4\n1 2\n1 5", "2 1...
p00460 Bingo
problem In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions. * The Bingo card is divided into squares of N rows and N columns, and one posi...
{ "input": [], "output": [] }
{ "input": [ "3 9 45\n3 100 50\n5 50 685\n0 0 0" ], "output": [ "1\n7\n74501" ] }
{ "input": [ "3 9 45\n3 100 50\n5 50 308\n0 0 0", "3 12 45\n3 100 75\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 50 308\n0 0 0", "3 12 45\n3 100 69\n5 90 548\n0 0 0", "3 12 45\n3 100 50\n5 50 331\n0 0 0", "3 3 45\n3 100 69\n5 50 308\n0 0 0", "3 12 60\n3 100 69\n5 90 308\n0 0 0", "3 3 45\n...
p00650 The House of Huge Family
Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in the near future. Mr. Dango's family, the huge family, is getting their new house. Scale of the house is as large as...
{ "input": [], "output": [] }
{ "input": [ "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0" ], "output": [ "1\n100\n0\n-1" ] }
{ "input": [ "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n1 1 100\n2 1\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 2 2\n0 2 1\n2 1\n0 1 100\n2 1\n0 1 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n0 1 100\n2 0\n0 0 0\n2 1\n0 1 -1\n0 0", "3 2\n0 1 2\n1 2 1\n2 1\n...
p00795 Co-occurrence Search
A huge amount of information is being heaped on WWW. Albeit it is not well-organized, users can browse WWW as an unbounded source of up-to-date information, instead of consulting established but a little out-of-date encyclopedia. However, you can further exploit WWW by learning more about keyword search algorithms. Fo...
{ "input": [], "output": [] }
{ "input": [ "Thefirstexampleistrivial.\n\nmfv\n\nAhugeamountofinformationisbeingheapedonWWW.Albeititisnot\nwell-organized,userscanbrowseWWWasanunboundedsourceof\nup-to-dateinformation,insteadofconsultingestablishedbutalittle\nout-of-dateencyclopedia.However,youcanfurtherexploitWWWby\nlearningmoreaboutkeywordsear...
{ "input": [ "Thefirstexampleistrivial.\n\nmfv\n\nAhugeamountofinformationisbeingheapedonWWW.Albeititisnot\nwell-organized,userscanbrowseWWWasanunboundedsourceof\nup-to-dateinformation,insteadofconsultingestablishedbutalittle\nout-of-dateencyclopedia.However,youcanfurtherexploitWWWby\nlearningmoreaboutkeywordsear...
p00926 Shopping
Example Input 10 3 3 7 8 9 2 5 Output 23
{ "input": [], "output": [] }
{ "input": [ "10 3\n3 7\n8 9\n2 5" ], "output": [ "23" ] }
{ "input": [ "10 3\n3 7\n8 9\n3 5", "10 3\n3 7\n8 9\n3 8", "10 3\n2 8\n8 9\n3 8", "10 3\n3 7\n8 9\n1 8", "9 3\n3 7\n8 9\n1 5", "10 3\n3 10\n8 9\n1 5", "10 3\n3 4\n8 9\n4 5", "18 3\n3 7\n7 9\n2 5", "18 3\n3 7\n7 9\n1 5", "18 3\n3 7\n7 17\n1 5", "15 3\n3 7\n8 10\n4 5", "1...
p01059 Gossip
Problem N idols, numbered from 1 to n in order, are lined up in a row. Idle i can transmit information to idle i-1 and idle i + 1 in a unit time. However, idol 1 can transmit information only to idol 2, and idol n can transmit information only to idol n-1. At time 0, m idols with numbers a1, a2, ..., am have secret i...
{ "input": [], "output": [] }
{ "input": [ "10 3\n2 5 7", "100000 1\n1", "10 5\n2 5 6 8 10", "3 2\n1 3" ], "output": [ "3", "99999", "1", "1" ] }
{ "input": [ "10 3\n2 5 8", "10 3\n3 5 7", "100001 1\n1", "110001 1\n1", "10 1\n2 2 8", "3 1\n2 2 12", "1 1\n1 3 12", "10 3\n2 5 6 8 10", "10 1\n1 4 8", "8 1\n2 2 7", "10 1\n3 0 8", "17 2\n2 2 12", "7 1\n2 3 12", "100001 1\n2", "110001 1\n2", "12 1\n2 0 ...
p01191 Grated Radish
Grated radish (daikon-oroshi) is one of the essential spices in Japanese cuisine. As the name shows, it’s made by grating white radish. You are developing an automated robot for grating radish. You have finally finished developing mechan- ical modules that grates radish according to given instructions from the microco...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2\n1\n42 3.141592653589793\n5 20\n3\n0 307.09242465218927\n180 307.09242465218927\n90 728.30573874452591" ], "output": [ "2.0 3.141592653589793\n8.660254038 5.235987756" ] }
{ "input": [ "2\n1 2\n1\n66 3.141592653589793\n5 20\n3\n0 307.09242465218927\n180 307.09242465218927\n90 728.30573874452591", "2\n1 2\n1\n110 3.141592653589793\n9 20\n3\n0 307.09242465218927\n180 307.09242465218927\n90 728.30573874452591", "2\n1 2\n1\n110 3.141592653589793\n9 20\n3\n0 307.09242465218927\n...
p01329 Stolen Jewel
The jewel, a national treasure of the Kingdom of Pal, was stolen by bandits. As an adventurer, you heard the rumor and headed for the thief's hideout and managed to get the jewels back. However, when I went to return the jewel to the castle of the Kingdom of Pal, the guard of the castle said, "My king has not complete...
{ "input": [], "output": [] }
{ "input": [ "6 7\n.......\n...#...\n...#.S.\n...###.\n.G.....\n.......\n2\nLL\nDD", "7 6\n......\n.####.\n.####.\n...S#.\n...##.\n...##.\n.....G\n3\nLD\nDD\nLLL\n7 8\nS#......\n.#.####.\n.#.#G.#.\n.#.##.#.\n.#....#.\n.######.\n........\n8\nDDDD\nDDDU\nUUUU\nUUUD\nRRRR\nRRRL\nLLLL\nLLLR\n3 8\n\nS......G\n\n2\...
{ "input": [ "6 7\n.......\n...#...\n/..#.S.\n...###.\n.G.....\n.......\n2\nLL\nDD", "7 6\n......\n.####.\n.####.\n...S#.\n...##.\n.##...\n.....G\n3\nLD\nDD\nLLL\n7 8\nS#......\n.#.####.\n.#.#G.#.\n.#.##.#.\n.#....#.\n.######.\n........\n8\nDDDD\nDDDU\nUUUU\nUUUD\nRRRR\nRRRL\nLLLL\nLLLR\n3 8\n\nS......G\n\n2\...
p01496 Bicube
Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black or some colorful color (such as red and blue) on the front side. Cutting off the unpainted part, she will have eight opened-up unit cubes. A unit cube here refers to a cube of which each face consists of one square. She is...
{ "input": [], "output": [] }
{ "input": [ "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a......
{ "input": [ "3 64\n.a....a....a....a....f....f....f....f...\nbc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.\n.#....#....#....#....#....#....#....#...", "3 40\n.a....a....a....a....f....f....f....f...\n.#eb#.#de#.#cd#.#bc#.#be#.#ed#.#dc#.#cb#\n.#....#....#....#....#....#....#....#...", "5 40\n.a....a....a....a.....
p01664 Sigma
I-σ A permutation of magnitude N is a sequence of elements in a sequence (1, 2, 3,…, N). For example, (5, 2, 1, 4, 3) is a permutation of size 5, while (1, 5, 1, 2, 3) is not. This problem is a reactive task. You play a response program and a "permutation guessing game". First of all, the response program internally ...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p01809 Let's Solve Geometric Problems
Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in...
{ "input": [], "output": [] }
{ "input": [ "1 2" ], "output": [ "2" ] }
{ "input": [ "1 3", "1 6", "3 2", "4 5", "3 10", "3 14", "2 14", "2 17", "3 11", "2 39", "2 13", "3 19", "2 15", "3 38", "3 23", "2 31", "3 55", "3 29", "1 42", "2 35", "2 41", "3 26", "3 47", "2 65", "1 30", "2 33...
p01944 Almost Infinite Glico
G: Almost Infinite Glico problem There is a field where N squares are arranged in a ring. The i-th (1 \ leq i \ leq N-1) cell is ahead of the i + 1th cell. However, if i = N, the next cell is the first cell. The first cell you are in is the first cell. From there, play rock-paper-scissors K times in a row according ...
{ "input": [], "output": [] }
{ "input": [ "10 3 2\n3\n6\n6" ], "output": [ "1\n0\n4\n2\n0\n0\n5\n0\n0\n4" ] }
{ "input": [ "10 3 2\n3\n10\n6", "10 3 2\n3\n10\n9", "11 3 2\n3\n10\n9", "11 3 2\n3\n17\n9", "11 3 2\n3\n17\n16", "11 2 2\n3\n17\n16", "11 1 2\n3\n17\n16", "7 3 2\n3\n6\n6", "10 3 2\n3\n16\n6", "2 3 2\n3\n10\n9", "11 3 2\n6\n17\n16", "2 2 2\n3\n17\n16", "9 1 2\n3\n1...
p02093 Invariant Tree
F: Invariant Tree Problem Statement You have a permutation p_1, p_2, ... , p_N of integers from 1 to N. You also have vertices numbered 1 through N. Find the number of trees while satisfying the following condition. Here, two trees T and T' are different if and only if there is a pair of vertices where T has an edge ...
{ "input": [], "output": [] }
{ "input": [ "4\n2 1 4 3" ], "output": [ "4" ] }
{ "input": [ "4\n3 2 4 1", "4\n2 1 3 4", "4\n1 2 3 4", "4\n3 1 4 2", "4\n4 3 2 1", "4\n1 2 4 3", "4\n1 3 2 4", "4\n1 3 4 2", "4\n1 4 2 3", "4\n1 4 3 2", "4\n3 1 2 4", "4\n4 1 3 2", "4\n4 1 2 3", "4\n2 4 3 1", "4\n3 2 1 4", "4\n2 3 1 4", "4\n2 3 4 1",...
p02226 Test
test UnionFind(バイナリ入力) Example Input Output
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02377 Minimum Cost Flow
Examples Input 4 5 2 0 1 2 1 0 2 1 2 1 2 1 1 1 3 1 3 2 3 2 1 Output 6 Input Output
{ "input": [], "output": [] }
{ "input": [ "4 5 2\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "" ], "output": [ "6", "" ] }
{ "input": [ "4 5 2\n0 0 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 2\n1 2 2 1\n0 3 1 3\n2 3 2 1", "4 5 3\n0 1 2 1\n0 2 1 2\n1 2 1 1\n1 3 1 3\n2 3 2 1", "4 5 2\n0 1 2 0\n0 2 1 4\n1 1 1 1\n1 3 1 3\n2 3 2 1", "10 5 0\n0 ...