name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p02751 Social Infrastructure Information Systems Division Hitachi Programming Contest 2020 - Odd Sum Rectangles
We have a grid with (2^N - 1) rows and (2^M-1) columns. You are asked to write 0 or 1 in each of these squares. Let a_{i,j} be the number written in the square at the i-th row from the top and the j-th column from the left. For a quadruple of integers (i_1, i_2, j_1, j_2) such that 1\leq i_1 \leq i_2\leq 2^N-1, 1\leq ...
{ "input": [], "output": [] }
{ "input": [ "1 2" ], "output": [ "111" ] }
{ "input": [ "1 1", "2 2", "2 1", "3 2", "4 1", "3 3", "5 1", "1 3", "3 1", "2 3", "1 6", "5 2", "4 2", "3 4", "2 4", "1 4", "1 7", "8 2", "3 8", "2 7", "1 10", "2 6", "2 5", "2 8", "3 6", "10 2", "6 3", "6...
p02886 AtCoder Beginner Contest 143 - TAKOYAKI FESTIVAL 2019
It's now the season of TAKOYAKI FESTIVAL! This year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i. As is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \times y health points. There are \frac{N...
{ "input": [], "output": [] }
{ "input": [ "3\n3 1 2", "7\n5 0 7 8 3 3 2" ], "output": [ "11", "312" ] }
{ "input": [ "3\n3 1 3", "7\n5 0 7 8 6 3 2", "3\n3 1 5", "7\n5 0 7 10 6 3 2", "3\n1 1 5", "7\n5 0 7 2 6 3 2", "3\n1 1 8", "7\n5 -1 7 2 6 3 2", "3\n0 1 8", "7\n5 -1 7 2 12 3 2", "3\n0 1 2", "7\n1 -1 7 2 12 3 2", "3\n0 1 1", "7\n1 -1 7 2 23 3 2", "3\n1 1 1", ...
p03021 AtCoder Grand Contest 034 - Complete Compress
You are given a tree with N vertices numbered 1, 2, ..., N. The i-th edge connects Vertex a_i and Vertex b_i. You are also given a string S of length N consisting of `0` and `1`. The i-th character of S represents the number of pieces placed on Vertex i. Snuke will perform the following operation some number of times:...
{ "input": [], "output": [] }
{ "input": [ "7\n0010101\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7", "7\n0010110\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7", "2\n01\n1 2" ], "output": [ "3", "-1", "0" ] }
{ "input": [ "2\n01\n2 2", "7\n0011101\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7", "7\n0111101\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7", "7\n0110110\n1 1\n2 3\n1 4\n1 5\n2 6\n6 7", "7\n0110110\n1 2\n2 3\n1 4\n1 5\n2 6\n6 7", "7\n0010101\n1 2\n4 3\n1 4\n4 5\n1 6\n6 7", "2\n01\n2 0", "2\n2\n2 0", "2\n4\n2...
p03161 Educational DP Contest - Frog 2
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ld...
{ "input": [], "output": [] }
{ "input": [ "2 100\n10 10", "5 3\n10 30 40 50 20", "10 4\n40 10 20 70 80 10 20 70 80 60", "3 1\n10 20 10" ], "output": [ "0", "30", "40", "20" ] }
{ "input": [ "2 100\n10 9", "5 3\n10 30 40 50 24", "3 4\n40 10 20 70 80 10 20 70 80 60", "3 1\n0 20 10", "3 4\n40 10 17 70 80 10 20 70 80 60", "2 100\n7 10", "10 4\n40 9 20 70 80 10 20 70 80 60", "3 1\n9 20 10", "2 100\n17 9", "3 4\n40 10 34 70 80 10 20 70 80 60", "3 1\n1 2...
p03304 SoundHound Inc. Programming Contest 2018 -Masters Tournament- - Ordinary Beauty
Let us define the beauty of a sequence (a_1,... ,a_n) as the number of pairs of two adjacent elements in it whose absolute differences are d. For example, when d=1, the beauty of the sequence (3, 2, 3, 10, 9) is 3. There are a total of n^m sequences of length m where each element is an integer between 1 and n (inclusi...
{ "input": [], "output": [] }
{ "input": [ "2 3 1", "1000000000 180707 0" ], "output": [ "1.0000000000", "0.0001807060" ] }
{ "input": [ "1000000000 180707 1", "1000000000 241440 1", "1001000000 241440 5", "1001000000 353960 8", "0001000000 353960 8", "0001000000 353960 15", "1001100000 353960 15", "1001100100 149885 23", "1001101100 149885 23", "1011101100 149885 23", "1111101100 149885 23", ...
p03464 AtCoder Grand Contest 020 - Ice Rink Game
An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces: * Form groups consisting of A_i children each! Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at m...
{ "input": [], "output": [] }
{ "input": [ "5\n3 4 100 3 2", "10\n2 2 2 2 2 2 2 2 2 2", "4\n3 4 3 2" ], "output": [ "-1", "2 3", "6 8" ] }
{ "input": [ "5\n3 7 100 3 2", "10\n2 3 2 2 2 2 2 2 2 2", "4\n3 3 2 2", "4\n4 3 2 2", "4\n3 5 3 2", "4\n1 1 2 2", "4\n3 4 2 2", "5\n3 7 100 5 2", "5\n3 7 100 2 2", "5\n3 4 100 3 3", "5\n3 7 101 3 2", "4\n3 6 2 2", "5\n3 12 100 5 2", "5\n3 7 100 1 2", "10\n2 ...
p03623 AtCoder Beginner Contest 071 - Meal Delivery
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and...
{ "input": [], "output": [] }
{ "input": [ "1 999 1000", "5 2 7" ], "output": [ "A", "B" ] }
{ "input": [ "1 999 0000", "1 381 1110", "5 1 7", "1 999 0100", "10 1 7", "1 999 0101", "10 2 7", "1 999 0001", "10 1 9", "1 381 0001", "10 2 9", "1 381 0101", "17 2 9", "1 381 0111", "23 2 9", "1 381 0110", "23 3 9", "23 1 9", "1 213 1110", ...
p03783 AtCoder Regular Contest 070 - NarrowRectangles
AtCoDeer the deer found N rectangle lying on the table, each with height 1. If we consider the surface of the desk as a two-dimensional plane, the i-th rectangle i(1≤i≤N) covers the vertical range of [i-1,i] and the horizontal range of [l_i,r_i], as shown in the following figure: <image> AtCoDeer will move these rect...
{ "input": [], "output": [] }
{ "input": [ "3\n2 5\n4 6\n1 4", "5\n123456 789012\n123 456\n12 345678901\n123456 789012\n1 23", "3\n1 3\n5 7\n1 3", "1\n1 400", "5\n999999999 1000000000\n1 2\n314 315\n500000 500001\n999999999 1000000000" ], "output": [ "0", "246433", "2", "0", "1999999680" ] }
{ "input": [ "3\n2 5\n4 6\n2 4", "5\n123456 789012\n17 456\n12 345678901\n123456 789012\n1 23", "3\n1 3\n5 8\n1 3", "5\n999999999 1000000000\n1 2\n314 70\n500000 500001\n999999999 1000000000", "5\n123456 789012\n17 456\n12 345678901\n40029 789012\n1 23", "3\n1 3\n8 8\n1 3", "5\n999999999 1...
p03952 AtCoder Grand Contest 006 - Median Pyramid Easy
We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically. <image> A pyramid with N=4 steps Snuke wrote a per...
{ "input": [], "output": [] }
{ "input": [ "4 4", "2 1" ], "output": [ "Yes\n1\n6\n3\n7\n4\n5\n2", "No" ] }
{ "input": [ "1 1", "2 2", "3 3", "7 7", "6 6", "5 5", "8 8", "4 1", "2 3", "3 1", "0 1", "7 1", "5 1", "9 1", "-1 1", "16 1", "-2 1", "13 1", "11 1", "0 -1", "10 1", "15 1", "17 1", "4 7", "-3 1", "8 1", "-4 1...
p00042 A Thief
A thief sneaked into a museum with a lot of treasures with only one large furoshiki. There are many things I want to steal, but the weight that the furoshiki can withstand is limited, and if it exceeds this, the furoshiki will tear. Therefore, the thief must consider a combination of treasures that will not break the p...
{ "input": [], "output": [] }
{ "input": [ "50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0" ], "output": [ "Case 1:\n220\n49\nCase 2:\n220\n49" ] }
{ "input": [ "50\n5\n60,10\n100,20\n120,30\n310,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0", "50\n5\n60,10\n100,20\n110,30\n310,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n00,4\n0", "50\n5\n60,10\n100,20\n100,32\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0", "50\n5\n60...
p00174 Badminton
It's been a while since I played with A, B, and C. Mr. A and Mr. B became players, and Mr. C became a referee and played a badminton singles game. The rules decided by the three people are as follows. * 3 Play the game. * The person who gets 11 points first wins the game. * The first serve of the first game starts wit...
{ "input": [], "output": [] }
{ "input": [ "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0" ], "output": [ "11 8\n10 12\n11 7\n11 8\n11 0\n0 11" ] }
{ "input": [ "AABBAAABABAABBBAABA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBBBBBB\n0", "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABABBAAAB\nAABABAAABBAABBBABAA\nAAAAAAAAAAA\nABBBBBABBBB\n0", "ABAABBBAABABAAABBAA\nAABBBABBABBAAABABABAAB\nBABAABAABABAB...
p00330 Word
The smallest unit of data handled by a computer is called a bit, and the amount of information that represents multiple bits together is called a word. Currently, many computers process one word as 32 bits. For a computer that represents one word in 32 bits, create a program that outputs the amount of data W given in ...
{ "input": [], "output": [] }
{ "input": [ "4", "3" ], "output": [ "128", "96" ] }
{ "input": [ "0", "5", "1", "2", "-1", "8", "-2", "14", "6", "26", "-3", "46", "-4", "80", "-7", "12", "-11", "24", "-10", "40", "-18", "67", "-35", "10", "-19", "18", "-21", "-5", "-6", "15", "...
p00503 Fish
problem To the west of the Australian continent is the wide Indian Ocean. Marine researcher JOI is studying the properties of N species of fish in the Indian Ocean. For each type of fish, a rectangular parallelepiped habitat range is determined in the sea. Fish can move anywhere in their habitat, including boundaries...
{ "input": [], "output": [] }
{ "input": [ "3 2\n30 50 0 50 70 100\n10 20 20 70 90 60\n40 60 20 90 90 70" ], "output": [ "49000" ] }
{ "input": [ "3 2\n10 50 0 50 70 100\n10 20 20 70 90 60\n40 60 20 90 90 70", "3 2\n10 50 0 50 70 100\n10 20 20 70 90 60\n40 60 20 90 90 98", "3 2\n10 50 0 50 70 000\n10 20 20 70 90 60\n40 60 20 90 90 98", "3 2\n20 50 0 50 70 000\n10 35 20 70 90 60\n40 111 20 102 90 131", "3 2\n30 50 0 50 70 100\n8...
p00687 Unable Count
> I would, if I could, > If I couldn't how could I? > I couldn't, without I could, could I? > Could you, without you could, could ye? > Could ye? could ye? > Could you, without you could, could ye? It is true, as this old rhyme says, that we can only DO what we can DO and we cannot DO what we cannot DO. Changing ...
{ "input": [], "output": [] }
{ "input": [ "10 2 3\n10 2 5\n100 5 25\n0 0 0" ], "output": [ "1\n2\n80" ] }
{ "input": [ "10 2 3\n10 2 5\n100 5 40\n0 0 0", "10 1 3\n10 2 5\n100 5 40\n0 0 0", "10 2 3\n14 2 5\n100 6 25\n0 0 0", "10 1 3\n10 2 5\n110 5 40\n0 0 0", "15 1 3\n10 2 6\n110 5 40\n0 0 0", "15 2 3\n10 2 6\n110 5 40\n0 0 0", "15 2 3\n13 2 6\n110 5 40\n0 0 0", "10 3 3\n10 2 5\n100 5 25\n0...
p00829 Leaky Cryptography
The ACM ICPC judges are very careful about not leaking their problems, and all communications are encrypted. However, one does sometimes make mistakes, like using too weak an encryption scheme. Here is an example of that. The encryption chosen was very simple: encrypt each chunk of the input by flipping some bits acco...
{ "input": [], "output": [] }
{ "input": [ "8\n1 1 1 1 1 1 1 1 8\n3 2 3 2 3 2 3 2 6\n3 4 4 7 7 b a 2 2e\ne1 13 ce 28 ca 6 ab 46 a6d\nb08 49e2 6128 f27 8cf2 bc50 7380 7fe1 723b\n4eba eb4 a352 fd14 6ac1 eed1 dd06 bb83 392bc\nef593c08 847e522f 74c02b9c 26f3a4e1 e2720a01 6fe66007\n7a4e96ad 6ee5cef6 3853cd88\n60202fb8 757d6d66 9c3a9525 fbcd7983 82...
{ "input": [ "8\n1 1 1 1 1 1 1 1 8\n3 2 3 2 3 2 3 2 6\n6 4 4 7 7 b a 2 2e\ne1 13 ce 28 ca 6 ab 46 a6d\nb08 49e2 6128 f27 8cf2 bc50 7380 7fe1 723b\n4eba eb4 a352 fd14 6ac1 eed1 dd06 bb83 392bc\nef593c08 847e522f 74c02b9c 26f3a4e1 e2720a01 6fe66007\n7a4e96ad 6ee5cef6 3853cd88\n60202fb8 757d6d66 9c3a9525 fbcd7983 82...
p00960 Making Perimeter of the Convex Hull Shortest
Problem D Making Perimeter of the Convex Hull Shortest The convex hull of a set of three or more planar points is, when not all of them are on one line, the convex polygon with the smallest area that has all the points of the set on its boundary or in its inside. Your task is, given positions of the points of a set, t...
{ "input": [], "output": [] }
{ "input": [ "10\n-53 62\n-19 58\n-11 11\n-9 -22\n45 -7\n37 -39\n47 -58\n-2 41\n-37 10\n13 42" ], "output": [ "72.96316928" ] }
{ "input": [ "10\n-53 62\n-19 58\n-11 11\n-1 -22\n45 -7\n37 -39\n47 -58\n-2 41\n-37 10\n13 42", "10\n-53 62\n-19 58\n-11 11\n-1 -22\n45 -7\n10 -39\n47 -58\n-2 4\n-37 10\n13 42", "10\n-53 62\n-19 58\n-19 11\n-1 -22\n45 -7\n10 -39\n47 -13\n-2 4\n-37 10\n13 42", "10\n-53 62\n-4 58\n-19 7\n-1 -22\n45 -4\n...
p01093 Selection of Participants of an Experiment
Selection of Participants of an Experiment Dr. Tsukuba has devised a new method of programming training. In order to evaluate the effectiveness of this method, he plans to carry out a control experiment. Having two students as the participants of the experiment, one of them will be trained under the conventional metho...
{ "input": [], "output": [] }
{ "input": [ "5\n10 10 10 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0" ], "output": [ "0\n1\n5" ] }
{ "input": [ "5\n10 10 1 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 70\n0", "5\n10 10 1 10 10\n5\n1 5 8 9 11\n7\n11 34 83 47 59 29 48\n0", "5\n10 10 1 10 10\n5\n1 5 8 5 11\n7\n11 34 83 47 59 29 48\n0", "5\n10 10 1 10 10\n5\n1 5 8 5 11\n7\n11 34 83 47 54 29 2\n0", "5\n10 10 10 10 10\n5\n1 5 8 9 11\...
p01229 Enegy Transporter
At a certain research institute, I was developing a medium for energy transfer. This medium has a polymer structure consisting of a special substance as shown in Fig. 3. Structure of energy transfer medium. --- (-α-Ea-β-) n Figure 3: Structure of energy transfer medium. The part shown by Ea in the figure is the Energ...
{ "input": [], "output": [] }
{ "input": [ "7\n1\n2\n2\n1 2\n3\n4 1 4\n3\n4 0 4\n5\n4 1 4 0 4\n5\n4 1 4 1 4\n5\n4 2 4 0 4" ], "output": [ "2\n2\n8\n4\n7\n12\n11" ] }
{ "input": [ "7\n1\n2\n2\n1 2\n3\n4 1 4\n3\n4 0 4\n5\n4 1 4 0 4\n5\n4 1 4 1 4\n5\n4 4 4 0 4", "7\n1\n2\n2\n1 2\n3\n4 1 4\n3\n4 0 4\n5\n4 1 4 0 4\n5\n4 1 4 1 4\n5\n4 4 5 0 4", "7\n1\n2\n2\n1 2\n3\n4 1 4\n3\n4 0 4\n5\n4 1 4 0 4\n5\n4 1 4 1 4\n5\n4 4 2 0 4", "7\n1\n2\n2\n1 2\n3\n4 1 4\n3\n4 0 3\n5\n4 1 4...
p01363 Alice and Bomb
Alice and Bob were in love with each other, but they hate each other now. One day, Alice found a bag. It looks like a bag that Bob had used when they go on a date. Suddenly Alice heard tick-tack sound. Alice intuitively thought that Bob is to kill her with a bomb. Fortunately, the bomb has not exploded yet, and there ...
{ "input": [], "output": [] }
{ "input": [ "1\n1 1\n4 -1 0 -2 -1 -1 -2 0 -1\n1\n0 3\n4 1 1 1 2 -1 2 -1 1\n1\n-6 -6\n6 1 -2 2 -2 2 3 -2 3 -2 1 1 1\n1\n-10 0\n4 0 -5 1 -5 1 5 0 5\n1\n10 1\n4 5 1 6 2 5 3 4 2\n2\n-47 -37\n4 14 3 20 13 9 12 15 9\n4 -38 -3 -34 -19 -34 -14 -24 -10\n0" ], "output": [ "1.00000000\n0.00000000\n3.23606798\n5.000...
{ "input": [ "1\n1 1\n4 -1 0 -2 -1 -1 -2 0 -1\n1\n0 3\n4 1 1 1 2 -1 2 -1 1\n1\n-6 -6\n6 1 -1 2 -2 2 3 -2 3 -2 1 1 1\n1\n-10 0\n4 0 -5 1 -5 1 5 0 5\n1\n10 1\n4 5 1 6 2 5 3 4 2\n2\n-47 -37\n4 14 3 20 13 9 12 15 9\n4 -38 -3 -34 -19 -34 -14 -24 -10\n0", "1\n1 1\n4 -1 0 -2 -1 -1 -2 0 -1\n1\n0 3\n4 1 1 1 2 -1 2 -1 ...
p01545 House Moving
Taro has decided to move. Taro has a lot of luggage, so I decided to ask a moving company to carry the luggage. Since there are various weights of luggage, I asked them to arrange them in order from the lightest one for easy understanding, but the mover left the luggage in a different order. So Taro tried to sort the l...
{ "input": [], "output": [] }
{ "input": [ "8\n6 2 1 3 8 5 4 7", "5\n1 5 3 2 4", "7\n1 2 3 4 5 6 7", "4\n1 4 2 3" ], "output": [ "19", "7", "0", "4" ] }
{ "input": [ "7\n1 2 5 4 3 6 7", "4\n2 4 2 2", "4\n1 4 3 2", "7\n1 3 2 4 5 6 7", "4\n3 4 1 2", "8\n7 2 1 3 8 5 4 6", "7\n1 2 8 1 3 6 7", "5\n2 5 3 1 4", "8\n5 2 1 3 8 6 4 7", "7\n2 1 5 4 3 6 7", "4\n2 4 1 3", "5\n1 6 3 1 4", "5\n1 4 3 2 5", "7\n1 2 3 5 4 6 7", ...
p01701 North North West
Problem Statement We can describe detailed direction by repeating the directional names: north, south, east and west. For example, northwest is the direction halfway between north and west, and northnorthwest is between north and northwest. In this problem, we describe more detailed direction between north and west a...
{ "input": [], "output": [] }
{ "input": [ "north\nwest\nnorthwest\nnorthnorthwest\nwestwestwestnorth\n#" ], "output": [ "0\n90\n45\n45/2\n315/4" ] }
{ "input": [], "output": [] }
p01845 Curry Making
Curry making As the ACM-ICPC domestic qualifying is approaching, you who wanted to put more effort into practice decided to participate in a competitive programming camp held at a friend's house. Participants decided to prepare their own meals. On the first night of the training camp, the participants finished the da...
{ "input": [], "output": [] }
{ "input": [ "10 5 3 4\n2 5 2 3\n91 13 7 62\n10 1 3 5\n20 100 2 20\n2 14 7 1\n0 0 0 0" ], "output": [ "2\n3\n0\n0\n9\n96" ] }
{ "input": [ "10 5 3 4\n2 5 2 3\n150 13 7 62\n10 1 3 5\n20 100 2 20\n2 14 7 1\n0 0 0 0", "10 5 3 4\n1 5 2 3\n150 13 7 62\n10 1 3 5\n20 100 3 20\n2 14 7 1\n0 0 0 0", "10 5 3 1\n2 5 2 3\n150 13 7 62\n10 1 3 5\n20 100 2 20\n2 14 7 1\n0 0 0 0", "10 5 3 4\n1 6 2 3\n150 13 7 62\n10 1 3 5\n20 100 3 20\n2 14 ...
p01981 Change of the Era Name
Revised The current era, Heisei, will end on April 30, 2019, and a new era will begin the next day. The day after the last day of Heisei will be May 1, the first year of the new era. In the system developed by the ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG), the date uses the Japanese calendar (the Japa...
{ "input": [], "output": [] }
{ "input": [ "HEISEI 1 1 8\nHEISEI 31 4 30\nHEISEI 31 5 1\nHEISEI 99 12 31\nHEISEI 38 8 30\nHEISEI 98 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n#" ], "output": [ "HEISEI 1 1 8\nHEISEI 31 4 30\n? 1 5 1\n? 69 12 31\n? 8 8 30\n? 68 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23" ] }
{ "input": [ "HEISEI 1 1 8\nHEISEI 31 4 30\nIESIEH 31 5 1\nHEISEI 99 12 31\nHEISEI 38 8 30\nHEISEI 98 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n#", "HEISEI 1 1 8\nHEISEI 31 4 30\nIESIEH 31 5 1\nHEISEI 99 12 31\nHEISEI 38 8 30\nHEISEI 98 2 22\nHEISEI 3 3 26\nHEISEI 28 4 23\n#", "HEISEI 1 1 8\nHEISEI 31 4 30\nIE...
p02127 AABABCAC
Problem Given the strings $ s $, $ t $. First, let the string set $ A = $ {$ s $}, $ B = \ phi $. At this time, I want to perform the following operations as much as possible. operation step1 Perform the following processing for all $ u ∊ A $. 1. From all subsequences of $ u $ (not necessarily contiguous), choose ...
{ "input": [], "output": [] }
{ "input": [ "abaabbabaabaabbabbabaabbab\nab", "AABABCAC\nA", "AbCdEfG\naBcDeFg" ], "output": [ "3", "2", "0" ] }
{ "input": [ "abaabbabaab`abbabbabaabbab\nab", "AABABCAC\nB", "AbCdEfG\naBcDeFh", "abaabbbbaab`abbabbabaabaab\nab", "AACABCAC\nB", "AbGdEfC\naBcDeFh", "abaabbbbaab`abbabbabaabaab\n`b", "AACABCAC\nC", "AbGdEfC\naBcDhFe", "abaabbbbaaa`abbabbabbabaab\n`b", "AACAACAC\nC", "...
p02268 Binary Search
You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S. Notes Constraints * Elements in S is sorted in ascending order * n ≤ 100000 * q ≤ 50000 * 0 ≤ an element in S ≤ 109 * 0 ≤ an element in T ≤ 109 ...
{ "input": [], "output": [] }
{ "input": [ "5\n1 1 2 2 3\n2\n1 2", "3\n1 2 3\n1\n5", "5\n1 2 3 4 5\n3\n3 4 1" ], "output": [ "2", "0", "3" ] }
{ "input": [ "5\n1 0 2 2 3\n2\n1 2", "3\n2 2 3\n1\n5", "5\n1 0 4 2 3\n2\n1 1", "5\n1 2 3 4 1\n5\n2 4 1", "5\n1 2 3 4 5\n3\n1 4 1", "5\n1 0 4 2 3\n2\n1 2", "3\n1 2 3\n1\n4", "5\n1 4 3 4 5\n3\n1 4 1", "3\n1 2 4\n1\n4", "5\n1 4 3 4 6\n3\n1 4 1", "5\n1 0 4 2 3\n3\n1 1", "3\...
p02415 Toggling Cases
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. Constraints * The length of the input string < 1200 Input A string is given in a line. Output Print the converted string in a line. Note that you do not need to convert any characters other than alphabetical lett...
{ "input": [], "output": [] }
{ "input": [ "fAIR, LATER, OCCASIONALLY CLOUDY." ], "output": [ "Fair, later, occasionally cloudy." ] }
{ "input": [ "f@IR, LATER, OCCASIONALLY CLOUDY.", "f@IR, LATER, YLLANOISACCO CLOUDY.", "f@IR, LATER, OLLANOISACCY CLOUDY.", "f@IR, LATER, OLKANOISACCY CLOUDY.", ",RI@f LATER, OLKANOISACCY CLOUDY.", ",RI@f KATER, OLKANOISACCY CLOUDY.", ",RI@g KATER, OLKANOISACCY CLOUDY.", ",RI@g KATER, ...
ababaaba
You are given a uniformly randomly generated string S, consisting of letters from the set {"A", "B"}. Your task is to find a string T that appears in S as a subsequence exactly twice. In other words, you need to find such a string T, that there exist exactly two sets of indexes i1, i2, ..., i|T| and j1, j2, ..., j|T| s...
{ "input": [], "output": [] }
{ "input": [ "2\nAAAA\nBAB" ], "output": [ "-1\nB" ] }
{ "input": [ "2\nA@AA\nBAB", "2\nAA?A\nBBB", "2\n@AAA\nABA", "2\nABAA\nBAA", "2\nABAA\nABB", "2\nABAA\n@BC", "2\nBABB\n?BB", "2\nBABB\nABA", "2\nAA@A\nBAB", "2\nAAAA\nABB", "2\nAA?A\nBAB", "2\nAAAA\nBBA", "2\nAAAB\nBBA", "2\nBAAA\nBBA", "2\nAAAA\n@BB", "...
chefeq
Chef has a box full of infinite number of identical coins. One day while playing, he made N piles each containing equal number of coins. Chef suddenly remembered an important task and left the room for sometime. While he was away, his newly hired assistant came across the piles and mixed them up while playing. When Che...
{ "input": [], "output": [] }
{ "input": [ "1\n4\n1 2 3 4" ], "output": [ "3\n" ] }
{ "input": [ "1\n4\n1 2 2 4", "1\n4\n1 2 2 2", "1\n4\n1 2 0 4", "1\n4\n1 1 1 1", "1\n4\n1 2 1 4", "1\n4\n1 0 2 2", "1\n4\n1 1 2 2", "1\n4\n1 1 1 2", "1\n4\n1 1 1 4", "1\n4\n1 1 0 4", "1\n4\n1 1 3 4", "1\n4\n1 4 2 4", "1\n4\n1 2 2 0", "1\n4\n1 -1 2 2", "1\n4\...
direl
Chef is giving a big party to all his friends and their relatives. Relatives of very far-away (by relation) will be present. Little Joe (uninvited) is curious to know how distant two people are, say X and Y. There are 6 fundamental relations: father relation, mother relation, son relation, daughter relation, brother re...
{ "input": [], "output": [] }
{ "input": [ "8 7\ntom is brother of ron\nron is brother of john\njohn is father of kel\nkel is son of cloe\ncloe is sister of ru\nanne is daughter of cloe\nru is mother of fred\n5\nkel john\nron kel\njohn ru\njohn kel\njohn anne" ], "output": [ "1\n2\n3\n1\n1" ] }
{ "input": [], "output": [] }
insomb6
A set of N dignitaries have arrived in close succession at Delhi and are awaiting transportation to Roorkee to participate in the inaugural ceremony of Cognizance. Being big sponsors of Cognizance, it has been deemed unsuitable by the organizing team to arrange for more than one dignitary to travel in a single vehicle....
{ "input": [], "output": [] }
{ "input": [ "4\nDivye\nRohit\nAkshat\nParth\nScorpio\nBMW\nFord\nChevrolet\n1 BMW\n1 Ford\n2 Scorpio Chevrolet\n1 Ford" ], "output": [ "No" ] }
{ "input": [], "output": [] }
ngame
Arpit & Nikhil were bored from their usual routine of studying, so they decided to play a game. The game was as follows - Given a number N the player must subtract 1, 2 or 3 from N in order to make a number that is divisble by 4. The game will continue until any player is able to make such a number, the corresponding...
{ "input": [], "output": [] }
{ "input": [ "1\n6" ], "output": [ "First\n" ] }
{ "input": [ "1\n10", "1\n0", "1\n17", "1\n7", "1\n5", "1\n1", "1\n-1", "1\n-2", "1\n-4", "1\n-3", "1\n2", "1\n-5", "1\n-7", "1\n-9", "1\n-14", "1\n3", "1\n4", "1\n11", "1\n13", "1\n8", "1\n-6", "1\n-8", "1\n-16", "1\n-11"...
sdsquare
Recently Chef become very much interested in perfect squares. We all know Chef and his weird interests. Anyways Chef will be soon writing his masters thesis on perfect squares revealing what-not-known properties of perfect squares. While doing his research, he happened to be confronted with some interesting perfect squ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 10\n100 10000" ], "output": [ "3\n9\n" ] }
{ "input": [ "2\n1 10\n100 11000", "2\n1 10\n100 01100", "2\n1 10\n110 10000", "2\n1 10\n110 11000", "2\n2 10\n100 11100", "2\n2 12\n110 11100", "2\n1 1\n010 10001", "2\n1 6\n110 10000", "2\n2 10\n100 01000", "2\n1 3\n110 10101", "2\n2 20\n110 01100", "2\n1 10\n101 0101...
1256_F. Equalizing Two Strings
You are given two strings s and t both of length n and both consisting of lowercase Latin letters. In one move, you can choose any length len from 1 to n and perform the following operation: * Choose any contiguous substring of the string s of length len and reverse it; * at the same time choose any contiguous ...
{ "input": [], "output": [] }
{ "input": [ "4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabcd\nbadc\n" ], "output": [ "NO\nYES\nNO\nYES\n" ] }
{ "input": [ "4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabdd\nbadc\n", "4\n4\nabcd\nabdc\n5\nababa\nabaab\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "4\n4\nabcd\nabdc\n5\naaabc\nbabaa\n4\nfdsa\nasdg\n4\nabdd\nbadc\n", "4\n4\ndabb\nabdb\n5\nababa\nababa\n4\nasdf\nasdg\n4\nabdd\nbadc\n", "4\n4\nab...
1342_F. Make It Ascending
You are given an array a consisting of n elements. You may apply several operations (possibly zero) to it. During each operation, you choose two indices i and j (1 ≤ i, j ≤ n; i ≠ j), increase a_j by a_i, and remove the i-th element from the array (so the indices of all elements to the right to it decrease by 1, and n...
{ "input": [], "output": [] }
{ "input": [ "4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n" ], "output": [ "3\n8 6\n2 5\n6 4\n7\n1 15\n1 13\n1 11\n1 9\n1 7\n1 5\n1 3\n1\n2 1\n0\n" ] }
{ "input": [ "4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 504 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n", "4\n8\n2 1 3 5 1 2 4 5\n15\n16384 8192 4096 2048 1024 504 256 128 64 32 16 8 4 2 1\n2\n3 3\n14\n1 2 3 4 5 6 8 8 9 10 11 12 13 14\n", "4\n8\n2 1 3 5 1 2 4 5\n15\...
1365_A. Matrix Game
Ashish and Vivek play a game on a matrix consisting of n rows and m columns, where they take turns claiming cells. Unclaimed cells are represented by 0, while claimed cells are represented by 1. The initial state of the matrix is given. There can be some claimed cells in the initial state. In each turn, a player must ...
{ "input": [], "output": [] }
{ "input": [ "4\n2 2\n0 0\n0 0\n2 2\n0 0\n0 1\n2 3\n1 0 1\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n" ], "output": [ "Vivek\nAshish\nVivek\nAshish\n" ] }
{ "input": [ "4\n2 2\n0 0\n0 0\n2 2\n0 0\n0 1\n2 3\n1 0 0\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n", "4\n2 2\n0 0\n0 0\n2 2\n1 0\n0 1\n2 3\n1 0 0\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n", "4\n2 2\n0 0\n0 0\n2 2\n1 0\n0 1\n2 3\n0 0 0\n1 1 0\n3 3\n1 0 0\n0 0 0\n1 0 0\n", "4\n2 2\n0 0\n0 0\n2 2\n0 0\n0 1\n2 3\n1 0 ...
64_D. Presents
You are given the prices of three presents. Also there are three sisters. It is known that the most valuable present is for the eldest sister. The second (by price) is for the second sister. And the less valuable present is for the youngest sister. If two (or three) presents have the same price, corresponding sisters m...
{ "input": [], "output": [] }
{ "input": [ "11 13 1\n", "30 10 30\n" ], "output": [ "2 1 3 ", "1 3 2 " ] }
{ "input": [], "output": [] }
final-voyage-1
"RMS Lusitania" was one of the world biggest ship of her time.On the outbreak of the First World War in 1914, she was commandeered by the Admiralty as an armed merchant cruiser. When Lusitania left New York for Liverpool on what would be her final voyage on 1 May 1915, submarine warfare was intensifying in the Atlantic...
{ "input": [], "output": [] }
{ "input": [ "2\n3 \n3\n1 2 3 \n2 4 8\n4 \n8\n2 4 5 7\n4 9 7 5\n\nSAMPLE" ], "output": [ "8\n13" ] }
{ "input": [ "2\n3 \n3\n1 2 3 \n2 4 5\n4 \n8\n2 4 5 7\n4 9 7 5\n\nSAMPLE", "2\n3 \n3\n1 2 3 \n2 4 5\n4 \n7\n2 4 5 7\n4 9 14 5\n\nSAMPLE", "2\n3 \n3\n1 2 3 \n2 4 5\n4 \n7\n2 4 5 7\n4 16 14 5\n\nSAMPLE", "2\n3 \n3\n1 2 3 \n0 4 5\n4 \n7\n2 4 5 7\n4 16 14 5\n\nSAMPLE", "2\n3 \n3\n1 2 3...
ikshus-love-for-binary-numbers
Ikshu's love for binary numbers Ikshu recently learnt to generate random numbers. He is generating stream binary numbers. Uptil now he has generated N bits of the binary number. Now, he wants to know if there is a streak of contiguous 1's of length K. Help him to find the probability of existence of such a streak in ...
{ "input": [], "output": [] }
{ "input": [ "5 1\n\nSAMPLE" ], "output": [ "31/32\n" ] }
{ "input": [ "5 1\n\nS@MPLE", "8 1\n\nSPM@LE", "1 1\n\nSPM@LE", "7 1\n\nSAMPLE", "10 1\n\nSPM@LE", "7 2\n\nSAMPLE", "2 1\n\nSPLALE", "4 1\n\nSPALLE", "10 2\n\nSPM@LE", "3 1\n\nSPALLE", "12 1\n\nSPL@LE", "6 2\n\nELPMAT", "13 2\n\nMPS@LE", "3 2\n\nSQMALE", "14...
shivani-and-vinna
Akshit and Rahul are playing a game. Initially, two positive integers A and B are written on a blackboard. The players take turns, starting with Akshit. On his or her turn, a player can replace A with A - kB for any positive integer k, or replace B with B - kA for any positive integer k. The first person to make one of...
{ "input": [], "output": [] }
{ "input": [ "2\n5 5 8 8\n11 11 2 2\n\nSAMPLE" ], "output": [ "Case #1: 0\nCase #2: 1" ] }
{ "input": [ "2\n9 5 8 8\n11 11 2 2\n\nSAMPLE", "2\n5 5 8 8\n11 11 2 1\n\nELPMAS", "2\n12 5 8 8\n1 11 2 2\n\nEAMPLS", "2\n21 5 15 8\n10 11 2 2\n\nSAMPLE", "2\n4 5 8 8\n11 11 2 2\n\nSAMPLD", "2\n21 5 15 8\n12 14 2 2\n\nELPMAS", "2\n21 4 29 8\n1 12 2 2\n\nSALPLE", "2\n4 5 8 8\n11 13 2 2\...
p02540 ACL Contest 1 - Reachable Towns
There are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \dots, x_N) and (y_1, y_2, \dots, y_N) are both permuations of (1, 2, \dots, N). For each k = 1,2,\dots,N, find the answer to the following question: Rng is in City k. Rng can perform the following move arbitrarily many t...
{ "input": [], "output": [] }
{ "input": [ "7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6", "4\n1 4\n2 3\n3 1\n4 2" ], "output": [ "3\n3\n1\n1\n2\n3\n2", "1\n1\n2\n2" ] }
{ "input": [ "7\n6 4\n4 2\n3 5\n7 1\n2 7\n5 3\n1 6", "4\n2 4\n1 3\n3 1\n4 2", "4\n2 4\n1 3\n3 2\n4 1", "4\n1 4\n2 3\n3 2\n4 1", "4\n1 4\n2 2\n3 1\n4 3", "4\n2 4\n1 2\n3 1\n4 3", "7\n6 4\n4 3\n3 5\n7 1\n2 6\n5 2\n1 7", "4\n2 4\n1 3\n3 1\n4 2", "4\n2 4\n1 3\n3 2\n4 1", "4\n1 4\n3...
p02671 AtCoder Grand Contest 044 - Strange Dance
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the positions in the circle, starting from an arbitrary position and going around clockwise. Initially each position in the circle is occupied by one person. The people are going to dance on two kinds of songs: salsa and rumba. * When a salsa i...
{ "input": [], "output": [] }
{ "input": [ "3\nSRSRRSRRRSRRRR", "2\nRRSRSSSSR", "1\nSRS" ], "output": [ "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10", "3 8 1 0 5 7 6 2 4", "2 0 1" ] }
{ "input": [ "2\nSRRRSSSSR", "1\nRRS", "1\nSRR", "2\nRSSSSRSRR", "1\nSSR", "2\nSRSRSRSSR", "1\nRSR", "2\nSSSSSRSRR", "2\nSRSRSRSRR", "3\nRRRRSRRRSRRSRS", "2\nRSSRRSSSR", "2\nSRRRRSSSR", "2\nRRSRSRSSR", "2\nRRSRSRSRS", "3\nRSRRSRRRSRRSRR", "2\nRSSSRRSSR",...
p02800 Keyence Programming Contest 2020 - Monochromization
We have an H \times W grid, where each square is painted white or black in the initial state. Given are strings A_1, A_2, ..., A_H representing the colors of the squares in the initial state. For each pair (i, j) (1 \leq i \leq H, 1 \leq j \leq W), if the j-th character of A_i is `.`, the square at the i-th row and j-t...
{ "input": [], "output": [] }
{ "input": [ "3 3\n...\n...\n...", "2 2\n#.\n.#", "2 4\n...\n...#", "6 7\n.......\n.......\n.#.....\n..#....\n.#.#...\n.......", "2 2\n.\n.#" ], "output": [ "230", "15", "150", "203949910", "15" ] }
{ "input": [ "3 2\n...\n...\n...", "2 1\n#.\n.#", "1 4\n...\n...#", "2 2\n..-\n...\n...", "4 3\n...\n...\n...", "2 8\n...\n...#", "6 2\n.......\n.......\n.#.....\n..#....\n.#.#...\n.......", "4 2\n...\n./.#", "6 1\n.......\n.......\n.#.....\n..#....\n.#.#/..\n.......", "1 1\n/....
p02936 AtCoder Beginner Contest 138 - Ki
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation...
{ "input": [], "output": [] }
{ "input": [ "6 2\n1 2\n1 3\n2 4\n3 6\n2 5\n1 10\n1 10", "4 3\n1 2\n2 3\n2 4\n2 10\n1 100\n3 1" ], "output": [ "20 20 20 20 20 20", "100 110 111 110" ] }
{ "input": [ "4 3\n1 2\n2 3\n1 4\n2 10\n1 100\n3 1", "4 3\n1 2\n2 3\n1 4\n2 10\n1 000\n3 1", "4 3\n1 2\n2 3\n2 4\n2 19\n1 100\n3 1", "2 3\n1 2\n2 3\n1 4\n2 10\n1 100\n3 1", "4 3\n1 2\n2 3\n2 4\n4 10\n1 100\n3 1", "4 3\n1 2\n2 3\n2 4\n2 19\n1 100\n2 1", "2 3\n1 2\n2 1\n1 4\n2 10\n2 100\n3 1...
p03073 AtCoder Beginner Contest 124 - Coloring Colorfully
N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N. The i-th tile from the left is painted black if the i-th character of S is `0`, and painted white if that character is `1`. You want to repaint some of the tiles black or white, so that any two a...
{ "input": [], "output": [] }
{ "input": [ "10010010", "0", "000" ], "output": [ "3", "0", "1" ] }
{ "input": [ "10110010", "010", "10110110", "00110110", "100", "10100110", "01110110", "01110111", "10011010", "1", "10111010", "10100111", "10100010", "01100110", "01100111", "101", "10111000", "10100101", "10100011", "00110111", "01...
p03215 Dwango Programming Contest V - Sum AND Subarrays
One day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a. For a nonempty contiguous subsequence a_l, ..., a_r (1 \leq l \leq r \leq N) of the sequence a, its beauty is defined as a_l + ... + a_r. Niwango-kun wants to ...
{ "input": [], "output": [] }
{ "input": [ "4 2\n2 5 2 5", "8 4\n9 1 8 2 7 5 6 4" ], "output": [ "12", "32" ] }
{ "input": [ "8 4\n9 1 8 2 7 5 6 6", "8 4\n9 1 8 2 7 8 6 6", "4 4\n2 5 2 5", "8 8\n9 1 8 2 7 5 6 4", "8 8\n9 1 11 2 7 5 6 4", "8 4\n8 1 15 2 7 8 6 6", "8 6\n8 1 15 2 7 8 6 6", "8 6\n8 1 27 2 7 8 6 6", "8 7\n7 1 11 2 14 5 6 4", "8 6\n8 1 27 2 7 8 7 2", "8 3\n7 1 11 2 14 5 6 ...
p03364 AtCoder Grand Contest 023 - Find Symmetries
Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i-th row from the top and the j-th column from the left is called Square (i,j). There is a lowercase English letter written in each square on the first board. The letter written in Square (i,j) is S_{i...
{ "input": [], "output": [] }
{ "input": [ "2\nab\nca", "5\nabcde\nfghij\nklmno\npqrst\nuvwxy", "4\naaaa\naaaa\naaaa\naaaa" ], "output": [ "2", "0", "16" ] }
{ "input": [ "2\nab\nda", "5\nabcde\nfghij\nklmno\npqrst\nuvvxy", "4\naaaa\naaaa\naaaa\nbaaa", "2\nab\nad", "5\nabcde\nfghij\nonmlk\npqrst\nuvwxy", "4\nbaaa\naaaa\naaaa\nbaaa", "2\nab\nac", "5\nedcba\nfghij\nonmlk\npqrst\nuvwxy", "4\nbaaa\naaa`\naaaa\nbaaa", "2\nba\nca", "5...
p03522 CODE FESTIVAL 2017 Exhibition (Parallel) - Increment and Swap
We have a sequence A of length N. On this sequence, we can perform the following two kinds of operations: * Swap two adjacent elements. * Select one element, and increment it by 1. We will repeatedly perform these operations so that A will be a non-decreasing sequence. Find the minimum required number of operati...
{ "input": [], "output": [] }
{ "input": [ "20\n8\n2\n9\n7\n4\n6\n7\n9\n7\n4\n7\n4\n4\n3\n6\n2\n3\n4\n4\n9", "5\n4\n1\n8\n8\n7" ], "output": [ "62", "2" ] }
{ "input": [ "20\n8\n2\n9\n7\n4\n6\n7\n9\n7\n4\n7\n4\n4\n3\n6\n0\n3\n4\n4\n9", "5\n4\n1\n8\n2\n7", "20\n8\n2\n9\n7\n4\n6\n7\n9\n7\n4\n7\n4\n8\n3\n6\n0\n3\n4\n4\n9", "5\n4\n1\n8\n2\n10", "20\n8\n2\n9\n7\n4\n6\n7\n9\n7\n4\n7\n4\n8\n3\n12\n0\n3\n4\n4\n9", "20\n8\n2\n9\n7\n4\n6\n7\n9\n5\n3\n7\n4\n...
p03687 AtCoder Grand Contest 016 - Shrinking
Snuke can change a string t of length N into a string t' of length N - 1 under the following rule: * For each i (1 ≤ i ≤ N - 1), the i-th character of t' must be either the i-th or (i + 1)-th character of t. There is a string s consisting of lowercase English letters. Snuke's objective is to apply the above operati...
{ "input": [], "output": [] }
{ "input": [ "serval", "whbrjpjyhsrywlqjxdbrbaomnw", "jackal", "zzz" ], "output": [ "3", "8", "2", "0" ] }
{ "input": [ "resval", "whbrjpjyhsrywlqjxcbrbaomnw", "zzy", "lakjac", "xmboabrbnxjrlwyrthyjpjrchv", "whcrjpbyhtxywkrlxnbrbaojmr", "smjoabjdoxmrjwypugydyqrchv", "whdrpxdwhuozxkrmxodjaaojkt", "xwwwnajdrxmrqwzpugnhlojced", "wyeoqidphazibqrnvxibngzwpx", "xpwzglbjquntrci{axpdiko...
p03840 AtCoder Grand Contest 008 - Tetromino Tiling
A tetromino is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively: a60bcb8e9e8f22e3af51049eda063392.png Snuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-tetrominos in his possession...
{ "input": [], "output": [] }
{ "input": [ "2 1 1 0 0 0 0", "0 0 10 0 0 0 0" ], "output": [ "3", "0" ] }
{ "input": [ "0 0 10 0 1 0 0", "1 1 1 0 0 0 0", "0 0 -1 0 2 0 2", "4 0 1 0 0 0 0", "0 3 0 0 1 0 0", "0 3 0 0 2 0 0", "6 0 2 0 0 0 0", "11 0 2 0 0 0 0", "14 0 2 0 0 0 0", "2 5 1 0 1 2 2", "23 0 2 0 0 0 0", "1 4 0 0 4 0 3", "1 0 0 1 7 -1 2", "10 1 2 0 0 -1 0", ...
p04007 AtCoder Grand Contest 004 - AND Grid
Snuke and Ciel went to a strange stationery store. Each of them got a transparent graph paper with H rows and W columns. Snuke painted some of the cells red in his paper. Here, the cells painted red were 4-connected, that is, it was possible to traverse from any red cell to any other red cell, by moving to vertically ...
{ "input": [], "output": [] }
{ "input": [ "5 5\n.....\n.#.#.\n.....\n.#.#.\n.....", "7 13\n.............\n.###.###.###.\n.#.#.#...#...\n.###.#...#...\n.#.#.#.#.#...\n.#.#.###.###.\n............." ], "output": [ ".....\n#####\n#....\n#####\n.....\n\n.###.\n.#.#.\n.#.#.\n.#.#.\n.....", ".............\n.###########.\n.###.###.##...
{ "input": [ "5 5\n.....\n.#.#.\n.....\n.#.#.\n.../.", "7 13\n.............\n.###.###.###.\n.#.#.#...#...\n.###.#...#...\n...#.#.#.#.#.\n.#.#.###.###.\n.............", "7 13\n.............\n.###.###.###.\n.#.#.#...#...\n...#...#.###.\n...#.#.#.#.#.\n.#.#.###.###.\n.............", "7 13\n.............\...
p00093 Leap Year
Create a program that outputs all leap years between the year a and year b. The leap year conditions are as follows. However, 0 <a ≤ b <3,000. If there is no leap year in the given period, output "NA". * The year is divisible by 4. * However, a year divisible by 100 is not a leap year. * However, a year divisible by ...
{ "input": [], "output": [] }
{ "input": [ "2001 2010\n2005 2005\n2001 2010\n0 0" ], "output": [ "2004\n2008\n\nNA\n\n2004\n2008" ] }
{ "input": [ "2001 2010\n1393 2005\n2001 2010\n0 0", "2063 2010\n1393 2005\n2001 2010\n0 0", "2063 2076\n1393 2005\n2001 2010\n0 0", "2063 2076\n197 2005\n2001 2010\n0 0", "2063 2076\n197 607\n2001 2010\n0 0", "2063 2076\n197 842\n2001 2010\n0 0", "3377 2076\n197 842\n2001 2010\n0 0", ...
p00225 Kobutanukitsuneko
Relative B man came to A child's house. He is 3 years old and loves singing. He is singing the song "Kobutanuki Tsuneko" (written and composed by Naozumi Yamamoto), which he learned from kindergarten. In this song, the four words "kobuta," "raccoon dog," "fox," and "cat" are arranged in order, and the last and first so...
{ "input": [], "output": [] }
{ "input": [ "5\napple\nyellow\ngeorgia\nking\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0" ], "output": [ "NG\nOK" ] }
{ "input": [ "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nyellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "5\napple\nyellow\ngeorgia\ngnik\nemail\n7\napple\nzellow\ngeorgia\nking\nemail\nwink\nlucky\n0", "5\napple\noellyw\ngeorgia\ngink\nlibme\n0\napplf\nzelmow\ngeorgia\nkgnj\nembil\nxink\nlkcuy\n0",...
p00387 Party Dress
Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of them and will carry several dresses with her. But the number of dresses she can carry with her may be smaller than that of the party opportunities. In that case, she has to wear some of her dre...
{ "input": [], "output": [] }
{ "input": [ "25 10", "3 5" ], "output": [ "1", "2" ] }
{ "input": [ "10 10", "3 9", "3 15", "3 26", "1 26", "1 43", "1 65", "1 18", "2 8", "2 3", "5 26", "1 30", "2 30", "3 28", "1 12", "1 20", "5 32", "2 21", "2 26", "1 75", "1 118", "1 36", "1 0", "2 57", "1 41", "5 ...
p00603 Riffle Shuffle
There are a number of ways to shuffle a deck of cards. Riffle shuffle is one such example. The following is how to perform riffle shuffle. There is a deck of n cards. First, we divide it into two decks; deck A which consists of the top half of it and deck B of the bottom half. Deck A will have one more card when n is ...
{ "input": [], "output": [] }
{ "input": [ "9 1\n3\n9 4\n1 2 3 4" ], "output": [ "3\n0" ] }
{ "input": [ "9 1\n3\n9 4\n1 2 6 4", "9 1\n3\n11 4\n1 2 6 4", "9 1\n3\n9 4\n1 1 6 6", "9 1\n2\n11 4\n1 2 6 4", "8 1\n3\n16 4\n1 1 3 4", "9 1\n2\n17 4\n1 2 6 4", "9 1\n3\n15 4\n2 1 6 6", "8 1\n3\n24 4\n1 1 3 4", "9 1\n4\n5 4\n1 2 6 4", "2 1\n4\n5 4\n1 2 6 4", "9 1\n3\n9 4\n1...
p00740 Next Mayor
One of the oddest traditions of the town of Gameston may be that even the town mayor of the next term is chosen according to the result of a game. When the expiration of the term of the mayor approaches, at least three candidates, including the mayor of the time, play a game of pebbles, and the winner will be the next ...
{ "input": [], "output": [] }
{ "input": [ "3 2\n3 3\n3 50\n10 29\n31 32\n50 2\n50 50\n0 0" ], "output": [ "1\n0\n1\n5\n30\n1\n13" ] }
{ "input": [ "3 2\n3 3\n3 50\n10 29\n57 32\n50 2\n50 50\n0 0", "3 2\n3 3\n4 50\n10 29\n57 32\n50 2\n50 50\n0 0", "3 2\n3 3\n4 50\n10 29\n57 32\n50 1\n50 50\n0 0", "3 3\n3 3\n3 50\n10 29\n31 32\n50 2\n50 50\n0 0", "3 2\n3 2\n3 50\n10 29\n57 32\n50 2\n50 50\n0 0", "3 2\n3 3\n4 50\n10 29\n57 4\n5...
p00879 Chemist's Math
You have probably learnt chemical equations (chemical reaction formulae) in your high-school days. The following are some well-known equations. 2H2 + O2 -> 2H2O (1) Ca(OH)2 + CO2 -> CaCO3 + H2O (2) N2 + 3H2 -> 2NH3 ...
{ "input": [], "output": [] }
{ "input": [ "N2+H2->NH3.\nNa+Cl2->NaCl.\nCa(OH)2+CO2->CaCO3+H2O.\nCaCl2+AgNO3->Ca(NO3)2+AgCl.\nC2H5OH+O2->CO2+H2O.\nC4H10+O2->CO2+H2O.\nA12B23+C34D45+ABCD->A6D7+B8C9.\nA98B+B98C+C98->A98B99C99.\nA2+B3+C5+D7+E11+F13->ABCDEF.\n." ], "output": [ "1 3 2\n2 1 2\n1 1 1 1\n1 2 1 2\n1 3 2 3\n2 13 8 10\n2 123 330...
{ "input": [ "N2+H2->NH3.\nNa+Cl2->NaCl.\nCa(OH)2+CO2->CaCO3+H2O.\nCaCl2+AgNO3->Ca(NO3)2+AgCl.\nC2H5OH+O2->CO2+H2O.\nC4H10+O2->CO2+H2O.\nA12B23+C34D45+ABCD->A6D7+B8C9.\nA98B+B89C+C98->A98B99C99.\nA2+B3+C5+D7+E11+F13->ABCDEF.\n.", "N2+H2->NH3.\nNa+Cl2->NaCl.\nCa(OH)2+CO2->CaCO3+H2O.\nCaCl2+AgNO3->Ca(NO3)2+AgCl...
p01010 Light Source
Problem N circular light sources are arranged on a two-dimensional plane. When a light source receives light, the light is emitted in a fan shape from the center point of the light source as shown in the figure below. <image> The center point of the light source is represented by (x, y) and the radius is represented ...
{ "input": [], "output": [] }
{ "input": [ "2\n90 10 10\n-3 0 1 45 10 90 10\n-6 0 2 30 3 180 10\n-9 0 1", "1\n90 10 20\n3 3 1 90 10 315 10\n6 0 1" ], "output": [ "10", "30" ] }
{ "input": [ "2\n90 10 10\n0 0 1 45 10 90 10\n-6 0 2 30 3 180 10\n-9 0 1", "1\n90 20 20\n3 3 1 90 10 315 10\n6 0 1", "2\n90 10 8\n0 0 1 45 10 90 10\n-6 -1 2 30 3 180 10\n-9 0 1", "1\n90 13 19\n3 2 2 180 10 327 10\n6 1 1", "1\n90 13 29\n3 2 2 180 10 327 10\n8 1 1", "1\n90 1 29\n3 2 2 180 10 10 ...
p01142 Karakuri Doll
Karakuri Doll Karakuri doll English text is not available in this practice contest. After many years of research, Karakuri puppeteer JAG has succeeded in developing a wonderful tea-drawing doll that combines traditional and latest techniques. This tea-drawing doll is placed in a teacup with tea in the kitchen (K) in...
{ "input": [], "output": [] }
{ "input": [ "5 3\n#####\n#K.M#\n#####\n9 5\n#########\n#.....###\n#.###..M#\n#K#######\n#########\n9 5\n#########\n#K......#\n####.####\n####M####\n#########\n9 5\n#########\n#M......#\n####.####\n####K####\n#########\n7 9\n#######\n#####M#\n#####.#\n#.....#\n#.###.#\n#.....#\n#.#####\n#K#####\n#######\n7 6\n###...
{ "input": [ "5 3\n#####\n#K.M#\n#####\n9 5\n#########\n#.....###\n#.###..M#\n#K#######\n#########\n9 5\n#########\n#K......#\n####.####\n####M####\n#########\n9 5\n#########\n#M......#\n####.####\n####K####\n#########\n7 9\n#######\n#####M#\n#####.#\n#.....#\n#.###.#\n#.....#\n#.#####\n#K#####\n#######\n7 6\n###...
p01281 Tatami
A tatami mat, a Japanese traditional floor cover, has a rectangular form with aspect ratio 1:2. When spreading tatami mats on a floor, it is prohibited to make a cross with the border of the tatami mats, because it is believed to bring bad luck. Your task is to write a program that reports how many possible ways to sp...
{ "input": [], "output": [] }
{ "input": [ "3 4\n4 4\n0 0" ], "output": [ "4\n2" ] }
{ "input": [ "3 1\n4 4\n0 0", "3 1\n6 4\n0 0", "3 4\n4 1\n0 0", "3 1\n4 2\n0 0", "3 2\n6 4\n0 0", "3 7\n4 1\n0 0", "4 4\n4 1\n0 0", "4 1\n4 2\n0 0", "3 7\n7 1\n0 0", "4 1\n6 4\n0 0", "4 1\n4 1\n0 0", "4 1\n10 4\n0 0", "4 4\n9 1\n0 0", "8 4\n2 1\n0 0", "6 1\n...
p01451 Roads on Towns
The Kingdom of Neva is home to two ethnic groups, the Totata and the Tutete. The biggest feature of the Totata tribe is that they eat sweet and sour pork with pineapple. However, the Tutete tribe eats vinegared pork in pineapple. These two peoples couldn't get along with each other, and the Totata and Tutete have been ...
{ "input": [], "output": [] }
{ "input": [ "2 3\n4 0\n0 0\n2 3\n2 -2\n3 1", "2 2\n0 0\n1 1\n2 0\n2 -1", "5 2\n-2 1\n1 2\n-1 3\n-1 5\n1 4\n0 4\n0 0" ], "output": [ "-1", "2.414213562373", "12.359173603117" ] }
{ "input": [ "2 3\n4 0\n-1 0\n2 3\n2 -2\n3 1", "2 2\n0 0\n1 2\n2 0\n2 -1", "5 2\n-2 0\n1 2\n-1 3\n-1 5\n1 4\n0 4\n0 0", "2 3\n2 2\n-2 0\n4 3\n2 -2\n-1 1", "2 3\n2 2\n-2 0\n4 6\n2 -2\n-1 1", "2 3\n2 2\n-2 0\n7 6\n2 -2\n-1 1", "5 2\n-2 1\n1 2\n-1 3\n-1 5\n1 5\n0 4\n0 0", "2 2\n0 0\n1 4\n...
p01601 Palindromic Number
Palindrome Problem Statement Find the number of palindromes closest to the integer n. Note that the non-negative integer x is the number of palindromes, which means that the character string in which x is expressed in decimal notation and the character string in which it is inverted are equal. For example, 0,7,33,10...
{ "input": [], "output": [] }
{ "input": [ "13", "106", "7447" ], "output": [ "11", "101", "7447" ] }
{ "input": [ "4", "8", "4752", "7", "23", "8517", "6", "39", "3483", "5", "1868", "1", "2667", "92", "3332", "61", "4989", "2", "5975", "5760", "741", "1111", "1000", "1001", "117", "6777", "3", "9", "2...
p01757 Tournament
This year too, the time has come for the National Programming Championships. In the district tournament where the right to participate in the national tournament is bet, 2n teams will face each other in a one-on-one winning tournament system. Team numbers 0, .. .2n − 1 are assigned to the tournament table, and the con...
{ "input": [], "output": [] }
{ "input": [ "1 1\n0 2\n1" ], "output": [ "1" ] }
{ "input": [ "1 1\n0 4\n1", "2 1\n0 4\n1", "0 1\n0 4\n0", "2 1\n0 4\n2", "3 1\n0 8\n0", "3 1\n0 8\n2", "3 1\n0 8\n3", "1 1\n0 8\n1", "1 1\n-1 3\n1", "2 1\n0 4\n0", "1 1\n0 2\n0", "1 1\n-2 2\n1", "0 1\n0 8\n0", "0 1\n0 1\n0", "0 2\n-1 1\n1", "0 1\n0 6\n0"...
p01897 DAG Trio (Hard)
This issue is the same configuration issue as D: DAG Trio (Easy), with only the constraints being different. input $ N \ M $ $ a_1 \ b_1 $ $ a_2 \ b_2 $ $ \ vdots $ $ a_M \ b_M $ output Print "YES" or "NO" on the $ 1 $ line. Example Input 3 3 1 2 2 3 3 1 Output YES
{ "input": [], "output": [] }
{ "input": [ "3 3\n1 2\n2 3\n3 1" ], "output": [ "YES" ] }
{ "input": [ "3 3\n1 3\n2 3\n3 1", "3 3\n1 1\n2 3\n3 2", "3 3\n1 2\n2 3\n3 2", "3 3\n1 2\n2 3\n1 1", "3 3\n1 2\n2 3\n2 1", "3 3\n1 2\n2 3\n2 2", "3 0\n1 2\n2 3\n2 2", "3 0\n1 2\n2 0\n2 2", "3 0\n1 2\n2 0\n2 1", "3 0\n1 2\n2 0\n2 0", "3 0\n1 3\n2 0\n2 0", "3 0\n1 3\n2 0\...
p02034 Round-trip String
E: Round-trip String story This is the world where all human beings have become competition programmers. In this world, there are many customs that you cannot think of in the present age. One of them is the custom of sending a character string when expressing gratitude to parents, especially mothers. There are region...
{ "input": [], "output": [] }
{ "input": [ "6\ntabata" ], "output": [ "3" ] }
{ "input": [ "6\natabat", "6\n`aactt", "6\natvcac", "6\n`tabat", "6\n`tacat", "6\n`aactu", "6\n`bactu", "6\n`aactv", "6\n`abctv", "6\nvtcba`", "6\n`abcuv", "6\nvucba`", "6\nvacbt`", "6\nbacvt`", "6\ntacvb`", "6\ntacvc`", "6\ntacvca", "6\nacvcat",...
p02177 iff
problem There are $ N $ propositions, named $ 1, 2, \ cdots, N $, respectively. Also, $ M $ information about the propositions is given. The $ i $ th information is "$ a_i $$". Given in the form "b_i $", which means that $ a_i $ is $ b_i $. ("If" is a logical conditional and the transition law holds.) $ For each propo...
{ "input": [], "output": [] }
{ "input": [ "5 2\n1 2\n2 1" ], "output": [ "1 2\n1 2\n3\n4\n5" ] }
{ "input": [ "5 2\n1 2\n2 2", "3 2\n1 2\n2 1", "3 2\n1 2\n3 1", "6 2\n1 2\n2 1", "9 2\n1 2\n2 4", "6 2\n1 1\n2 1", "17 2\n1 2\n2 4", "4 2\n2 2\n3 1", "26 2\n2 2\n4 4", "12 2\n2 2\n4 4", "1 0\n2 2\n1 1", "17 2\n1 2\n2 1", "7 1\n2 1\n3 0", "28 2\n1 2\n4 6", "1...
p02320 Knapsack Problem with Limitations
You have N items that you want to put them into a knapsack. Item i has value vi, weight wi and limitation mi. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have combined weight at most W, that is capacity of the knapsack. * You can select at m...
{ "input": [], "output": [] }
{ "input": [ "2 100\n1 1 100\n2 1 50", "4 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2" ], "output": [ "150", "12" ] }
{ "input": [ "2 100\n1 1 100\n2 1 25", "5 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2", "2 101\n1 1 100\n2 1 25", "5 8\n4 2 2\n2 1 1\n1 2 4\n3 2 2", "2 101\n1 1 100\n1 1 25", "5 3\n4 2 2\n2 1 1\n1 2 3\n3 2 2", "5 3\n4 1 2\n2 1 1\n1 2 3\n3 2 2", "6 3\n3 1 4\n2 1 0\n2 2 0\n3 2 2", "2 100\n1 2 100\...
p02465 Set Difference
Find the difference of two sets $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}\\}$, $A - B$. Constraints * $1 \leq n, m \leq 200,000$ * $0 \leq a_0 < a_1 < ... < a_{n-1} \leq 10^9$ * $0 \leq b_0 < b_1 < ... < b_{m-1} \leq 10^9$ Input The input is given in the following format. $n$ $a_0 \; a...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 5 8\n2\n2 5" ], "output": [ "1\n3\n8" ] }
{ "input": [ "5\n1 2 3 5 8\n2\n4 5", "5\n1 2 3 5 8\n0\n4 5", "5\n0 2 3 5 8\n0\n0 5", "5\n-1 2 3 5 8\n0\n0 5", "5\n-1 2 3 5 14\n0\n0 9", "5\n0 2 3 5 8\n2\n4 5", "5\n-1 2 3 5 16\n0\n0 5", "5\n0 2 3 5 11\n2\n4 5", "5\n-1 2 3 5 27\n0\n0 18", "5\n0 2 3 5 11\n2\n4 9", "5\n0 2 3 5...
arrgame2
Problem Statement Little Chef doesn't love math anymore. He loves Aleksandra. Sashen'ka is nice. They spend all the time together. Even their birthdays they are celebrating together, because they were born on the same day :) And now, this day is coming... Chef know that most of all Sasha loves numbers, that's why...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n3\n4\n2\n2 3\n1 4\n2\n2 4\n2 2" ], "output": [ "1.000000\n1.500000\n0.000000" ] }
{ "input": [ "3\n1\n3\n4\n2\n2 3\n1 4\n2\n3 4\n2 2", "3\n1\n3\n4\n2\n2 6\n1 4\n2\n2 4\n2 2", "3\n1\n3\n4\n2\n2 1\n1 4\n2\n3 4\n2 2", "3\n1\n4\n4\n2\n2 6\n1 4\n2\n2 4\n2 2", "3\n1\n4\n4\n2\n2 6\n1 4\n2\n2 4\n2 6", "3\n1\n6\n4\n2\n2 -1\n1 4\n2\n3 4\n2 2", "3\n1\n4\n4\n2\n2 6\n2 4\n2\n2 4\n2 ...
clco06
One night Mr.X and Mr.Y were playing a game. To test Mr.Y's intelligence Mr.X gives him an interesting problem to solve. He gives him a number N and asks him to swap the digits in the number such that a smallest number M is obtained without leading zeroes. Mr.Y thinks this is an easy problem to solve and immediately gi...
{ "input": [], "output": [] }
{ "input": [ "2\n310\n103\n1\n2" ], "output": [ "AC\nWA" ] }
{ "input": [ "2\n310\n129\n1\n2", "2\n597\n79\n0\n0", "2\n0\n0\n-2\n0", "2\n-1\n-1\n1\n1", "2\n310\n129\n0\n2", "2\n310\n222\n0\n2", "2\n310\n79\n0\n2", "2\n597\n79\n0\n2", "2\n597\n79\n-1\n0", "2\n147\n79\n0\n0", "2\n147\n79\n1\n0", "2\n221\n79\n1\n0", "2\n221\n66\...
fest03
Golu is a student of Computer Engineering and he decided to make a project for himself.So he started working on URL shortner.While working on project he got confused.You are a good friend of Golu so he asked you for help. You have given a link and you have to convert it into a short link using algorithm given by Golu. ...
{ "input": [], "output": [] }
{ "input": [ "3\ncodechef.com\nfacebook.com/home/\nssss" ], "output": [ "ocul.in/c3e2o2\nocul.in/o4c2e2\nocul.in/s4a0a0" ] }
{ "input": [], "output": [] }
lecandy
A Little Elephant and his friends from the Zoo of Lviv like candies very much. There are N elephants in the Zoo. The elephant with number K (1 ≤ K ≤ N) will be happy if he receives at least AK candies. There are C candies in all in the Zoo. The Zoo staff is interested in knowing whether it is possible to make all the...
{ "input": [], "output": [] }
{ "input": [ "2\n2 3\n1 1\n3 7\n4 2 2" ], "output": [ "Yes\nNo\n" ] }
{ "input": [ "2\n2 1\n1 1\n3 7\n4 2 2", "2\n2 1\n1 2\n3 7\n0 2 2", "2\n2 2\n1 1\n3 3\n4 1 6", "2\n2 2\n1 1\n3 3\n0 0 3", "2\n2 1\n1 2\n3 7\n4 2 2", "2\n2 1\n2 2\n3 7\n0 2 2", "2\n2 1\n2 2\n3 13\n0 2 2", "2\n2 1\n2 2\n3 13\n-1 2 2", "2\n2 1\n4 2\n3 13\n-1 2 2", "2\n2 1\n4 2\n3 1...
poker
In poker, you have 5 cards. There are 10 kinds of poker hands (from highest to lowest): royal flush - ace, king, queen, jack and ten, all in the same suit straight flush - five cards of the same suit in sequence, such as 10,9,8,7,6 of clubs; ace can be counted both as the highest card or as the lowest card - A,2,3,4...
{ "input": [], "output": [] }
{ "input": [ "3\nAH KH QH TH JH\nKH 5S 3C 5C 7D\nQH QD 2S QC 2C" ], "output": [ "royal flush\npair\nfull house\n" ] }
{ "input": [ "3\nAH KH QH TH JH\nKH 5S 3D 5C 7D\nQH QD 2S QC 2C", "3\nAH KH QH TH JH\nKH 5S 3C 5C 7D\nQH QD 3S QC 2C", "3\nAH KH QH TH JH\nKH 4S 3C 5C 8D\nQH QD 2S QC 2C", "3\nAH KH QH TH JH\nJH 6S 3C 5C 7D\nQH QD 4S QC 2C", "3\nAH KH QH TH JH\nKH 5S 3D 5C 8D\nQH QD 2S QC 2C", "3\nAH KH QH TH ...
subbxor
A straightforward question. Given an array of positive integers you have to print the number of subarrays whose XOR is less than K. Subarrays are defined as a sequence of continuous elements Ai, Ai+1, ..., Aj . XOR of a subarray is defined as Ai^Ai+1^ ... ^Aj. Symbol ^ is Exclusive Or. You can read more about i...
{ "input": [], "output": [] }
{ "input": [ "1\n5 2\n4 1 3 2 7" ], "output": [ "3" ] }
{ "input": [ "1\n5 2\n4 1 3 1 7", "1\n8 2\n4 1 3 1 12", "1\n8 2\n3 1 3 1 12", "1\n1 2\n3 1 1 1 12", "1\n-1 4\n3 1 1 3 11", "1\n-1 0\n2 1 1 0 57", "1\n-1 -1\n2 0 1 0 57", "1\n0 -1\n1 -1 1 1 102", "1\n0 -1\n2 -1 1 0 102", "1\n-1 -1\n0 -1 2 2 51", "1\n-1 -1\n1 -1 1 4 58", ...
100_C. A+B
Bijan is new to programming. He learned recently that programmers do not code every bit of their apps from scratch. For example they never write a code to sum two integers, because their languages have the ability to do the sum. But can they use it? Can an experienced coder who has attended more than 100 contests, sum...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n", "1390\n2011\n", "12345\n54321\n" ], "output": [ "5\n", "3401\n", "66666\n" ] }
{ "input": [], "output": [] }
1371_A. Magical Sticks
A penguin Rocher has n sticks. He has exactly one stick with length i for all 1 ≤ i ≤ n. He can connect some sticks. If he connects two sticks that have lengths a and b, he gets one stick with length a + b. Two sticks, that were used in the operation disappear from his set and the new connected stick appears in his se...
{ "input": [], "output": [] }
{ "input": [ "4\n1\n2\n3\n4\n" ], "output": [ "1\n1\n2\n2\n" ] }
{ "input": [ "4\n1\n2\n3\n8\n", "4\n1\n2\n1\n4\n", "4\n1\n2\n3\n12\n", "4\n2\n2\n3\n15\n", "4\n2\n2\n3\n5\n", "4\n1\n2\n4\n4\n", "4\n1\n2\n3\n14\n", "4\n1\n3\n1\n4\n", "4\n2\n2\n6\n15\n", "4\n1\n2\n5\n4\n", "4\n1\n2\n3\n20\n", "4\n1\n3\n3\n5\n", "4\n2\n2\n6\n8\n", ...
1418_C. Mortal Kombat Tower
You and your friend are playing the game Mortal Kombat XI. You are trying to pass a challenge tower. There are n bosses in this tower, numbered from 1 to n. The type of the i-th boss is a_i. If the i-th boss is easy then its type is a_i = 0, otherwise this boss is hard and its type is a_i = 1. During one session, eith...
{ "input": [], "output": [] }
{ "input": [ "6\n8\n1 0 1 1 0 1 1 1\n5\n1 1 1 1 0\n7\n1 1 1 1 0 0 1\n6\n1 1 1 1 1 1\n1\n1\n1\n0\n" ], "output": [ "2\n2\n2\n2\n1\n0\n" ] }
{ "input": [ "6\n8\n1 0 1 1 0 1 1 1\n5\n1 1 1 1 1\n7\n1 1 1 1 0 0 1\n6\n1 1 1 1 1 1\n1\n1\n1\n0\n", "6\n8\n1 0 1 1 0 1 0 1\n5\n1 1 1 1 1\n7\n1 1 1 1 0 0 1\n6\n1 1 1 1 1 1\n1\n1\n1\n0\n", "6\n8\n1 0 1 1 0 1 1 1\n5\n1 1 1 1 0\n7\n1 1 1 1 0 0 1\n6\n0 1 1 1 1 1\n1\n1\n1\n0\n", "6\n8\n0 0 1 1 0 1 1 1\n5\n1...
algorithm-guru
Once Algorithm guru gave a simple problem to his students.He gave a list of n integers say, A={a1,a2,a3...an} and another integer, x representing the expected sum. He said students to select numbers from array list(0 or more numbers) such that the sum of these numbers is as close as possible but not exceeding to the su...
{ "input": [], "output": [] }
{ "input": [ "2\n3 12\n1 6 9\n5 9\n3 4 4 4 8\n\nSAMPLE" ], "output": [ "12\n9" ] }
{ "input": [ "2\n3 12\n1 6 9\n5 9\n3 4 4 4 8\n\nEAMPLS", "2\n3 22\n1 6 9\n5 9\n3 4 4 4 8\n\nEAMPLS", "2\n5 22\n1 10 9\n5 3\n3 4 8 4 8\n\nEAMPLS", "2\n5 22\n1 10 9\n5 6\n3 4 8 4 8\n\nEAMPLS", "2\n5 22\n2 12 3\n17 11\n2 4 8 4 8\n\nE@MPLS", "2\n5 22\n4 12 3\n17 11\n2 4 8 3 8\n\nE@MPLS", "2\n5...
bytelandian-conversions
In Byteland,conversion of numbers between different bases has always been a herculian task.They always make errors in these conversions. People in Byteland always write one of the digits wrong when they convert a number to a new base and write it down. For example, when they convert the number 56 into binary (base 2...
{ "input": [], "output": [] }
{ "input": [ "1010\n212\n\nSAMPLE" ], "output": [ "14" ] }
{ "input": [], "output": [] }
p02589 AtCoder Grand Contest 047 - First Second
Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx. You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) / 2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the other? Constraints...
{ "input": [], "output": [] }
{ "input": [ "6\nb\na\nabc\nc\nd\nab", "3\nabcxyx\ncyx\nabc" ], "output": [ "5", "1" ] }
{ "input": [ "3\nabcxyx\ncyx\nabb", "3\nabxxyc\ncyx\nabb", "6\nb\na\nabb\nc\nd\nab", "6\nb\na\nabb\nc\nd\nba", "3\naxxbyc\ncyx\nabb", "3\naxxbyc\ncyx\naab", "3\naxxbyc\ncyw\naab", "3\naxxbyc\ncyw\nbaa", "3\ncybxxa\ncyw\nbaa", "3\ncabxxy\ncyw\nbaa", "3\ndabxxy\ncyw\nbaa", ...
p02720 AtCoder Beginner Contest 161 - Lunlun Number
A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: * In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most 1. For example, 1234, 1, and 334 are lunlun numbers, while ...
{ "input": [], "output": [] }
{ "input": [ "13", "1", "15", "100000" ], "output": [ "21", "1", "23", "3234566667" ] }
{ "input": [ "8", "2", "12", "9", "20", "37", "10", "3", "5", "6", "4", "24", "16", "21", "7", "45", "14", "29", "17", "39", "11", "55", "25", "40", "32", "78", "59", "18", "30", "58", "35", ...
p02850 AtCoder Beginner Contest 146 - Coloring Edges on Tree
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colo...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n2 3", "6\n1 2\n1 3\n1 4\n1 5\n1 6", "8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n6 8" ], "output": [ "2\n1\n2", "5\n1\n2\n3\n4\n5", "4\n1\n2\n3\n4\n1\n1\n2" ] }
{ "input": [ "8\n1 2\n2 3\n2 4\n2 5\n4 7\n5 6\n2 8", "8\n1 2\n2 3\n2 4\n4 5\n4 7\n5 6\n2 8", "8\n1 2\n2 3\n2 4\n2 5\n4 7\n3 6\n6 8", "8\n1 2\n2 3\n2 4\n2 5\n4 7\n3 6\n5 8", "8\n1 2\n2 3\n3 4\n2 5\n4 7\n5 6\n2 8", "8\n1 2\n2 3\n2 4\n2 5\n4 7\n2 6\n6 8", "8\n1 2\n2 3\n2 4\n2 5\n4 7\n2 6\n7 8...
p02987 AtCoder Beginner Contest 132 - Fifty-Fifty
You are given a 4-character string S consisting of uppercase English letters. Determine if S consists of exactly two kinds of characters which both appear twice in S. Constraints * The length of S is 4. * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: S ...
{ "input": [], "output": [] }
{ "input": [ "FFEE", "FREE", "STOP", "ASSA" ], "output": [ "Yes", "No", "No", "Yes" ] }
{ "input": [ "EEFF", "FQEE", "SPOT", "ASRA", "EEQF", "SPNT", "ARSA", "EEQG", "RPNT", "ARSB", "EDQG", "TNPR", "AQSB", "GQDE", "TMPR", "@QSB", "GEDQ", "TRPM", "@QBS", "GEDP", "TRMP", "SBQ@", "GDDP", "PRMT", "S@QB", "...
p03128 AtCoder Beginner Contest 118 - Match Matching
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectiv...
{ "input": [], "output": [] }
{ "input": [ "101 9\n9 8 7 6 5 4 3 2 1", "20 4\n3 7 8 4", "15 3\n5 4 6" ], "output": [ "71111111111111111111111111111111111111111111111111", "777773", "654" ] }
{ "input": [ "101 9\n9 8 7 6 5 4 3 1 1", "20 4\n3 7 8 7", "15 4\n5 4 6", "15 7\n5 3 6", "15 6\n5 1 6", "12 6\n5 1 6", "101 9\n9 8 1 6 5 4 3 2 1", "20 4\n3 7 8 5", "15 3\n5 4 9", "15 7\n2 3 6", "15 6\n7 3 6", "20 4\n2 7 9 7", "23 3\n5 3 6", "15 7\n4 3 6", "10...
p03271 AtCoder Regular Contest 102 - Revenge of BBuBBBlesort!
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the state where p_i=i for every i can be reached by performing the following operation any number of times: * Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three. Cons...
{ "input": [], "output": [] }
{ "input": [ "6\n5\n3\n4\n1\n2\n6", "5\n5\n2\n1\n4\n3", "4\n3\n2\n4\n1", "7\n3\n2\n1\n6\n5\n4\n7" ], "output": [ "No", "Yes", "No", "Yes" ] }
{ "input": [ "6\n5\n3\n8\n1\n2\n6", "4\n3\n2\n3\n1", "6\n5\n3\n8\n1\n2\n3", "4\n3\n2\n2\n1", "6\n4\n3\n8\n1\n2\n3", "4\n3\n1\n2\n1", "4\n6\n1\n2\n1", "4\n10\n1\n2\n1", "4\n10\n1\n2\n2", "4\n10\n1\n2\n4", "4\n8\n1\n2\n4", "6\n5\n3\n4\n1\n2\n4", "5\n6\n2\n1\n4\n3", ...
p03428 AtCoder Grand Contest 021 - Holes
There are N holes in a two-dimensional plane. The coordinates of the i-th hole are (x_i,y_i). Let R=10^{10^{10^{10}}}. Ringo performs the following operation: * Randomly choose a point from the interior of a circle of radius R centered at the origin, and put Snuke there. Snuke will move to the hole with the smallest ...
{ "input": [], "output": [] }
{ "input": [ "2\n0 0\n1 1", "5\n0 0\n2 8\n4 5\n2 6\n3 10" ], "output": [ "0.5\n0.5", "0.43160120892732328768\n0.03480224363653196956\n0.13880483535586193855\n0.00000000000000000000\n0.39479171208028279727" ] }
{ "input": [ "2\n0 0\n1 0", "5\n0 0\n2 9\n4 5\n2 6\n3 10", "5\n0 0\n3 9\n4 5\n2 6\n3 10", "5\n0 0\n5 9\n4 5\n2 6\n3 10", "5\n0 0\n5 9\n4 8\n2 6\n3 10", "5\n0 0\n5 9\n3 8\n2 7\n3 10", "5\n-1 0\n5 9\n3 8\n2 7\n3 10", "5\n-1 0\n5 9\n2 8\n2 7\n3 10", "5\n-1 0\n5 9\n2 1\n2 7\n3 10", ...
p03586 Tenka1 Programmer Contest - ModularPowerEquation!!
Process the Q queries below. * You are given two integers A_i and M_i. Determine whether there exists a positive integer K_i not exceeding 2 × 10^{18} such that A_i^{K_i} ≡ K_i (mod M_i), and find one if it exists. Constraints * 1 \leq Q \leq 100 * 0 \leq A_i \leq 10^9(1 \leq i \leq Q) * 1 \leq M_i \leq 10^9(1 \leq ...
{ "input": [], "output": [] }
{ "input": [ "3\n177 168\n2028 88772\n123456789 987654321", "4\n2 4\n3 8\n9 6\n10 7" ], "output": [ "7953\n234831584\n471523108231963269", "4\n11\n9\n2" ] }
{ "input": [ "3\n177 168\n2028 149618\n123456789 987654321", "3\n177 168\n2028 19211\n123456789 987654321", "3\n177 168\n978 19211\n123456789 987654321", "3\n177 168\n978 19211\n235722608 987654321", "3\n177 168\n978 24407\n235722608 987654321", "3\n177 168\n978 24407\n153960391 987654321", ...
p03744 AtCoder Regular Contest 072 - Dam
You are in charge of controlling a dam. The dam can store at most L liters of water. Initially, the dam is empty. Some amount of water flows into the dam every morning, and any amount of water may be discharged every night, but this amount needs to be set so that no water overflows the dam the next morning. It is know...
{ "input": [], "output": [] }
{ "input": [ "4 15\n1000000000 15\n9 5\n8 6\n7 4", "4 15\n0 15\n2 5\n3 6\n4 4", "3 10\n10 10\n20 5\n4 3" ], "output": [ "1000000000.0000000\n666666669.6666666\n400000005.0000000\n293333338.8666667", "0.0000000\n0.6666667\n1.8666667\n2.9333333", "10.0000000\n15.0000000\n13.2000000" ] }
{ "input": [ "4 15\n1000000000 15\n9 5\n8 6\n2 4", "4 15\n0 15\n2 5\n3 6\n3 4", "4 15\n1100000000 15\n9 5\n8 6\n2 4", "1 15\n1100000000 15\n9 5\n8 6\n2 4", "4 15\n1000000000 15\n9 5\n8 6\n8 4", "4 15\n0 15\n3 5\n3 6\n4 4", "3 10\n10 10\n28 5\n4 3", "4 15\n1010000000 15\n9 5\n8 6\n2 4",...
p03904 CODE FESTIVAL 2016 Elimination Tournament Round 1 (Parallel) - Problem where Commas Separate Digits
You are given a string S consisting of digits between `1` and `9`, inclusive. You will insert at most K commas (`,`) into this string to separate it into multiple numbers. Your task is to minimize the maximum number among those produced by inserting commas. Find minimum possible such value. Constraints * 0 ≦ K < |S|...
{ "input": [], "output": [] }
{ "input": [ "8\n127356176351764127645176543176531763517635176531278461856198765816581726586715987216581", "2\n15267315", "0\n12456174517653111" ], "output": [ "5317635176", "315", "12456174517653111" ] }
{ "input": [ "8\n43266374421506181316476940597816436166806677255242361468471610026822687122922205449870", "2\n18507108", "0\n16408165208164532", "8\n40128623404893484002387295456399127508365095926846364056621145505791833348402674818341", "2\n32230236", "0\n9618006448576549", "8\n7063777014...
p00010 Circumscribed Circle of a Triangle
Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle 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 * $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$ * $ n \leq 20$ Input Inpu...
{ "input": [], "output": [] }
{ "input": [ "1\n0.0 0.0 2.0 0.0 2.0 2.0" ], "output": [ "1.000 1.000 1.414" ] }
{ "input": [ "1\n0.0 0.0 2.0 0.5127281311709682 2.0 2.0", "1\n0.0 0.0 2.4487612247110815 0.5127281311709682 2.0 2.0", "1\n0.0 0.0 2.4487612247110815 0.5127281311709682 2.0 2.033916337250816", "1\n0.0 0.8678187768154128 2.4487612247110815 0.5127281311709682 2.0 2.033916337250816", "1\n0.67374655923...
p00142 Nature of Prime Numbers
A prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divided by n are the same, so they are different from each other. The number is (n -1) / 2. The set of n...
{ "input": [], "output": [] }
{ "input": [ "11\n15\n0" ], "output": [ "4\n4\n4\n4\n4\n2\n2\n4\n2\n4\n4\n2" ] }
{ "input": [ "11\n23\n0", "11\n45\n0", "11\n77\n0", "11\n13\n0", "11\n17\n0", "11\n25\n0", "11\n37\n0", "11\n5\n0", "11\n69\n0", "11\n19\n0", "11\n21\n0", "11\n27\n0", "11\n11\n0", "11\n31\n0", "11\n33\n0", "11\n29\n0", "11\n7\n0", "11\n3\n0", ...
p00275 The Outcome of Bonze
One of the games that uses the Hyakunin Isshu tag is "Buddhist turning". It is a simple game that uses only picture cards, so it is widely enjoyed. There are various derivative types of rules, but the shaved turn considered here is performed by N participants according to the following rules. * Use a total of 100 card...
{ "input": [], "output": [] }
{ "input": [ "2\nSSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n2\nSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL\n5\nMMMMMMSLSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLMMMMLMLSMLMSMMMMMMMSMMMMMMLMMMMMSMMMLMM...
{ "input": [ "2\nSSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n2\nSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL\n5\nMMMMMMSLSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLMMMMLMLSSLMSMMMMMMMMMMMMMMLMMMMMSMMMLMM...
p00463 Amidakuji
problem You are playing with J using the Midakuji. The Amida lottery consists of n vertical bars and m horizontal bars. The vertical bars are numbered from 1 to n in order from the left, and the vertical bar i The positive integer si is written at the bottom of. <image> Figure 3-1 Example of Amidakuji (n = 4, m = 5,...
{ "input": [], "output": [] }
{ "input": [ "4 5 7 2\n20\n80\n100\n50\n1 1\n2 6\n2 3\n1 5\n3 1\n2 2 5 1\n10\n20\n1 1\n1 3\n0 0 0 0" ], "output": [ "100\n10" ] }
{ "input": [ "4 5 7 2\n20\n80\n100\n50\n1 1\n2 6\n2 3\n1 5\n3 1\n2 2 5 1\n10\n19\n1 1\n1 3\n0 0 0 0", "4 5 7 2\n38\n80\n100\n50\n1 1\n2 6\n2 3\n1 5\n3 1\n2 2 5 1\n10\n19\n1 1\n1 3\n0 0 0 0", "4 5 7 2\n38\n80\n100\n50\n1 1\n2 4\n2 3\n1 5\n3 1\n2 2 5 0\n10\n19\n1 1\n1 3\n0 0 0 0", "4 5 7 2\n20\n80\n100\...
p00653 School of Killifish
Jon is the leader of killifish. Jon have a problem in these days. Jon has a plan to built new town in a pond. Of course new towns should have a school for children. But there are some natural enemies in a pond. Jon thinks that the place of a school should be the safest place in a pond for children. Jon has asked by so...
{ "input": [], "output": [] }
{ "input": [ "3 3 4\n1 2 3\n4 2 2\n2 1 1\n0 0 2 2\n0 0 1 1\n1 0 1 0\n0 1 1 2\n1 10 4\n1 2 3 4 5 6 7 8 9 10\n0 0 0 9\n0 0 0 4\n0 5 0 9\n0 4 0 5\n0 0 0" ], "output": [ "1\n1\n4\n2\n1\n1\n6\n5" ] }
{ "input": [ "3 3 4\n1 3 3\n4 2 2\n2 1 1\n0 0 2 2\n0 0 1 1\n1 0 1 0\n0 1 1 2\n1 10 4\n1 2 3 4 5 6 7 8 9 10\n0 0 0 9\n0 0 0 4\n0 5 0 9\n0 4 0 5\n0 0 0", "3 3 4\n1 2 3\n4 0 2\n2 1 1\n0 0 2 2\n0 0 1 1\n1 0 1 0\n0 1 1 2\n1 10 4\n1 2 3 4 5 6 7 8 9 10\n0 0 0 9\n0 0 0 4\n0 5 0 9\n0 4 0 5\n0 0 0", "3 3 4\n1 3 3\n...
p00798 Push!!
Mr. Schwarz was a famous powerful pro wrestler. He starts a part time job as a warehouseman. His task is to move a cargo to a goal by repeatedly pushing the cargo in the warehouse, of course, without breaking the walls and the pillars of the warehouse. There may be some pillars in the warehouse. Except for the locatio...
{ "input": [], "output": [] }
{ "input": [ "5 5\n0 0 0 0 0\n4 2 0 1 1\n0 1 0 0 0\n1 0 0 0 3\n1 0 0 0 0\n5 3\n4 0 0 0 0\n2 0 0 0 0\n0 0 0 0 3\n7 5\n1 1 4 1 0 0 0\n1 1 2 1 0 0 0\n3 0 0 0 0 0 0\n0 1 0 1 0 0 0\n0 0 0 1 0 0 0\n6 6\n0 0 0 0 0 3\n0 0 0 0 0 0\n0 0 0 0 0 0\n0 0 0 0 0 0\n0 2 0 0 0 0\n4 0 0 0 0 0\n0 0" ], "output": [ "5\n-1\n11\...
{ "input": [ "5 5\n0 0 0 0 0\n4 2 0 1 1\n0 1 0 0 0\n1 0 0 0 3\n1 0 0 0 0\n5 3\n4 0 0 0 0\n2 0 0 0 0\n0 0 0 0 3\n7 5\n1 1 4 1 0 0 0\n1 1 2 1 0 0 0\n3 0 0 0 0 0 0\n0 1 0 1 0 0 0\n0 0 0 1 0 0 0\n6 6\n0 0 0 0 0 3\n0 0 0 0 0 -1\n0 0 0 0 0 0\n0 0 0 0 0 0\n0 2 0 0 0 0\n4 0 0 0 0 0\n0 0", "5 5\n0 0 0 0 0\n4 2 0 1 1\n...
p00929 There is No Alternative
Example Input 4 4 1 2 3 1 3 3 2 3 3 2 4 3 Output 1 3
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 2 3\n1 3 3\n2 3 3\n2 4 3" ], "output": [ "1 3" ] }
{ "input": [ "4 4\n1 2 3\n1 3 3\n2 3 3\n2 4 6", "4 4\n1 2 4\n1 3 3\n2 3 3\n2 4 6", "4 4\n1 3 4\n1 3 0\n2 3 3\n2 4 6", "4 4\n1 3 4\n1 3 0\n2 3 5\n2 4 6", "4 4\n1 2 3\n1 3 3\n2 3 3\n2 4 9", "4 4\n1 4 3\n1 3 0\n2 3 5\n2 4 6", "4 4\n1 2 2\n1 3 3\n2 3 3\n2 4 3", "4 4\n1 2 4\n1 3 3\n2 3 3\n1...
p01062 Courage Test
P "Today is the recording of a program of a liver test project." O-type Chieri "Ki, Kimo no good ..." Kanako Shimura "Is Chieri-chan okay?" Akane Tsukino "As expected, Mr. P! It's a wonderful commentary that clearly shows the situation in one line! Come on! Let's run toward the fireball!" P "The rules are simple, w...
{ "input": [], "output": [] }
{ "input": [ "4 2 3\n1 2\n2 3\n3 4", "6 1 5\n1 2\n1 4\n2 3\n4 5\n3 6", "8 3 6\n1 2\n2 4\n3 4\n4 5\n5 6\n6 7\n7 8", "4 1 4\n1 2\n2 3\n3 4" ], "output": [ "Yes", "No", "No", "Yes" ] }
{ "input": [ "4 2 3\n1 3\n2 3\n3 4", "2 1 5\n1 2\n1 4\n2 3\n4 5\n3 6", "6 1 5\n1 2\n1 4\n2 3\n2 5\n3 6", "4 2 3\n1 3\n1 3\n3 4", "6 1 5\n1 2\n2 4\n2 3\n2 5\n3 6", "4 2 1\n1 3\n1 3\n3 4", "6 1 5\n1 2\n2 4\n2 3\n2 5\n3 3", "8 3 6\n1 2\n2 4\n3 2\n4 5\n5 6\n6 7\n7 8", "4 1 4\n1 2\n2 3\...
p01194 Web 0.5
In a forest, there lived a spider named Tim. Tim was so smart that he created a huge, well-structured web. Surprisingly, his web forms a set of equilateral and concentric N-sided polygons whose edge lengths form an arithmetic sequence. <image> Figure 1: An example web of Tim Corresponding vertices of the N-sided pol...
{ "input": [], "output": [] }
{ "input": [ "5 1\n2 1 3 2\n2 1 2 2\n0 0" ], "output": [ "4.18" ] }
{ "input": [ "5 1\n2 1 3 2\n2 1 2 2\n0 1", "5 1\n2 1 5 2\n2 1 2 2\n0 1", "5 1\n1 1 5 2\n2 1 2 2\n0 1", "5 1\n1 1 0 2\n2 1 2 2\n0 1", "5 1\n2 1 3 2\n2 1 4 2\n0 1", "5 1\n2 1 1 2\n2 1 2 2\n0 1", "5 1\n1 1 5 1\n2 1 2 0\n0 1", "5 1\n1 1 1 2\n4 1 2 2\n0 1", "5 1\n1 1 10 1\n2 -1 2 0\n0 2...
p01332 Three Silhouettes
JAVA (Japan Aerospace Voyage Agency) launched a spacecraft in 2003 as part of its space development project. One of the purposes of launching this spacecraft is to approach the asteroid Ishikawa and collect samples of its surface material. Despite various accidents, the spacecraft reached Ishikawa and finally returned ...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0\n100 0\n100 100\n0 100\n4\n0 0\n100 0\n100 100\n0 100\n4\n0 0\n100 0\n100 100\n0 100\n3\n0 0\n100 0\n0 100\n3\n0 0\n100 0\n0 100\n3\n0 0\n100 0\n0 100\n5\n0 0\n200 0\n200 200\n100 100\n0 200\n5\n0 0\n200 0\n100 100\n200 200\n0 200\n4\n0 0\n200 0\n200 200\n0 200\n0\n0\n0", "4\n0 0\n100 0\n...
{ "input": [], "output": [] }
p01499 Rabbit Game Playing
Honestly, a rabbit does not matter. There is a rabbit playing a stage system action game. In this game, every stage has a difficulty level. The rabbit, which always needs challenges, basically wants to play more difficult stages than he has ever played. However, he sometimes needs rest too. So, to compromise, he admit...
{ "input": [], "output": [] }
{ "input": [ "3 1\n1\n2\n3", "5 3\n9\n2\n6\n8\n8", "5 7\n9\n9\n9\n1\n5" ], "output": [ "4", "24", "48" ] }
{ "input": [ "3 0\n1\n2\n3", "5 3\n9\n1\n6\n8\n8", "5 8\n9\n9\n9\n1\n5", "3 1\n1\n2\n6", "5 2\n9\n1\n6\n8\n8", "6 2\n9\n1\n6\n8\n8", "5 8\n14\n9\n9\n1\n5", "6 2\n9\n1\n6\n11\n9", "5 8\n14\n24\n12\n1\n1", "5 8\n14\n38\n9\n1\n0", "5 3\n14\n38\n3\n0\n0", "7 3\n2\n0\n28\n11...
p01670 Medical Inspection
D - Medical Inspection Problem Statement The government has declared a state of emergency due to the MOFU syndrome epidemic in your country. Persons in the country suffer from MOFU syndrome and cannot get out of bed in the morning. You are a programmer working for the Department of Health. You have to take prompt mea...
{ "input": [], "output": [] }
{ "input": [ "3 3 2\n1 2\n2 3\n3 1" ], "output": [ "2" ] }
{ "input": [ "3 3 1\n1 2\n2 3\n3 1", "3 3 3\n1 2\n2 3\n3 1", "6 1 2\n1 3\n2 6\n4 1", "6 0 1\n1 2\n1 3\n5 1", "6 3 1\n1 2\n2 3\n3 1", "6 3 1\n1 2\n2 3\n5 1", "6 3 1\n1 2\n4 3\n5 1", "3 3 0\n1 2\n2 3\n3 1", "9 3 1\n1 2\n2 3\n3 1", "6 3 1\n1 2\n4 3\n4 1", "3 3 0\n1 2\n2 3\n3 2...