name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p03041 AtCoder Beginner Contest 126 - Changing a Character
You are given a string S of length N consisting of `A`, `B` and `C`, and an integer K which is between 1 and N (inclusive). Print the string S after lowercasing the K-th character in it. Constraints * 1 ≤ N ≤ 50 * 1 ≤ K ≤ N * S is a string of length N consisting of `A`, `B` and `C`. Input Input is given from Standa...
{ "input": [], "output": [] }
{ "input": [ "4 3\nCABA", "3 1\nABC" ], "output": [ "CAbA", "aBC" ] }
{ "input": [ "4 1\nCABA", "3 2\nABC", "4 1\nCABB", "3 2\nACC", "4 1\nC@BB", "3 2\nBCC", "5 1\nD@BB", "5 1\nE@BB", "5 1\nBB@E", "5 1\nBB@D", "1 3\nCABA", "3 2\nCBA", "4 1\nCBBA", "3 2\nBDC", "4 2\nCBBA", "6 2\nCCA", "3 2\nCDB", "10 1\nC?BB", "...
p03183 Educational DP Contest - Tower
There are N blocks, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Block i has a weight of w_i, a solidness of s_i and a value of v_i. Taro has decided to build a tower by choosing some of the N blocks and stacking them vertically in some order. Here, the tower must satisfy the following condition: * For eac...
{ "input": [], "output": [] }
{ "input": [ "5\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000", "3\n2 2 20\n2 1 30\n3 1 40", "4\n1 2 10\n3 1 10\n2 4 10\n1 6 10", "8\n9 5 7\n6 2 7\n5 7 3\n7 8 8\n1 9 6\n3 3 3\n4 1 7\n4 5 5" ], "output": [ "5000000000", "50", "40", ...
{ "input": [ "5\n1 10000 1000000001\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000", "3\n2 2 20\n2 1 30\n3 1 47", "4\n1 2 10\n3 1 10\n2 4 15\n1 6 10", "8\n9 5 7\n6 2 7\n5 7 3\n7 8 8\n1 8 6\n3 3 3\n4 1 7\n4 5 5", "4\n1 2 10\n3 1 10\n2 4 29\n1 6 10", "4\n1 2 10\n...
p03330 AtCoder Beginner Contest 099 - Good Grid
There is a grid with N rows and N columns of squares. Let (i,j) be the square at the i-th row from the top and the j-th column from the left. These squares have to be painted in one of the C colors from Color 1 to Color C. Initially, (i,j) is painted in Color c_{i,j}. We say the grid is a good grid when the following...
{ "input": [], "output": [] }
{ "input": [ "4 3\n0 12 71\n81 0 53\n14 92 0\n1 1 2 1\n2 1 1 2\n2 2 1 3\n1 1 2 2", "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n3 3" ], "output": [ "428", "3" ] }
{ "input": [ "2 3\n0 1 1\n1 1 1\n1 4 0\n1 2\n3 3", "2 3\n0 1 1\n1 1 1\n2 4 0\n1 2\n3 3", "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n1 3", "2 3\n0 2 1\n1 1 1\n2 4 0\n1 2\n3 3", "2 3\n0 1 1\n1 0 1\n1 4 0\n1 2\n2 3", "2 3\n0 1 1\n1 0 1\n1 4 -1\n1 2\n2 3", "2 3\n0 2 1\n1 1 1\n2 2 -1\n1 2\n3 3", "4 3\...
p03489 AtCoder Regular Contest 087 - Good Sequence
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, an sequence b is a good sequence when the following condition holds true: * For each element x in b, the value x occurs exactly x times in...
{ "input": [], "output": [] }
{ "input": [ "8\n2 7 1 8 2 8 1 8", "1\n1000000000", "6\n1 2 2 3 3 3", "4\n3 3 3 3", "5\n2 4 1 4 2" ], "output": [ "5", "1", "0", "1", "2" ] }
{ "input": [ "8\n2 7 1 8 2 8 1 15", "1\n0000000000", "6\n1 2 2 3 3 1", "5\n2 4 1 4 1", "8\n4 7 1 8 2 8 1 12", "5\n1 4 2 4 2", "1\n0000000001", "4\n0 3 3 3", "8\n2 7 1 8 2 8 1 12", "1\n1000001000", "6\n0 2 2 3 3 1", "5\n1 4 1 4 1", "1\n1010001000", "6\n0 2 2 3 0 ...
p03651 AtCoder Grand Contest 018 - Getting Difference
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is written....
{ "input": [], "output": [] }
{ "input": [ "4 11\n11 3 7 15", "3 5\n6 9 3", "5 12\n10 2 8 6 4", "3 7\n9 3 4" ], "output": [ "POSSIBLE", "IMPOSSIBLE", "IMPOSSIBLE", "POSSIBLE" ] }
{ "input": [ "4 11\n11 3 7 10", "3 5\n6 9 6", "5 19\n10 2 8 6 4", "3 7\n18 3 4", "3 11\n11 3 7 10", "3 5\n6 16 6", "5 19\n10 2 8 6 1", "3 7\n18 0 4", "2 5\n6 16 6", "5 19\n10 2 7 6 1", "3 7\n16 0 4", "2 0\n6 16 6", "5 11\n10 2 7 6 1", "3 7\n16 1 4", "2 0\n6 ...
p03807 AtCoder Grand Contest 010 - Addition
There are N integers written on a blackboard. The i-th integer is A_i. Takahashi will repeatedly perform the following operation on these numbers: * Select a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them. * Then, write a new integer on the blackboard ...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5", "3\n1 2 3" ], "output": [ "NO", "YES" ] }
{ "input": [ "5\n1 1 3 4 5", "3\n2 2 3", "5\n1 1 3 8 5", "3\n2 2 6", "5\n1 1 4 8 5", "3\n2 2 7", "5\n1 1 4 8 2", "3\n1 2 7", "5\n1 1 2 8 2", "3\n1 0 7", "5\n2 1 2 8 2", "3\n1 0 13", "5\n2 2 2 8 2", "3\n1 0 19", "5\n2 2 2 11 2", "3\n1 0 11", "5\n2 3 2...
p03975 Kyoto University Programming Contest 2016 - A Barricade
Summer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. The barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the...
{ "input": [], "output": [] }
{ "input": [ "4 3 6\n9\n6\n8\n1", "5 5 9\n4\n3\n6\n9\n1", "2 1 2\n1\n2", "5 4 9\n5\n6\n7\n8\n9" ], "output": [ "4", "4", "1", "1" ] }
{ "input": [ "4 1 6\n9\n6\n8\n1", "2 1 2\n2\n2", "5 5 5\n5\n6\n11\n8\n9", "4 1 11\n7\n6\n0\n1", "4 3 6\n9\n6\n6\n1", "5 5 18\n5\n6\n7\n8\n9", "5 4 9\n5\n6\n11\n8\n9", "4 1 6\n9\n6\n0\n1", "2 2 2\n2\n2", "5 5 9\n5\n6\n11\n8\n9", "4 1 6\n7\n6\n0\n1", "2 2 2\n2\n1", "2...
p00064 Secret Number
The new PIN is hard to remember. I was told that I shouldn't take notes, but I don't think I can remember them. Therefore, I decided to embed a numerical value in the text and make a note of the PIN. Here, the sum of all the numbers is the PIN. Create a program that reads the memorandum and outputs the PIN code. In...
{ "input": [], "output": [] }
{ "input": [ "Thereare100yenonthetable.Iam17yearsold.\nIshouldgohomeat6pm." ], "output": [ "123" ] }
{ "input": [ "Thereare100yenonthetable.Iam17yearsold.\n.mp6taemohogdluohsI", ".dlosr`ey71maI.elbasehtnoney001eraerehT\n.mp6taelohdgoltohsI", ".closr`ey71maI-elbasegtnoney001eragrehT\nIshptkogdhomemt5q`.", "Thergarn100yeeontgesable-Iam17ye`rsolc.\nIshptkogdhomemt5q`.", "Thergarn10Iyeeontgesable-0am...
p00196 Baseball Championship
Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways. 1. The team with the most ...
{ "input": [], "output": [] }
{ "input": [ "6\nA 1 0 0 2 0\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 0 0 1 2\nE 2 0 0 0 0\nF 1 1 0 2 1\n4\ng 1 1 1\nh 0 1 2\nw 0 0 0\nb 0 2 1\n0" ], "output": [ "E\nA\nB\nD\nF\nC\nw\nh\nb\ng" ] }
{ "input": [ "6\nA 1 0 0 2 0\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 0 0 1 2\nE 2 0 0 0 0\nF 1 1 0 2 1\n4\ng 1 1 1\nh 0 1 2\nx 0 0 0\nb 0 2 1\n0", "6\nA 1 0 0 2 -1\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 0 0 1 2\nE 2 0 0 0 0\nF 1 1 0 2 1\n4\ng 1 1 1\nh 0 1 2\nx 0 0 0\nb 0 2 1\n0", "6\nA 1 0 0 2 -1\nB 0 0 1 1 0\nC 1 1 1 1 1...
p00350 String Game
You gave the twins Ai and Zu a program of games using strings. In this game, Ai and Zu each select a substring from the character string, compare them, and the person who chooses the smaller one will get points. The two competed and played the game many times. However, I got tired of playing games for the same string m...
{ "input": [], "output": [] }
{ "input": [ "13\naizualgorithm\n9\ncomp 1 1 4 5\ncomp 2 6 1 5\nset 9 12 b\ncomp 9 9 10 10\ncomp 5 8 1 4\nset 1 10 z\nset 11 13 x\ncomp 8 10 1 5\ncomp 1 5 1 5" ], "output": [ "s\nt\ne\nt\ns\ne" ] }
{ "input": [ "13\naizualgorithm\n9\ncomp 1 1 4 5\ncomp 2 6 1 5\nset 15 12 b\ncomp 9 9 10 10\ncomp 5 8 1 4\nset 1 10 z\nset 11 13 x\ncomp 8 10 1 5\ncomp 1 5 1 5", "13\naizualgorithm\n9\ncomp 1 1 4 5\ncomp 2 6 1 5\nset 9 12 b\ncomp 9 9 10 10\ncomp 5 8 1 4\nset 1 10 z\nset 11 6 x\ncomp 8 10 1 5\ncomp 1 5 1 5", ...
p00546 Zombie Island
problem The island where JOI lives has been invaded by zombies. JOI decided to escape to the shelter, which is set as the safest shelter on the island. The island where JOI lives consists of N towns from town 1 to town N, and the towns are connected by roads. There are M roads on the island, all of which connect two ...
{ "input": [], "output": [] }
{ "input": [ "13 21 1 1\n1000 6000\n7\n1 2\n3 7\n2 4\n5 8\n8 9\n2 5\n3 4\n4 7\n9 10\n10 11\n5 9\n7 12\n3 6\n4 5\n1 3\n11 12\n6 7\n8 11\n6 13\n7 8\n12 13" ], "output": [ "11000" ] }
{ "input": [ "13 21 1 1\n1000 6000\n7\n1 2\n3 7\n2 4\n5 8\n8 9\n2 5\n3 4\n6 7\n9 10\n10 11\n5 9\n7 12\n3 6\n4 5\n1 3\n11 12\n6 7\n8 11\n6 13\n7 8\n12 13", "13 21 1 1\n1000 6000\n7\n2 2\n3 7\n2 4\n5 8\n8 9\n2 5\n3 4\n6 7\n9 10\n10 11\n5 9\n7 12\n3 6\n4 5\n1 3\n11 12\n6 7\n8 11\n6 13\n7 8\n12 13", "13 21 1 ...
p00710 Hanafuda Shuffle
There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. There is a deck of n cards. Starting from the p-th card from the top of the deck, c cards are pulled out and put on the top of the deck, a...
{ "input": [], "output": [] }
{ "input": [ "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0" ], "output": [ "4\n4" ] }
{ "input": [ "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 0\n0 0", "5 0\n3 1\n3 1\n10 3\n1 10\n10 1\n8 0\n0 0", "5 0\n3 1\n3 1\n10 2\n1 10\n10 1\n11 0\n0 0", "5 2\n3 1\n3 1\n10 3\n1 11\n10 1\n8 3\n0 0", "6 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 0\n0 0", "5 0\n3 1\n3 1\n10 3\n2 10\n10 1\n8 0\n0 0", "5 0\n...
p00849 Manhattan Wiring
There is a rectangular area containing n × m cells. Two cells are marked with "2", and another two with "3". Some cells are occupied by obstacles. You should connect the two "2"s and also the two "3"s with non-intersecting lines. Lines can run only vertically or horizontally connecting centers of cells without obstacle...
{ "input": [], "output": [] }
{ "input": [ "5 5\n0 0 0 0 0\n0 0 0 3 0\n2 0 2 0 0\n1 0 1 1 1\n0 0 0 0 3\n2 3\n2 2 0\n0 3 3\n6 5\n2 0 0 0 0\n0 3 0 0 0\n0 0 0 0 0\n1 1 1 0 0\n0 0 0 0 0\n0 0 2 3 0\n5 9\n0 0 0 0 0 0 0 0 0\n0 0 0 0 3 0 0 0 0\n0 2 0 0 0 0 0 2 0\n0 0 0 0 3 0 0 0 0\n0 0 0 0 0 0 0 0 0\n9 9\n3 0 0 0 0 0 0 0 2\n0 0 0 0 0 0 0 0 0\n0 0 0 0...
{ "input": [ "5 5\n0 0 0 0 0\n0 0 0 3 0\n2 0 2 0 0\n1 0 1 1 1\n0 0 0 0 3\n2 3\n2 2 0\n0 3 3\n6 5\n2 0 0 0 0\n0 3 0 0 0\n0 0 0 0 0\n1 1 1 0 0\n0 0 0 0 0\n0 0 2 3 0\n5 9\n0 0 0 0 0 0 0 0 0\n0 0 0 0 3 0 0 0 0\n0 2 0 0 0 0 0 2 0\n0 0 0 0 3 0 0 0 0\n0 0 0 0 0 0 0 0 0\n9 9\n3 0 0 0 0 0 0 0 2\n0 0 0 0 0 0 0 0 0\n0 0 0 0...
p00981 Wall Painting
Wall Painting Here stands a wall made of a number of vertical panels. The panels are not painted yet. You have a number of robots each of which can paint panels in a single color, either red, green, or blue. Each of the robots, when activated, paints panels between a certain position and another certain position in a...
{ "input": [], "output": [] }
{ "input": [ "8 5 10 5\n1 1 7\n3 1 2\n1 5 6\n3 1 4\n3 6 8" ], "output": [ "70" ] }
{ "input": [ "8 3 10 5\n1 1 7\n3 1 2\n1 5 6\n3 1 4\n3 6 8", "14 3 10 5\n1 2 7\n3 1 2\n2 5 6\n3 1 4\n3 6 8", "8 3 9 5\n1 1 7\n3 1 2\n1 5 6\n3 1 4\n3 6 8", "14 3 3 5\n1 2 7\n3 1 2\n2 5 6\n3 1 4\n3 6 8", "4 3 10 5\n1 2 0\n3 1 2\n2 6 6\n3 1 4\n3 6 2", "14 3 3 5\n1 2 6\n3 1 2\n2 5 6\n3 1 4\n3 6 8",...
p01113 Floating-Point Numbers
Floating-Point Numbers In this problem, we consider floating-point number formats, data representation formats to approximate real numbers on computers. Scientific notation is a method to express a number, frequently used for numbers too large or too small to be written tersely in usual decimal form. In scientific no...
{ "input": [], "output": [] }
{ "input": [ "1\n0000000000000000000000000000000000000000000000000000\n2\n0000000000000000000000000000000000000000000000000000\n3\n0000000000000000000000000000000000000000000000000000\n4\n0000000000000000000000000000000000000000000000000000\n7\n1101000000000000000000000000000000000000000000000000\n100\n1100011010...
{ "input": [ "1\n0000000000000000000000000000000000000000000000000000\n2\n0000000000000000000000000000000000000000000000000000\n3\n0000000000000000001000000000000000000000000000000000\n4\n0000000000000000000000000000000000000000000000000000\n7\n1101000000000000000000000000000000000000000000000000\n100\n1100011010...
p01251 Left Hand Rule
The left-hand rule, which is also known as the wall follower, is a well-known strategy that solves a two- dimensional maze. The strategy can be stated as follows: once you have entered the maze, walk around with keeping your left hand in contact with the wall until you reach the goal. In fact, it is proven that this st...
{ "input": [], "output": [] }
{ "input": [ "3 3 3\n1 0 1 2\n1 2 2 2\n2 2 2 1\n0 0 1 0 1 1\n3 3 4\n1 0 1 2\n1 2 2 2\n2 2 2 1\n2 1 1 1\n0 0 1 0 1 1\n3 3 0\n0 0 1 0 1 1\n0 0 0" ], "output": [ "9\nImpossible\nImpossible" ] }
{ "input": [ "3 3 3\n1 0 1 2\n1 2 2 2\n2 2 2 1\n0 0 1 0 1 1\n3 3 4\n1 0 1 2\n1 2 2 2\n2 2 2 1\n2 1 1 1\n0 0 2 0 1 1\n3 3 0\n0 0 1 0 1 1\n0 0 0", "3 3 3\n1 0 1 2\n1 2 2 2\n2 3 2 1\n0 0 1 0 1 1\n3 3 4\n1 0 1 2\n1 2 2 2\n2 2 2 1\n2 1 1 1\n1 0 2 0 1 1\n3 3 0\n0 0 1 0 1 1\n0 0 0", "3 3 3\n1 0 1 2\n1 2 2 2\n2 3...
p01412 Power of Power
Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well. Today's training is to perform a very large number of calculations to improve the calculation power and raise awareness. Exponentiation is an operation that easily produces large numbers....
{ "input": [], "output": [] }
{ "input": [ "3\n0\n0\n1000000000", "4\n7\n5\n10\n6" ], "output": [ "1000000000\n0\n0", "5\n6\n7\n10" ] }
{ "input": [ "3\n0\n0\n1000000010", "4\n11\n5\n10\n6", "4\n6\n5\n10\n6", "4\n6\n5\n20\n6", "4\n2\n5\n20\n6", "4\n2\n5\n10\n6", "4\n2\n5\n10\n5", "4\n0\n5\n10\n5", "4\n0\n7\n10\n5", "4\n0\n7\n10\n1", "4\n0\n7\n10\n0", "3\n0\n0\n0000000000", "4\n7\n8\n10\n6", "4\n...
p01566 Pipeline Plans
There are twelve types of tiles in Fig. 1. You were asked to fill a table with R × C cells with these tiles. R is the number of rows and C is the number of columns. How many arrangements in the table meet the following constraints? * Each cell has one tile. * the center of the upper left cell (1,1) and the center of...
{ "input": [], "output": [] }
{ "input": [ "3 3\n0 1 1 0 0 0 0 0 0 0 0 7", "2 4\n0 0 1 1 1 2 0 1 0 0 1 1", "3 3\n0 0 0 0 0 0 0 0 0 0 0 10", "3 3\n4 2 2 0 0 0 0 0 0 0 0 1", "5 2\n0 1 1 1 0 1 2 1 2 0 0 1" ], "output": [ "66", "2012", "1", "2", "8512" ] }
{ "input": [ "4 4\n0 0 1 1 1 2 0 1 0 0 1 1", "3 3\n0 0 1 0 0 0 0 0 0 0 0 10", "3 3\n0 2 1 0 0 0 0 0 0 0 0 7", "2 4\n0 0 1 1 1 3 0 1 0 0 1 1", "5 2\n1 1 1 1 0 1 2 1 2 0 0 1", "4 2\n0 1 1 0 0 1 2 0 2 0 0 1", "5 2\n1 1 1 1 0 1 2 2 2 0 0 1", "2 3\n1 0 1 1 0 2 0 1 0 0 1 0", "5 2\n1 0 1 ...
p01728 KuruKuruKururin
Helilin has the shape of a line segment with a length of 2 L on a two-dimensional plane. There are several line-segment-shaped obstacles around the heliline. Helilin loses strength when it comes in contact with obstacles. Perfectionist Helilin decides to finish unscathed. Helilin can do the following: * Translation ...
{ "input": [], "output": [] }
{ "input": [ "1 2\n3 3\n2 -1\n4\n1 0 1 5\n0 1 6 1\n0 4 6 4\n5 0 5 5", "1 4\n3 3\n7 0\n5\n1 0 1 5\n0 1 6 1\n0 4 6 4\n8 0 2 5\n6 0 4 2", "2 2\n4 2\n4 5\n5\n1 5 2 0\n0 4 3 4\n0 1 8 1\n7 0 7 5\n8 4 5 4", "1 2\n3 3\n2 -1\n4\n1 0 1 5\n0 1 4 1\n0 4 6 4\n5 0 5 5" ], "output": [ "-1", "3", "-1"...
{ "input": [ "1 2\n3 3\n2 -1\n4\n1 0 1 5\n0 1 6 1\n0 4 6 4\n5 0 2 5", "2 2\n4 2\n4 5\n5\n1 5 2 0\n0 4 3 4\n0 1 8 1\n7 0 12 5\n8 4 5 4", "0 4\n3 3\n7 0\n5\n1 0 1 5\n0 1 6 1\n0 4 6 4\n8 0 2 5\n6 0 4 2", "2 2\n4 2\n5 5\n5\n1 7 2 0\n0 4 3 0\n0 1 8 1\n7 0 12 5\n8 4 5 4", "1 2\n3 3\n2 -1\n4\n1 0 1 5\n0 ...
p01866 Hamming Distance
Problem statement There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D $. The Hamming distance between integers expressed in $ 2 $ is the n...
{ "input": [], "output": [] }
{ "input": [ "5\n00001\n3" ], "output": [ "11101" ] }
{ "input": [ "5\n00001\n4", "5\n00000\n3", "5\n00001\n1", "5\n10001\n1", "5\n10001\n2", "5\n10001\n4", "5\n10000\n1", "5\n00010\n1", "5\n00001\n0", "5\n00010\n0", "5\n01100\n0", "5\n00011\n0", "5\n00011\n2", "5\n11101\n3", "5\n01000\n0", "5\n00000\n0", ...
p02003 Board
problem Given the squares of $ R * C $. Each square is either an empty square or a square with a hole. The given square meets the following conditions. * The cells with holes are connected. (You can move a square with a hole in the cross direction to any square with a hole) * Empty cells are connected. You can gen...
{ "input": [], "output": [] }
{ "input": [ "5 5\n.....\n.#.#.\n.###.\n.#.#.\n....." ], "output": [ "3" ] }
{ "input": [ "3 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "3 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "2 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "4 2\n.....\n.#.#/\n.###.\n.#.#.\n.....", "0 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "4 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "0 1\n.....\n.#.#.\n.##\"...
p02147 A Polygon And Circles
Problem Given a convex polygon consisting of $ N $ vertices and the center coordinates of $ M $ circles. The radius of all circles is $ r $. I want to find the minimum real number $ r $ that satisfies the following conditions. Condition: Every point inside a convex polygon is contained in at least one circle. Const...
{ "input": [], "output": [] }
{ "input": [ "4\n2 3\n1 2\n2 1\n3 2\n4\n1 3\n1 1\n3 3\n3 1", "7\n-96469 25422\n-55204 -45592\n-29140 -72981\n98837 -86795\n92303 63297\n19059 96012\n-67980 70342\n17\n-4265 -14331\n33561 72343\n52055 98952\n-71189 60872\n10459 -7512\n-11981 57756\n-78228 -28044\n37397 -69980\n-27527 -51966\n22661 -16694\n1375...
{ "input": [ "4\n2 3\n1 2\n1 1\n3 2\n4\n1 3\n1 1\n3 3\n3 1", "4\n2 3\n1 2\n1 1\n3 2\n4\n1 3\n1 1\n2 3\n3 1", "4\n2 3\n1 2\n1 1\n3 0\n4\n1 3\n1 1\n2 3\n3 0", "4\n2 3\n1 2\n1 1\n3 0\n4\n1 3\n1 1\n0 3\n3 0", "4\n0 3\n1 4\n1 1\n3 0\n4\n1 3\n1 1\n0 3\n3 0", "4\n0 3\n1 4\n1 1\n3 1\n4\n1 3\n1 1\n0 3\...
p02288 Maximum Heap
A binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other than the root, $A[i] \leq A[parent(i)]$, that is, the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values ...
{ "input": [], "output": [] }
{ "input": [ "10\n4 1 3 2 16 9 10 14 8 7" ], "output": [ "16 14 10 8 7 9 3 2 4 1" ] }
{ "input": [ "10\n4 1 3 2 16 9 10 2 8 7", "10\n4 1 3 2 23 9 10 2 8 7", "10\n7 1 3 2 23 9 10 2 8 7", "10\n7 1 3 2 23 9 10 2 8 9", "10\n0 1 3 2 23 9 10 2 8 9", "10\n0 1 3 2 23 9 10 2 13 9", "10\n0 1 3 2 23 9 10 3 13 9", "10\n0 1 3 2 23 9 10 3 13 11", "10\n0 1 3 2 23 9 10 3 16 11", ...
p02435 Stack
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out). For $n$ stack $S_i$ ($i = 0, 1, ..., n-1$), perform a sequence of the following operations. * push($t$, $x$): Insert an integer $x$ to $S_t$. * top($t$): Report the value which should be deleted next from $S_t$. If $...
{ "input": [], "output": [] }
{ "input": [ "3 9\n0 0 1\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0" ], "output": [ "3\n5\n2" ] }
{ "input": [ "3 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 0\n1 2\n2 0\n1 0", "3 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 0 5\n1 0\n1 2\n2 0\n1 0", "3 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 2 5\n1 1\n1 2\n2 0\n1 0", "6 9\n0 0 0\n0 0 2\n0 0 3\n0 2 4\n0 0 5\n1 1\n1 2\n2 0\n1 0", "3 9\n0 0 0\n0 0 2\n0 0 1\n0 2 4\n0 2...
arhn01
Problem description. An arithmetic progression(AP) is a sequence of numbers such that the difference of any two successive members of the sequence is a constant. For example:- 1, 4, 7, 10, 13, 16, 19, ... A geometric progression(GP) is a sequence of numbers where each term after the first is found by multiplying the p...
{ "input": [], "output": [] }
{ "input": [ "4 7 10\n2 6 18\n0 0 0" ], "output": [ "AP 13\nGP 54\n" ] }
{ "input": [ "4 7 10\n2 10 18\n0 0 0", "4 7 7\n2 10 18\n0 0 0", "4 5 5\n2 10 18\n0 0 0", "7 7 7\n2 10 18\n0 0 0", "4 7 10\n2 6 10\n0 0 0", "7 7 7\n2 6 18\n0 0 0", "5 5 5\n2 10 18\n0 0 0", "6 7 8\n2 10 18\n0 0 0", "3 4 5\n2 10 18\n0 0 0", "4 5 5\n4 10 20\n0 0 0", "6 8 8\n2 1...
cktfev
As the cricket fever is on,you are given the task of calculating the run rate of a cricket match,but you are only provided with overs completed , current run rate and runs scored in next over.So you have to calculate the new run rate correctly upto two decimal places. Input The first line of the input contains an int...
{ "input": [], "output": [] }
{ "input": [ "1\n16 6 8" ], "output": [ "6.12" ] }
{ "input": [ "1\n16 6 5", "1\n16 6 0", "1\n16 0 0", "1\n16 0 1", "1\n1 0 1", "1\n1 0 2", "1\n2 0 2", "1\n4 0 3", "1\n4 1 5", "1\n4 2 5", "1\n4 2 0", "1\n4 2 -1", "1\n3 2 -1", "1\n3 2 0", "1\n16 6 12", "1\n16 6 3", "1\n15 6 0", "1\n3 0 1", "1\...
fbfrw2
Problem description In the climax of an upcoming Bollywood movie "BHAI HO!", Bhai is standing at the centre of a large battlefield. Bhai is sorrounded by the army of Bacchha Singh from all sides. Each soldier of Bacchha's army is at some distance from Bhai. They all are heading towards Bhai with swords in their hands. ...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n3 4 3 7 9\n5\n3 3 3 3 3" ], "output": [ "Bhai Ho!\nKilled 3" ] }
{ "input": [ "2\n5\n3 3 3 7 9\n5\n3 3 3 3 3", "2\n5\n3 3 2 1 9\n5\n3 3 3 5 3", "2\n9\n3 3 2 1 9\n5\n3 5 3 9 3", "2\n9\n3 3 2 0 9\n5\n3 5 3 9 3", "2\n5\n3 3 3 7 0\n5\n3 3 3 3 3", "2\n9\n3 3 2 0 9\n5\n3 7 0 9 3", "2\n9\n3 3 1 1 9\n5\n3 3 4 1 3", "2\n18\n3 3 3 1 4\n5\n3 14 3 0 11", "2...
lcpesy
As we all know, Chef is cooking string for long days, his new discovery on string is the longest common pattern length. The longest common pattern length between two strings is the maximum number of characters that both strings have in common. Characters are case sensitive, that is, lower case and upper case characters...
{ "input": [], "output": [] }
{ "input": [ "4\nabcd\nxyz\nabcd\nbcda\naabc\nacaa\nCodechef\nelfedcc" ], "output": [ "0\n4\n3\n5\n" ] }
{ "input": [ "4\nabcd\nxyz\nabcd\nbcda\nacba\nacaa\nCodechef\nelfedcc", "4\nbdca\nxyz\nabcd\nbcda\nabca\nacaa\nCodechff\nelfedcc", "4\nbdca\nyyz\nabdd\nbcda\nabca\nacaa\nCodechff\nelfedcc", "4\nabcd\nxyz\nabcd\nbcda\nacba\nacba\nCodechef\nelfedcc", "4\nbdca\nxyz\nabcd\nbcea\nabca\nacaa\nCodechef\n...
pinoch1
Pinocchio is a very interesting fictional character. Each time he lies, his nose is extended by 1 cm . Pinocchio and Lampwick are best friends. But Pinocchio's habit of lying has increased manyfold nowadays which has left Lampwick really upset. As a result, he has decided to maintain a diary recording the length of ...
{ "input": [], "output": [] }
{ "input": [ "1\n7\n1 2 2 3 4 5 5" ], "output": [ "4\n" ] }
{ "input": [ "1\n7\n1 2 2 3 5 5 5", "1\n7\n1 2 2 3 4 5 7", "1\n7\n2 2 2 3 4 5 7", "1\n7\n2 2 2 3 5 5 5", "1\n7\n1 2 2 2 4 5 5", "1\n7\n1 1 2 3 5 5 5", "1\n7\n1 2 2 3 5 7 5", "1\n7\n1 2 2 3 5 9 5", "1\n7\n1 2 2 3 5 12 5", "1\n7\n1 2 2 3 5 12 2", "1\n7\n1 2 2 4 5 12 2", "...
strpalin
Chef likes strings a lot but he likes palindromic strings more. Today, Chef has two strings A and B, each consisting of lower case alphabets. Chef is eager to know whether it is possible to choose some non empty strings s1 and s2 where s1 is a substring of A, s2 is a substring of B such that s1 + s2 is a palindromic ...
{ "input": [], "output": [] }
{ "input": [ "3\nabc\nabc\na\nb\nabba\nbaab" ], "output": [ "Yes\nNo\nYes\n" ] }
{ "input": [ "3\nabc\nabc\nb\nb\nabba\nbaab", "3\nbaa\n`cc\nb\nb\n`bab\nbaac", "3\naab\n_dc\na\nb\nba`b\ncbaa", "3\nabc\nacc\na\nb\nabba\nbaab", "3\nbaa\ndc^\n`\nb\n`b`b\naaac", "3\n_ba\ndb`\nb\na\ndb`b\nc_ac", "3\ncbb\n`ab\nb\nb\n`bc`\na_aa", "3\nabb\nabc\nb\nb\nabba\nbaab", "3\na...
1054_G. New Road Network
The king of some country N decided to completely rebuild the road network. There are n people living in the country, they are enumerated from 1 to n. It is possible to construct a road between the house of any citizen a to the house of any other citizen b. There should not be more than one road between any pair of citi...
{ "input": [], "output": [] }
{ "input": [ "2\n4 3\n0011\n1110\n0111\n3 3\n011\n101\n110\n" ], "output": [ "YES\n1 2\n2 3\n3 4\nNO\n" ] }
{ "input": [ "2\n4 3\n0011\n1111\n0111\n3 3\n011\n101\n110\n", "2\n4 3\n0011\n1110\n0111\n3 3\n011\n111\n110\n", "2\n4 3\n0011\n1110\n0101\n3 3\n011\n101\n110\n", "2\n4 3\n1011\n1100\n0111\n3 3\n011\n111\n110\n", "2\n4 3\n0011\n0111\n0111\n3 3\n011\n101\n110\n", "2\n4 3\n0011\n0111\n1111\n3 3\...
1459_A. Red-Blue Shuffle
There are n cards numbered 1, …, n. The card i has a red digit r_i and a blue digit b_i written on it. We arrange all n cards in random order from left to right, with all permutations of 1, …, n having the same probability. We then read all red digits on the cards from left to right, and obtain an integer R. In the sa...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n777\n111\n3\n314\n159\n5\n09281\n09281\n" ], "output": [ "\nRED\nBLUE\nEQUAL\n" ] }
{ "input": [ "3\n3\n777\n111\n3\n314\n159\n5\n14195\n09281\n", "3\n3\n777\n111\n3\n314\n159\n5\n14195\n18546\n", "3\n3\n777\n111\n3\n196\n159\n5\n14195\n11156\n", "3\n3\n777\n111\n3\n314\n159\n5\n14195\n18703\n", "3\n3\n150\n111\n3\n314\n159\n5\n14195\n11156\n", "3\n3\n777\n100\n3\n591\n159\n5...
1509_B. TMT Document
The student council has a shared document file. Every day, some members of the student council write the sequence TMT (short for Towa Maji Tenshi) in it. However, one day, the members somehow entered the sequence into the document at the same time, creating a jumbled mess. Therefore, it is Suguru Doujima's task to fig...
{ "input": [], "output": [] }
{ "input": [ "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nTMTTTT\n6\nTTMMTT\n" ], "output": [ "\nYES\nNO\nYES\nNO\nYES\n" ] }
{ "input": [ "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nMTTTTT\n6\nTTMMTT\n", "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nMTTTTT\n6\nTTMTTM\n", "5\n3\nTMT\n3\nMTT\n6\nTTTMMT\n6\nTMTTTT\n6\nTTMMTT\n", "5\n3\nTTM\n3\nTTM\n6\nTMTMTT\n6\nMTTTTT\n6\nTTMMTT\n", "5\n3\nTTM\n3\nTMT\n6\nTMTMTT\n6\nMTTTTT\n6\nTTMMTT\n", "...
162_F. Factorial zeros
You are given a positive integer n. Output the number of trailing zeros in n! (n! denotes a product of integers between 1 and n, inclusive). Input The only line of input contains an integer n (1 ≤ n ≤ 1000000). Output Output the number of trailing zeros in n!. Examples Input 6 Output 1 Input 24 Output 4...
{ "input": [], "output": [] }
{ "input": [ "6\n", "24\n" ], "output": [ "1\n", "4\n" ] }
{ "input": [], "output": [] }
brio-and-his-house-10
Brio wants to get a beautiful house constructed near the National Highway. As his in laws are very much fond of triangles, he decided to give his house a perfect Triangular Shape. Now, here comes the problem that he faces. The plots in Hackers' Land are all circular in shape. You need to help Brio find the area of the ...
{ "input": [], "output": [] }
{ "input": [ "2\n5.0000 3.0000 4.0000\n12.0000 13.0000 5.0000\n\n\nSAMPLE" ], "output": [ "19.6344\n132.7284\n" ] }
{ "input": [ "2\n5.0000 3.5218061682463278 4.0000\n12.0000 13.0000 5.0000\n\n\nSAMPLE", "2\n5.0000 3.5218061682463278 4.0000\n12.0000 13.173512536333314 5.0000\n\n\nSAMPLE", "2\n5.757769514565519 3.5218061682463278 4.0000\n12.0000 13.173512536333314 5.0000\n\n\nSAMPLE", "2\n5.757769514565519 3.5218061...
mishtis-castle
To defend her castle Count Mishti has invented a new challenge. In this challenge, the participant goes to a room that has n corridors and each corridor has n cells. Each cell has some coins of gold in it i.e. the jth cell of the ith corridor has a[i][j] gold coins ( 1 ≤ i ≤ n && 1 ≤ j ≤ n). The participant starts at ...
{ "input": [], "output": [] }
{ "input": [ "2\n2 7\n0 0\n8 0\n2 5\n0 1\n3 0\n\nSAMPLE" ], "output": [ "1\n-1" ] }
{ "input": [], "output": [] }
palindromic-prime
Consider the palindromic prime numbers(Numbers which are palindrome as well as prime).Let p be the product of non zero digits of a nth palindromic prime number.Let product of digits of a palindromic prime is multiplied by a number m to generate number q(q=p*m).Your task is simple; you have to find number of divisors of...
{ "input": [], "output": [] }
{ "input": [ "1\n2 1\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [], "output": [] }
tshirtselection-1
Ben believes a lot in tarot cards. He believes that they are lucky for him. He even decides to wear clothes according to the color predicted by a draw of a card. This irritates his wife, because sometimes he wears the same color t-shirt continuously if his cards so predict. Now, his wife wants to go on a vacation wit...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n1 2 3 4 5\n6\n1 2 1 3 1 5\n\n\nSAMPLE" ], "output": [ "1 5\n2 4\n" ] }
{ "input": [ "2\n5\n1 2 3 4 5\n6\n1 2 1 3 1 8\n\n\nSAMPLE", "2\n5\n0 2 6 4 5\n6\n1 2 2 3 1 8\n\n\nSAMPLE", "2\n5\n0 2 6 8 5\n6\n1 2 2 3 2 8\n\n\nSAMPLE", "2\n5\n1 2 3 4 5\n6\n1 2 0 3 1 5\n\n\nSAMPLE", "2\n5\n1 1 3 4 5\n6\n1 2 0 3 1 10\n\n\nSAMPLE", "2\n5\n2 2 3 4 5\n5\n1 2 1 3 1 15\n\n\nSAMPLE...
p02583 AtCoder Beginner Contest 175 - Making Triangle
We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i. In how many ways can we choose three of the sticks with different lengths that can form a triangle? That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions: ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1", "10\n9 4 6 1 9 6 10 6 6 8", "6\n4 5 4 3 3 5", "5\n4 4 9 7 5" ], "output": [ "0", "39", "8", "5" ] }
{ "input": [ "2\n1 0", "10\n9 4 8 1 9 6 10 6 6 8", "6\n4 5 8 3 3 5", "5\n4 4 3 7 5", "10\n9 4 16 1 9 6 10 6 6 8", "6\n4 5 6 3 3 5", "5\n4 0 3 7 5", "10\n9 7 16 1 9 6 10 6 6 8", "5\n4 -1 0 7 5", "10\n9 7 13 2 9 6 10 6 6 8", "10\n9 7 22 2 9 6 10 6 6 8", "6\n1 5 7 3 7 5", ...
p02714 AtCoder Beginner Contest 162 - RGB Triplets
We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j. Constraints * 1 \leq N \leq 4000 * S is a string of length N consisting of...
{ "input": [], "output": [] }
{ "input": [ "4\nRRGB", "39\nRBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB" ], "output": [ "1", "1800" ] }
{ "input": [ "4\nBGRR", "39\nBBBGBBBRBGBRBGBRBGGBRRRBBGRRBBGGBRGBRBR", "39\nRBRBRRBGGBBRRGBBGRRBGGBRBGBRBGBRBBBGBBB", "4\nGRRB", "39\nRRRBGRBGGBBRRGBBRBRBGGBRBGBRBGBRBBBGBBB", "39\nBBBGBBBRBGBRBGBRBGGBRRBBBGRRBBGGBRGRRBR", "39\nRRRBGRBGGBBRRGBBRBRBGGBRBGBRBGBBBBBGBBR", "39\nRRRBGRBGGBB...
p02843 Sumitomo Mitsui Trust Bank Programming Contest 2019 - 100 to 105
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy s...
{ "input": [], "output": [] }
{ "input": [ "615", "217" ], "output": [ "1", "0" ] }
{ "input": [ "386", "0", "59", "115", "10", "53", "3", "84", "4", "97", "8", "173", "7", "89", "5", "145", "2", "192", "1", "160", "73", "11", "12", "18", "9", "13", "14", "16", "604", "248", "3...
p02980 AtCoder Grand Contest 035 - Two Histograms
We have a square grid with N rows and M columns. Takahashi will write an integer in each of the squares, as follows: * First, write 0 in every square. * For each i=1,2,...,N, choose an integer k_i (0\leq k_i\leq M), and add 1 to each of the leftmost k_i squares in the i-th row. * For each j=1,2,...,M, choose an intege...
{ "input": [], "output": [] }
{ "input": [ "10 7", "2 3", "1 2", "314159 265358" ], "output": [ "995651918", "234", "8", "70273732" ] }
{ "input": [ "10 11", "4 3", "2 2", "314159 217986", "10 10", "1 3", "2 4", "180944 217986", "1 11", "0 3", "2 8", "180944 374453", "1 19", "1 8", "180944 99984", "1 35", "180944 102049", "1 12", "180944 191217", "1 18", "1 6", "-...
p03121 World Tour Finals 2019 - Triangular Lamps Easy
There is an infinitely large triangular grid, as shown below. Each point with integer coordinates contains a lamp. <image> Initially, only the lamp at (X, 0) was on, and all other lamps were off. Then, Snuke performed the following operation zero or more times: * Choose two integers x and y. Toggle (on to off, off t...
{ "input": [], "output": [] }
{ "input": [ "4\n-2 1\n-2 2\n0 1\n1 0" ], "output": [ "-1" ] }
{ "input": [ "4\n-2 1\n-2 2\n-1 1\n1 0", "4\n-2 2\n-2 2\n0 1\n1 0", "4\n-2 2\n-2 2\n1 1\n1 0", "4\n-2 2\n-2 2\n1 2\n1 0", "4\n-2 2\n-2 2\n1 4\n1 0", "4\n-3 1\n-2 2\n0 1\n1 0", "4\n-4 1\n-2 2\n-1 2\n1 0", "4\n-2 2\n-2 3\n0 1\n0 0", "4\n0 2\n-2 2\n1 1\n1 0", "4\n-2 2\n-2 2\n0 4\n...
p03263 AtCoder Beginner Contest 109 - Make Them Even
There is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j). In Cell (i, j), a_{ij} coins are placed. You can perform the following operation any number of times: Operation: Choose a cell that was not chosen before and con...
{ "input": [], "output": [] }
{ "input": [ "1 5\n9 9 9 9 9", "3 2\n1 0\n2 1\n1 0", "2 3\n1 2 3\n0 1 1" ], "output": [ "2\n1 1 1 2\n1 3 1 4", "3\n1 1 1 2\n1 2 2 2\n3 1 3 2", "3\n2 2 2 3\n1 1 1 2\n1 3 1 2" ] }
{ "input": [ "1 5\n9 9 9 9 11", "3 2\n1 0\n2 1\n1 -1", "2 3\n1 2 3\n0 2 1", "2 3\n1 2 3\n-1 2 1", "2 3\n1 2 6\n-1 2 1", "0 5\n9 3 15 9 11", "2 3\n0 2 7\n-1 2 0", "2 3\n0 2 7\n-1 1 0", "2 3\n0 1 7\n-1 0 0", "2 3\n0 1 2\n-1 0 0", "2 3\n0 1 2\n-1 -1 0", "2 3\n0 2 2\n-1 0 0...
p03421 AtCoder Regular Contest 091 - LISDL
Determine if there exists a sequence obtained by permuting 1,2,...,N that satisfies the following conditions: * The length of its longest increasing subsequence is A. * The length of its longest decreasing subsequence is B. If it exists, construct one such sequence. Constraints * 1 \leq N,A,B \leq 3\times 10^5 * ...
{ "input": [], "output": [] }
{ "input": [ "7 7 1", "300000 300000 300000", "5 3 2" ], "output": [ "1 2 3 4 5 6 7", "-1", "2 4 1 5 3" ] }
{ "input": [ "7 0 1", "1 1 1", "6 1 6", "6 3 3", "8 2 4", "2 1 2", "4 2 2", "3 1 3", "3 2 2", "566480 300000 300000", "5 0 2", "7 0 2", "566480 313898 300000", "5 -1 2", "7 -1 2", "566480 327138 300000", "1 -1 2", "7 -1 4", "566480 327138 364...
p03579 CODE FESTIVAL 2017 qual B - 3 Steps
Rng has a connected undirected graph with N vertices. Currently, there are M edges in the graph, and the i-th edge connects Vertices A_i and B_i. Rng will add new edges to the graph by repeating the following operation: * Operation: Choose u and v (u \neq v) such that Vertex v can be reached by traversing exactly thr...
{ "input": [], "output": [] }
{ "input": [ "6 5\n1 2\n2 3\n3 4\n4 5\n5 6", "5 5\n1 2\n2 3\n3 1\n5 4\n5 1" ], "output": [ "4", "5" ] }
{ "input": [ "6 5\n1 2\n2 3\n3 4\n4 5\n4 6", "5 5\n1 2\n2 3\n3 1\n5 3\n5 1", "6 5\n1 2\n2 2\n3 4\n4 5\n5 6", "5 5\n1 2\n2 3\n3 2\n5 4\n5 1", "6 5\n1 2\n2 3\n3 4\n4 5\n3 6", "12 5\n1 2\n2 3\n3 3\n0 5\n4 6", "9 5\n1 2\n2 3\n3 3\n0 5\n4 6", "15 5\n1 2\n2 3\n3 3\n0 5\n4 2", "8 5\n1 1\n...
p03736 AtCoder Regular Contest 073 - Many Moves
There are N squares in a row. The squares are numbered 1, 2, ..., N from left to right. You have two pieces, initially placed on square A and B, respectively. You will be asked to process Q queries of the following kind, in the order received: * Given an integer x_i, move one of the two pieces of your choice to squar...
{ "input": [], "output": [] }
{ "input": [ "8 3 1 8\n3 5 1", "9 2 1 9\n5 9", "9 2 1 9\n5 1", "11 16 8 1\n1 1 5 1 11 4 5 2 5 3 3 3 5 5 6 7" ], "output": [ "7", "4", "4", "21" ] }
{ "input": [ "8 3 1 8\n1 5 1", "9 1 1 9\n5 9", "11 16 8 1\n1 2 5 1 11 4 5 2 5 3 3 3 5 5 6 7", "9 2 1 6\n5 9", "9 2 1 9\n1 1", "8 3 1 8\n1 7 1", "9 2 1 9\n2 1", "11 16 8 1\n1 3 5 1 11 8 5 2 5 3 3 3 5 5 6 7", "11 16 8 1\n1 1 3 1 11 4 5 2 5 3 3 3 5 5 6 7", "12 16 11 1\n1 1 5 1 11 ...
p03898 CODE FESTIVAL 2016 Relay (Parallel) - Problem on Tree
There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects the vertices p_i and q_i. Among the sequences of distinct vertices v_1, v_2, ..., v_M that satisfy the following condition, find the maximum value of M. * For every 1 \leq i < M, the path connecting the vertices v_i and v_{i+1}...
{ "input": [], "output": [] }
{ "input": [ "10\n7 9\n1 2\n6 4\n8 1\n3 7\n6 5\n2 10\n9 6\n2 6", "4\n1 2\n2 3\n2 4" ], "output": [ "8", "3" ] }
{ "input": [ "10\n7 9\n1 2\n6 5\n8 1\n3 7\n6 5\n2 10\n9 6\n2 6", "10\n7 9\n1 2\n6 4\n8 1\n3 7\n2 5\n2 10\n9 6\n2 6", "10\n7 9\n1 2\n6 4\n8 1\n3 1\n6 5\n2 10\n9 6\n2 6", "4\n1 2\n2 3\n4 4", "4\n1 2\n3 3\n4 4", "4\n2 2\n3 3\n4 4", "4\n1 3\n2 3\n4 2", "10\n7 9\n1 2\n6 4\n8 1\n3 7\n2 5\n2 ...
p00004 Simultaneous Equation
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution. Input The input consists of several data sets, 1 line for each data set. In a ...
{ "input": [], "output": [] }
{ "input": [ "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5", "2 -1 -3 1 -1 -3\n2 -1 -3 -9 9 27" ], "output": [ "-1.000 2.000\n1.000 4.000", "0.000 3.000\n0.000 3.000" ] }
{ "input": [ "1 2 3 4 5 6\n2 -1 -4 -1 -1 -5", "2 -1 -3 1 0 -3\n2 -1 -3 -9 9 27", "1 2 3 4 5 5\n2 -1 -4 -1 -1 -5", "3 -1 -3 1 0 -3\n2 -1 -3 -9 9 27", "1 2 3 4 5 4\n2 -1 -4 -1 -1 -5", "3 -1 -3 1 0 -3\n2 -1 -3 -9 18 27", "1 1 3 4 5 4\n2 -1 -4 -1 -1 -5", "3 -2 -3 1 0 -3\n2 -1 -3 -9 18 27",...
p00136 Frequency Distribution of Height
The height of the student was measured at the medical examination. Create a program that takes height data as input, creates a frequency distribution, and outputs it. The frequency distribution is divided into 6 classes in 5 cm increments, and the number of people is indicated by * (half-width asterisk). However, if th...
{ "input": [], "output": [] }
{ "input": [ "4\n180.3\n168.2\n165.5\n175.3", "21\n179.4\n171.5\n156.6\n173.0\n169.4\n181.2\n172.4\n170.0\n163.6\n165.9\n173.5\n168.2\n162.5\n172.0\n175.1\n172.3\n167.5\n175.9\n186.2\n168.0\n178.6" ], "output": [ "1:\n2:**\n3:\n4:*\n5:*\n6:", "1:***\n2:*****\n3:*******\n4:****\n5:*\n6:*" ] }
{ "input": [ "4\n180.3\n168.42932428490565\n165.5\n175.3", "21\n180.11768905370886\n171.5\n156.6\n173.0\n169.4\n181.2\n172.4\n170.0\n163.6\n165.9\n173.5\n168.2\n162.5\n172.0\n175.1\n172.3\n167.5\n175.9\n186.2\n168.0\n178.6", "4\n181.18433876305002\n170.39693722948385\n166.4360577935364\n175.91022475280127...
p00269 Arts and Crafts
Izua University Elementary School is famous as one of Japan's leading competition programmer training schools. The teachers at this school have a wide range of algorithmic knowledge and utilize it on a daily basis. As a teacher, you will be in charge of drawing and crafting classes this year. In this class, all childre...
{ "input": [], "output": [] }
{ "input": [ "2 2 1\n5 3\n2 2\n3 3 1\n2 0\n1 2\n2 2\n1 1\n2 2 1\n5 3\n2 2\n3 2 1\n2 0\n1 2\n2 2\n1 1\n2 2 2\n5 3\n2 2\n3 2 1\n2 0\n1 2\n2 2\n1 1\n4 3 1\n2 2 1\n3 2 2\n2 3 3\n1 2 2\n5 4 3\n1 1 0\n1 0 1\n1 0 2\n1 1 2\n2 2 2\n1 0 1\n2 0 2\n1 1 1\n0 0 0" ], "output": [ "-1\n9\n6\n7" ] }
{ "input": [ "2 2 1\n5 3\n2 2\n3 2 1\n2 0\n1 2\n2 2\n1 1\n2 2 1\n5 3\n2 2\n3 2 1\n2 0\n1 2\n2 2\n1 1\n2 2 2\n5 3\n2 2\n3 2 1\n2 0\n1 2\n2 2\n1 1\n4 3 1\n2 2 1\n3 2 2\n2 3 3\n1 2 2\n5 4 3\n1 1 0\n1 0 1\n1 0 2\n1 1 2\n2 2 2\n1 0 1\n2 0 2\n1 1 1\n0 0 0", "2 2 1\n5 3\n2 2\n3 2 1\n2 0\n1 2\n2 2\n1 1\n2 2 1\n5 3\n2...
p00457 Chain
problem There are the following games. N characters are lined up in a vertical row. The color of these characters is red, blue, or yellow, and in the initial state, four or more characters of the same color are not lined up in a row. The player can select a character at a certain position and change it to another col...
{ "input": [], "output": [] }
{ "input": [ "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0" ], "output": [ "3\n12" ] }
{ "input": [ "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n5\n2\n1\n3\n2\n1\n3\n0", "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n2\n1\n2\n5\n2\n1\n3\n2\n1\n3\n0", "12\n3\n2\n1\n1\n2\n3\n2\n0\n2\n1\n1\n3\n12\n3\n2\n1\n2\n2\n5\n2\n1\n3\n2\n1\n3\n0", "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\...
p00647 It's our delight!!
You are a student of University of Aizu. And you work part-time at a restaurant. Staffs of the restaurant are well trained to be delighted to provide more delicious products faster. The speed providing products particularly depends on skill of the staff. So, the manager of the restaurant want to know how long it take...
{ "input": [], "output": [] }
{ "input": [ "5\n12:57 59\n20:12 15\n12:19 21\n18:52 03\n16:09 14\n0" ], "output": [ "lunch 100\ndinner 50\nmidnight no guest" ] }
{ "input": [ "5\n12:57 59\n20:22 15\n12:19 21\n18:52 03\n16:09 14\n0", "5\n12:57 59\n22:02 15\n12:19 21\n18:52 03\n16:09 14\n0", "5\n12:57 105\n20:12 15\n12:19 21\n18:52 03\n16:09 14\n0", "5\n12:57 59\n20:22 15\n12:19 38\n18:52 03\n16:09 14\n0", "5\n21:57 59\n20:22 30\n12:19 38\n18:52 3\n16:09 14\...
p00791 Trapezoids
If you are a computer user, you should have seen pictures drawn with ASCII characters. Such a picture may not look as good as GIF or Postscript pictures, but is much easier to handle. ASCII pictures can easily be drawn using text editors, and can convey graphical information using only text-based media. Program s extra...
{ "input": [], "output": [] }
{ "input": [ "7\n********\n* *\n* *** *\n* * * *\n* *** *\n* *\n********\n9\n\n***\n* *\n***** *****\n* *\n*** *****\n* *\n* *\n***\n11\n**** *******************\n* * ********* * *\n****** * * **** ...
{ "input": [ "7\n********\n* *\n* *** *\n* * * *\n* *** *\n* *\n********\n9\n\n***\n* *\n***** *****\n* *\n*** *****\n* *\n* *\n***\n11\n**** *******************\n* * ********* * *\n****** * * **** ...
p00923 |C(O||W||A*RD*||S)* CROSSWORD Puzzle|
The first crossword puzzle was published on December 21, 1913 by Arthur Wynne. To celebrate the centennial of his great-great-grandfather's invention, John "Coward" Wynne1 was struggling to make crossword puzzles. He was such a coward that whenever he thought of a tricky clue for a word, he couldn’t stop worrying if pe...
{ "input": [], "output": [] }
{ "input": [ "2 2\n^(C|I|T|Y)*$\n^(C|O|P|S)*$\n^(F|L|I|P)*$\n^(B|A|C|K)*$\n2 2\n^HE|LL|O*$\n^(P|L|E|A|S|E)*$\n^(H|L)*$\n^EP|IP|EF$\n4 4\n^LONG|TALL|S*ALLY$\n^(R*EV*|OL*U(TIO)*N)*$\n^(STRAWBERRY|F*I*E*L*D*S*|FOREVER)*$\n^P.S.|I|LOVE|YOU$\n^(RE|A|L)((L|OV*E)*)$\n^(LUC*Y*|IN.THE.SKY)(WITH|DI*A*M*ON*D*S*)$\n^(IVE*|GO...
{ "input": [ "2 2\n^(C|I|T|Y)*$\n^(C|O|P|S)*$\n^(F|L|I|P)*$\n^(B|A|C|K)*$\n2 2\n^HE|LL|O*$\n^(P|L|E|A|S|E)*$\n^(H|L)*$\n^EP|IP|FE$\n4 4\n^LONG|TALL|S*ALLY$\n^(R*EV*|OL*U(TIO)*N)*$\n^(STRAWBERRY|F*I*E*L*D*S*|FOREVER)*$\n^P.S.|I|LOVE|YOU$\n^(RE|A|L)((L|OV*E)*)$\n^(LUC*Y*|IN.THE.SKY)(WITH|DI*A*M*ON*D*S*)$\n^(IVE*|GO...
p01056 Lights of Apartment
Problem A-chan, Rika-chan, and Hart-kun came to visit the condominium. The three decided to sneak into a room where they could manage the electricity in all the rooms and play a trick. This condominium has the shape of n cubes lined up in a row. Each cube has one side length increasing by 1 from the west (1,2,3, ...,...
{ "input": [], "output": [] }
{ "input": [ "3 2\n2 2\n2 3", "3 1\n0 4" ], "output": [ "14", "27" ] }
{ "input": [ "3 2\n2 2\n2 4", "3 1\n0 3", "4 2\n2 2\n2 4", "8 2\n2 2\n2 4", "10 2\n2 2\n2 4", "10 2\n2 2\n2 8", "4 1\n0 3", "18 2\n2 2\n2 4", "8 2\n2 2\n2 8", "3 0\n2 2\n2 7", "4 0\n0 3", "18 2\n0 2\n2 4", "9 2\n2 2\n2 8", "9 2\n2 3\n2 8", "2 0\n2 2\n1 7", ...
p01188 Slippy Floors
The princess of the Fancy Kingdom has been loved by many people for her lovely face. However the witch of the Snow World has been jealous of the princess being loved. For her jealousy, the witch has shut the princess into the Ice Tower built by the witch’s extreme magical power. As the Ice Tower is made of cubic ice b...
{ "input": [], "output": [] }
{ "input": [ "3\n10 30\n......#############...........\n....##_____________#..........\n...#________________####......\n..#________####_________#.....\n.#________#....##________#....\n#_________#......#________#...\n#__________###...#_____^^_#...\n.#__________A_#...#____^^_#...\n..#___________#...#_>__###....\n.....
{ "input": [ "3\n10 30\n......#############...........\n....##_____________#..........\n...#________________####......\n..#________####_________#.....\n.#________#....##________#....\n#_________#......#________#...\n#__________###...#_____^^_#...\n.#__________A_#...#____^^_#...\n..#___________#...#_>__###....\n.....
p01325 The Melancholy of Thomas Right
The story of yesterday evening. After finishing the lecture at the university as usual and feeding the cats on campus, which is a daily routine, when I got home, people in work clothes were working on replacing the door of my house. .. That's not a particularly headache for me, but the brown door with the familiar keys...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2\n2 1\n3\n2 1 2\n2 1 2\n10\n0 1 1 2 5 5 5 8 8 9\n0 1 3 3 3 6 6 6 7 9\n0", "10\n0 1 1 2 5 5 5 8 8 9\n0 1 3 3 3 6 6 6 7 9", "3\n2 1 2\n2 1 2", "2\n1 2\n2 1" ], "output": [ "Yes\nNo\nYes", "Yes", "No", "Yes" ] }
{ "input": [ "2\n1 2\n2 1\n3\n0 1 2\n2 1 2\n10\n0 1 1 2 5 5 5 8 8 9\n0 1 3 3 3 6 6 6 7 9\n0", "10\n0 1 1 2 5 5 5 8 8 9\n0 1 4 3 3 6 6 6 7 9", "2\n0 0\n0 0", "2\n1 2\n2 1\n3\n2 1 2\n2 1 2\n10\n0 1 1 2 5 5 5 8 8 9\n0 1 3 3 3 6 6 6 8 9\n0", "2\n1 2\n2 0\n3\n2 1 2\n2 0 2\n10\n0 1 1 2 5 5 5 8 8 9\n0 1 ...
p01493 DisconnectedGame
Example Input 3 NNN NNN NNN Output Taro
{ "input": [], "output": [] }
{ "input": [ "3\nNNN\nNNN\nNNN" ], "output": [ "Taro" ] }
{ "input": [ "3\nNNN\nNNO\nNNN", "3\nNMN\nNNO\nNNN", "3\nNMN\nNNP\nNNN", "3\nMMN\nNNO\nNNN", "3\nMMN\nONN\nNNN", "3\nMMN\nONN\nMNN", "3\nMMN\nNNO\nMNN", "3\nMMN\nNNO\nMON", "3\nNMN\nNNO\nMON", "3\nNMN\nNNO\nMNN", "3\nNMN\nMNO\nMNN", "3\nNLN\nMNO\nMNN", "3\nNLN\nMNO\...
p01655 Ancient Scrolls
Problem Statement You bought 3 ancient scrolls from a magician. These scrolls have a long string, and the lengths of the strings are the same. He said that these scrolls are copies of the key string to enter a dungeon with a secret treasure. However, he also said, they were copied so many times by hand, so the string ...
{ "input": [], "output": [] }
{ "input": [ "3 1\nACM\nIBM\nICM\n5 2\niwzwz\niziwi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLnlyyGDA\nyLRnvyyGDA\n0 0" ], "output": [ "ICM\niwiwi\n-1\nAARAlNyGDA" ] }
{ "input": [ "3 1\nACM\nIBM\nICM\n5 2\niwzwz\niziwi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLolyyGDA\nyLRnvyyGDA\n0 0", "3 1\nACM\nIBM\nICM\n5 2\niwzwz\niziwi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyGWx\nyyLolyyGDA\nyLGnvyyRDA\n0 0", "3 1\nACM\nIBM\nICM\n1 2\niwzwz\niwizi\nzwizi\n1 0\nA\nB\nC\n10 5\njLRNlNyG...
p01806 Dice Stamp
Dice Stamp Dice stamp At a local fair, you found a game store you've never seen before. This is a game in which N 6-sided dice are dropped and rolled on the board. More precisely, N buttons are tied to N dice on a one-to-one basis, and pressing the button causes the corresponding dice to fall onto the board. It is a ...
{ "input": [], "output": [] }
{ "input": [ "1\n0 0\n1 2 3 4 5 6\nRRRRBBBBLLLLFFFF\n2\n0 0\n1 1 1 1 1 1\nRRR\n2 2\n100 100 100 100 100 100\nFFF\n1\n1000 -1000\n1 2 3 4 5 6\nLFRB\n4\n-3 -4\n1 2 3 4 5 6\nBBBBBBBB\n4 -3\n11 12 13 14 15 16\nLLLLLLLL\n3 4\n21 22 23 24 25 26\nFFFFFFFF\n-4 3\n31 32 33 34 35 36\nRRRRRRRR\n3\n-2 -2\n9 3 1 1 1 1\nRRRRBL...
{ "input": [ "1\n0 0\n1 2 3 4 5 6\nRRRRBBBBLLLLFFFF\n2\n0 0\n1 1 1 1 1 1\nRRR\n2 2\n100 100 100 100 100 100\nFFF\n1\n1010 -1000\n1 2 3 4 5 6\nLFRB\n4\n-3 -4\n1 2 3 4 5 6\nBBBBBBBB\n4 -3\n11 12 13 14 15 16\nLLLLLLLL\n3 4\n21 22 23 24 25 26\nFFFFFFFF\n-4 3\n31 32 33 34 35 36\nRRRRRRRR\n3\n-2 -2\n9 3 1 1 1 1\nRRRRBL...
p01941 Indecision
D: Indecision-Indecision- problem Ebi-chan has been addicted to gal games lately, and her goal now is to capture two heroines at the same time. Ebi-chan can use several events to increase her liking from the heroine, but only one heroine can be selected for each event. However, Ebi-chan does not forget to follow the...
{ "input": [], "output": [] }
{ "input": [ "3 4\n3 2 2\n2 1 1\n2 1 1" ], "output": [ "5" ] }
{ "input": [ "3 4\n4 2 2\n2 1 1\n2 1 1", "3 4\n4 2 2\n2 1 1\n3 2 1", "3 4\n4 2 2\n2 1 2\n3 2 1", "1 4\n4 2 2\n3 1 4\n3 2 1", "1 4\n5 2 5\n3 1 1\n3 2 2", "1 4\n4 1 4\n2 1 -1\n0 3 0", "3 4\n3 2 2\n2 1 1\n2 1 2", "1 4\n5 3 2\n3 1 1\n3 2 2", "3 4\n4 2 2\n4 1 1\n3 2 1", "3 4\n4 2 2\...
p02090 Shuttle Run
C: Shuttle Run Story University H has a unique physical fitness test program, aiming to grow the mindset of students. Among the items in the program, shuttle run is well-known as especially eccentric one. Surprisingly, there are yokans (sweet beans jellies) on a route of the shuttle run. Greedy Homura-chan would like...
{ "input": [], "output": [] }
{ "input": [ "1 3\n1 2" ], "output": [ "2" ] }
{ "input": [ "1 3\n1 4", "1 3\n1 5", "1 3\n1 10", "1 0\n0 2", "1 3\n1 1", "1 3\n1 9", "1 0\n0 0", "1 3\n0 15", "1 3\n2 12", "1 3\n2 24", "1 3\n2 13", "1 3\n1 8", "1 3\n1 18", "1 2\n0 3", "1 3\n1 20", "1 5\n2 14", "1 4\n1 6", "1 3\n1 29", "8 2...
p02222 Painting Tree
Problem statement Modulo is very good at drawing trees. Over the years, Modulo has drawn a picture of a tree with $ N $ vertices. The vertices of this tree are numbered from $ 1 $ to $ N $, and the vertices $ a_i $ and $ b_i $$ (1 \ leq i \ leq N-1) $ are directly connected by edges. All vertices are not yet painted....
{ "input": [], "output": [] }
{ "input": [ "7\n1 3\n2 3\n3 4\n4 5\n4 6\n6 7" ], "output": [ "1100111" ] }
{ "input": [ "7\n1 3\n2 3\n3 4\n4 5\n4 6\n3 7", "7\n1 3\n2 3\n3 4\n7 5\n4 6\n6 7", "7\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7", "7\n1 5\n2 3\n3 4\n1 5\n4 6\n6 4", "7\n1 3\n2 3\n3 4\n4 5\n4 6\n6 4", "7\n1 3\n2 3\n3 4\n7 5\n4 6\n3 7", "7\n1 5\n2 3\n3 4\n4 5\n4 6\n6 4", "7\n1 3\n2 3\n3 4\n4 5\n2 6\...
p02374 Range Query on a Tree
Write a program which manipulates a weighted rooted tree $T$ with the following operations: * $add(v,w)$: add $w$ to the edge which connects node $v$ and its parent * $getSum(u)$: report the sum of weights of all edges from the root to node $u$ The given tree $T$ consists of $n$ nodes and every node has a unique I...
{ "input": [], "output": [] }
{ "input": [ "6\n2 1 2\n2 3 5\n0\n0\n0\n1 4\n7\n1 1\n0 3 10\n1 2\n0 4 20\n1 3\n0 5 40\n1 4", "2\n1 1\n0\n4\n0 1 1\n1 1\n0 1 1\n1 1", "4\n1 1\n1 2\n1 3\n0\n6\n0 3 1000\n0 2 1000\n0 1 1000\n1 1\n1 2\n1 3" ], "output": [ "0\n0\n10\n60", "1\n2", "1000\n2000\n3000" ] }
{ "input": [ "2\n1 1\n0\n5\n0 1 1\n1 1\n0 1 1\n1 1", "2\n1 1\n0\n5\n0 1 2\n1 1\n0 1 1\n1 1", "6\n2 1 2\n2 3 5\n0\n0\n0\n1 4\n7\n1 0\n0 3 10\n1 2\n0 4 20\n1 3\n0 5 40\n1 4", "2\n1 1\n0\n4\n0 1 1\n1 1\n0 1 1\n1 2", "4\n1 1\n1 2\n1 3\n0\n6\n0 3 1000\n0 2 1000\n0 1 1000\n1 1\n1 2\n1 4", "2\n1 1\n0...
anubtg
Problem description It is winter super sale and all the shops have various offers. Suraj selected N items to buy and he is standing in the billing queue. It was then he noticed the offer "Buy two, get two". That means for every two items you buy, they give you two items for free. However, items can be of varying price,...
{ "input": [], "output": [] }
{ "input": [ "3\n4\n1 1 2 2\n2\n10 200\n7\n1 1 10 2 2 2 1" ], "output": [ "4\n210\n14\n" ] }
{ "input": [ "3\n4\n1 1 2 1\n2\n10 200\n7\n1 1 10 2 2 2 1", "3\n4\n1 1 2 2\n2\n10 200\n7\n1 2 10 2 2 2 1", "3\n4\n1 1 2 2\n2\n10 200\n7\n1 2 10 2 2 3 1", "3\n4\n1 1 2 2\n2\n20 200\n7\n1 2 10 2 2 3 1", "3\n4\n1 1 2 2\n2\n34 200\n7\n1 2 10 2 2 3 1", "3\n4\n1 1 2 2\n2\n10 200\n7\n1 1 13 2 2 2 1",...
chplgns
Chef has N simple polygons (non self intersecting polygons) in which no two of them intersect with each other. For any two polygons P1, P2, either P1 lies inside P2 or vice versa. Chef wants you to count number of polygons lying strictly inside each of the polygons. Input First line of the input contains an integer T...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 3 -3 -3 3 -3" ], "output": [ "1 0 2" ] }
{ "input": [ "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 1 -3 -3 3 -3", "1\n2\n6\n0 4 -1 1 2 1 0 -1 1 -2 -3 -2\n2\n-1 -1 1 -1 1 0\n2\n3 3 -2 1 -3 -3 3 -3", "1\n1\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -3 -2\n3\n-1 -1 1 -1 1 0\n2\n3 3 -4 1 -3 -3 3 -3", "1\n3\n6\n0 4 -1 1 4 1 0 -1 1 -2 -3...
equality
An equation is an equality containing one or more variables. Solving the equation consists of determining which values of the variables make the equality true. In this situation, variables are also known as unknowns and the values which satisfy the equality are known as solutions. An equation differs from an identity i...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n9 6 5\n4\n13 11 10 8" ], "output": [ "1 4 5\n1 3 4 6\n" ] }
{ "input": [ "2\n3\n9 5 5\n4\n13 11 10 8", "2\n3\n14 5 5\n4\n13 11 10 8", "2\n3\n14 5 8\n4\n13 11 10 8", "2\n3\n9 6 7\n4\n13 11 10 8", "2\n3\n9 5 5\n4\n4 11 10 8", "2\n3\n14 5 8\n4\n13 18 10 8", "2\n3\n9 5 5\n4\n4 11 10 11", "2\n3\n14 5 8\n4\n13 18 2 8", "2\n3\n1 5 5\n4\n4 11 10 11...
knightmv
Chef develops his own computer program for playing chess. He is at the very beginning. At first he needs to write the module that will receive moves written by the players and analyze it. The module will receive a string and it should report at first whether this string represents the correct pair of cells on the chess...
{ "input": [], "output": [] }
{ "input": [ "4\na1-b3\nd2-h8\na3 c4\nErrorError" ], "output": [ "Yes\nNo\nError\nError\n" ] }
{ "input": [ "4\na1-b3\nd2-h8\na3 d4\nErrorError", "4\na1b-3\nd2-h8\n3a d4\nErrorError", "4\n3-b1a\n8h-2d\n3a d4\nErrorError", "4\na1-b3\nd2-h8\n3a d4\nErrorError", "4\n3-b1a\nd2-h8\n3a d4\nErrorError", "4\n3-b1a\n8h-2d\n3a 4d\nErrorError", "4\n3-b1a\n8h-2d\na3 d4\nErrorError", "4\n4-b...
pairing
The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees are compatible. Two employees that are not compatible cannot be paired togeth...
{ "input": [], "output": [] }
{ "input": [ "2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 1" ], "output": [ "1 4\n2\n" ] }
{ "input": [ "2\n4 5\n0 1\n1 2\n2 3\n1 3\n3 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n0 3\n1 3\n1 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n1 3\n1 3\n2 0\n4 3\n0 1\n2 3\n2 0", "2\n4 5\n0 1\n1 2\n1 3\n0 3\n3 0\n4 1\n0 1\n2 3\n2 1", "2\n4 5\n-1 1\n1 2\n0 3\n1 3\n1 0\n4 3\n0 1\n1 3\n2 0", "2\n8...
sreeni
Mr. Sreeniketan the owner of Madras Super Kings is a very superstitious owner. He believes that certain gestures help the team to perform well. Whenever the team enters the field , they form a huddle to discuss strategies. Sreeni wishes that they always stay in the same cyclic order that he instructs them to. So, if th...
{ "input": [], "output": [] }
{ "input": [ "2\nBLAW\nAWBL\nAAABBL\nLBABAA" ], "output": [ "YES\nNO\n" ] }
{ "input": [ "2\nBLAW\nAWBL\nAAABBL\nAABABL", "2\nBLAW\nAWBK\n@AABBL\nAABABL", "2\nBLAW\nAWBL\n@AABBL\nAABABL", "2\nBLAX\nAWBK\n@AABBL\nAABABL", "2\nBLAX\nAWBK\n@BABBL\nAABABL", "2\nBLAX\nAWBK\n@BBABL\nAABABL", "2\nBLAX\nAWBK\n@BBABL\nAAB@BL", "2\nBLAX\nAWBK\nLBABB@\nAAB@BL", "2\nB...
1431_D. Used Markers
Your University has a large auditorium and today you are on duty there. There will be n lectures today — all from different lecturers, and your current task is to choose in which order ord they will happen. Each lecturer will use one marker to write something on a board during their lecture. Unfortunately, markers bec...
{ "input": [], "output": [] }
{ "input": [ "4\n4\n1 2 1 2\n2\n2 1\n3\n1 1 1\n4\n2 3 1 3\n" ], "output": [ "\n4 1 3 2\n1 2\n3 1 2\n4 3 2 1\n" ] }
{ "input": [], "output": [] }
1506_A. Strange Table
Polycarp found a rectangular table consisting of n rows and m columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": * cells are numbered starting from one; * cells are numbered from left to right by columns, and inside each column from top to bottom; ...
{ "input": [], "output": [] }
{ "input": [ "5\n1 1 1\n2 2 3\n3 5 11\n100 100 7312\n1000000 1000000 1000000000000\n" ], "output": [ "\n1\n2\n9\n1174\n1000000000000\n" ] }
{ "input": [ "5\n1 1 1\n2 2 3\n3 5 11\n100 100 7312\n1000000 1000010 1000000000000\n", "5\n1 1 1\n2 2 3\n3 7 11\n100 100 7312\n1000000 1000000 1000000000000\n", "5\n1 1 1\n2 2 3\n3 5 11\n100 100 7312\n1001000 1000010 1000000000000\n", "5\n1 1 1\n2 2 3\n3 6 11\n100 100 7312\n1000000 1000000 10000000000...
958_C2. Encryption (medium)
Heidi has now broken the first level of encryption of the Death Star plans, and is staring at the screen presenting her with the description of the next code she has to enter. It looks surprisingly similar to the first one – seems like the Empire engineers were quite lazy... Heidi is once again given a sequence A, but...
{ "input": [], "output": [] }
{ "input": [ "4 3 10\n3 4 7 2\n", "10 5 12\n16 3 24 13 9 8 7 5 12 12\n" ], "output": [ "16\n", "37\n" ] }
{ "input": [ "4 3 10\n3 2 7 2\n", "10 5 6\n16 3 24 13 9 8 7 5 12 12\n", "10 5 6\n16 3 24 13 9 8 7 8 12 12\n", "10 5 6\n16 3 24 1 9 8 7 3 12 12\n", "4 3 10\n3 0 7 2\n", "10 5 12\n16 3 24 13 9 8 7 5 5 12\n", "4 3 10\n0 2 7 2\n", "10 5 6\n16 3 24 13 9 8 7 1 12 12\n", "10 5 6\n16 3 24 ...
blocks
You have 4 types of lego blocks, of sizes (1 x 1 x 1), (1 x 1 x 2), (1 x 1 x 3), and (1 x 1 x 4). Assume that you have an infinite number of blocks of each type. Using these blocks, you want to make a wall of height N and width M. The wall should not have any holes in it. The wall you build should be one solid structu...
{ "input": [], "output": [] }
{ "input": [ "4\n2 2\n3 2\n2 3\n4 4\n\nSAMPLE" ], "output": [ "3\n7\n9\n3375" ] }
{ "input": [ "4\n2 2\n3 2\n2 3\n4 4\n\nELPMAS", "4\n3 2\n3 2\n2 3\n4 4\n\nELPMAS", "4\n3 2\n3 2\n2 3\n4 5\n\nELPMAS", "4\n2 2\n4 2\n2 3\n4 4\n\nSAMPLE", "4\n3 2\n3 2\n3 3\n4 4\n\nELPMAS", "4\n3 2\n3 2\n2 6\n4 5\n\nELPMAS", "4\n2 2\n3 2\n2 3\n7 4\n\nELPMBS", "4\n3 2\n4 2\n2 6\n4 5\n\nEL...
painting-the-road
There is a kingdom, that has a long straight road of length L meters and width 0. Coordinate x on the road denotes point that is at x meters from the start of the road. That is coordinate 0 denotes beginning of the road and coordinate L denotes end of the road. The road has to be painted with color. There are K proposa...
{ "input": [], "output": [] }
{ "input": [ "3\n9 6\n2 7 10\n7 8 3\n3 4 8\n0 8 2\n5 6 4\n3 7 1\n9 6\n7 8 6\n6 9 6\n2 5 8\n3 6 10\n0 7 6\n2 9 1\n3 4\n0 3 8\n0 2 4\n0 1 10\n2 3 8\n\nSAMPLE" ], "output": [ "-1\n7\n8" ] }
{ "input": [ "3\n9 6\n2 7 10\n7 8 3\n3 4 8\n0 8 2\n5 6 4\n3 7 2\n9 6\n7 8 6\n6 9 6\n2 5 8\n3 6 10\n0 7 6\n2 9 1\n3 4\n0 3 8\n0 2 4\n0 1 10\n2 3 8\n\nSAMPLE", "3\n9 6\n2 7 10\n7 8 3\n3 4 8\n1 8 2\n5 6 8\n3 7 2\n9 6\n7 8 6\n6 9 6\n4 5 8\n3 6 10\n0 7 6\n2 9 1\n3 4\n0 3 13\n0 2 4\n0 1 10\n2 3 8\n\nSAMPLE", "3...
toss-ka-boss
Cricket has gone from a history of format which are test match, 50-50 and 20-20. Therefore, ICC decided to start a new type of format i.e. toss. For this ICC started a competition known as ‘Toss ka Boss’. Here the team captains compete with each other. For the first match we have two captains which will compete with ea...
{ "input": [], "output": [] }
{ "input": [ "5\nHHTTHTTHHH\nHHTTTTTTTTTT\nTTTTTTTTTTTTHT\nHHHHHHHHHH\nHHHHTHHHHTHHHHT\n\nSAMPLE" ], "output": [ "10\n3\n1\n55\n30\n" ] }
{ "input": [ "5\nHHTTHTTHHH\nHHTTTTTTTTTT\nTTTTTTTTTTTTHT\nHHHHHHHHHH\nHHHHTHHHHTHHHHT\n\nSBMPLE", "5\nHHTTHTTHHH\nTTTHTTTTTTHT\nTTTTTTTTTTTTHT\nHHHHHHHHHH\nHHHHTHHHHTHHHHT\n\nSBMPLE", "5\nHHTTHTTHHH\nTTTHTTTTTTHT\nTTTTTTTTTTTTHT\nHHHHHHHHHH\nHHHHHTHHTHTHHHH\n\nSALPLF", "5\nHHTTHTTHHH\nTHTTTTTTHTTT\nT...
p02569 AtCoder Library Practice Contest - Lazy Segment Tree
You are given a binary array A=(A_1,A_2,\cdots,A_N) of length N. Process Q queries of the following types. The i-th query is represented by three integers T_i,L_i,R_i. * T_i=1: Replace the value of A_j with 1-A_j for each L_i \leq j \leq R_i. * T_i=2: Calculate the inversion(*) of the array A_{L_i},A_{L_i+1},\cdots,A...
{ "input": [], "output": [] }
{ "input": [ "5 5\n0 1 0 0 1\n2 1 5\n1 3 4\n2 2 5\n1 1 3\n2 1 2" ], "output": [ "2\n0\n1" ] }
{ "input": [ "5 5\n0 1 0 0 1\n2 1 5\n1 3 4\n2 2 3\n1 1 3\n2 1 2", "5 5\n0 1 0 0 1\n2 1 5\n1 3 4\n2 2 5\n1 1 1\n2 1 2", "5 5\n0 1 0 0 1\n2 1 5\n1 3 4\n2 2 5\n2 1 3\n2 1 2", "5 5\n1 1 0 0 1\n2 1 5\n1 3 4\n2 2 5\n2 1 3\n2 1 2", "5 5\n0 1 0 0 0\n2 1 5\n1 3 4\n2 2 3\n1 2 3\n2 1 1", "5 3\n1 1 0 0 1\...
p02700 AtCoder Beginner Contest 164 - Battle
Takahashi and Aoki will have a battle using their monsters. The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively. The two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ... Here, an attack decreases ...
{ "input": [], "output": [] }
{ "input": [ "46 4 40 5", "10 9 10 10" ], "output": [ "Yes", "No" ] }
{ "input": [ "46 4 4 5", "10 9 13 10", "64 4 4 5", "5 9 13 10", "64 8 4 5", "5 9 3 10", "54 8 4 5", "5 13 3 10", "54 8 2 5", "5 14 3 10", "54 6 2 5", "5 14 3 12", "54 6 0 5", "7 14 3 12", "79 6 0 5", "7 14 1 12", "79 6 0 10", "7 7 1 12", "79 ...
p02829 AtCoder Beginner Contest 148 - Round One
Takahashi is solving quizzes. He has easily solved all but the last one. The last quiz has three choices: 1, 2, and 3. With his supernatural power, Takahashi has found out that the choices A and B are both wrong. Print the correct choice for this problem. Constraints * Each of the numbers A and B is 1, 2, or 3. * ...
{ "input": [], "output": [] }
{ "input": [ "1\n2", "3\n1" ], "output": [ "3", "2" ] }
{ "input": [ "3\n2", "1\n3", "3\n001", "3\n2", "1\n3", "3\n001" ], "output": [ "1\n", "2\n", "2\n", "1\n", "2\n", "2\n" ] }
p02966 AtCoder Grand Contest 036 - Negative Cycle
We have a weighted directed graph with N vertices numbered 0 to N-1. The graph initially has N-1 edges. The i-th edge (0 \leq i \leq N-2) is directed from Vertex i to Vertex i+1 and has a weight of 0. Snuke will now add a new edge (i → j) for every pair i, j (0 \leq i,j \leq N-1,\ i \neq j). The weight of the edge wi...
{ "input": [], "output": [] }
{ "input": [ "4\n1 1 1\n1 1 1\n1 1 1\n1 1 1", "3\n2 1\n1 4\n3 3", "10\n190587 2038070 142162180 88207341 215145790 38 2 5 20\n32047998 21426 4177178 52 734621629 2596 102224223 5 1864\n41 481241221 1518272 51 772 146 8805349 3243297 449\n918151 126080576 5186563 46354 6646 491776 5750138 2897 161\n3656 75...
{ "input": [ "4\n1 1 2\n1 1 1\n1 1 1\n1 1 1", "3\n2 1\n1 1\n3 3", "10\n190587 2038070 142162180 88207341 215145790 38 2 5 20\n32047998 21426 4177178 52 734621629 2596 102224223 5 1864\n49 481241221 1518272 51 772 146 8805349 3243297 449\n918151 126080576 5186563 46354 6646 491776 5750138 2897 161\n3656 75...
p03101 AtCoder Beginner Contest 121 - White Cells
There are H rows and W columns of white square cells. You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns. How many white cells will remain? It can be proved that this count does not depend on what rows and columns are chosen. Constraints * All values i...
{ "input": [], "output": [] }
{ "input": [ "2 4\n2 4", "5 5\n2 3", "3 2\n2 1" ], "output": [ "0", "6", "1" ] }
{ "input": [ "2 4\n2 3", "5 5\n2 2", "4 2\n2 1", "4 5\n2 2", "4 0\n2 1", "7 5\n2 2", "4 0\n0 1", "7 5\n1 2", "4 -1\n0 1", "7 5\n0 2", "4 0\n-1 1", "4 1\n2 4", "7 5\n0 1", "4 1\n3 4", "4 0\n-2 2", "4 -1\n-2 2", "12 1\n1 2", "5 -1\n-2 2", "5 0\...
p03249 AtCoder Regular Contest 103 - Distance Sums
You are given a sequence D_1, D_2, ..., D_N of length N. The values of D_i are all distinct. Does a tree with N vertices that satisfies the following conditions exist? * The vertices are numbered 1,2,..., N. * The edges are numbered 1,2,..., N-1, and Edge i connects Vertex u_i and v_i. * For each vertex i, the sum of ...
{ "input": [], "output": [] }
{ "input": [ "15\n57\n62\n47\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "2\n1\n2", "7\n10\n15\n13\n18\n11\n14\n19" ], "output": [ "1 10\n1 11\n2 8\n2 15\n3 5\n3 9\n4 5\n4 10\n5 15\n6 12\n6 14\n7 13\n9 12\n11 13", "-1", "1 2\n1 3\n1 5\n3 4\n5 6\n6 7" ] }
{ "input": [ "15\n57\n62\n37\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "2\n0\n2", "7\n10\n15\n13\n18\n11\n24\n19", "15\n57\n62\n74\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "2\n-1\n2", "7\n10\n15\n18\n18\n11\n24\n19", "15\n57\n62\n74\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\...
p03400 AtCoder Beginner Contest 092 - Chocolate
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X ...
{ "input": [], "output": [] }
{ "input": [ "5\n30 44\n26\n18\n81\n18\n6", "3\n7 1\n2\n5\n10", "2\n8 20\n1\n10" ], "output": [ "56", "8", "29" ] }
{ "input": [ "5\n30 44\n26\n18\n81\n27\n6", "3\n7 1\n1\n5\n10", "2\n8 20\n1\n19", "3\n7 1\n2\n5\n19", "2\n8 23\n1\n19", "5\n1 44\n26\n18\n76\n27\n6", "3\n1 1\n2\n5\n19", "3\n1 2\n2\n5\n15", "5\n1 52\n26\n21\n11\n27\n6", "3\n1 0\n2\n5\n15", "3\n0 0\n1\n5\n15", "5\n1 87\n...
p03565 AtCoder Beginner Contest 076 - Dubious Document 2
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more t...
{ "input": [], "output": [] }
{ "input": [ "?tc????\ncoder", "??p??d??\nabc" ], "output": [ "atcoder", "UNRESTORABLE" ] }
{ "input": [ "?tc??@?\ncoder", ">q???d?>\n_ba", "d>>>???q\na`a", "d>>>???q\naaa", "??p??d??\nabb", "?tc??@?\ncnder", "??p??d??\n`bb", "?tc??@?\nendcr", "??p??d??\n`ab", "@tc??@?\nendcr", "??p??d??\nba`", "@tc??@?\nendcq", "??p??d??\nb``", "@tc???@\nendcq", "...
p03720 AtCoder Beginner Contest 061 - Counting Roads
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? Constraints * 2≤N,M≤50 * 1≤a_i,b_i≤N * a_i ≠ b_i * All input values a...
{ "input": [], "output": [] }
{ "input": [ "4 3\n1 2\n2 3\n1 4", "8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8", "2 5\n1 2\n2 1\n1 2\n2 1\n1 2" ], "output": [ "2\n2\n1\n1", "3\n3\n2\n2\n2\n1\n1\n2", "5\n5" ] }
{ "input": [ "3 5\n1 2\n2 1\n1 2\n2 1\n1 2", "3 5\n1 2\n2 1\n1 2\n1 1\n1 2", "8 7\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8", "8 7\n1 3\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8", "2 5\n1 2\n2 1\n1 2\n2 2\n1 2", "8 7\n1 3\n3 4\n1 5\n2 8\n3 7\n5 2\n5 1\n6 8", "4 3\n1 2\n4 3\n1 4", "8 8\n1 2\n3 4...
p03880 CODE FESTIVAL 2016 Grand Final(Parallel) - Cheating Nim
A cheetah and a cheater are going to play the game of Nim. In this game they use N piles of stones. Initially the i-th pile contains a_i stones. The players take turns alternately, and the cheetah plays first. In each turn, the player chooses one of the piles, and takes one or more stones from the pile. The player who ...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n3\n4", "3\n100\n100\n100" ], "output": [ "3", "-1" ] }
{ "input": [ "3\n3\n3\n4", "3\n001\n100\n100", "3\n2\n3\n3", "3\n2\n1\n3", "3\n4\n5\n8", "3\n101\n100\n100", "3\n3\n5\n4", "3\n3\n4\n4", "3\n011\n100\n100", "3\n100\n110\n100", "3\n3\n5\n8", "3\n010\n100\n100", "3\n3\n1\n4", "3\n011\n100\n101", "3\n100\n110\...
p04041 AtCoder Regular Contest 058 - Iroha and Haiku
Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. Iroha is looking for X,Y,Z-Haiku (defined below) in integer sequences. Consider all integer sequences of length N whose elements are between 1 and 10, inclusive. Out of those 10^N sequences, how many ...
{ "input": [], "output": [] }
{ "input": [ "40 5 7 5", "4 5 7 5", "3 5 7 5", "37 4 2 3" ], "output": [ "562805100", "34", "1", "863912418" ] }
{ "input": [ "37 4 3 3", "5 4 3 3", "5 4 2 3", "0 4 2 3", "8 5 7 5", "3 3 7 5", "7 4 2 3", "37 3 3 3", "5 8 3 3", "8 4 2 3", "8 5 7 3", "7 4 1 3", "37 3 2 3", "7 8 3 3", "8 5 2 3", "8 4 7 3", "7 5 1 3", "7 3 3 3", "15 5 2 3", "5 4 7 3", ...
p00122 Summer of Pyonkichi
The University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyonkichi lives in this park. Pyonkichi is not good at hot weather, and on summer days when the sun is...
{ "input": [], "output": [] }
{ "input": [ "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 9 0\n0 0" ], "output": [ "OK\nNA" ] }
{ "input": [ "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\n0 0", "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\n0 0", "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\n6 1\n10\n6 4 3 3 1 2 0 10 4 ...
p00255 Salary for a Plumber
I am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have too many pipes, you can't connect them all in one day. Even in such a case, the master smiles and gi...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1 1\n3 3\n4\n3 3 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0" ], "output": [ "12\n48\n76" ] }
{ "input": [ "3\n1 1 1\n3 3\n4\n3 1 3 3\n1 1 1\n5\n1 2 3 4 5\n4 3 2 1\n0", "3\n1 1 1\n3 3\n4\n3 1 3 3\n1 1 1\n5\n1 2 3 4 5\n3 3 2 1\n0", "3\n0 1 1\n3 3\n4\n3 1 3 3\n1 1 1\n5\n1 2 3 4 5\n3 3 2 1\n0", "3\n0 1 1\n3 3\n4\n3 1 5 3\n1 1 1\n5\n1 2 3 4 5\n3 3 2 1\n0", "3\n1 1 2\n3 3\n4\n3 3 3 3\n1 1 1\n5\...
p00441 The Oldest Site
problem Once upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in the ruins. Was a clue to the location of the building. There is a description of the temple in the l...
{ "input": [], "output": [] }
{ "input": [ "10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0" ], "output": [ "10\n10" ] }
{ "input": [ "10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n10\n2 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0", "10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 1\n5 3\n0 5\n5 2\n10\n2 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0", "10\n9 4\n4 4\n1 1\n4 2\n2 5\n5 8\n4 1\n5 3\n0 5\n5 2\n10\n2 4\n4 3...
p00632 Ghost Buster!
The city is full of ghosts, something the average person doesn't know about. Most of them are harmless, but the trouble is that there are quite a few evil spirits that curse people. There was a girl who fought against such evil spirits. She goes to high school with a faceless face during the day, but at night she walk...
{ "input": [], "output": [] }
{ "input": [ "4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n5\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n2\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n4\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n442668\n1 10\nA#.......B\n55555554\n1 10\nA#.......B\n55555555\n0 0" ], "output": [ "18 0 6\n15 3 6\n6 0 0\n14 0 4\n72 ...
{ "input": [ "4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n5\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n2\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n4\n4 7\nA#...#B\n.#.#.#.\n.#.#.#.\n...#...\n442668\n1 10\nA#.-.....B\n55555554\n1 10\nA#.......B\n55555555\n0 0", "4 7\nA#...#B\n.#.#.#.\n.#.#.\".\n...#...\n5\n4 7\nA#...
p00776 Encryption System
Encryption System A programmer developed a new encryption system. However, his system has an issue that two or more distinct strings are `encrypted' to the same string. We have a string encrypted by his system. To decode the original string, we want to enumerate all the candidates of the string before the encryption....
{ "input": [], "output": [] }
{ "input": [ "enw\nabc\nabcdefghijklmnopqrst\nz\n#" ], "output": [ "1\nfox\n5\nacc\nacd\nbbd\nbcc\nbcd\n17711\nacceeggiikkmmooqqssu\nacceeggiikkmmooqqstt\nacceeggiikkmmooqqstu\nacceeggiikkmmooqrrtt\nacceeggiikkmmooqrrtu\nbcdefghijklmnopqrrtt\nbcdefghijklmnopqrrtu\nbcdefghijklmnopqrssu\nbcdefghijklmnopqrst...
{ "input": [ "enw\nbbc\nabcdefghijklmnopqrst\nz\n#", "enw\ncbb\nabcdefggijklmnopqrst\nz\n#", "enw\ncbb\nabcsefggijklmnopqrdt\nz\n#", "enw\nabb\nabcdefghijklmnopqrst\nz\n#", "enw\nbcc\nabcdefghijklmnopqrst\nz\n#", "enw\ncbb\ntsrqponmlkjihgfedcba\nz\n#", "enw\nabb\ntsrqponmlkjihgfedcba\nz\n#...
p00907 Find the Outlier
Professor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial function f(x) = x2 + 2x + 1, for instance, a possible expected calculation result is 1 (= f(0)), 4 (= f(1)...
{ "input": [], "output": [] }
{ "input": [ "2\n1.0\n4.0\n12.0\n16.0\n25.0\n1\n-30.5893962764\n5.76397083962\n39.3853798058\n74.3727663177\n4\n42.4715310246\n79.5420238202\n28.0282396675\n-30.3627807522\n-49.8363481393\n-25.5101480106\n7.58575761381\n5\n-21.9161699038\n-48.469304271\n-24.3188578417\n-2.35085940324\n-9.70239202086\n-47.27095106...
{ "input": [ "2\n1.0\n4.0\n12.0\n16.0\n25.0\n1\n-30.5893962764\n5.76397083962\n39.3853798058\n74.3727663177\n0\n42.4715310246\n79.5420238202\n28.0282396675\n-30.3627807522\n-49.8363481393\n-25.5101480106\n7.58575761381\n5\n-21.9161699038\n-48.469304271\n-24.3188578417\n-2.35085940324\n-9.70239202086\n-47.27095106...
p01041 Distinct Dictionary
Background There was a person who loved dictionaries. They love to make their own dictionaries. So you decided to add the ability to customize their dictionaries. Problem First, there is an empty dictionary that doesn't contain any words. Given N strings Sid and Q queries. Each query is given with a query type k and...
{ "input": [], "output": [] }
{ "input": [ "3\napple\napp\nbanana\n9\n1 1\n3 1\n3 2\n3 3\n2 1\n1 2\n3 1\n3 2\n3 3", "7\naaaab\naaa\naaaa\naaaaaabc\nabbbbbc\nab\nabbb\n13\n1 1\n3 2\n1 4\n3 2\n1 3\n3 2\n2 3\n3 3\n1 5\n1 7\n3 6\n2 5\n3 6" ], "output": [ "1\n1\n-1\n-1\n2\n-1", "1\n4\n3\n4\n7\n7" ] }
{ "input": [ "7\naaaab\naaa\naaaa\naaaaaabc\nabbbbbc\naa\nabbb\n13\n1 1\n3 2\n1 4\n3 2\n1 3\n3 2\n2 3\n3 3\n1 5\n1 7\n3 6\n2 5\n3 6", "7\naaaab\naaa\naaaa\naaa`aabc\nabbbbbc\naa\nabbb\n13\n1 1\n3 2\n1 4\n3 2\n1 3\n3 2\n2 3\n3 3\n1 5\n1 7\n3 4\n2 5\n3 6", "7\naaaab\naaa\naaba\naaaaaabc\nabbbbbc\nab\nabbb\n...
p01174 Rotation Estimation
Mr. Nod is an astrologist and has defined a new constellation. He took two photos of the constellation to foretell a future of his friend. The constellation consists of n stars. The shape of the constellation in these photos are the same, but the angle of them are different because these photos were taken on a differen...
{ "input": [], "output": [] }
{ "input": [ "3\n0.0 0.0\n1.0 1.0\n0.0 1.0\n3.0 3.0\n2.0 2.0\n3.0 2.0\n0" ], "output": [ "3.14159265359" ] }
{ "input": [], "output": [] }
p01310 Drawing Lots
Natsume loves big cats. Natsume decided to head to a corner of the schoolyard where stray cats always gather in order to brush the stray cats, which is a daily routine today. N cats gathered at the spot today. Natsume wanted to brush everyone, but suddenly she was able to do something just before she came there, and s...
{ "input": [], "output": [] }
{ "input": [ "4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n4 2 1\n10 1\n10 3" ], "output": [ "1\n0\n1\n1\n0\n1\n1\n2\n0\n1\n0\n1\n2" ] }
{ "input": [ "4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 2\n1 0 1\n0 2 1\n10 1\n10 3", "4\n3 2 1\n20 1\n10 2\n5 7 3\n70 1\n60 4\n50 2\n40 4\n30 1\n20 3\n10 3\n1 0 1\n0 0 1\n10 1\n10 4", "4\n3 2 1\n20 1\n10 2\n5 7 3\n79 1\n60 3\n50 2\n21 4\n10 1\n30 3\n18 3\n1 0 1\n0 0 1\n3 1\n10 4...
p01479 Chicken or the Egg
Time Limit: 8 sec / Memory Limit: 64 MB Example Input eggchickenegg Output egg
{ "input": [], "output": [] }
{ "input": [ "eggchickenegg" ], "output": [ "egg" ] }
{ "input": [ "egichgckenegg", "egechmilfgcgg", "egichnckegegg", "egechickgnegg", "egichgbkenegg", "egickgbhenegg", "eghchickenegg", "egichnckfgegg", "egickgbhemegg", "egibkgbhemegg", "eggchickemegg", "egechnckigegg", "egihcgbkenegg", "egickfbhenegg", "egcchn...
p01640 Get Lost
ICPC World Finals Day 5 Mr. Tee got lost in the city of R country. The trouble is that the streets are similar, so I have no idea where I am now. Country R is "sorry", so you have to return to the hotel before being attacked by the enemy. Fortunately, I only remember how it turned, so let's go random. problem \\ (w ...
{ "input": [], "output": [] }
{ "input": [ "w h g" ], "output": [ "9" ] }
{ "input": [], "output": [] }
p01791 Card Game Strategy
Example Input 4 2 58 100 10 10 50 80 Output 75 2 3
{ "input": [], "output": [] }
{ "input": [ "4 2 58 100\n10 10 50 80" ], "output": [ "75\n2 3" ] }
{ "input": [ "6 2 58 100\n10 10 50 80", "6 2 15 100\n10 10 50 80", "6 3 15 100\n10 10 50 80", "6 3 15 100\n10 10 12 80", "6 3 15 100\n10 10 20 80", "6 4 15 100\n10 10 20 80", "9 4 15 100\n10 10 20 80", "13 3 24 100\n10 10 23 80", "13 3 24 100\n20 10 23 80", "13 3 24 100\n20 18 ...