name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p03353 AtCoder Beginner Contest 097 - K-th Substring
You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also,...
{ "input": [], "output": [] }
{ "input": [ "aba\n4", "atcoderandatcodeer\n5", "z\n1" ], "output": [ "b", "andat", "z" ] }
{ "input": [ "aba\n5", "y\n1", "aba\n1", "{\n1", "|\n1", "bba\n4", "atcoderandatcodeer\n2", "aab\n5", "cba\n4", "atcoderandatcodeer\n4", "aca\n2", "atcoderandatcodeer\n3", "ada\n2", "ada\n4", "c`a\n1", "aea\n4", "dab\n2", "bae\n2", "baa\n5", ...
p03513 Code Festival Team Relay (Parallel) - Nice to Meet You
There are N islands floating in Ringo Sea, and M travel agents operate ships between these islands. For convenience, we will call these islands Island 1, 2, …, N, and call these agents Agent 1, 2, …, M. The sea currents in Ringo Sea change significantly each day. Depending on the state of the sea on the day, Agent i (...
{ "input": [], "output": [] }
{ "input": [ "5 5\n1 3\n2 4\n3 4\n3 5\n4 5", "6 6\n1 2\n2 3\n3 4\n4 5\n5 6\n1 6", "4 3\n1 3\n2 3\n3 4" ], "output": [ "18", "64", "6" ] }
{ "input": [ "6 6\n1 2\n2 3\n3 8\n4 5\n5 6\n1 6", "9 8\n1 2\n1 3\n-1 8\n4 5\n6 3\n1 6", "5 4\n1 3\n2 4\n3 4\n3 5\n4 5", "4 3\n1 3\n2 3\n1 4", "6 4\n1 2\n1 3\n-1 8\n4 5\n6 2\n1 6", "9 1\n1 2\n1 3\n-1 8\n4 5\n6 3\n1 6", "6 9\n1 2\n2 3\n3 8\n4 5\n6 6\n1 6", "9 1\n1 4\n1 3\n-1 8\n4 5\n6 1\...
p03675 AtCoder Regular Contest 077 - pushpush
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations. Constraints...
{ "input": [], "output": [] }
{ "input": [ "6\n0 6 7 6 7 0", "4\n1 2 3 4", "1\n1000000000", "3\n1 2 3" ], "output": [ "0 6 6 0 7 7", "4 2 1 3", "1000000000", "3 1 2" ] }
{ "input": [ "6\n1 6 7 6 7 0", "4\n1 4 3 4", "1\n1000010000", "3\n2 2 3", "6\n1 10 7 6 7 0", "4\n1 4 0 4", "1\n1100010000", "3\n4 2 3", "6\n1 10 7 6 4 0", "4\n0 4 0 4", "1\n1100010100", "3\n6 2 3", "6\n1 10 7 4 4 0", "4\n0 1 0 4", "1\n1100110000", "3\n6 ...
p03829 AtCoder Beginner Contest 052 - Walk and Teleport
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i. You are now at town 1, and you want to visit all the ...
{ "input": [], "output": [] }
{ "input": [ "7 1 100\n40 43 45 105 108 115 124", "7 1 2\n24 35 40 68 72 99 103", "4 2 5\n1 2 5 7" ], "output": [ "84", "12", "11" ] }
{ "input": [ "7 1 100\n40 43 45 3 108 115 124", "7 1 2\n24 35 40 26 72 99 103", "7 1 100\n40 43 45 3 108 196 37", "7 1 100\n40 67 45 3 146 196 37", "7 1 101\n40 67 45 3 146 196 37", "7 2 101\n40 67 45 3 146 196 37", "7 2 101\n40 67 30 4 146 147 37", "7 2 101\n40 105 30 4 146 147 37", ...
p03996 CODE FESTIVAL 2016 qual A - LRU Puzzle
There are N arrays. The length of each array is M and initially each array contains integers (1,2,...,M) in this order. Mr. Takahashi has decided to perform Q operations on those N arrays. For the i-th (1≤i≤Q) time, he performs the following operation. * Choose an arbitrary array from the N arrays and move the intege...
{ "input": [], "output": [] }
{ "input": [ "3 3\n6\n1 2 2 3 3 3", "2 3\n3\n3 2 1", "2 2\n3\n2 1 2", "3 2\n3\n2 1 2" ], "output": [ "No", "Yes", "Yes", "No" ] }
{ "input": [ "3 3\n6\n1 2 2 3 0 3", "1 3\n3\n3 2 1", "1 5\n3\n3 2 1", "1 5\n3\n3 0 1", "3 3\n6\n0 2 2 3 3 3", "2 3\n3\n3 0 1", "2 3\n3\n2 1 2", "4 2\n3\n2 1 2", "3 3\n6\n1 2 2 2 0 3", "0 5\n3\n3 2 1", "1 9\n3\n3 0 1", "2 4\n3\n2 1 2", "4 2\n3\n0 1 2", "6 3\n6\n1...
p00084 Search Engine
Internet search engines, such as Google, automatically sort and categorize web pages around the world to create a huge database. It also parses the search keywords entered by the user and creates an inquiry statement for database search. In each case, complicated processing is performed to realize efficient search, bu...
{ "input": [], "output": [] }
{ "input": [ "Win today's preliminary contest and be qualified to visit University of Aizu.", "Rain, rain, go to Spain." ], "output": [ "Win and visit Aizu", "Rain rain Spain" ] }
{ "input": [ "Win today's preliminary contest and be qualified to visit University fo Aizu.", "Rain, rain, go ot Spain.", "Rain, iarn, og ot Spain.", "Win todax's premiminary contest and be qualified to vhsit Uniwersity fo Aizu.", "niW todax's premiminary contest and be qualified to vhsit Uniwersi...
p00216 Cutting Down Water Bills
Mr. Matsudaira is always careful about eco-friendliness in his life. Last month's water charge was 4280 yen, which exceeded the usual target of 4000 yen, so we have been trying to save water this month. How much have you saved on your water bill compared to last month? Enter this month's water usage w [m3] and create ...
{ "input": [], "output": [] }
{ "input": [ "29\n40\n0\n-1" ], "output": [ "620\n-1120\n3130" ] }
{ "input": [ "29\n40\n-1\n-1", "29\n17\n-1\n-1", "29\n21\n-1\n-1", "29\n12\n-1\n-1", "29\n28\n-1\n-2", "29\n56\n-1\n-1", "29\n16\n-1\n1", "29\n60\n0\n-1", "29\n9\n-1\n-1", "29\n30\n-1\n-2", "29\n28\n0\n-1", "29\n32\n-1\n-1", "29\n24\n-1\n1", "29\n97\n0\n-1", ...
p00376 Red Dragonfly
It’s still hot every day, but September has already come. It’s autumn according to the calendar. Looking around, I see two red dragonflies at rest on the wall in front of me. It’s autumn indeed. When two red dragonflies’ positional information as measured from the end of the wall is given, make a program to calculate ...
{ "input": [], "output": [] }
{ "input": [ "50 25", "25 25", "20 30" ], "output": [ "25", "0", "10" ] }
{ "input": [ "50 12", "25 13", "27 30", "50 0", "25 17", "27 22", "58 0", "25 11", "27 37", "26 0", "50 11", "35 37", "26 -1", "50 14", "15 37", "22 -1", "50 6", "18 -1", "84 6", "22 13", "6 -1", "84 0", "33 13", "87 0", ...
p00594 What Color Is The Universe?
On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered, | <image> ---|--- "There are many stars in the space. What color is the universe if...
{ "input": [], "output": [] }
{ "input": [ "8\n3 1 2 3 3 1 5 3\n7\n5 2 5 3 4 5 5\n0" ], "output": [ "NO COLOR\n5" ] }
{ "input": [ "8\n3 1 2 3 3 1 5 3\n7\n5 2 5 3 4 0 5\n0", "8\n3 1 2 3 3 1 5 3\n7\n5 0 5 3 4 5 5\n0", "8\n3 1 3 3 3 1 5 3\n7\n1 2 0 3 4 0 5\n0", "8\n2 3 0 3 6 4 6 9\n7\n0 4 0 5 6 0 0\n0", "8\n3 0 3 3 3 1 5 3\n7\n5 2 5 3 4 5 5\n0", "8\n4 1 3 3 0 1 4 3\n0\n0 3 1 5 7 1 5\n0", "8\n4 1 3 3 0 2 4 5...
p00730 Cut the Cake
Today is the birthday of Mr. Bon Vivant, who is known as one of the greatest patissiers in the world. Those who are invited to his birthday party are gourmets from around the world. They are eager to see and eat his extremely creative cakes. Now a large box-shaped cake is being carried into the party. It is not beautif...
{ "input": [], "output": [] }
{ "input": [ "3 5 6\n1 18\n2 19\n1 2\n3 4 1\n1 1\n2 1\n3 1\n0 2 5\n0 0 0" ], "output": [ "4 4 6 16\n1 1 1 1\n10" ] }
{ "input": [ "3 5 6\n1 18\n2 31\n1 2\n3 4 1\n1 1\n2 1\n3 1\n0 2 5\n0 0 0", "3 5 6\n1 35\n2 31\n1 2\n3 4 1\n1 1\n2 1\n3 1\n0 2 5\n0 0 0", "3 5 6\n1 48\n2 31\n1 2\n3 4 1\n1 1\n2 1\n3 1\n0 2 5\n0 0 0", "3 5 6\n1 48\n2 6\n1 2\n3 4 1\n1 1\n2 1\n3 1\n0 2 5\n0 0 0", "3 7 6\n1 35\n2 31\n1 2\n3 4 1\n1 1\n2...
p00870 Search of Concatenated Strings
The amount of information on the World Wide Web is growing quite rapidly. In this information explosion age, we must survive by accessing only the Web pages containing information relevant to our own needs. One of the key technologies for this purpose is keyword search. By using well-known search engines, we can easily...
{ "input": [], "output": [] }
{ "input": [ "3 1\naa\nb\nccc\naabccczbaacccbaazaabbcccaa\n3 1\na\nb\nc\ncbbcbcbabaacabccaccbaacbccbcaaaccccbcbcbbcacbaacccaccbbcaacbbabbabaccc\n3 4\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
{ "input": [ "3 1\naa\nb\nccc\naabccczbaacccbaazaabbcccaa\n3 1\na\nb\nc\ncbbcbcbabaacabccaccbaacbccbcaaaccccbcbcbbcacbaacccaccbbcaacbbabbabaccc\n3 4\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
p01001 General of Taiko
Problem At a certain arcade, there is a game of playing Japanese drums according to the musical score that flows along with the song. The score consists of cells of length L, and each cell has a blank or note, a symbol that represents the action the player should take. There are two types of notes, each with a "ton" t...
{ "input": [], "output": [] }
{ "input": [ "9 0 0 0\n0 9 0 0\n0 0 0 0\n0 0 0 0\n5\n1 1 1 1 1\n1000 500\n10 10 10 10\n10 10 10 10\n10 10 10 10\n10 10 10 10\n5\n1 0 2 0 1\n1000 2000\n3 8 6 10\n0 1 6 8\n10 2 4 7\n8 6 6 8\n19\n2 2 0 2 2 0 2 1 0 1 2 0 1 2 0 1 0 2 2\n200 100\n-1 -1 -1 -1" ], "output": [ "0.3024000000\n0.0000000000\n0.512000...
{ "input": [ "9 0 0 0\n0 9 0 0\n0 0 0 0\n0 0 0 0\n5\n1 1 1 1 1\n1000 500\n10 10 10 10\n10 10 10 10\n10 10 10 10\n10 19 10 10\n5\n1 0 2 0 1\n1000 2000\n3 8 6 10\n0 1 6 8\n10 2 4 7\n8 6 6 8\n19\n2 2 0 2 2 0 2 1 0 1 2 0 1 2 0 1 0 2 2\n200 100\n-1 -1 -1 -1", "9 0 0 0\n0 9 0 0\n0 0 0 0\n0 0 0 0\n5\n1 1 1 1 1\n1000...
p01133 Dragon Fantasy
Peace, which was supposed to last forever, suddenly ended. The Demon King, who had been sealed long ago, has finally revived. But when the world was about to be covered in darkness, a brave man appeared. The hero then set out on a journey to collect legendary crystals scattered around the world. Legend has it that if y...
{ "input": [], "output": [] }
{ "input": [ "2 0 0 10 10\n1 1\n4 4\n2 0 0 10 10\n1 1\n6 6\n2 0 0 10 10\n1 1\n5 5\n0 0 0 0 0" ], "output": [ "YES\nNO\nNO" ] }
{ "input": [ "2 0 0 10 10\n2 1\n4 4\n2 0 0 10 10\n1 1\n6 6\n2 0 0 10 10\n1 1\n5 5\n0 0 0 0 0", "2 0 0 13 10\n2 1\n4 0\n2 0 0 10 18\n1 1\n6 6\n4 0 0 10 10\n1 1\n5 5\n0 0 0 0 0", "2 0 0 10 10\n2 1\n4 0\n2 0 0 10 10\n1 1\n6 6\n2 0 0 15 10\n1 0\n5 5\n0 0 0 0 0", "2 0 0 20 10\n1 1\n4 4\n0 0 0 12 10\n1 1\n6...
p01272 Shore Erosion
You are a programmer working for your local city hall. The town you live in has a thriving tourism industry, especially the beaches on the shores of remote islands. The area around this island is composed of sandy beaches, but in recent years the area of ​​the sandy beaches has decreased due to coastal erosion. The Tou...
{ "input": [], "output": [] }
{ "input": [ "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1\n0 0\n10 0\n10 10\n0 10\n0 0" ], "output": [ "22.6524758425\n23.8994949366\n32.0000000000" ] }
{ "input": [ "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1\n1 0\n10 0\n10 10\n0 10\n0 0", "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1\n1 0\n17 0\n10 10\n0 10\n0 0", "3 1\n0 0\n10 0\n5 10\n3 1\n0 0\n10 0\n0 10\n4 2\n0 0\n10 0\n10 10\n0 10\n0 0", "3 1\n0 0\n10 -1\n5 10\n3 1\n0 0\n10 0\n0 10\n4 1...
p01442 Mysterious Maze
A robot in a two-dimensional maze again. The maze has an entrance and an exit this time, though. Just as in the previous problem, the maze is made up of H × W grid cells, its upper side faces north, and each cell is either empty or wall. Unlike the previous, on the other hand, one of the empty cells is connected to th...
{ "input": [], "output": [] }
{ "input": [ "2 2 1\nL\nG.\n#S\n2 2 2\nRR\nG.\n.S\n3 3 6\nLLLLLL\nG#.\n...\n.#S\n0 0 0", "2 2 1\nL\nG.\nS\n2 2 2\nRR\nG.\n.S\n3 3 6\nLLLLLL\nG#.\n...\n.#S\n0 0 0" ], "output": [ "Yes\nNo\nYes", "Yes\nNo\nYes" ] }
{ "input": [ "2 3 1\nL\nG.\n#S\n2 2 2\nRR\nG.\n.S\n3 3 6\nLLLLLL\nG#.\n...\n.#S\n0 0 0", "2 3 1\nL\nG.\n#S\n2 2 2\nRR\n.G\n.S\n3 3 6\nLLLLLL\nG$.\n...\n.#S\n0 0 0", "2 2 1\nL\n-G\nS\n2 2 2\nRR\nG-\n.S\n3 3 6\nLLLLLL\nG#.\n.-/\n.#S\n0 0 0", "2 2 1\nL\nG.\nS\n2 2 2\nRR\nG.\n.S\n3 3 6\nLLLLLL\nG#.\n...\n...
p01591 Approximate Circle
Problem A: Approximate Circle Consider a set of n points (x1, y1), ..., (xn,yn) on a Cartesian space. Your task is to write a program for regression to a circle x2 + y2 + ax + by + c = 0. In other words, your program should find a circle that minimizes the error. Here the error is measured by the sum over square dista...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0\n100 0\n100 100\n0 100", "3\n0 0\n10 0\n5 100" ], "output": [ "-100.000 -100.000 0.000", "-10.000 -99.750 0.000" ] }
{ "input": [ "3\n0 0\n10 0\n4 100", "3\n0 0\n7 0\n4 100", "3\n0 0\n1 0\n4 100", "3\n0 0\n1 0\n7 100", "3\n1 0\n10 0\n5 100", "3\n0 0\n1 0\n3 100", "3\n0 0\n1 0\n5 100", "3\n1 0\n6 0\n5 100", "3\n0 0\n10 0\n8 100", "3\n0 0\n1 0\n2 100", "3\n0 0\n16 0\n4 100", "3\n0 0\n6 ...
p01748 Distance Sum
There are n cities and n − 1 roads, which are trees. Cities are numbered from 1 to n. When city 1 is taken as the root, the parent of city i is pi, and the distance between i and pi is di. Sunuke wants to solve the following problem for each k of 1 or more and n or less. Minimum value of the sum of the distances from ...
{ "input": [], "output": [] }
{ "input": [ "10\n4 1\n1 1\n3 1\n3 1\n5 1\n6 1\n6 1\n8 1\n4 1", "15\n1 3\n12 5\n5 2\n12 1\n7 5\n5 1\n6 1\n12 1\n11 1\n12 4\n1 1\n5 5\n10 4\n1 2" ], "output": [ "0\n3\n3\n4\n5\n7\n10\n13\n16\n19", "0\n3\n9\n13\n14\n21\n22\n29\n31\n37\n41\n41\n47\n56\n59" ] }
{ "input": [ "10\n4 1\n1 1\n3 1\n3 1\n5 1\n6 1\n6 1\n8 1\n1 1", "15\n1 3\n12 5\n5 2\n12 1\n14 5\n5 1\n6 1\n12 1\n11 1\n12 4\n1 1\n5 5\n10 4\n1 2", "15\n1 3\n12 5\n5 2\n12 1\n14 5\n6 1\n6 1\n12 1\n11 1\n12 4\n1 1\n5 5\n10 4\n1 2", "15\n1 3\n12 5\n5 2\n12 1\n14 5\n6 1\n6 1\n12 1\n11 1\n5 4\n1 1\n5 5\n3 ...
p01888 Multisect
Example Input 1 10 2 1 1 1 Output 2.0
{ "input": [], "output": [] }
{ "input": [ "1 10 2\n1 1 1" ], "output": [ "2.0" ] }
{ "input": [ "1 10 1\n1 1 1", "0 10 1\n1 1 1", "0 10 1\n1 0 1", "0 10 2\n1 -1 1", "1 10 2\n1 1 2", "1 18 2\n1 1 2", "-1 10 1\n1 1 0", "0 14 1\n1 -1 1", "2 18 2\n1 1 2", "0 10 1\n1 2 0", "1 14 1\n1 -1 1", "2 18 2\n1 2 2", "0 10 1\n0 2 0", "1 10 2\n0 1 1", "1 ...
p02025 Angel Relief
K: Relief (Angel Relief) Tenma, an angel, decides to save a city. The city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with houses in each parcel. The $ X $ th section from the north and the $ Y $ th section from the west are represented by $ (X, Y) $. The house in parc...
{ "input": [], "output": [] }
{ "input": [ "2 2\n1 2\n4 8" ], "output": [ "60" ] }
{ "input": [ "2 2\n1 2\n0 8", "2 2\n1 2\n-1 8", "2 2\n1 2\n-1 12", "2 2\n1 2\n-2 12", "0 2\n1 2\n-2 12", "2 2\n1 2\n0 14", "2 2\n1 2\n0 24", "1 2\n0 1\n-3 12", "1 2\n0 2\n-3 12", "1 2\n0 3\n-3 12", "2 2\n0 3\n-3 12", "2 2\n0 3\n-5 9", "3 1\n0 1\n1 9", "3 1\n0 2\...
p02167 Bus
Problem There are $ N $ bus stops clockwise, numbered from $ 1 $ to $ N $ in a circle. Adjacent bus stops are connected by a road. For each $ i \ (1 \ le i \ le N) $, the length of the direct connection between the bus stop $ i $ and the bus stop $ i + 1 $ is $ d_i $ meters. However, bus stop $ N + 1 $ means bus stop ...
{ "input": [], "output": [] }
{ "input": [ "4 6 7\n45 72 81 47\nR 1 47202\nL 1 2156\nL 2 95728\nR 1 30739\nL 3 39679\nL 4 86568\n3 2\n3 4\n1 2\n2 4\n4 3\n1 4\n2 1", "3 1 6\n1 2 3\nR 1 1\n1 2\n1 3\n2 1\n2 3\n3 1\n3 2" ], "output": [ "431200\n629552\n431200\n629552\n275968\n101332\n528220", "1\n3\n6\n3\n6\n7" ] }
{ "input": [ "4 6 7\n45 72 81 47\nR 1 47202\nL 1 2156\nL 2 95728\nR 1 30739\nL 3 39679\nL 4 86568\n3 2\n3 4\n1 2\n3 4\n4 3\n1 4\n2 1", "3 1 6\n1 2 3\nR 1 1\n1 2\n1 3\n2 1\n2 3\n3 1\n1 2", "3 1 6\n1 2 3\nR 1 1\n1 2\n1 3\n2 1\n2 3\n3 1\n1 3", "3 1 6\n1 2 4\nR 1 1\n1 2\n1 3\n2 1\n2 3\n3 1\n1 2", "3 1...
p02308 Cross Points of a Circle and a Line
For given a circle $c$ and a line $l$, print the coordinates of the cross points of them. Constraints * $p1$ and $p2$ are different * The circle and line have at least one cross point * $1 \leq q \leq 1,000$ * $-10,000 \leq cx, cy, x1, y1, x2, y2 \leq 10,000$ * $1 \leq r \leq 10,000$ Input The input is given in the...
{ "input": [], "output": [] }
{ "input": [ "2 1 1\n2\n0 1 4 1\n3 0 3 3" ], "output": [ "1.00000000 1.00000000 3.00000000 1.00000000\n3.00000000 1.00000000 3.00000000 1.00000000" ] }
{ "input": [ "2 0 1\n2\n0 1 4 1\n3 0 3 3", "2 0 2\n2\n0 1 4 1\n3 0 3 3", "2 0 2\n2\n0 1 4 2\n3 0 3 3", "2 0 2\n2\n0 1 4 2\n3 0 5 3", "2 0 2\n1\n0 1 4 2\n3 0 5 3", "2 0 2\n1\n0 1 4 0\n3 0 5 3", "2 0 2\n1\n0 1 8 0\n1 0 5 3", "2 0 2\n1\n0 2 8 0\n1 0 5 3", "2 0 2\n1\n0 0 8 0\n1 0 5 3",...
p02456 Set: Delete
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique. * insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation. * find($x$): Report the number of $x$ in $S$ (0 or 1). * delete($x$): Delete $x$ from $S$. Constraints ...
{ "input": [], "output": [] }
{ "input": [ "8\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\n0 2" ], "output": [ "1\n2\n3\n1\n0\n1\n3" ] }
{ "input": [ "8\n0 1\n0 2\n0 2\n2 2\n1 1\n1 2\n1 3\n0 2", "8\n0 1\n0 4\n0 2\n2 2\n1 1\n1 2\n1 3\n0 2", "8\n0 1\n0 4\n0 2\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n0 1\n0 4\n0 1\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n0 2\n0 3\n0 1\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n0 2\n0 3\n0 2\n2 2\n1 1\n1 4\n1 3\n0 2", "8\n1 1...
bipin3
Zombies zombies everywhere!!  In a parallel world of zombies, there are N zombies. There are infinite number of unused cars, each of same model only differentiated by the their colors. The cars are of K colors. A zombie parent can give birth to any number of zombie-children (possibly zero), i.e. each zombie will have...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2\n3 3" ], "output": [ "2\n12\n" ] }
{ "input": [ "2\n1 2\n3 3", "2\n2 3\n3 3", "2\n1 0\n3 3", "2\n2 1\n5 3", "2\n2 1\n5 4", "2\n2 1\n5 5", "2\n2 2\n5 5", "2\n2 2\n7 5", "2\n2 3\n7 5", "2\n2 3\n7 4", "2\n2 2\n5 3", "2\n1 3\n3 3", "2\n2 1\n5 0", "2\n2 2\n7 0", "2\n2 3\n7 9", "2\n2 6\n7 4", ...
codeit1
Jagjit Singh (Jaggi) is among the few fastest athletes of Thapar. Just before the Thapar Olympics he thought of a new way to practice. He decided he will run in intervals. In each interval , he will run at a particular speed. You have to calculate the total distance traveled by him, given the speed M and time S for eac...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n2 5\n1 6\n3 10\n5\n1 1\n2 2\n3 3\n4 10\n5 1" ], "output": [ "46\n59" ] }
{ "input": [ "2\n3\n2 5\n1 6\n6 10\n5\n1 1\n2 2\n3 3\n4 10\n5 1", "2\n3\n2 4\n1 6\n6 10\n5\n1 1\n2 2\n3 3\n4 10\n5 1", "2\n3\n2 4\n1 6\n6 10\n5\n1 1\n2 2\n3 3\n4 10\n5 0", "2\n3\n2 5\n1 6\n3 10\n5\n1 1\n2 2\n3 3\n4 10\n5 2", "2\n3\n2 5\n1 6\n6 10\n5\n1 1\n2 1\n3 3\n4 10\n5 1", "2\n3\n2 4\n1 6\...
ftrip
Alice's school is planning to take some students from her class on a field trip. Alice is really excited about it. There are a total of S students in her class. But due to budget constraints, the school is planning to take only N students for the trip. These students will be picked randomly. And each student has equal ...
{ "input": [], "output": [] }
{ "input": [ "3\n10 10 5 3\n10 4 6 4\n3 2 2 1" ], "output": [ "1.000000\n0.000000\n0.500000\n" ] }
{ "input": [ "3\n10 10 5 3\n10 4 1 4\n3 2 2 1", "3\n10 10 5 3\n10 4 6 4\n3 2 2 0", "3\n10 9 5 3\n10 8 1 2\n3 2 2 2", "3\n15 10 7 3\n10 3 4 4\n3 3 2 1", "3\n10 9 5 4\n10 8 1 2\n3 2 2 4", "3\n10 10 5 3\n10 4 1 0\n3 2 3 1", "3\n10 9 5 6\n10 8 1 2\n3 2 2 4", "3\n10 10 9 3\n10 1 1 4\n6 3 2 ...
lucky1
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Let Fd(x) equals to the number of digits d in decimal representation of the positive integer x. Chef...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n10\n100" ], "output": [ "6\n31\n1266\n" ] }
{ "input": [ "3\n3\n10\n000", "3\n2\n10\n000", "3\n2\n10\n001", "3\n1\n10\n001", "3\n2\n10\n011", "3\n2\n6\n011", "3\n1\n10\n011", "3\n1\n10\n010", "3\n0\n10\n010", "3\n0\n6\n010", "3\n0\n3\n010", "3\n-1\n3\n010", "3\n1\n3\n010", "3\n1\n1\n010", "3\n2\n1\n01...
prom06
Damian Wayne and Carrie Kelly are classmates and best friends. Since class 5, they have been in the same section. They usually sat on the last bench so that they could chat all they want during the class. One day, during the ancient martial arts period, Master Kirigi caught them and asked Damian to sit in the first ben...
{ "input": [], "output": [] }
{ "input": [ "2\ndie another day.\ni'm batman." ], "output": [ "v0w s56bzw9 vsg.\n0'4 tsb4s5." ] }
{ "input": [], "output": [] }
tdiv
ABC School is organising a sporting event. But they don’t know which game they should take up, so that every person can be divided in equally-sized teams with no one left over. Now, the school consists of various classes. You are given an array ‘A’ consisting of strength of these classes. Assuming a game of every possi...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 2 3\n3\n4 12 6\n2\n8 12" ], "output": [ "1\n2\n4" ] }
{ "input": [ "3\n3\n1 4 3\n3\n4 12 6\n2\n8 12", "3\n3\n1 4 3\n3\n4 12 6\n2\n15 12", "3\n3\n1 4 3\n3\n4 3 6\n2\n15 12", "3\n3\n1 2 3\n3\n4 12 9\n2\n8 12", "3\n3\n1 2 3\n3\n3 12 9\n2\n8 12", "3\n3\n1 7 5\n3\n4 2 6\n2\n28 3", "3\n3\n1 4 5\n1\n5 2 17\n1\n30 0", "3\n3\n1 1 3\n3\n3 12 9\n2\n...
1490_B. Balanced Remainders
You are given a number n (divisible by 3) and an array a[1 ... n]. In one move, you can increase any of the array elements by one. Formally, you choose the index i (1 ≤ i ≤ n) and replace a_i with a_i + 1. You can choose the same index i multiple times for different moves. Let's denote by c_0, c_1 and c_2 the number o...
{ "input": [], "output": [] }
{ "input": [ "4\n6\n0 2 5 5 4 8\n6\n2 0 2 1 0 0\n9\n7 1 3 4 2 10 3 9 6\n6\n0 1 2 3 4 5\n" ], "output": [ "\n3\n1\n3\n0\n" ] }
{ "input": [ "4\n6\n0 2 5 5 4 1\n6\n2 0 2 1 0 0\n9\n7 1 3 4 2 10 3 9 6\n6\n0 1 2 3 4 5\n", "4\n6\n0 2 5 5 4 1\n6\n2 0 2 1 0 0\n9\n7 1 3 4 2 10 3 9 6\n6\n1 1 2 3 4 5\n", "4\n6\n0 2 5 5 4 1\n6\n2 0 2 1 0 0\n9\n7 1 3 4 2 10 3 9 2\n6\n1 1 2 3 4 5\n", "4\n6\n0 2 5 5 4 1\n6\n2 0 2 1 0 0\n9\n7 1 3 4 2 10 3 9...
188_B. A + Reverse B
You are given numbers a and b. Calculate the sum of a and reverse of b. A reverse of a number is a number which contains the same digits in reverse order. For example, reverse of 230 is 32, and reverse of 0 is 0. Input The input contains two integers a and b (0 ≤ a, b ≤ 109), separated by a single space. The numbers ...
{ "input": [], "output": [] }
{ "input": [ "5 15\n", "73 9180\n" ], "output": [ "56\n", "892\n" ] }
{ "input": [], "output": [] }
aniruddhas-queue-4
Aniruddha is given a milestone M to reach in terms of distance. He is living in a different Galaxy where there are N days in a year.At the ith day he can walk atmost X distance.Assuming he walks optimally you need to output the minimum day number on which he will reach the milestone. Input The first input line contai...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n1 5 0 0 2\n9\n3\n1 0 3\n2\n\nSAMPLE" ], "output": [ "1\n3\n" ] }
{ "input": [ "2\n5\n1 5 0 0 2\n9\n3\n1 -1 3\n2\n\nSAMPLE", "2\n5\n1 5 0 0 2\n9\n3\n2 0 3\n2\n\nELPMAS", "2\n5\n1 5 0 0 4\n9\n3\n2 0 3\n2\n\nELPMAS", "2\n5\n1 5 0 1 2\n9\n3\n1 0 2\n2\n\nSAMPLF", "2\n5\n1 5 0 1 2\n9\n3\n1 1 1\n2\n\nSAMPLF", "2\n5\n1 5 0 0 2\n9\n3\n1 1 1\n2\n\nSAMPLF", "2\n5\...
digit
This problem is as simple as short. Just find how many numbers from A to B with sum of digits from X to Y are divisible by K. Input The first line contains 5 space-separated positive integers: A, B, X, Y, K Output Output one number - answer for the question. Constraints 0 < A, B, K ≤ 10^13 0 < X, Y ≤ 1000 A ≤...
{ "input": [], "output": [] }
{ "input": [ "5 86 1 6 4\n\nSAMPLE" ], "output": [ "6" ] }
{ "input": [], "output": [] }
get-time-in-words-now-1
Given the time in numerals we may convert it into words, as shown below: 5:00→ five o' clock 5:01→ one minute past five 5:10→ ten minutes past five 5:30→ half past five 5:40→ twenty minutes to six 5:45→ quarter to six 5:47→ thirteen minutes to six 5:28→ twenty eight minutes past five Write a program which prin...
{ "input": [], "output": [] }
{ "input": [ "5 \n47\n\nSAMPLE" ], "output": [ "thirteen minutes to six\n" ] }
{ "input": [ "5 \n47\n\nSAMPME", "5 \n54\n\nSAMPME", "5 \n5\n\nS@EPOM", "5 \n53\n\nS@EPMM", "5 \n51\n\nSAMPMD", "5 \n41\n\nEMPNAS", "5 \n55\n\nS@GPNN", "5 \n48\n\nMOPE@S", "5 \n57\n\nTAMPLE", "5 \n44\n\nEMPMAS", "5 \n50\n\nNSPH?N", "5 \n0\n\nMOPE@S", "5 ...
substring
Maggu has just joined play school. His teacher taught him A,a,B,b,C,c. He is much fascinated with these letters and now he is looking only for those strings which contains these letters only. But as i said he is a little guy he cant calculate the number of such sub-strings alone. So,he asked you (The String Calculator...
{ "input": [], "output": [] }
{ "input": [ "5\nAXa\nABC\nAXBC\nAaBbCc\nXxYyZz\n\nSAMPLE" ], "output": [ "2\n6\n4\n21\n0\n" ] }
{ "input": [ "5\nAXa\nCBA\nAXBC\nAaBbCc\nXxYyZz\n\nSAMPLE", "5\nAXa\nCBA\nAXBC\nA`BbCc\nXxYyZz\n\nSAMPLE", "5\nAXa\nB@C\nAYBC\nA`BbCc\nXxYyZz\n\nSALPME", "5\nAYa\nD@B\nAYCC\nA`CbBc\nYZyzxX\n\nSAPLME", "5\nAaY\nD@B\nCYAC\nA`CbBc\nYZyzxX\n\nSAPLME", "5\nAYa\nDB@\nBAXB\ndcBB`B\ny[YyxY\n\nEMOKAS",...
vasya-and-party
Today is Vasya's birthday. On this special occasion, he has organized a party for all of his friends. These friends are enumerated by integers from 1 to N. Each of Vasya's friends has a Knowledge Level. In addition, each of them knows an arbitrary number of other people at the party. This friendship is bidirectional an...
{ "input": [], "output": [] }
{ "input": [ "5 4\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n\nSAMPLE" ], "output": [ "1\n" ] }
{ "input": [ "5 4\n1 2 3 4 5\n1 2\n2 3\n3 3\n4 5\n\nSAMPLE", "5 4\n1 1 3 3 5\n1 2\n3 3\n3 3\n4 5\n\nSAMPLE", "5 2\n1 1 1 0 2\n1 3\n2 3\n5 0\n0 0\n\nFLPMAS", "5 4\n1 1 3 4 5\n1 2\n2 3\n3 3\n4 5\n\nSAMPLE", "5 4\n1 1 3 3 5\n1 2\n2 3\n3 3\n4 5\n\nSAMPLE", "5 4\n1 1 6 3 5\n1 2\n3 3\n3 3\n4 5\n\nSA...
p02608 AIsing Programming Contest 2020 - XYZ Triplets
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). Constraints * All values in input are integers. * 1 \leq N \leq 10^4 Input Input is given from Sta...
{ "input": [], "output": [] }
{ "input": [ "20" ], "output": [ "0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0" ] }
{ "input": [ "27", "13", "3", "2", "4", "8", "14", "1", "31", "53", "10", "5", "6", "11", "15", "9", "16", "12", "22", "7", "29", "23", "21", "18", "17", "32", "33", "45", "25", "28", "24", ...
p02739 AtCoder Grand Contest 043 - Topology
Given are a positive integer N and a sequence of length 2^N consisting of 0s and 1s: A_0,A_1,\ldots,A_{2^N-1}. Determine whether there exists a closed curve C that satisfies the condition below for all 2^N sets S \subseteq \\{0,1,\ldots,N-1 \\}. If the answer is yes, construct one such closed curve. * Let x = \sum_{i ...
{ "input": [], "output": [] }
{ "input": [ "2\n1000", "1\n10", "2\n1001", "1\n11" ], "output": [ "Possible\n6\n1 0\n2 0\n2 1\n1 1\n0 1\n0 0\n1 0", "Possible\n4\n0 0\n0 1\n1 1\n1 0\n0 0", "Impossible", "Possible\n0\n1 1" ] }
{ "input": [ "1\n0", "1\n13", "2\n1010", "2\n1100", "2\n1110", "2\n0001", "2\n0101", "1\n12", "2\n0111", "2\n1111", "2\n0011", "2\n0010", "2\n0100", "2\n1101", "2\n1011", "2\n0110", "1\n17", "1\n1", "1\n18", "1\n16", "1\n14", "1\n...
p02874 AtCoder Grand Contest 040 - Two Contests
10^9 contestants, numbered 1 to 10^9, will compete in a competition. There will be two contests in this competition. The organizer prepared N problems, numbered 1 to N, to use in these contests. When Problem i is presented in a contest, it will be solved by all contestants from Contestant L_i to Contestant R_i (inclus...
{ "input": [], "output": [] }
{ "input": [ "4\n1 20\n2 19\n3 18\n4 17", "4\n4 7\n1 4\n5 8\n2 5", "10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n456651538 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526" ], "output": [ "...
{ "input": [ "4\n0 20\n2 19\n3 18\n4 17", "4\n4 7\n1 4\n5 8\n2 8", "10\n457835016 996058008\n456475528 529149798\n455108441 512701454\n455817105 523506955\n457368248 814532746\n455073228 459494089\n888688315 774276744\n457667152 974637457\n457293701 800549465\n456580262 636471526", "4\n0 20\n2 19\n3 1...
p03008 diverta 2019 Programming Contest 2 - Squirrel Merchant
The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns. His plan is as follows: 1. Get out of the nest with N acorns in his hands. 2. Go to Exchange A and do some trades. 3. Go to Exchange B and do some trades. 4. Go to Exchange A and do some...
{ "input": [], "output": [] }
{ "input": [ "23\n1 1 1\n2 1 1" ], "output": [ "46" ] }
{ "input": [ "23\n1 1 1\n2 2 1", "23\n1 2 1\n2 1 1", "23\n1 2 1\n2 0 1", "23\n0 2 1\n2 0 1", "23\n1 1 2\n1 1 0", "23\n1 1 1\n2 0 1", "23\n1 4 1\n2 1 1", "23\n1 1 2\n2 3 0", "23\n0 2 1\n4 0 1", "23\n1 8 1\n2 1 1", "23\n0 2 1\n1 0 1", "23\n1 1 2\n2 0 0", "23\n1 5 1\n2...
p03148 AtCoder Beginner Contest 116 - Various Sushi
There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i. You are choosing K among these N pieces to eat. Your "satisfaction" here will be calculated as follows: * The satisfaction is the sum of the "base total deliciousness" and the "variety bonus". * The base total de...
{ "input": [], "output": [] }
{ "input": [ "6 5\n5 1000000000\n2 990000000\n3 980000000\n6 970000000\n6 960000000\n4 950000000", "7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n4 5", "5 3\n1 9\n1 7\n2 6\n2 5\n3 1" ], "output": [ "4900000016", "25", "26" ] }
{ "input": [ "6 5\n5 1000000000\n2 990000000\n3 1109665355\n6 970000000\n6 960000000\n4 950000000", "7 4\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n3 5", "5 3\n1 9\n1 0\n2 6\n2 5\n3 1", "7 1\n1 1\n2 1\n3 1\n4 6\n4 5\n4 5\n3 5", "5 3\n1 9\n1 0\n2 6\n2 5\n3 2", "6 5\n5 1000000000\n4 990000000\n3 1109665355\...
p03292 AtCoder Beginner Contest 103 - Task Scheduling Problem
You have three tasks, all of which need to be completed. First, you can complete any one task at cost 0. Then, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|. Here, |x| denotes the absolute value of x. Find the minimum total cost required to complete all the task. Constrain...
{ "input": [], "output": [] }
{ "input": [ "1 6 3", "100 100 100", "11 5 5" ], "output": [ "5", "0", "6" ] }
{ "input": [ "1 12 3", "100 100 000", "11 5 2", "1 24 3", "3 5 2", "1 16 4", "4 3 2", "100 111 000", "4 3 0", "2 16 7", "100 111 001", "5 3 0", "100 111 010", "110 111 110", "0 1 6", "1 1 8", "110 001 010", "0 1 8", "14 2 1", "011 001 011...
p03448 AtCoder Beginner Contest 087 - Coins
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n2\n100", "30\n40\n50\n6000", "5\n1\n0\n150" ], "output": [ "2", "213", "0" ] }
{ "input": [ "2\n2\n4\n100", "30\n40\n77\n6000", "5\n0\n0\n150", "30\n47\n77\n6000", "5\n0\n0\n0", "2\n2\n5\n100", "2\n2\n10\n100", "30\n47\n77\n10696", "5\n0\n1\n0", "2\n0\n10\n100", "30\n56\n77\n10696", "5\n1\n1\n0", "2\n0\n10\n110", "30\n56\n77\n13326", "...
p03608 AtCoder Beginner Contest 073 - joisino's travel
There are N towns in the State of Atcoder, connected by M bidirectional roads. The i-th road connects Town A_i and B_i and has a length of C_i. Joisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order). She will fly to the first town she visits, and fly back from the last town she visi...
{ "input": [], "output": [] }
{ "input": [ "4 6 3\n2 3 4\n1 2 4\n2 3 3\n4 3 1\n1 4 1\n4 2 2\n3 1 6", "3 3 3\n1 2 3\n1 2 1\n2 3 1\n3 1 4", "3 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2" ], "output": [ "3", "2", "4" ] }
{ "input": [ "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 2 2\n3 1 6", "5 3 2\n1 3\n2 3 2\n1 3 6\n1 2 2", "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 3 1\n1 4 1\n4 1 2\n3 1 6", "5 3 2\n1 3\n2 3 2\n1 3 6\n1 1 2", "3 3 3\n1 2 3\n1 2 1\n2 2 1\n3 1 4", "4 6 3\n2 3 4\n1 2 4\n2 3 6\n4 4 1\n1 4 1\n4 2 2\n3 1 6", ...
p03769 AtCoder Grand Contest 012 - Tautonym Puzzle
We will call a string x good if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `abcabcabc` and `abba` are not good. Eagle and Owl created a puzzle on ...
{ "input": [], "output": [] }
{ "input": [ "7", "299" ], "output": [ "4\n1 1 1 1", "23\n32 11 11 73 45 8 11 83 83 8 45 32 32 10 100 73 32 83 45 73 32 11 10" ] }
{ "input": [ "8", "203", "3", "45", "6", "22", "10", "35", "17", "52", "12", "84", "24", "2", "14", "0", "1", "39", "580", "9", "200", "4", "48", "13", "19", "16", "26", "40", "21", "60", "5", ...
p03938 AtCoder Grand Contest 007 - Construct Sequences
You are given a permutation p of the set {1, 2, ..., N}. Please construct two sequences of positive integers a_1, a_2, ..., a_N and b_1, b_2, ..., b_N satisfying the following conditions: * 1 \leq a_i, b_i \leq 10^9 for all i * a_1 < a_2 < ... < a_N * b_1 > b_2 > ... > b_N * a_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a...
{ "input": [], "output": [] }
{ "input": [ "3\n3 2 1", "3\n2 3 1", "2\n1 2" ], "output": [ "1 2 3\n5 3 1", "5 10 100\n100 10 1", "1 4\n5 4" ] }
{ "input": [ "2\n1 0", "2\n0 -1", "3\n2 0 1", "3\n1 3 2", "3\n1 -1 0", "3\n0 2 1", "3\n0 1 2", "3\n2 1 0", "2\n2 1", "2\n2 -1", "2\n-1 0", "2\n0 1", "2\n-1 2", "3\n1 0 2", "3\n-1 3 1", "3\n-1 0 1", "3\n0 -1 1", "3\n1 0 -1", "3\n0 -1 -2", ...
p00030 Sum of Integers
Write a program that extracts n different numbers from the numbers 0 to 9 and outputs the number of combinations that add up to s. Each n number is from 0 to 9, and the same number cannot be used in one combination. For example, if n is 3 and s is 6, the combination of the three numbers totaling 6 is 1 + 2 + 3 = 6 0 +...
{ "input": [], "output": [] }
{ "input": [ "3 6\n3 1\n0 0" ], "output": [ "3\n0" ] }
{ "input": [ "3 5\n3 1\n0 0", "3 0\n5 1\n0 0", "1 0\n5 1\n0 0", "3 6\n3 0\n0 0", "2 5\n1 1\n0 0", "2 0\n1 1\n0 0", "3 2\n0 0\n0 0", "2 2\n0 0\n0 0", "3 7\n3 1\n0 0", "3 8\n3 1\n0 0", "1 5\n1 1\n0 0", "3 5\n1 1\n0 0", "3 9\n10 1\n0 0", "3 8\n1 1\n0 0", "4 0\n...
p00161 Sport Meet
An autumn sports festival is held. There are four events: foot race, ball-carrying, obstacle race, and relay. There are n teams participating, and we would like to commend the team with the shortest total time in this 4th event as the "winner", the next smallest team as the "runner-up", and the second team from the bot...
{ "input": [], "output": [] }
{ "input": [ "8\n34001 3 20 3 8 6 27 2 25\n20941 3 5 2 41 7 19 2 42\n90585 4 8 3 12 6 46 2 34\n92201 3 28 2 47 6 37 2 58\n10001 3 50 2 42 7 12 2 54\n63812 4 11 3 11 6 53 2 22\n54092 3 33 2 54 6 18 2 19\n25012 3 44 2 58 6 45 2 46\n4\n1 3 23 1 23 1 34 4 44\n2 5 12 2 12 3 41 2 29\n3 5 24 1 24 2 0 3 35\n4 4 49 2 22 4...
{ "input": [ "8\n34001 3 20 3 8 6 27 2 25\n20941 3 5 2 41 7 19 2 42\n90585 4 8 3 12 6 46 2 34\n92201 3 28 2 47 6 37 2 58\n10001 3 50 2 42 7 12 2 54\n63812 4 11 3 11 6 98 2 22\n54092 3 33 2 54 6 18 2 19\n25012 3 44 2 58 6 45 2 46\n4\n1 3 23 1 23 1 34 4 44\n2 5 12 2 12 3 41 2 29\n3 5 24 1 24 2 0 3 35\n4 4 49 2 22 4...
p00318 Ruins
The Aiz Archaeological Society has set out to investigate the ruins of the ancient nation Iwashiro, which sinks in the Hibara Sea. The ruins are somewhere in the Hibara Sea. Therefore, I decided to use an exploration radar to roughly mark the location of the ruins by radar exploration from the coastline and estimate ho...
{ "input": [], "output": [] }
{ "input": [ "3\n0 3\n1 2\n2 1", "2\n0 2\n1 2", "2\n0 1\n3 2" ], "output": [ "1.0", "1.936", "0.0" ] }
{ "input": [ "2\n1 2\n1 2", "2\n0 1\n4 2", "2\n1 2\n0 2", "2\n2 2\n0 2", "2\n2 2\n0 1", "2\n3 2\n0 2", "2\n0 2\n0 1", "3\n-1 3\n1 2\n2 2", "2\n1 1\n0 1", "2\n0 3\n1 3", "2\n0 3\n2 3", "2\n4 4\n0 1", "2\n-1 3\n2 3", "3\n0 3\n0 2\n4 3", "2\n0 4\n1 3", "2\n...
p00488 Lunch
problem At the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The price is the total price of pasta and juice minus 50 yen. Given the price of pasta and juice for a ...
{ "input": [], "output": [] }
{ "input": [ "800\n700\n900\n198\n330" ], "output": [ "848" ] }
{ "input": [ "800\n1126\n900\n198\n330", "800\n1126\n900\n132\n330", "800\n1126\n206\n132\n330", "800\n1126\n180\n132\n330", "800\n1126\n180\n29\n330", "800\n1126\n280\n29\n330", "800\n1860\n376\n29\n330", "800\n1860\n376\n39\n330", "800\n1860\n376\n77\n330", "800\n1860\n376\n3...
p00674 Strawberry Cake
Sha, Nero, Eri, and Ko, who entered the University of Aizu Elementary School (Aizu University and Small), decided to participate in a programming contest called IPPC in order to play an active role as a competition programmer. However, IPPCs are required to participate in the contest as a team of three people, and it i...
{ "input": [], "output": [] }
{ "input": [ "4\n-100 -100\n100 -100\n100 100\n-100 100\n4\n-99 -100\n100 -100\n100 100\n-99 100\n4\n-100 -99\n100 -99\n100 100\n-100 100\n14\n-99 -70\n-92 -79\n10 -98\n37 -100\n62 -95\n77 -69\n88 -47\n92 -10\n96 28\n100 91\n42 92\n-62 92\n-88 91\n-98 64\n0" ], "output": [ "100.000000000000000 0.000000000...
{ "input": [ "4\n-100 -100\n100 -100\n100 100\n-100 100\n4\n-99 -100\n100 -100\n100 100\n-99 000\n4\n-100 -99\n100 -99\n100 100\n-100 100\n14\n-99 -70\n-92 -79\n10 -98\n37 -100\n62 -95\n77 -69\n88 -47\n92 -10\n96 28\n100 91\n42 92\n-62 92\n-88 91\n-98 64\n0", "4\n-100 -100\n100 -100\n100 100\n-100 100\n4\n-99...
p00817 True Liars
After having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ashore on a foggy island. Though he was exhausted and despaired, he was still fortunate to remember a legend of the foggy island, which he had heard from patriarchs in his childhood. This must be the island in the legen...
{ "input": [], "output": [] }
{ "input": [ "2 1 1\n1 2 no\n2 1 no\n3 2 1\n1 1 yes\n2 2 yes\n3 3 yes\n2 2 1\n1 2 yes\n2 3 no\n5 4 3\n1 2 yes\n1 3 no\n4 5 yes\n5 6 yes\n6 7 no\n0 0 0" ], "output": [ "no\nno\n1\n2\nend\n3\n4\n5\n6\nend" ] }
{ "input": [ "2 1 1\n1 2 no\n2 1 no\n3 2 1\n1 1 sey\n2 2 yes\n3 3 yes\n2 2 1\n1 2 yes\n2 3 no\n5 4 3\n1 2 yes\n1 3 no\n4 5 yes\n5 6 yes\n6 7 no\n0 0 0", "2 1 1\n1 2 no\n2 1 no\n3 2 1\n1 1 yes\n2 2 yes\n3 1 yes\n2 2 1\n1 2 yes\n2 3 no\n5 4 3\n1 2 yes\n1 3 no\n4 5 yes\n5 6 yes\n6 7 no\n0 0 0", "2 1 1\n1 2 n...
p00948 Distribution Center
Example Input 4 3 1000 1 2000 2 3000 3 Output 2 3 4 4
{ "input": [], "output": [] }
{ "input": [ "4 3\n1000 1\n2000 2\n3000 3" ], "output": [ "2 3 4 4" ] }
{ "input": [ "8 3\n1000 1\n2000 2\n3000 3", "8 3\n1010 1\n2889 2\n3000 5", "9 3\n1010 1\n2889 2\n4734 5", "9 3\n1010 2\n2889 2\n4734 5", "4 3\n1000 1\n2000 2\n3000 1", "8 3\n1000 1\n2889 2\n439 3", "16 3\n1010 1\n2889 2\n3000 3", "8 3\n1010 1\n2889 2\n4734 4", "9 3\n1010 2\n2889 2\...
p01081 Char Swap
Problem Given a string S of even length. You can swap two adjacent characters in the string S as many times as you like. How many operations do we need to do to make the string S a palindrome? If it is not possible to make a palindrome, output -1. Constraints * 2 ≤ | S | ≤ 4 x 105 * All strings are composed of lower...
{ "input": [], "output": [] }
{ "input": [ "acca", "acpcacpc", "aizu" ], "output": [ "0", "3", "-1" ] }
{ "input": [ "acccacpp", "bizu", "acpcaccp", "ffxx", "acppaccc", "xffx", "xdxd", "bjzu", "acocaccp", "ajzu", "akzu", "akyu", "bkyu", "auyk", "uayk", "yauk", "kuay", "kuby", "ktby", "ybtk", "kbty", "yctk", "ycsk", "ycsj", ...
p01217 Jaggie Spheres
Let J(n) be a three-dimensional body that * is a union of unit cubes whose all vertices lie on integer coordinates, * contains all points that are closer than the distance of √n to the origin, and * is the smallest of all such bodies. The figure below shows how J(1), J(2), and J(3) look. <image> Figure 1: Jaggie ...
{ "input": [], "output": [] }
{ "input": [ "1\n2\n3\n4\n0" ], "output": [ "6\n30\n30\n6" ] }
{ "input": [ "1\n2\n6\n4\n0", "1\n1\n6\n4\n0", "1\n1\n6\n5\n0", "1\n1\n9\n5\n0", "1\n1\n9\n2\n0", "1\n1\n10\n2\n0", "1\n1\n10\n0\n0", "1\n1\n10\n1\n0", "1\n1\n11\n1\n0", "1\n2\n6\n2\n0", "1\n2\n6\n5\n0", "1\n1\n9\n0\n0", "1\n1\n11\n2\n0", "1\n1\n10\n-1\n0", ...
p01351 Usagitobi
There is a board of m × n squares. The squares of i rows and j columns are represented by (i, j) (0 ≤ i <m, 0 ≤ j <n). When the rabbit is at (x, y), it can jump to ((x + a) mod m, (y + b) mod n) or ((x + c) mod m, (y + d) mod n) it can. Now the rabbit is at (0, 0). If you can't go back to the square that once jumped,...
{ "input": [], "output": [] }
{ "input": [ "6 6 2 2 2 4" ], "output": [ "8" ] }
{ "input": [ "2 6 2 2 2 4", "3 6 2 2 2 4", "4 6 2 2 2 8", "4 2 2 2 2 8", "4 2 1 2 2 8", "1 2 1 2 3 8", "1 5 2 0 4 2", "3 6 2 2 2 7", "3 7 2 2 2 4", "4 3 0 2 1 8", "2 5 1 2 0 2", "2 8 0 2 3 15", "2 14 0 2 2 4", "2 27 0 2 2 4", "2 13 0 4 3 15", "2 27 0 1 1...
p01533 Acrophobia
C: Acrophobia Yayoi Takasugi is a super-selling idol. There is one thing she is not good at. It's a high place ... She is extremely afraid of heights. This time, due to the producer's inadequacy, she decided to take on the following challenges on a variety show. This location will be held in a room in a ninja mansion...
{ "input": [], "output": [] }
{ "input": [ "3 4\nS.M\n...\n...\nM.G" ], "output": [ "9" ] }
{ "input": [ "3 4\nM.S\n...\n...\nM.G", "3 4\nM.S\n...\n...\nG.M", "3 4\nS.N\n...\n...\nM.G", "3 4\nM.S\n...\n...\nMG.", "3 4\nL.S\n...\n...\nN.G", "3 4\nL.S\n...\n...\nNG.", "3 4\nM.S\n...\n...\n.GM", "3 4\n.MS\n...\n...\nM.G", "3 4\n.MS\n...\n...\nG.M", "3 4\n.MS\n...\n..-\nM...
p01689 Dowsing Machine
C --Dowsing Machine Story People make noise with X and Y, but the coming era will be "D". "Paklin Monster D" is a very popular game in which "D people" search for treasure using the "D machine" developed by the secret society "R team". In this game, the person D in the square with the grid map repeatedly moves to th...
{ "input": [], "output": [] }
{ "input": [ "6 10 3 4\n##########\n#........#\n#...D....#\n#........#\n#........#\n##########\n2 4 6\n3 2 0\n7 4 2\n8 4 3\n1 4 1" ], "output": [ "Yes" ] }
{ "input": [ "6 10 3 4\n##########\n#........#\n#...D....\"\n#........#\n#........#\n##########\n2 4 6\n3 2 0\n7 4 2\n8 4 3\n1 4 1", "6 10 3 4\n##########\n#........#\n#...D....\"\n#........#\n#........#\n##########\n2 4 11\n3 2 0\n7 6 2\n8 4 3\n1 4 1", "6 10 3 4\n##########\n#........#\n#...D....\"\n#......
p01833 Modern Announce Network
Example Input 4 2 1 1 1 2 3 4 3 1 2 2 4 3 4 Output 2 1
{ "input": [], "output": [] }
{ "input": [ "4 2 1 1\n1 2\n3\n4\n3\n1 2\n2 4\n3 4" ], "output": [ "2 1" ] }
{ "input": [ "4 2 1 1\n1 2\n3\n4\n3\n1 4\n2 4\n3 4", "4 2 1 1\n2 2\n3\n4\n3\n1 2\n2 4\n3 4", "4 2 1 1\n1 1\n3\n4\n3\n1 2\n2 4\n3 4", "4 2 1 1\n1 2\n3\n4\n3\n2 4\n2 4\n3 4", "4 2 1 1\n1 2\n3\n4\n3\n1 1\n2 4\n3 4", "4 2 1 1\n1 2\n3\n4\n3\n2 4\n4 4\n3 4", "4 2 1 1\n1 2\n3\n4\n3\n2 4\n4 3\n3 4...
p01968 Hierarchical Calculator
B: 階層的計算機 (Hierarchical Calculator) Problem Ebi-chan has N formulae: y = a_i x for i =1, ..., N (inclusive). Now she considers a subsequence of indices with length k: s_1, s_2, ..., s_k. At first, let x_0 be 1 and evaluate s_1-th formulae with x = x_0. Next, let x_1 be the output of s_1 and evaluate s_2-th formulae w...
{ "input": [], "output": [] }
{ "input": [ "4\n2 0 -2 1" ], "output": [ "1\n1" ] }
{ "input": [ "4\n2 -1 -2 1", "4\n2 0 -1 1", "4\n1 -1 -2 0", "4\n0 -1 -1 1", "4\n-1 -1 0 2", "4\n-1 -2 0 2", "4\n2 -1 1 2", "4\n-1 1 -2 0", "4\n2 -1 2 2", "4\n1 2 -1 1", "4\n0 -1 0 -2", "4\n1 0 -2 -1", "4\n2 2 -1 1", "4\n-1 2 -2 2", "4\n-1 0 2 0", "4\n1 2...
p02115 Piano
Problem Gaccho is trying to play the piano. The piano on the right side produces a higher note. Gaccho has a certain score and plays according to that score. The score contains notes in chronological order that indicate which key should be played at a given time. Chords (sounds produced when multiple keys are pressed...
{ "input": [], "output": [] }
{ "input": [ "5\n4\n5\n2\n1\n3", "3\n4\n4\n4", "3\n2\n5\n1" ], "output": [ "3", "1", "2" ] }
{ "input": [ "5\n6\n5\n2\n1\n3", "3\n4\n8\n4", "5\n2\n5\n2\n1\n3", "3\n1\n1\n1", "5\n7\n2\n0\n-1\n-2", "3\n0\n5\n1", "3\n4\n6\n4", "3\n0\n5\n2", "5\n2\n5\n1\n1\n3", "3\n4\n2\n4", "3\n0\n4\n2", "5\n2\n4\n1\n1\n3", "3\n7\n2\n4", "3\n0\n0\n2", "5\n2\n4\n1\n1\n0...
p02255 Insertion Sort
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3", "6\n5 2 4 6 1 3" ], "output": [ "1 2 3\n1 2 3\n1 2 3", "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6" ] }
{ "input": [ "3\n2 2 3", "6\n5 2 5 6 1 3", "3\n2 4 3", "6\n5 2 5 8 1 3", "3\n2 4 5", "6\n5 4 5 8 1 3", "3\n2 4 8", "6\n5 4 5 7 1 3", "3\n2 6 8", "6\n5 4 5 7 1 0", "3\n4 6 8", "6\n5 4 5 0 1 0", "3\n4 2 8", "6\n5 4 5 1 1 0", "3\n6 2 8", "6\n5 4 5 2 1 0", ...
p02403 Print a Rectangle
Draw a rectangle which has a height of H cm and a width of W cm. Draw a 1-cm square by single '#'. Constraints * 1 ≤ H ≤ 300 * 1 ≤ W ≤ 300 Input The input consists of multiple datasets. Each dataset consists of two integers H and W separated by a single space. The input ends with two 0 (when both H and W are zero)...
{ "input": [], "output": [] }
{ "input": [ "3 4\n5 6\n2 2\n0 0" ], "output": [ "####\n####\n####\n\n######\n######\n######\n######\n######\n\n##\n##" ] }
{ "input": [ "3 4\n5 6\n2 3\n0 0", "3 4\n5 6\n2 0\n0 0", "3 4\n5 6\n2 4\n0 0", "4 4\n5 6\n2 0\n0 0", "4 4\n5 6\n4 0\n0 0", "4 3\n5 6\n4 -1\n0 0", "3 5\n5 6\n2 2\n0 0", "3 4\n5 0\n2 2\n0 0", "3 4\n5 6\n2 1\n0 0", "6 4\n5 6\n2 4\n0 0", "3 4\n5 6\n4 -1\n0 0", "8 3\n5 6\n4 ...
amr15a
Kattapa, as you all know was one of the greatest warriors of his time. The kingdom of Maahishmati had never lost a battle under him (as army-chief), and the reason for that was their really powerful army, also called as Mahasena. Kattapa was known to be a very superstitious person. He believed that a soldier is "lucky"...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5" ], "output": [ "NOT READY\n" ] }
{ "input": [ "5\n1 2 3 0 5", "5\n1 2 3 0 2", "5\n1 2 4 0 2", "5\n1 4 4 0 2", "5\n1 4 4 1 2", "5\n1 4 4 2 2", "5\n1 6 4 2 2", "5\n1 8 4 2 2", "5\n1 8 3 2 2", "5\n1 8 3 2 1", "5\n2 8 3 2 1", "5\n2 8 3 2 0", "5\n2 8 3 3 0", "5\n4 8 3 3 0", "5\n4 6 3 3 0", "...
chfbooks
The chef has a book stand. He and his friend bought some books (say n). The book stand has only 2 empty shelves. The chef made an observation that the paper quality, the weight of a single paper and the dimensions of all the books are the same. The chef made a restriction, to the books that can be kept on the shelves. ...
{ "input": [], "output": [] }
{ "input": [ "1\n5 2\n4 1 3 2 5" ], "output": [ "9" ] }
{ "input": [ "1\n5 2\n4 1 2 2 5", "1\n5 2\n8 1 2 2 5", "1\n10 2\n8 1 4 2 5", "1\n1 2\n8 1 5 2 5", "1\n1 1\n8 1 5 2 5", "1\n1 1\n8 1 5 3 5", "1\n1 3\n8 0 5 3 5", "1\n1 3\n14 0 5 3 5", "1\n0 3\n28 1 5 3 9", "1\n1 3\n28 1 5 1 9", "1\n1 3\n28 2 5 1 9", "1\n1 3\n28 2 5 1 3",...
egbobrd
Some chefs go for a tour lasting N days. They take packages of bread for food. Each package has K pieces of breads. On the i^th day, they eat Ai pieces of bread. Unfortunately, chefs are very lazy people, and they always forget to close the package of breads, so each day the last piece of bread becomes exposed to mold ...
{ "input": [], "output": [] }
{ "input": [ "3\n3 4\n3 1 2\n1 1\n1\n2 4\n8 8" ], "output": [ "2\n1\n4\n" ] }
{ "input": [ "3\n3 4\n3 1 2\n1 1\n1\n2 4\n8 1", "3\n3 4\n3 1 2\n1 1\n1\n2 2\n8 1", "3\n3 4\n6 1 2\n1 1\n1\n2 2\n8 1", "3\n3 4\n6 1 2\n1 1\n1\n2 2\n10 1", "3\n3 4\n3 1 0\n1 1\n1\n2 4\n8 8", "3\n3 4\n3 1 4\n1 1\n1\n2 4\n8 1", "3\n3 5\n3 1 2\n1 1\n2\n2 2\n8 1", "3\n3 4\n3 1 2\n1 1\n1\n2 4...
kgp14b
A DNA sequence can be represented by a string of letters T, A, C, and G representing four different amino acids. DNA sequences are often matched to infer structural or functional similarities between living beings. Given two DNA sequences X and Y, the sequence Y is said to be contained in X if Y can be obtained from X ...
{ "input": [], "output": [] }
{ "input": [ "2\n7 6\nTAGCTAG\nATCATG\n10 9\nGGATGCTACA\nTCTACCGTA" ], "output": [ "Case 1: 9\nCase 2: 13" ] }
{ "input": [], "output": [] }
oneking
N one dimensional kingdoms are represented as intervals of the form [ai , bi] on the real line. A kingdom of the form [L, R] can be destroyed completely by placing a bomb at a point x on the real line if L ≤ x ≤ R. Your task is to determine minimum number of bombs required to destroy all the one dimensional kingdoms....
{ "input": [], "output": [] }
{ "input": [ "1\n3\n1 3\n2 5\n6 9" ], "output": [ "2\n" ] }
{ "input": [ "1\n3\n1 3\n0 5\n6 9", "1\n3\n1 3\n2 5\n1 6", "1\n3\n2 3\n0 1\n12 9", "1\n3\n1 3\n0 5\n12 9", "1\n3\n1 3\n0 7\n12 9", "1\n3\n1 3\n-1 7\n12 9", "1\n3\n1 3\n-1 7\n12 13", "1\n3\n1 3\n2 5\n6 6", "1\n3\n1 3\n0 5\n6 13", "1\n3\n0 3\n0 5\n6 9", "1\n3\n1 3\n0 12\n12 9...
spcandy
Cyael is a teacher at a very famous school in Byteland and she is known by her students for being very polite to them and also to encourage them to get good marks on their tests. Then, if they get good marks she will reward them with candies :) However, she knows they are all very good at Mathematics, so she decided to...
{ "input": [], "output": [] }
{ "input": [ "2\n10 2\n100 3" ], "output": [ "5 0\n33 1\n" ] }
{ "input": [ "2\n10 2\n101 3", "2\n10 0\n101 3", "2\n18 0\n101 3", "2\n18 0\n111 3", "2\n18 0\n110 3", "2\n25 0\n110 3", "2\n25 0\n010 3", "2\n25 0\n000 3", "2\n16 0\n000 2", "2\n2 0\n000 0", "2\n1 0\n000 0", "2\n10 1\n100 3", "2\n10 2\n101 1", "2\n18 1\n101 3",...
1071_D. Familiar Operations
You are given two positive integers a and b. There are two possible operations: 1. multiply one of the numbers by some prime p; 2. divide one of the numbers on its prime factor p. What is the minimum number of operations required to obtain two integers having the same number of divisors? You are given severa...
{ "input": [], "output": [] }
{ "input": [ "8\n9 10\n100 17\n220 70\n17 19\n4 18\n32 20\n100 32\n224 385\n" ], "output": [ "1\n3\n1\n0\n1\n0\n1\n1\n" ] }
{ "input": [ "8\n9 10\n100 17\n220 70\n17 19\n4 18\n32 20\n101 32\n224 385\n", "8\n9 10\n101 17\n220 70\n17 19\n4 18\n32 20\n101 32\n224 385\n", "8\n12 11\n101 17\n217 70\n17 19\n4 18\n32 20\n101 32\n224 385\n", "8\n12 11\n101 17\n217 70\n17 19\n4 18\n32 5\n101 32\n224 385\n", "8\n12 11\n101 17\n2...
1302_J. Keep talking and nobody explodes – hard
This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543) You have the safe lock which consists of 100 decimal digits. If you rotate some digit, it increases by one, except 9 which becomes 0. Initially, the lock contains num...
{ "input": [], "output": [] }
{ "input": [ "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n" ], "output": [ "\n970001000600030002000011170661703494309997001286100090870009...
{ "input": [], "output": [] }
1346_C. Spring Cleaning
Tanya wants to organize her bookcase. There are n bookshelves in the bookcase, the i-th bookshelf contains a_i books on it. Tanya will be satisfied if each bookshelf contains no more than k books. Tanya can do one of the two following operations to achieve her goal: 1. Choose exactly one bookshelf and put all the ...
{ "input": [], "output": [] }
{ "input": [ "6\n5 4 3 5\n1 2 2 3 5\n5 3 4 5\n1 5 1 5 5\n5 4 5 6\n1 2 5 3 5\n4 3 2 10\n4 4 1 1\n4 3 10 2\n4 4 1 1\n4 1 5 4\n1 2 1 3\n" ], "output": [ "\n3\n9\n6\n4\n2\n9\n" ] }
{ "input": [], "output": [] }
1430_D. String Deletion
You have a string s consisting of n characters. Each character is either 0 or 1. You can perform operations on the string. Each operation consists of two steps: 1. select an integer i from 1 to the length of the string s, then delete the character s_i (the string length gets reduced by 1, the indices of characters ...
{ "input": [], "output": [] }
{ "input": [ "5\n6\n111010\n1\n0\n1\n1\n2\n11\n6\n101010\n" ], "output": [ "3\n1\n1\n1\n3\n" ] }
{ "input": [ "5\n6\n111010\n1\n1\n1\n1\n2\n11\n6\n101010\n", "5\n6\n111000\n1\n1\n1\n1\n2\n11\n6\n101010\n", "5\n6\n011011\n1\n0\n1\n1\n2\n11\n6\n111000\n", "5\n6\n111111\n1\n0\n1\n1\n2\n11\n6\n101010\n", "5\n6\n111000\n1\n1\n1\n1\n2\n18\n6\n000010\n", "5\n6\n111011\n1\n1\n1\n1\n2\n11\n6\n1010...
1453_F. Even Harder
Gildong is now developing a puzzle game. The puzzle consists of n platforms numbered from 1 to n. The player plays the game as a character that can stand on each platform and the goal of the game is to move the character from the 1-st platform to the n-th platform. The i-th platform is labeled with an integer a_i (0 ≤...
{ "input": [], "output": [] }
{ "input": [ "3\n4\n1 1 1 0\n5\n4 3 2 1 0\n9\n4 1 4 2 1 0 2 1 0\n" ], "output": [ "\n0\n3\n2\n" ] }
{ "input": [ "3\n4\n1 1 1 0\n5\n4 3 2 1 0\n9\n4 1 4 3 1 0 2 1 0\n", "3\n4\n1 1 1 0\n5\n4 3 2 1 0\n9\n4 1 4 2 1 0 2 0 0\n", "3\n4\n1 1 1 0\n5\n2 3 2 1 0\n9\n3 1 4 1 1 0 2 1 0\n", "3\n4\n1 1 1 0\n5\n4 3 2 1 0\n9\n4 2 4 3 1 0 2 1 0\n", "3\n4\n2 1 1 0\n5\n2 3 2 1 0\n9\n3 1 4 1 0 0 2 1 0\n", "3\n4\...
1504_B. Flip the Bits
There is a binary string a of length n. In one operation, you can select any prefix of a with an equal number of 0 and 1 symbols. Then all symbols in the prefix are inverted: each 0 becomes 1 and each 1 becomes 0. For example, suppose a=0111010000. * In the first operation, we can select the prefix of length 8 sin...
{ "input": [], "output": [] }
{ "input": [ "5\n10\n0111010000\n0100101100\n4\n0000\n0000\n3\n001\n000\n12\n010101010101\n100110011010\n6\n000111\n110100\n" ], "output": [ "\nYES\nYES\nNO\nYES\nNO\n" ] }
{ "input": [ "5\n10\n0111010000\n0100101100\n4\n0000\n0000\n3\n000\n000\n12\n010101010101\n100110011010\n6\n000111\n110100\n", "5\n10\n0111010000\n0101101100\n4\n0000\n0000\n3\n000\n000\n12\n010101010101\n100110011010\n6\n000111\n110100\n", "5\n10\n0111010000\n0101101100\n4\n0000\n0000\n3\n000\n000\n12\n0...
1528_A. Parsa's Humongous Tree
Parsa has a humongous tree on n vertices. On each vertex v he has written two integers l_v and r_v. To make Parsa's tree look even more majestic, Nima wants to assign a number a_v (l_v ≤ a_v ≤ r_v) to each vertex v such that the beauty of Parsa's tree is maximized. Nima's sense of the beauty is rather bizarre. He de...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n1 6\n3 8\n1 2\n3\n1 3\n4 6\n7 9\n1 2\n2 3\n6\n3 14\n12 20\n12 19\n2 12\n10 17\n3 17\n3 2\n6 5\n1 5\n2 6\n4 6\n" ], "output": [ "\n7\n8\n62\n" ] }
{ "input": [ "3\n2\n1 6\n3 8\n1 2\n3\n1 3\n4 6\n7 9\n1 2\n2 3\n6\n4 14\n12 20\n12 19\n2 12\n10 17\n3 17\n3 2\n6 5\n1 5\n2 6\n4 6\n", "3\n2\n1 6\n3 8\n1 2\n3\n1 3\n4 6\n7 9\n1 2\n2 3\n6\n3 14\n12 20\n12 19\n2 12\n10 17\n3 17\n3 3\n6 5\n1 5\n2 6\n4 6\n", "3\n2\n1 6\n3 6\n1 2\n3\n1 3\n4 6\n7 9\n1 2\n2 3\n6\n...
178_E3. The Beaver's Problem - 2
Offering the ABBYY Cup participants a problem written by the Smart Beaver is becoming a tradition. He proposed the following problem. You are given a monochrome image, that is, an image that is composed of two colors (black and white). The image is given in raster form, that is, as a matrix of pixels' colors, and the ...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
345_F. Superstitions Inspection
You read scientific research regarding popularity of most famous superstitions across various countries, and you want to analyze their data. More specifically, you want to know which superstitions are popular in most countries. The data is given as a single file in the following format: country name on a separate line...
{ "input": [], "output": [] }
{ "input": [ "Ukraine\n* Friday the 13th\n* black cat\n* knock the wood\nUSA\n* wishing well\n* friday the 13th\nHolland\nFrance\n* Wishing Well\n", "Spain\n* Tuesday the 13th\nItaly\n* Friday the 17th\nRussia\n* Friday the 13th\nEngland\n* rabbit foot\n" ], "output": [ "friday the 13th \nwi...
{ "input": [], "output": [] }
628_E. Zbazi in Zeydabad
A tourist wants to visit country Zeydabad for Zbazi (a local game in Zeydabad). The country Zeydabad is a rectangular table consisting of n rows and m columns. Each cell on the country is either 'z' or '.'. The tourist knows this country is named Zeydabad because there are lots of ''Z-pattern"s in the country. A ''Z-...
{ "input": [], "output": [] }
{ "input": [ "4 4\nzzzz\nzzz.\n.z..\nzzzz\n", "1 4\nz.z.\n", "2 2\nzz\nzz\n" ], "output": [ "16\n", "2\n", "5\n" ] }
{ "input": [ "1 4\n.z.z\n", "4 4\nzzzz\nzzz.\n..z.\nzzzz\n", "4 4\nzzzz\n.zzz\n..z.\nzzzz\n", "3 4\nzzzz\n.zzz\n..z.\nzzzz\n", "1 4\nzzzz\nzzz.\n..z.\nzzzz\n", "2 4\nzzzz\n.zzz\n.z..\nz{zz\n", "1 4\nz..z\n", "1 2\nzz\nzz\n", "1 4\n..zz\n", "1 2\nzz\nzy\n", "3 4\nzzzz\nzzz.\...
838_B. Diverging Directions
You are given a directed weighted graph with n nodes and 2n - 2 edges. The nodes are labeled from 1 to n, while the edges are labeled from 1 to 2n - 2. The graph's edges can be split into two parts. * The first n - 1 edges will form a rooted spanning tree, with node 1 as the root. All these edges will point away fro...
{ "input": [], "output": [] }
{ "input": [ "5 9\n1 3 1\n3 2 2\n1 4 3\n3 5 4\n5 1 5\n3 1 6\n2 1 7\n4 1 8\n2 1 1\n2 1 3\n2 3 5\n2 5 2\n1 1 100\n2 1 3\n1 8 30\n2 4 2\n2 2 4\n" ], "output": [ "0\n1\n4\n8\n100\n132\n10\n" ] }
{ "input": [ "5 9\n1 3 1\n3 2 2\n1 4 6\n3 5 4\n5 1 5\n3 1 6\n2 1 7\n4 1 8\n2 1 1\n2 1 3\n2 3 5\n2 5 2\n1 1 100\n2 1 3\n1 8 30\n2 4 2\n2 2 4\n", "5 9\n1 3 1\n3 2 2\n1 4 6\n3 5 4\n5 1 5\n3 1 6\n2 1 12\n4 1 8\n2 1 1\n2 1 3\n2 3 5\n2 5 2\n1 1 100\n2 1 3\n1 8 30\n2 4 2\n2 2 4\n", "5 9\n1 3 1\n3 2 2\n1 4 8\n3 5...
crack-the-code
Rufus wants to go to the Lily's birthday party to surprise Lily. But Lily's party invitation has a unique code on it which is in the form X-Y(e.g. 123-456). So Rufus need a invitation but he fails to get the invitation. So he decided to make a invitation on his own with a fake code on it. But each code has a unique ch...
{ "input": [], "output": [] }
{ "input": [ "2\n3 10\n2 8\n\nSAMPLE" ], "output": [ "INVALID\nVALID\n" ] }
{ "input": [ "2\n3 10\n1 8\n\nSAMPLE", "2\n3 10\n1 16\n\nSAMPLE", "2\n4 10\n1 16\n\nSAMPLE", "2\n1 4\n2 8\n\nSAMPLE", "2\n3 4\n2 8\n\nSAMPLE", "2\n3 8\n2 8\n\nSAMPLE", "2\n4 9\n1 16\n\nSAMPLE", "2\n3 10\n2 8\n\nSAMELP", "2\n3 10\n1 8\n\nELPMAS", "2\n3 8\n1 16\n\nSAMPLE", "2...
fixing-of-file
On Unix computers, data is stored in directories. There is one root directory, and this might have several directories contained inside of it, each with different names. These directories might have even more directories contained inside of them, and so on. A directory is uniquely identified by its name and its parent...
{ "input": [], "output": [] }
{ "input": [ "2\n0 2\n/home/gcj/finals\n/home/gcj/quals\n2 1\n/chicken\n/chicken/egg\n/chicken\n\nSAMPLE" ], "output": [ "Case #1: 4\nCase #2: 0" ] }
{ "input": [ "2\n0 2\n/home/gcj/finals\n/hole/gcj/quals\n2 1\n/chicken\n/chicken/egg\n/chicken\n\nSAMPLE", "2\n0 2\n/home/gcj/sinalf\n/home/gcj/quals\n2 1\n/chicken\n/chicken/egg\n/chicken\n\nSAMPLE", "2\n0 2\n/home/gcj/finals\n/hole/gcj/quals\n1 1\n/chicken\n/cgicken/egg\n/chicken\n\nSAMPLE", "2\n0 2...
recursion
Problem : Bajirao asks Avni out on a date. However, Avni will go out with him only on one condition : Bajirao has to tell her all possible N - digit numbers such that all the digits of every number he tells her are distinct , non-zero and less than or equal to N. Also, he has to tell her all these numbers in asc...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n2\n3\n\nSAMPLE" ], "output": [ "1 \n12 21 \n123 132 213 231 312 321 \n" ] }
{ "input": [ "3\n1\n2\n3\n\nELPMAS", "3\n1\n3\n3\n\nELPMAS", "3\n1\n3\n6\n\nELPMAS", "3\n1\n3\n7\n\nELPMAS", "3\n1\n2\n7\n\nELPMAS", "3\n2\n3\n3\n\nELPL@S", "3\n1\n4\n7\n\nELPMAS", "3\n3\n3\n3\n\nELPL@S", "3\n1\n4\n1\n\nELPMAS", "3\n1\n1\n3\n\nS@MPDL", "3\n4\n3\n3\n\nELPM@S...
softsort-7
Let us define an easy Sorting Algorithm called SoftSort. SoftSort Sorting algorithm involves use of IF and ELSE decision statements only. For example : To sort two numbers a and b. SoftSort Algorithm's Code is given below. void print(int a,int b){ printf( "%d %d\n",a,b); } void sort( int a, int b){ if( b < ...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n2\n3\n\nSAMPLE" ], "output": [ "6\n9\n21\n" ] }
{ "input": [ "3\n1\n2\n3\n\nSALPME", "3\n1\n1\n3\n\nSALPME", "3\n1\n3\n3\n\nSAMPLE", "3\n2\n1\n3\n\nSALPMF", "3\n1\n3\n1\n\nSAMPLE", "3\n2\n3\n1\n\nSAMPLE", "3\n2\n3\n2\n\nSAMPLE", "3\n2\n2\n2\n\nSAMPLE", "3\n4\n2\n2\n\nELPMAS", "3\n4\n2\n1\n\nELOMAS", "3\n4\n3\n1\n\nSCLOKE...
times-pal-1
A palindrome is a string that is the same whether it is read from left to right or from right to left. Chota Bheem likes palindromes a lot. As a birthday gift he received two strings A and B. Now he is curious if there is a way to insert string B into string A so that the resulting string is a palindrome. You agreed to...
{ "input": [], "output": [] }
{ "input": [ "1\naba\nb\n\nSAMPLE" ], "output": [ "2\n" ] }
{ "input": [ "1\nabb\nb\n\nSAMPLE", "1\ncaa\nc\n\nSLMF@P", "1\nbdb\nd\n\nPLMG@S", "1\nbba\nb\n\nSAMPLE", "1\nbba\nb\n\nSAMELP", "1\nbba\nb\n\nPAMELS", "1\nbb`\nb\n\nPAMELS", "1\n`bb\nb\n\nPAMELS", "1\n`bb\nb\n\nPAEMLS", "1\n`cb\nb\n\nPAEMLS", "1\n`ca\nb\n\nPAEMLS", "1\n...
p02562 AtCoder Library Practice Contest - MinCostFlow
You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). A nonnegative integer A_{i,j} is written for each square (i,j). You choose some of the squares so that each row and column contains at most K chosen squares. Under this constraint, calculate the maximum v...
{ "input": [], "output": [] }
{ "input": [ "3 2\n10 10 1\n10 10 1\n1 1 10", "3 1\n5 3 2\n1 4 8\n7 6 9" ], "output": [ "50\nXX.\nXX.\n..X", "19\nX..\n..X\n.X." ] }
{ "input": [ "3 1\n10 10 1\n10 10 1\n1 1 10", "3 2\n5 10 1\n10 10 1\n1 1 10", "1 1\n5 3 2\n1 4 8\n7 6 9", "3 2\n5 10 1\n10 6 1\n1 1 10", "3 2\n5 10 1\n10 6 1\n1 1 15", "1 1\n1 3 2\n1 4 8\n7 12 9", "3 1\n18 10 0\n8 10 1\n1 1 10", "3 2\n5 10 1\n10 6 1\n1 1 18", "2 1\n1 3 2\n1 4 8\n7 ...
p02693 AtCoder Beginner Contest 165 - We Love Golf
Takahashi the Jumbo will practice golf. His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive). If he can achieve the objective, print `OK`; if he cannot, print `NG`. Constraints * All values in input are integers. * 1 \leq A \leq B \...
{ "input": [], "output": [] }
{ "input": [ "4\n5 7", "7\n500 600", "1\n11 11" ], "output": [ "NG", "OK", "OK" ] }
{ "input": [ "4\n5 9", "4\n1 1", "4\n2 9", "4\n2 16", "4\n2 23", "4\n0 23", "4\n1 23", "4\n1 20", "4\n1 8", "4\n1 11", "4\n1 15", "4\n1 2", "4\n2 2", "4\n1 7", "7\n500 983", "4\n1 9", "4\n4 16", "4\n2 37", "4\n0 46", "4\n0 20", "4\n2 ...
p02822 AtCoder Beginner Contest 149 - Surrounded Nodes
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N). Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all th...
{ "input": [], "output": [] }
{ "input": [ "4\n1 2\n2 3\n3 4", "4\n1 2\n1 3\n1 4", "7\n4 7\n3 1\n2 6\n5 2\n7 1\n2 7", "3\n1 2\n2 3" ], "output": [ "375000003", "250000002", "570312505", "125000001" ] }
{ "input": [ "4\n1 2\n2 3\n2 4", "4\n1 2\n2 3\n1 4", "7\n4 7\n3 1\n2 6\n5 4\n7 1\n2 7", "3\n1 2\n1 3", "7\n4 7\n3 1\n3 6\n5 4\n7 1\n2 7", "7\n4 7\n3 1\n2 6\n5 1\n7 1\n2 7", "7\n4 7\n3 1\n3 6\n5 1\n7 1\n2 1", "7\n4 7\n3 2\n2 6\n5 2\n7 1\n2 7", "7\n4 7\n3 1\n1 6\n5 2\n5 1\n2 4", ...
p02958 AtCoder Beginner Contest 135 - 0 or 1 Swap
We have a sequence p = {p_1,\ p_2,\ ...,\ p_N} which is a permutation of {1,\ 2,\ ...,\ N}. You can perform the following operation at most once: choose integers i and j (1 \leq i < j \leq N), and swap p_i and p_j. Note that you can also choose not to perform it. Print `YES` if you can sort p in ascending order in th...
{ "input": [], "output": [] }
{ "input": [ "5\n2 4 3 5 1", "7\n1 2 3 4 5 6 7", "5\n5 2 3 4 1" ], "output": [ "NO", "YES", "YES" ] }
{ "input": [ "5\n3 4 3 5 1", "5\n5 0 3 4 1", "5\n3 4 3 0 1", "5\n5 0 3 7 1", "5\n3 4 3 1 1", "5\n5 0 3 4 2", "5\n3 4 1 1 1", "5\n4 0 3 4 2", "5\n3 8 1 1 1", "5\n8 0 3 4 2", "5\n3 8 1 1 2", "5\n11 0 3 4 2", "5\n1 8 1 1 2", "5\n2 0 3 4 2", "5\n1 8 1 1 4", ...
p03094 AtCoder Grand Contest 032 - One Third
We have a round pizza. Snuke wants to eat one third of it, or something as close as possible to that. He decides to cut this pizza as follows. First, he divides the pizza into N pieces by making N cuts with a knife. The knife can make a cut along the segment connecting the center of the pizza and some point on the ci...
{ "input": [], "output": [] }
{ "input": [ "2", "3", "10", "1000000" ], "output": [ "138888890", "179012347", "954859137", "44679646" ] }
{ "input": [ "4", "6", "15", "8", "11", "7", "1", "5", "18", "9", "26", "20", "28", "13", "14", "17", "19", "27", "44", "12", "24", "21", "30", "32", "22", "51", "53", "79", "68", "147", "42", ...
p03240 AtCoder Beginner Contest 112 - Pyramid
In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc. The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). Aoki, an explorer, conducted a survey to identify the center ...
{ "input": [], "output": [] }
{ "input": [ "2\n0 0 100\n1 1 98", "3\n99 1 191\n100 1 192\n99 0 192", "4\n2 3 5\n2 1 5\n1 2 5\n3 2 5" ], "output": [ "0 0 100", "100 0 193", "2 2 6" ] }
{ "input": [ "2\n-1 0 100\n2 1 98", "3\n99 1 191\n000 1 192\n99 0 192", "2\n-2 0 100\n2 2 98", "3\n99 1 191\n000 1 154\n99 0 192", "3\n99 1 191\n000 1 210\n99 0 192", "2\n-1 -1 101\n2 3 98", "3\n99 1 191\n000 1 180\n99 0 192", "3\n99 1 191\n010 1 154\n99 0 192", "3\n99 1 191\n000 1...
p03393 AtCoder Grand Contest 022 - Diverse Word
Gotou just received a dictionary. However, he doesn't recognize the language used in the dictionary. He did some analysis on the dictionary and realizes that the dictionary contains all possible diverse words in lexicographical order. A word is called diverse if and only if it is a nonempty string of English lowercase...
{ "input": [], "output": [] }
{ "input": [ "zyxwvutsrqponmlkjihgfedcba", "atcoder", "abcdefghijklmnopqrstuvwzyx", "abc" ], "output": [ "-1", "atcoderb", "abcdefghijklmnopqrstuvx", "abcd" ] }
{ "input": [ "redocta", "azcdefghijklmnopqrstuvwbyx", "cba", "redoctb", "bca", "bac", "abd", "atcodes", "abcdefghijklmnopqrytuvwzsx", "btcoder", "bad", "acb", "cab", "dba", "atcored", "qedoctb", "ascored", "btcodeq", "ascorfd", "btcedoq",...
p03556 AtCoder Beginner Contest 077 - Around Square
Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer. Constraints * 1 \leq N \leq 10^9 * N is an integer. Input Input is given from Standard Input in the following format: N Output Print the largest square number not exceeding N...
{ "input": [], "output": [] }
{ "input": [ "81", "10", "271828182" ], "output": [ "81", "9", "271821169" ] }
{ "input": [ "70", "12", "115087508", "135", "167542739", "7", "16", "317532200", "315132601", "2", "262957414", "385753315", "269979070", "193485646", "0", "286256676", "334866881", "582764924", "26", "307671928", "38", "52093794...
p03711 AtCoder Beginner Contest 062 - Grouping
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. b4ab979900ed647703389d4349eb84ee.png Constraints * x and y are integers. * 1 ≤ x < y ≤ 12 Input Input i...
{ "input": [], "output": [] }
{ "input": [ "2 4", "1 3" ], "output": [ "No", "Yes" ] }
{ "input": [ "2 8", "1 10", "1 4", "2 3", "2 10", "4 3", "7 3", "7 6", "7 4", "7 5", "4 5", "1 5", "1 2", "0 2", "-1 2", "2 1", "1 1", "2 0", "2 6", "3 3", "7 1", "5 4", "7 10", "5 5", "2 5", "2 9", "3 6", ...
p03867 AtCoder Regular Contest 064 - Rotated Palindromes
Takahashi and Aoki are going to together construct a sequence of integers. First, Takahashi will provide a sequence of integers a, satisfying all of the following conditions: * The length of a is N. * Each element in a is an integer between 1 and K, inclusive. * a is a palindrome, that is, reversing the order of elem...
{ "input": [], "output": [] }
{ "input": [ "1000000000 1000000000", "1 10", "4 2", "6 3" ], "output": [ "875699961", "10", "6", "75" ] }
{ "input": [ "1000001000 1000000000", "1 5", "2 2", "11 3", "1000001000 1010000000", "2 4", "16 3", "1000000000 1010000000", "2 0", "4 4", "25 3", "1001000000 1010000000", "6 4", "25 1", "1001000000 1010010000", "1001100000 1010010000", "1001100000 1...
p04031 AtCoder Beginner Contest 043 - Be Together
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal integers by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See ...
{ "input": [], "output": [] }
{ "input": [ "2\n4 8", "3\n1 1 3", "3\n4 2 5", "4\n-100 -100 -100 -100" ], "output": [ "8", "3", "5", "0" ] }
{ "input": [ "2\n5 8", "3\n1 1 6", "3\n4 3 5", "4\n-100 -45 -100 -100", "2\n5 11", "3\n1 1 8", "3\n3 3 5", "3\n0 1 8", "3\n3 0 5", "2\n10 6", "3\n0 0 8", "3\n3 0 10", "3\n0 0 14", "3\n3 0 7", "2\n17 5", "3\n-1 0 14", "3\n3 0 13", "2\n17 1", "...
p00115 Starship UAZ Advance
Stellar history 2005.11.5. You are about to engage an enemy spacecraft as the captain of the UAZ Advance spacecraft. Fortunately, the enemy spaceship is still unnoticed. In addition, the space coordinates of the enemy are already known, and the "feather cannon" that emits a powerful straight beam is ready to launch. Af...
{ "input": [], "output": [] }
{ "input": [ "-10 6 6\n10 6 6\n0 10 0\n0 10 10\n0 0 10", "-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 0 10" ], "output": [ "MISS", "HIT" ] }
{ "input": [ "-10 6 6\n10 2 6\n0 10 0\n0 10 10\n0 0 10", "-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 1 10", "-10 6 6\n20 2 6\n0 10 0\n0 10 10\n0 0 10", "-10 0 0\n10 0 0\n0 10 0\n0 0 10\n0 1 10", "-10 6 6\n20 2 6\n0 10 1\n0 10 10\n0 0 10", "-10 -1 0\n10 0 0\n0 10 0\n0 0 10\n0 1 10", "-10 6 6\n20 2...
p00248 Magic Square
A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel. Her magic is activated by drawing a magic circle using some magical stones and strings. This magic circle is drawn by placing stones and tying several pairs of ston...
{ "input": [], "output": [] }
{ "input": [ "5 4\n1 2\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n5 0\n0 0" ], "output": [ "yes\nno\nyes" ] }
{ "input": [ "5 4\n1 2\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "5 4\n1 2\n2 3\n3 4\n5 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "5 4\n2 2\n2 3\n3 4\n5 5\n4 6\n1 2\n1 3\n1 4\n1 4\n1 4\n3 4\n0 0\n0 0", "5 4\n2 1\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 4\n1 4\n3 4\n0 0\n0 0", ...
p00429 String
Given a string consisting of only numbers from 0 to 9, consider the operation of creating a new string from that string according to the following rules. Read the given string one character at a time from the left end. Go, if the same number a continues r, write the number r and the number a in this order without separ...
{ "input": [], "output": [] }
{ "input": [ "5\n11\n5\n11\n0" ], "output": [ "13112221\n13112221" ] }
{ "input": [ "5\n11\n5\n21\n0", "5\n18\n5\n21\n0", "5\n18\n5\n1\n0", "5\n18\n6\n1\n0", "5\n28\n6\n1\n0", "5\n28\n11\n1\n0", "5\n28\n3\n1\n0", "5\n43\n3\n1\n0", "5\n43\n3\n0\n0", "5\n11\n5\n15\n0", "5\n11\n5\n17\n0", "5\n0\n5\n21\n0", "5\n6\n5\n1\n0", "5\n31\n6\n...
p00625 Frisbee Dogs
Klein is trying to get her dog Jack into the Frisbee Dog Tournament. But she's not sure if Jack will get a good grade. For her, she simulates the tournament to get Jack's grade. I want you to create a program to estimate. The tournament is held by N dogs on a two-dimensional plane. At the start of the tournament, the ...
{ "input": [], "output": [] }
{ "input": [ "2 1\n12 5 3\n0 17 3\n0 0 2 2\n2 3\n2 0 2\n100 100 2\n0 0 -1 0\n-2 -5 0 3\n100 100 1 1\n0 0" ], "output": [ "1 0\n2 1" ] }
{ "input": [ "2 1\n12 5 1\n0 17 3\n0 0 2 2\n2 3\n2 0 2\n100 100 2\n0 0 -1 0\n-2 -5 0 3\n100 100 1 1\n0 0", "2 1\n7 5 1\n0 17 3\n0 0 2 2\n2 3\n2 0 2\n110 101 2\n0 0 -1 0\n-2 -5 0 3\n100 100 1 0\n0 0", "2 1\n7 5 1\n1 17 3\n0 0 2 2\n2 3\n0 0 2\n100 001 0\n0 1 -1 1\n-2 -9 0 3\n000 100 1 0\n0 0", "2 1\n7 3...
p00769 Hierarchical Democracy
Hierarchical Democracy The presidential election in Republic of Democratia is carried out through multiple stages as follows. 1. There are exactly two presidential candidates. 2. At the first stage, eligible voters go to the polls of his/her electoral district. The winner of the district is the candidate who takes a ...
{ "input": [], "output": [] }
{ "input": [ "6\n[[123][4567][89]]\n[[5][3][7][3][9]]\n[[[99][59][63][85][51]][[1539][7995][467]][[51][57][79][99][3][91][59]]]\n[[[37][95][31][77][15]][[43][5][5][5][85]][[71][3][51][89][29]][[57][95][5][69][31]][[99][59][65][73][31]]]\n[[[[9][7][3]][[3][5][7]][[7][9][5]]][[[9][9][3]][[5][9][9]][[7][7][3]]][[[5]...
{ "input": [ "6\n[[133][4567][89]]\n[[5][3][7][3][9]]\n[[[99][59][63][85][51]][[1539][7995][467]][[51][57][79][99][3][91][59]]]\n[[[37][95][31][77][15]][[43][5][5][5][85]][[71][3][51][89][29]][[57][95][5][69][31]][[99][59][65][73][31]]]\n[[[[9][7][3]][[3][5][7]][[7][9][5]]][[[9][9][3]][[5][9][9]][[7][7][3]]][[[5]...