name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p02552 AtCoder Beginner Contest 178 - Not
Given is an integer x that is greater than or equal to 0, and less than or equal to 1. Output 1 if x is equal to 0, or 0 if x is equal to 1. Constraints * 0 \leq x \leq 1 * x is an integer Input Input is given from Standard Input in the following format: x Output Print 1 if x is equal to 0, or 0 if x is equal ...
{ "input": [], "output": [] }
{ "input": [ "1", "0" ], "output": [ "0", "1" ] }
{ "input": [ "000", "000" ], "output": [ "1\n", "1\n" ] }
p02683 AtCoder Beginner Contest 167 - Skill Up
Constraints * All values in input are integers. * 1\leq N, M\leq 12 * 1\leq X\leq 10^5 * 1\leq C_i \leq 10^5 * 0\leq A_{i, j} \leq 10^5 Input Input is given from Standard Input in the following format: N M X C_1 A_{1,1} A_{1,2} \cdots A_{1,M} C_2 A_{2,1} A_{2,2} \cdots A_{2,M} \vdots C_N A_{N,1} A_{N,2} \cdots A_{...
{ "input": [], "output": [] }
{ "input": [ "3 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5", "3 3 10\n60 2 2 4\n70 8 7 9\n50 2 3 9", "8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 8 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2" ], "output": [ "-1", "120", "1067" ] }
{ "input": [ "2 3 10\n100 3 1 4\n100 1 5 9\n100 2 6 5", "3 3 10\n60 2 2 4\n70 8 7 2\n50 2 3 9", "8 5 22\n100 3 7 5 3 1\n164 4 5 2 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4 3 3 6\n235 4 6 6 9 7\n394 3 6 1 6 2\n872 8 4 3 7 2", "8 5 22\n100 3 7 5 3 1\n164 4 5 1 7 8\n334 7 2 7 2 9\n234 4 7 2 8 2\n541 5 4...
p02811 AtCoder Beginner Contest 150 - 500 Yen Coins
Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print `Yes`; otherwise, print `No`. Constraints * 1 \leq K \leq 100 * 1 \leq X \leq 10^5 Input Input is given from Standard Input in the following format: K X Output If the coins add up to X yen or more, prin...
{ "input": [], "output": [] }
{ "input": [ "1 501", "4 2000", "2 900" ], "output": [ "No", "Yes", "Yes" ] }
{ "input": [ "0 501", "4 1282", "0 900", "0 588", "8 1282", "0 50", "0 192", "13 1282", "-1 50", "0 379", "10 1282", "0 88", "1 379", "10 333", "0 165", "2 379", "10 53", "1 165", "0 246", "10 96", "1 227", "1 246", "10 105", ...
p02948 AtCoder Beginner Contest 137 - Summer Vacation
There are N one-off jobs available. If you take the i-th job and complete it, you will earn the reward of B_i after A_i days from the day you do it. You can take and complete at most one of these jobs in a day. However, you cannot retake a job that you have already done. Find the maximum total reward that you can ea...
{ "input": [], "output": [] }
{ "input": [ "5 3\n1 2\n1 3\n1 4\n2 1\n2 3", "1 1\n2 1", "3 4\n4 3\n4 1\n2 2" ], "output": [ "10", "0", "5" ] }
{ "input": [ "5 3\n1 2\n1 3\n1 4\n1 1\n2 3", "3 4\n4 3\n4 1\n3 2", "5 3\n1 2\n1 0\n1 4\n1 1\n2 3", "1 3\n1 2\n1 0\n1 4\n1 1\n2 3", "3 4\n4 3\n3 0\n3 4", "3 4\n4 3\n3 1\n2 4", "3 0\n4 3\n3 1\n2 4", "1 1\n1 21\n8 2\n0 81", "3 5\n4 3\n4 1\n2 2", "3 4\n4 3\n4 1\n6 2", "5 3\n1 2...
p03084 ExaWizards 2019 - More Realistic Manhattan Distance
In Takaha-shi, the capital of Republic of AtCoder, there are N roads extending east and west, and M roads extending north and south. There are no other roads. The i-th east-west road from the north and the j-th north-south road from the west cross at the intersection (i, j). Two east-west roads do not cross, nor do two...
{ "input": [], "output": [] }
{ "input": [ "9 7 10\nEEEEEWEWW\nNSSSNSN\n4 6 9 2\n3 7 6 7\n7 5 3 5\n1 1 8 1\n4 3 5 4\n7 4 6 4\n2 5 8 6\n6 6 2 7\n2 4 7 5\n7 2 9 7", "4 5 4\nEEWW\nNSNNS\n4 1 1 4\n1 3 1 2\n4 2 3 2\n3 3 3 5", "3 3 2\nEEE\nSSS\n1 1 3 3\n3 3 1 1" ], "output": [ "9\n-1\n4\n9\n2\n3\n7\n7\n6\n-1", "6\n11\n5\n4", ...
{ "input": [ "6 3 2\nEEE\nSSS\n1 1 3 3\n3 3 1 1", "4 5 2\nEEWW\nNSNNS\n4 1 1 4\n1 3 1 2\n4 2 3 2\n3 3 3 5", "4 5 4\nEEWW\nNSNNS\n4 1 1 4\n1 3 1 2\n4 2 3 2\n3 3 4 5", "6 3 1\nEEE\nSSS\n1 1 3 3\n3 4 1 1", "3 3 1\nEEE\nSSS\n1 2 3 3\n3 3 1 2", "6 3 1\nEEE\nSSS\n1 1 3 1\n6 4 1 1", "4 5 4\nEEWW\...
p03229 Tenka1 Programmer Beginner Contest - Align
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like. Constraints * 2 \leq N \leq 10^5 * 1 \leq A_i \leq 10^9 * All values in input are integers. Input Input is given f...
{ "input": [], "output": [] }
{ "input": [ "3\n5\n5\n1", "6\n3\n1\n4\n1\n5\n9", "5\n6\n8\n1\n2\n3" ], "output": [ "8", "25", "21" ] }
{ "input": [ "3\n5\n6\n1", "6\n6\n1\n4\n1\n5\n9", "5\n6\n8\n1\n1\n3", "3\n5\n3\n1", "6\n6\n1\n4\n1\n1\n9", "5\n6\n4\n1\n1\n3", "3\n0\n3\n1", "6\n6\n1\n7\n1\n1\n9", "5\n6\n4\n1\n2\n3", "3\n0\n0\n1", "6\n6\n1\n7\n0\n1\n9", "5\n6\n4\n1\n0\n3", "3\n-1\n0\n1", "6\n6\...
p03377 AtCoder Beginner Contest 094 - Cats and Dogs
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * 1 \leq X \leq 200 * All values in input...
{ "input": [], "output": [] }
{ "input": [ "2 2 6", "3 5 4", "5 3 2" ], "output": [ "NO", "YES", "NO" ] }
{ "input": [ "2 0 6", "2 5 4", "5 3 3", "2 -1 6", "4 5 4", "2 3 3", "2 0 0", "5 5 4", "2 3 5", "2 0 1", "2 5 8", "2 3 9", "3 0 1", "2 2 8", "4 3 9", "1 0 1", "2 0 8", "0 3 9", "3 0 2", "2 -1 8", "-1 3 9", "3 0 3", "4 -1 8", ...
p03544 AtCoder Beginner Contest 079 - Lucas Number
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2) Constraints * 1≤N≤86 * It is guaranteed that the answer is less than 10^{18}. ...
{ "input": [], "output": [] }
{ "input": [ "5", "86" ], "output": [ "11", "939587134549734843" ] }
{ "input": [ "1", "2", "4", "3", "30", "49", "6", "8", "7", "58", "9", "13", "14", "55", "12", "19", "20", "16", "24", "21", "10", "28", "56", "17", "27", "50", "81", "34", "44", "22", "72", ...
p03698 AtCoder Beginner Contest 063 - Varied
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. Constraints * 2 ≤ |S| ≤ 26, where |S| denotes the length of S. * S consists of lowercase English letters. Input Input is given from Standard Input in the following format: S Output If all ...
{ "input": [], "output": [] }
{ "input": [ "uncopyrightable", "different", "no" ], "output": [ "yes", "no", "yes" ] }
{ "input": [ "uncopyrightacle", "np", "tnereffid", "elcathgirypocnu", "dnereffit", "mp", "elcathgirxpocnu", "enereffit", "pm", "elcathgiqxpocnu", "emereffit", "pl", "elcathgiqxcopnu", "fmereffit", "ol", "elcathfiqxcopnu", "fmerdffit", "lo", "...
p03853 AtCoder Beginner Contest 049 - Thin
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, p...
{ "input": [], "output": [] }
{ "input": [ "9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........", "2 2\n*.\n.*", "1 4\n***." ], "output": [ ".....***....***.....\n.....***....**...
{ "input": [ "9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*.*..*.......\n........**.*........\n.........**.........", "2 2\n*.\n*.", "1 4\n**).", "9 20\n.....***....***.....\n....*...*..*...*....\n...*...
p04020 AtCoder Grand Contest 003 - Simplified mahjong
Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i. Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1. Snuke wants to create the maximum number of pairs from his card...
{ "input": [], "output": [] }
{ "input": [ "8\n2\n0\n1\n6\n0\n8\n2\n1", "4\n4\n0\n3\n2" ], "output": [ "9", "4" ] }
{ "input": [ "8\n2\n0\n1\n6\n1\n8\n2\n1", "4\n4\n0\n3\n1", "8\n2\n0\n1\n9\n1\n8\n2\n1", "4\n3\n0\n3\n1", "4\n0\n0\n3\n1", "8\n1\n0\n1\n9\n1\n5\n2\n1", "8\n1\n0\n1\n1\n1\n5\n1\n1", "8\n0\n0\n1\n4\n1\n5\n1\n1", "8\n0\n0\n1\n4\n1\n5\n2\n1", "8\n1\n1\n2\n0\n1\n5\n4\n2", "8\n2\n...
p00104 Magical Tiles
There is a magic room in a homestead. The room is paved with H × W tiles. There are five different tiles: * Tile with a east-pointing arrow * Tile with a west-pointing arrow * Tile with a south-pointing arrow * Tile with a north-pointing arrow * Tile with nothing Once a person steps onto a tile which has an arrow, ...
{ "input": [], "output": [] }
{ "input": [ "10 10\n>>>v..>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v", "10 10\n>>>v..>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v<<<<...v\n.v.v.^...v\n.v.v.^<<<<\n.v.v.....v\n.v...^...v\n.>>>>^....\n6 10\n>>>>>>>>>v\n.........v\n.........v\n>>>>v....v\n^...v....v\n^<<<<<<<<<\n0 0" ], "output": [ "5...
{ "input": [ "10 10\n>>>.v.>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v", "10 20\n>>>v..>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v", "10 10\n>>>v..>>>v\n...v..^..v\n>>>>>>^..v\n.........v\n.v<<<<...v\n.v.v.^...v\n.v.v.^<<<<\n.v.v.....v\n.v...^...v\n.?>>>^....\n6 10\n>>>>>>>>>v\n.........v\n.........v\n>...
p00238 Time to Study
Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed in 24-hour notation in...
{ "input": [], "output": [] }
{ "input": [ "10\n3\n6 11\n12 15\n18 22\n14\n2\n6 11\n13 20\n0" ], "output": [ "OK\n2" ] }
{ "input": [ "10\n3\n6 11\n12 15\n18 22\n14\n2\n6 14\n13 20\n0", "10\n3\n8 11\n12 19\n18 38\n14\n2\n6 14\n5 6\n0", "10\n3\n8 11\n12 19\n18 38\n8\n2\n6 6\n5 6\n0", "10\n3\n6 11\n12 15\n18 22\n14\n2\n6 1\n13 20\n0", "10\n3\n6 11\n12 15\n34 22\n14\n2\n6 14\n13 20\n0", "10\n3\n8 11\n12 19\n18 9\n8...
p00409 Prayer for Iwashiro
In the ancient nation of Iwashiro, priests pray to calm disasters in the event of a disaster. The priest selects the character string S from the ancient documents and proceeds with the ritual by repeating the following. * Select one place in the string $ S $, replace the character written there with another character...
{ "input": [], "output": [] }
{ "input": [ "6 5\nababac\n6 b\n3 c\n4 a\n5 b\n6 c" ], "output": [ "2\n6\n6\n6\n3" ] }
{ "input": [ "6 5\nababac\n6 b\n2 c\n4 a\n5 b\n6 c", "6 5\nababac\n6 b\n2 b\n4 b\n5 b\n6 c", "6 5\nabacac\n6 b\n2 b\n4 b\n5 c\n6 c", "6 5\nababac\n3 b\n3 c\n4 a\n5 b\n1 c", "6 5\nabacac\n6 b\n2 b\n4 c\n5 c\n5 d", "6 2\nababac\n3 a\n5 c\n4 a\n5 b\n1 c", "6 5\nababac\n6 b\n4 c\n4 b\n5 b\n1 c...
p00614 ICPC: Ideal Coin Payment and Change
Taro, a boy who hates any inefficiencies, pays coins so that the number of coins to be returned as change is minimized in order to do smoothly when he buys something. One day, however, he doubt if this way is really efficient. When he pays more number of coins, a clerk consumes longer time to find the total value. May...
{ "input": [], "output": [] }
{ "input": [ "123 3 0 2 0 1 1\n999 9 9 9 9 9 9\n0 0 0 0 0 0 0" ], "output": [ "6\n3" ] }
{ "input": [ "123 3 0 2 0 1 1\n999 9 9 9 9 9 10\n0 0 0 0 0 0 0", "123 3 1 2 0 1 1\n1315 8 9 9 9 14 10\n0 0 0 0 0 0 0", "105 3 1 2 1 2 1\n999 9 9 9 1 15 10\n0 0 0 0 0 0 0", "123 5 1 2 2 0 1\n999 21 9 9 1 9 10\n0 0 0 0 0 0 0", "105 3 1 2 1 2 1\n1413 9 9 9 1 15 10\n0 0 0 0 0 0 0", "167 3 1 2 1 2 ...
p00752 Laser Beam Reflections
A laser beam generator, a target object and some mirrors are placed on a plane. The mirrors stand upright on the plane, and both sides of the mirrors are flat and can reflect beams. To point the beam at the target, you may set the beam to several directions because of different reflections. Your job is to find the shor...
{ "input": [], "output": [] }
{ "input": [ "2\n30 10 30 75\n60 30 60 95\n90 0\n0 100\n1\n20 81 90 90\n10 90\n90 10\n2\n10 0 10 58\n20 20 20 58\n0 70\n30 0\n4\n8 0 8 60\n16 16 16 48\n16 10 28 30\n16 52 28 34\n24 0\n24 64\n5\n8 0 8 60\n16 16 16 48\n16 10 28 30\n16 52 28 34\n100 0 100 50\n24 0\n24 64\n0" ], "output": [ "180.2775637731994...
{ "input": [ "2\n30 10 30 75\n60 30 60 95\n90 0\n0 100\n1\n20 81 125 90\n10 90\n90 10\n2\n10 0 10 58\n20 20 20 58\n0 70\n30 0\n4\n8 0 8 60\n16 16 16 48\n16 10 28 30\n16 52 28 34\n24 0\n24 64\n5\n8 0 8 60\n16 16 16 48\n16 10 28 30\n16 52 28 34\n100 0 100 50\n24 0\n24 64\n0", "2\n30 10 30 75\n60 30 60 95\n90 0\...
p00890 Test Case Tweaking
You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answer is a desired value such as the number representing this year 2010. So you ...
{ "input": [], "output": [] }
{ "input": [ "3 3 3\n1 2 3\n2 3 3\n1 3 8\n12 12 2010\n1 2 0\n2 3 3000\n3 4 0\n4 5 3000\n5 6 3000\n6 12 2010\n2 7 100\n7 8 200\n8 9 300\n9 10 400\n10 11 500\n11 6 512\n10 18 1\n1 2 9\n1 3 2\n1 4 6\n2 5 0\n2 6 10\n2 7 2\n3 5 10\n3 6 3\n3 7 10\n4 7 6\n5 8 10\n6 8 2\n6 9 11\n7 9 3\n8 9 9\n8 10 8\n9 10 1\n8 2 1\n0 0 0...
{ "input": [ "3 3 3\n1 2 3\n2 3 3\n1 3 8\n12 12 2010\n1 2 0\n2 3 3000\n3 4 0\n4 5 3000\n5 6 3000\n6 12 2010\n2 7 100\n7 8 200\n8 9 300\n9 10 400\n10 11 500\n11 6 512\n10 18 1\n1 2 7\n1 3 2\n1 4 6\n2 5 0\n2 6 10\n2 7 2\n3 5 10\n3 6 3\n3 7 10\n4 7 6\n5 8 10\n6 8 2\n6 9 11\n7 9 3\n8 9 9\n8 10 8\n9 10 1\n8 2 1\n0 0 0...
p01022 Yu-kun Likes Building Block
Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves rectangular blocks as much as programming. Yu-kun has been enthusiastic about making mountains with building blocks recently. Yu-kun was playing with...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1\n2 2\n3 3", "5\n1 5\n2 4\n3 3\n4 2\n5 1", "5\n2 3\n3 5\n1 2\n1 4\n3 5", "10\n5 11\n12 12\n4 14\n22 12\n11 13\n3 3\n3 3\n12 5\n55 55\n1 1" ], "output": [ "1", "5", "2", "3" ] }
{ "input": [ "3\n0 1\n2 2\n3 3", "5\n1 5\n2 4\n3 3\n0 2\n5 1", "5\n2 3\n3 5\n1 2\n0 4\n3 5", "10\n5 11\n12 12\n4 14\n38 12\n11 13\n3 3\n3 3\n12 5\n55 55\n1 1", "5\n1 3\n0 4\n3 0\n0 3\n3 1", "10\n0 9\n16 1\n6 48\n22 0\n12 0\n4 0\n0 11\n19 9\n103 55\n0 2", "3\n0 1\n2 2\n5 3", "5\n1 5\n2 ...
p01154 Light The Room
You are given plans of rooms of polygonal shapes. The walls of the rooms on the plans are placed parallel to either x-axis or y-axis. In addition, the walls are made of special materials so they reflect light from sources as mirrors do, but only once. In other words, the walls do not reflect light already reflected at ...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0\n2 0\n2 2\n0 2\n1 1\n6\n2 2\n2 5\n0 5\n0 0\n5 0\n5 2\n1 4\n0" ], "output": [ "0.000\n3.000" ] }
{ "input": [ "4\n0 0\n2 0\n2 2\n0 2\n1 1\n6\n2 2\n2 5\n0 5\n0 0\n5 0\n8 2\n1 4\n0", "4\n0 0\n2 0\n2 2\n0 2\n1 1\n6\n2 2\n2 5\n-1 5\n0 0\n5 0\n8 2\n1 4\n0", "4\n0 0\n2 0\n2 2\n0 2\n1 1\n6\n2 2\n2 5\n-1 5\n0 0\n8 0\n8 2\n1 4\n0", "4\n0 0\n2 0\n2 2\n0 2\n1 1\n6\n2 2\n2 5\n-1 5\n0 0\n16 0\n8 2\n1 4\n0", ...
p01293 Whist
Whist is a game played by four players with a standard deck of playing cards. The players seat around a table, namely, in north, east, south, and west. This game is played in a team-play basis: the players seating opposite to each other become a team. In other words, they make two teams we could call the north-south te...
{ "input": [], "output": [] }
{ "input": [ "H\n4C 8H QS 5D JD KS 8S AH 6H 7H 3S 7S 6D\nTC JC JS KD AC QC QD 2H QH 3H 3C 7C 4D\n6C 9C AS TD 5H 6S 5S KH TH AD 9S 8D 2D\n8C 5C 2S 7D KC 4S TS JH 4H 9H 2C 9D 3D\nD\n8D 9D 9S QS 4H 5H JD JS 9H 6S TH 6H QH\nQD 9C 5S 7S 7H AC 2D KD 6C 3D 8C TC 7C\n5D QC 3S 4S 3H 3C 6D KS JC AS 5C 8H TS\n4D 4C 8S 2S 2H...
{ "input": [ "H\n4C 8H QS 5D JD KS 8S AH 6H 7H 3S 7S 6D\nTC JC JS KD AC QC QD 2H QH 3H 3C 7C 4D\n6C 9C AS TD 5H 6S 5S KH TH AD 9S 8D 2D\n8C 5C 2S 7D KC 4S TS JH 4H 9H 2C 9D 3D\nD\n8D 9D 9S QS 4H H5 JD JS 9H 6S TH 6H QH\nQD 9C 5S 7S 7H AC 2D KD 6C 3D 8C TC 7C\n5D QC 3S 4S 3H 3C 6D KS JC AS 5C 8H TS\n4D 4C 8S 2S 2H...
p01462 Network Reliability
An undirected graph is given. Each edge of the graph disappears with a constant probability. Calculate the probability with which the remained graph is connected. Input The first line contains three integers N (1 \leq N \leq 14), M (0 \leq M \leq 100) and P (0 \leq P \leq 100), separated by a single space. N is the...
{ "input": [], "output": [] }
{ "input": [ "3 3 10\n1 2\n2 3\n3 1", "4 5 50\n1 2\n2 3\n3 4\n4 1\n1 3", "3 3 50\n1 2\n2 3\n3 1" ], "output": [ "0.972000000000", "0.437500000000", "0.500000000000" ] }
{ "input": [ "4 5 50\n1 2\n2 3\n3 4\n4 2\n1 3", "3 0 50\n1 2\n2 3\n3 1", "3 3 10\n1 2\n3 3\n3 1", "4 5 50\n2 2\n2 3\n3 4\n4 1\n1 3", "1 0 31\n1 2\n2 3\n3 0", "2 3 10\n1 2\n3 3\n3 1", "3 0 31\n1 2\n2 3\n3 1", "3 0 31\n1 1\n2 3\n3 1", "3 0 43\n1 1\n2 3\n3 1", "3 0 43\n1 1\n2 3\n1...
p01621 Sim Forest 2013
There is a game called Sim Forest 2013. In this game, the player can become a forest god and raise forest animals. Animals hatch from eggs and breed. When certain conditions are met, eggs are mutated with a certain probability to give birth to new races of animals. There is an animal encyclopedia in this game, and wh...
{ "input": [], "output": [] }
{ "input": [ "1 1 3 All All 1 1\n2 37 5 All Night 150 1\n16 2 20 All Day 5 10\n1 14 15 Mon All 20000 100\n0 0 0 None None 0 0" ], "output": [ "1.0000000000\n0.2192439716\n0.9884707850\n0.0649933899" ] }
{ "input": [ "1 1 3 All All 1 1\n2 37 2 All Night 150 1\n16 2 20 All Day 5 10\n1 14 15 Mon All 20000 100\n0 0 0 None None 0 0", "1 1 3 Alm All 1 1\n3 37 2 All Night 150 1\n18 2 19 All Day 5 10\n1 14 15 Mno All 23674 100\n0 0 0 None None 0 0", "2 1 3 Alm All 1 1\n3 37 2 All Nifht 150 1\n18 2 19 All Eay 5 1...
p01774 Digital Clock
C: Digital Clock story Aizu Nyan has recently caught a cold. I can't get out of bed because I'm too lazy. The spicy appearance is also cute. However, Aizu Nyan, who had no choice but to spare time, came up with a way to play with the digital clock under the pillow. The number of glowing bars of a digital clock as sh...
{ "input": [], "output": [] }
{ "input": [ "28\n0" ], "output": [ "1" ] }
{ "input": [ "28\n000", "28\n000" ], "output": [ "1\n", "1\n" ] }
p01908 Password
problem AOR Ika wants to create a strong password that consists only of lowercase letters. AOR Ika-chan, who was given an example of $ N $ of dangerous passwords by a friend, decided to create a password that meets all of the following conditions. 1. The length is at least one character. 2. Different from any contigu...
{ "input": [], "output": [] }
{ "input": [ "5\npassword\nlogin\nadmin\nroot\nmaster" ], "output": [ "b" ] }
{ "input": [ "5\npassword\nlogin\nnimda\nroot\nmaster", "5\nbraprswp\nlofho\nojdma\nsnnt\nfuarsm", "5\nbraprsxp\noofhk\nojcma\nsnnt\nfuarsm", "5\napssword\nlogin\nnimda\nroot\nmaster", "5\nopssward\nlogin\nnimda\nroot\nmaster", "5\ndrawsspo\nlogin\nnimda\nroot\nmaster", "5\ndrawsspo\nlogin...
p02047 String Magic
String magic As a witch, you are still practicing magic today. You now have the string X, which consists of lowercase letters, at hand. The task of your training today is to change this string to another string Y. You have mastered four types of magic that change strings, and you can cast them as many times as you li...
{ "input": [], "output": [] }
{ "input": [ "typewriter\nperiodicity\n100010\n100100\n101000\n110000\nperiodicity\ntypewriter\n100010\n100100\n101000\n110000\nperiodicity\ntypewriter\n100010\n100100\n101000\n1\ndomestic\ncontest\n100010\n100100\n101000\n110000\n#" ], "output": [ "823120\n1001540\n603217\n502210" ] }
{ "input": [ "typewriter\nperiodicity\n100010\n100100\n111000\n110000\nperiodicity\ntypewriter\n100010\n100100\n101000\n110000\nperiodicity\ntypewriter\n100010\n100100\n101000\n1\ndomestic\ncontest\n100010\n100100\n101000\n110000\n#", "typewriter\nperiodicity\n100010\n100100\n111000\n110000\nperiodicity\ntype...
p02189 Min Element
Min Element Given the sequence a_1, a_2, .., a_N. Find the minimum number in this sequence. If the minimum value is in more than one place, answer the one with the lowest number. input N a_1 a_2 ... a_N output Output the smallest i such that a_i is the minimum value in the sequence. Constraint * 1 \ leq N \ ...
{ "input": [], "output": [] }
{ "input": [ "6\n8 6 9 1 2 1" ], "output": [ "4" ] }
{ "input": [ "6\n8 6 9 0 2 1", "6\n8 6 9 1 2 0", "6\n3 33 0 2 10 0", "6\n3 18 3 4 0 0", "6\n6 0 9 1 2 1", "6\n1 6 9 1 2 0", "6\n1 6 9 0 2 0", "6\n8 3 9 1 2 1", "6\n6 6 9 0 2 1", "6\n8 6 9 2 2 0", "6\n1 6 9 1 3 0", "6\n2 6 9 0 2 0", "6\n8 3 9 1 3 1", "6\n6 6 9 0 ...
p02343 Disjoint Set: Union Find Tree
Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}. First of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively. Next, the program should read an integer q and manipulate the set for q queries. There are two kinds of que...
{ "input": [], "output": [] }
{ "input": [ "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0" ], "output": [ "0\n0\n1\n1\n1\n0\n1\n1" ] }
{ "input": [ "5 12\n0 2 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 2 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 2 4\n1 2 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "5 12\n0 1 4\...
p02476 Remainder of Big Integers
Remainder of Big Integers Given two integers $A$ and $B$, compute the remainder of $\frac{A}{B}$. Input Two integers $A$ and $B$ separated by a space character are given in a line. Output Print the remainder in a line. Constraints * $0 \leq A, B \leq 10^{1000}$ * $B \ne 0$ Sample Input 1 5 8 Sample Output...
{ "input": [], "output": [] }
{ "input": [ "5 8" ], "output": [ "5" ] }
{ "input": [ "5 3", "9 3", "9 6", "16 6", "4 3", "5 7", "6 7", "8 13", "10 16", "11 12", "18 11", "9 54", "12 47", "14 28", "9 1", "5 1", "4 1", "4 2", "6 2", "8 2", "8 3", "0 8", "5 5", "10 6", "18 1", "6 1", ...
cdxm1
Like most of the demanding childs.Pratik don't stop until he gets that.He keep on repeating the name of that thing again and again. For example if he want a computer,He will keep on repeating "computer" again and again. His dad has decided to answer to his demand as "Yes" or "No" without any delay.Otherwise there would...
{ "input": [], "output": [] }
{ "input": [ "computer\n4\n3 7\n2 10\n5 21\n11 26" ], "output": [ "No\nYes\nYes\nNo" ] }
{ "input": [ "computer\n4\n5 7\n2 10\n5 21\n11 26", "computer\n4\n5 7\n2 7\n5 21\n11 26", "computer\n4\n0 11\n2 7\n5 35\n11 26", "computer\n4\n0 11\n2 2\n5 35\n11 26", "pomcuter\n4\n-2 11\n2 3\n5 35\n18 26", "computer\n4\n-1 7\n2 7\n5 21\n11 26", "computer\n4\n0 11\n2 2\n5 35\n11 27", ...
dcgame
Devu and Churu love to play games a lot. Today, they have an array A consisting of N positive integers. First they listed all N × (N+1) / 2 non-empty continuous subarrays of the array A on a piece of paper and then replaced all the subarrays on the paper with the maximum element present in the respective subarray. Devu...
{ "input": [], "output": [] }
{ "input": [ "3 5\n1 2 3\n> 1 D\n< 2 C\n= 3 D\n> 4 C\n< 5 D" ], "output": [ "DCDDC" ] }
{ "input": [], "output": [] }
iiti13
John Watson always knew that one of the favourite hobbies of Sherlock Holmes was to tinker with ciphers. Though Watson was not that good with ciphers, he learnt a few things being with him. Right now, Watson is in trouble! He has been locked in a room and the only way to get out of the room is through deciphering a kn...
{ "input": [], "output": [] }
{ "input": [ "3\n5\nabcde\n1 2 3 4 5\n6\nfluxus\n6 5 4 3 2 1\n8\nhrcksleo\n5 5 7 5 6 8 7 8" ], "output": [ "abcde\nfluxus\nsherlock" ] }
{ "input": [], "output": [] }
name1
In an attempt to reduce the growing population, Archer was asked to come up with a plan. Archer being as intelligent as he is, came up with the following plan: If N children, with names C1, C2, ..., CN, are born to parents with names A and B, and you consider C to be the concatenation of all the names of the children, ...
{ "input": [], "output": [] }
{ "input": [ "3\ntom marvoloriddle\n2\nlord\nvoldemort\ncheap up\n1\nheapcup\nbruce wayne\n2\nbat\nman" ], "output": [ "YES\nYES\nNO\n" ] }
{ "input": [ "3\ntom marwoloriddle\n2\nlord\nvoldemort\ncheap up\n1\nheapcup\nbruce wayne\n2\nbat\nman", "3\ntom marwoloriedle\n2\nlnrd\nvoldemort\ncheap qu\n1\nheapcup\nbeucr wayne\n2\nbat\nman", "3\ntom marvoloriddle\n2\nlord\nvoldemort\ncheap pu\n1\nheapcup\nbruce wayne\n2\nbat\nman", "3\ntom marvo...
rrjoke
Vadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem: Given N points on a plane. Each point p is defined by it's two integer coordinates — px and py. The distance between points a and b is min(|ax - bx|, |ay - by|). You should choose a starting point and...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n1 2\n0 0\n3\n3 3\n0 0\n0 3" ], "output": [ "3\n0\n" ] }
{ "input": [ "2\n2\n1 2\n1 0\n3\n3 3\n0 0\n0 3", "2\n2\n2 3\n0 0\n2\n3 -1\n-1 0\n1 1", "2\n2\n2 2\n1 0\n1\n3 0\n-1 1\n-1 2", "2\n2\n1 2\n1 0\n3\n3 3\n-1 0\n0 3", "2\n2\n1 2\n1 0\n3\n3 0\n-1 0\n0 3", "2\n2\n1 2\n1 0\n3\n3 0\n-1 0\n0 1", "2\n2\n1 2\n1 0\n3\n3 0\n-1 0\n1 1", "2\n2\n1 2\n1...
wolvxr
For Turbo C++ Users : Read the following document before attempting the question : Problem description Logan is tired of not being able to clear security clearances while travelling (thanks to his Adamantium skeleton :\ ). He goes to Magneto for some help regarding this matter. Magneto decides to help him, but o...
{ "input": [], "output": [] }
{ "input": [ "1\n2" ], "output": [ "0\n" ] }
{ "input": [ "1\n0", "1\n1", "1\n-1", "1\n-2", "1\n4", "1\n8", "1\n5", "1\n10", "1\n9", "1\n6", "1\n12", "1\n21", "1\n34", "1\n59", "1\n81", "1\n36", "1\n18", "1\n15", "1\n30", "1\n-4", "1\n-8", "1\n-14", "1\n-22", "1\n-38...
1196_C. Robot Breakout
n robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous! Fortunately, even though your robots have escaped, you still have some control over them. First of all, you know the locat...
{ "input": [], "output": [] }
{ "input": [ "4\n2\n-1 -2 0 0 0 0\n-1 -2 0 0 0 0\n3\n1 5 1 1 1 1\n2 5 0 1 0 1\n3 5 1 0 0 0\n2\n1337 1337 0 1 1 1\n1336 1337 1 1 0 1\n1\n3 5 1 1 1 1\n" ], "output": [ "1 -1 -2\n1 2 5\n0\n1 -100000 -100000\n" ] }
{ "input": [ "4\n2\n-1 -2 0 0 0 0\n-1 -2 0 0 0 0\n3\n1 5 1 1 1 1\n2 5 0 0 0 1\n3 5 1 0 0 0\n2\n1337 1337 0 1 1 1\n1336 1337 1 1 0 1\n1\n3 5 1 1 1 1\n", "4\n2\n-1 -2 0 0 0 0\n0 -2 0 0 0 0\n3\n1 5 1 1 1 1\n2 5 0 1 0 1\n3 5 1 0 0 0\n2\n1337 1337 0 1 1 1\n1336 1337 1 1 0 1\n1\n3 5 1 1 1 1\n", "4\n2\n-1 -2 0 0...
1403_C. Chess Rush
The mythic world of Chess Land is a rectangular grid of squares with R rows and C columns, R being greater than or equal to C. Its rows and columns are numbered from 1 to R and 1 to C, respectively. The inhabitants of Chess Land are usually mentioned as pieces in everyday language, and there are 5 specific types of t...
{ "input": [], "output": [] }
{ "input": [ "8 8 5\nP 1 2\nR 4 8\nQ 2 3\nB 3 6\nK 5 5\n" ], "output": [ "\n0 0\n2 2\n2 5\n2 2\n7 393\n" ] }
{ "input": [], "output": [] }
bear-and-chocolate
View Russian Translation Limak is a little polar bear. Today he found something delicious in the snow. It's a square bar of chocolate with N x N pieces. Some pieces are special because there are cherries on them. You might be surprised by cherries on a chocolate but you've never been on the Arctic Circle, have you? L...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n###\n##.\n###\n4\n####\n.##.\n.#..\n#...\n\nSAMPLE" ], "output": [ "NO\nYES\n" ] }
{ "input": [ "2\n3\n###\n##.\n$##\n4\n####\n.##.\n.#..\n#...\n\nSAMPLE", "2\n3\n###\n#\".\n###\n4\n####\n.\"#.\n.#..\n...#\n\nSAMFLP", "2\n3\n###\n#$.\n##$\n4\n####\n.##.\n.#..\n#...\n\nELPMAS", "2\n3\n$##\n#\".\n###\n4\n###\"\n.##.\n..#.\n./.#\n\nSAMFLP", "2\n3\n###\n##.\n###\n4\n####\n.##.\n.#.....
nikhil-and-binary-numbers
Nikhil has written N binary integers (i.e. eithim zero or one) on a copy. He recently learned about XOR operation. Now He wants to erase exactly one integer in the array so that the XOR of the remaining N - 1 numbers is zero. Please help him to calculate the number of ways of doing so. Input The first line of the inp...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n1 0 0 0 0\n5\n1 1 1 1 1\n\nSAMPLE" ], "output": [ "1\n5\n" ] }
{ "input": [ "2\n5\n1 0 0 0 0\n5\n1 0 1 1 1\n\nSAMPLE", "2\n5\n1 0 0 1 0\n5\n1 0 1 1 1\n\nSAMPLE", "2\n5\n1 0 0 1 0\n5\n1 0 1 1 0\n\nSAMPLD", "2\n2\n1 0 0 0 0\n5\n1 1 1 1 1\n\nSAMPLE", "2\n5\n1 0 0 1 0\n5\n1 1 1 1 1\n\nSAMPLE", "2\n5\n0 0 0 1 0\n5\n1 0 1 0 0\n\nSAMPLD", "2\n5\n0 0 0 0 0\n5...
the-football-fest-6
The very famous football club Manchester United decided to popularize football in India by organizing a football fest. The fest had many events for different sections of people. For the awesome coders of Hacker Earth, there was an event called PASS and BACK. In this event, the coders were given N passes and players hav...
{ "input": [], "output": [] }
{ "input": [ "1\n10 23\nP 86\nP 63\nP 60\nB\nP 47\nB\nP 99\nP 9\nB\nB\n\nSAMPLE" ], "output": [ "Player 9\n" ] }
{ "input": [ "1\n10 23\nP 42\nP 63\nP 60\nB\nP 47\nB\nP 99\nP 9\nB\nB\n\nSAMPLE", "1\n1 23\nP 42\nQ 63\nP 60\nB\nP 47\nB\nP 99\nP 9\nB\nB\n\nSAMPLE", "1\n10 24\nP 42\nO 63\nQ 60\nB\nP 47\nB\nQ 99\nP 15\nB\nB\n\nSBMPLE", "1\n7 24\nP 42\nP 63\nP 60\nB\nP 47\nB\nP 99\nP 9\nB\nB\n\nSAMPEL", "1\n10 23\...
p02657 AtCoder Beginner Contest 169 - Multiplication 1
Compute A \times B. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: A B Output Print the value A \times B as an integer. Examples Input 2 5 Output 10 Input 100 100 Output 10000
{ "input": [], "output": [] }
{ "input": [ "2 5", "100 100" ], "output": [ "10", "10000" ] }
{ "input": [ "4 5", "100 000", "4 -1", "001 100", "2 -1", "001 110", "1 -1", "101 110", "101 111", "1 1", "101 101", "101 001", "1 2", "1 3", "111 001", "111 011", "-1 3", "011 011", "-1 6", "-2 6", "001 010", "-4 6", "-3 6", ...
p02786 AtCoder Beginner Contest 153 - Caracal vs Monster
Caracal is fighting with a monster. The health of the monster is H. Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens: * If the monster's health is 1, it drops to 0. * If the monster's health, X, is greater than 1, that monster disappear...
{ "input": [], "output": [] }
{ "input": [ "4", "1000000000000", "2" ], "output": [ "7", "1099511627775", "3" ] }
{ "input": [ "8", "1010000000000", "3", "7", "1", "18", "1110100001000", "46", "77", "140", "426", "635", "1010000001000", "5", "1011000000000", "6", "14", "1010001000000", "12", "1010100001000", "10", "1011000000010", "101000...
p02922 AtCoder Beginner Contest 139 - Power Socket
Takahashi's house has only one socket. Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets. One power strip with A sockets can extend one empty socket into A empty sockets. Find the minimum number of power strips required. Constraints * All values in inp...
{ "input": [], "output": [] }
{ "input": [ "4 10", "8 8", "8 9" ], "output": [ "3", "1", "2" ] }
{ "input": [ "2 10", "8 4", "4 9", "2 5", "7 9", "2 9", "4 14", "2 15", "4 1", "2 8", "2 14", "2 7", "2 13", "2 17", "2 26", "3 31", "2 24", "2 12", "2 23", "2 11", "2 33", "4 57", "2 19", "2 22", "2 29", "3 41", ...
p03057 AtCoder Grand Contest 033 - Go around a Circle
Consider a circle whose perimeter is divided by N points into N arcs of equal length, and each of the arcs is painted red or blue. Such a circle is said to generate a string S from every point when the following condition is satisfied: * We will arbitrarily choose one of the N points on the perimeter and place a piece...
{ "input": [], "output": [] }
{ "input": [ "4 7\nRBRRBRR", "12 10\nRRRRBRRRRB", "3 3\nBBB" ], "output": [ "2", "78", "4" ] }
{ "input": [ "4 6\nRBRRBRR", "5 7\nRBRRBRR", "12 9\nRRRRBRRRRB", "12 10\nRRRRRRBRRB", "5 0\nRBRRBRR", "16 9\nRRRRBRRRRB", "4 3\nRRRBBRR", "4 3\nRRBBRRR", "2 1\nRBRRBRR", "3 1\nRBRRBRR", "1 1\nBRRRBRR", "0 5\nRRBBRRR", "23 1\nBRRRRBRRRR", "17 1\nBRRRRBRRRR", ...
p03201 AtCoder Grand Contest 029 - Powers of two
Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball cannot belong to multiple pairs. Find the maximum possible number of pai...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3", "5\n3 11 14 5 13" ], "output": [ "1", "2" ] }
{ "input": [ "5\n3 21 14 5 13", "5\n2 3 24 6 13", "5\n2 3 38 3 10", "5\n3 24 14 5 13", "5\n3 24 14 10 13", "5\n3 24 16 10 13", "5\n3 36 16 10 13", "5\n3 36 16 14 13", "5\n3 3 16 14 13", "5\n3 3 24 14 13", "5\n3 3 24 6 13", "5\n2 3 24 6 9", "5\n2 3 24 6 14", "5\n...
p03348 AtCoder Grand Contest 024 - Isomorphism Freak
Coloring of the vertices of a tree G is called a good coloring when, for every pair of two vertices u and v painted in the same color, picking u as the root and picking v as the root would result in isomorphic rooted trees. Also, the colorfulness of G is defined as the minimum possible number of different colors used ...
{ "input": [], "output": [] }
{ "input": [ "8\n1 2\n2 3\n4 3\n5 4\n6 7\n6 8\n3 6", "13\n5 6\n6 4\n2 8\n4 7\n8 9\n3 2\n10 4\n11 10\n2 4\n13 10\n1 8\n12 1", "5\n1 2\n2 3\n3 4\n3 5", "10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n3 8\n5 9\n3 10" ], "output": [ "3 4", "4 12", "2 4", "4 6" ] }
{ "input": [ "8\n1 2\n2 3\n4 3\n5 8\n6 7\n6 8\n3 6", "13\n5 6\n5 4\n2 8\n4 7\n8 9\n3 2\n10 4\n11 10\n2 4\n13 10\n1 8\n12 1", "10\n1 2\n2 3\n3 4\n4 5\n8 6\n6 7\n3 8\n5 9\n3 10", "13\n5 6\n5 4\n2 8\n4 7\n8 9\n3 2\n10 4\n11 10\n2 5\n13 10\n1 8\n12 1", "10\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n3 8\n5 9\n3 10...
p03508 Code Festival Team Relay (Parallel) - Shock
You are given an undirected graph G. G has N vertices and M edges. The vertices are numbered from 1 through N, and the i-th edge (1 ≤ i ≤ M) connects Vertex a_i and b_i. G does not have self-loops and multiple edges. You can repeatedly perform the operation of adding an edge between two vertices. However, G must not h...
{ "input": [], "output": [] }
{ "input": [ "4 1\n1 3", "2 0", "9 6\n1 4\n1 8\n2 5\n3 6\n4 8\n5 7" ], "output": [ "2", "0", "12" ] }
{ "input": [ "4 0\n1 3", "9 6\n1 4\n1 8\n2 5\n3 6\n4 1\n5 7", "7 0\n1 3", "9 6\n1 4\n1 8\n2 5\n3 6\n4 1\n5 5", "14 0\n2 3", "14 1\n2 3", "8 0\n2 4", "6 1\n1 3", "2 -1", "7 1\n1 3", "10 0\n2 3", "13 0\n2 3", "21 0\n2 2", "27 0\n2 4", "8 1\n2 4", "15 0\n0 ...
p03669 AtCoder Grand Contest 017 - Jigsaw
We have N irregular jigsaw pieces. Each piece is composed of three rectangular parts of width 1 and various heights joined together. More specifically: * The i-th piece is a part of height H, with another part of height A_i joined to the left, and yet another part of height B_i joined to the right, as shown below. Her...
{ "input": [], "output": [] }
{ "input": [ "10 4\n1 1 0 3\n2 3 2 0\n1 2 3 0\n2 1 0 0\n3 2 0 2\n1 1 3 0\n3 2 0 0\n1 3 2 0\n1 1 1 3\n2 3 0 0", "3 4\n1 1 0 0\n2 2 0 1\n3 3 1 0", "4 2\n1 1 0 1\n1 1 0 1\n1 1 0 1\n1 1 0 1" ], "output": [ "YES", "YES", "NO" ] }
{ "input": [ "10 4\n1 1 0 3\n2 3 2 0\n1 2 3 0\n2 1 0 0\n3 2 0 2\n1 1 3 0\n3 2 0 0\n1 3 4 0\n1 1 1 3\n2 3 0 0", "3 4\n1 1 0 0\n2 2 0 1\n3 2 1 0", "4 2\n1 1 0 1\n1 1 0 2\n1 1 0 1\n1 1 0 1", "10 4\n1 1 0 3\n2 3 2 0\n0 2 3 0\n2 1 0 0\n3 2 0 2\n1 1 3 0\n3 2 0 0\n1 3 4 0\n1 1 1 3\n2 3 0 0", "3 4\n1 1 0 ...
p03824 AtCoder Grand Contest 009 - Uninity
We will recursively define uninity of a tree, as follows: (Uni is a Japanese word for sea urchins.) * A tree consisting of one vertex is a tree of uninity 0. * Suppose there are zero or more trees of uninity k, and a vertex v. If a vertex is selected from each tree of uninity k and connected to v with an edge, the res...
{ "input": [], "output": [] }
{ "input": [ "12\n1 2\n2 3\n2 4\n4 5\n5 6\n6 7\n7 8\n5 9\n9 10\n10 11\n11 12", "7\n1 2\n2 3\n2 4\n4 6\n6 7\n7 5" ], "output": [ "3", "2" ] }
{ "input": [ "12\n1 2\n2 3\n2 4\n4 5\n5 6\n6 7\n7 8\n5 9\n9 10\n3 11\n11 12", "12\n1 2\n2 3\n2 4\n4 5\n5 6\n6 7\n7 8\n10 9\n9 10\n10 11\n11 12", "7\n1 2\n2 3\n0 4\n4 6\n6 7\n7 5", "12\n0 4\n2 3\n3 4\n4 5\n5 6\n6 5\n7 9\n2 9\n11 10\n4 11\n11 12", "12\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n5 9\n9 10\n3...
p03991 AtCoder Grand Contest 005 - Many Easy Problems
One day, Takahashi was given the following problem from Aoki: * You are given a tree with N vertices and an integer K. The vertices are numbered 1 through N. The edges are represented by pairs of integers (a_i, b_i). * For a set S of vertices in the tree, let f(S) be the minimum number of the vertices in a subtree of ...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n2 3", "4\n1 2\n1 3\n1 4", "7\n1 2\n2 3\n2 4\n4 5\n4 6\n6 7" ], "output": [ "3\n7\n3", "4\n15\n13\n4", "7\n67\n150\n179\n122\n45\n7" ] }
{ "input": [ "7\n1 4\n2 3\n2 4\n4 5\n4 6\n6 7", "7\n1 4\n2 3\n2 1\n4 5\n4 6\n6 7", "7\n1 2\n4 3\n2 6\n4 5\n4 6\n6 7", "4\n1 2\n1 3\n2 4", "3\n1 3\n2 3", "7\n1 4\n4 3\n2 6\n6 5\n4 6\n6 7", "7\n1 2\n2 3\n2 4\n6 5\n4 6\n6 7", "7\n1 4\n2 3\n2 1\n4 5\n3 6\n4 7", "7\n1 4\n2 5\n3 2\n7 5\n...
p00079 Area of Polygon
Write a program that reads the coordinates of the vertices of a convex n-sided polygon (a polygon whose internal angles are less than 180 degrees, that is, a polygon that is not dented) and outputs its area. The vertices are named Vertex 1, Vertex 2, Vertex 3, ... Vertex n according to the order of edge connections. H...
{ "input": [], "output": [] }
{ "input": [ "0.0,0.0\n0.0,1.0\n1.0,1.0\n2.0,0.0\n1.0,-1.0" ], "output": [ "2.500000" ] }
{ "input": [ "0.0,0.0\n0.0,1.0\n1.1,0.0\n2.0,0.0\n1.0,-1.0", "0.0,0.0\n0.0,1.0\n1.0,1.0\n2.0,0.0\n1.1,-1.0", "0.0,0.0\n0.1,1.0\n1.0,1.0\n2.0,0.0\n1.0,-1.0", "0.0,0.0\n0.0,1.0\n0.1,1.0\n2.0,0.0\n1.1,-1.0", "0.0,0.0\n0.1,1.0\n1.0,1.0\n1.0,0.0\n1.0,-1.0", "0.0,0.0\n0.0,1.0\n1.0,1.0\n2.0,0.0\n1.0,...
p00211 Jogging
At Akabeko Elementary School, all the students participate in a slightly unusual jogging. Students run their own lap courses at their own pace. After going around each of your courses, you will be returned to elementary school. How many laps do they all meet at the same time in elementary school after they all start el...
{ "input": [], "output": [] }
{ "input": [ "2\n4 3\n5 4\n5\n789 289\n166 46\n9 4\n617 252\n972 303\n2\n8 5\n32 20\n0" ], "output": [ "15\n16\n1598397732\n1209243492\n1939462992\n1782294192\n1360317793\n1\n1" ] }
{ "input": [ "2\n4 3\n8 4\n5\n789 289\n166 46\n9 4\n617 252\n972 303\n2\n8 5\n32 20\n0", "2\n4 3\n9 4\n5\n789 289\n166 46\n9 4\n617 252\n972 303\n2\n8 5\n32 20\n0", "2\n4 3\n9 4\n5\n789 5\n166 46\n9 4\n617 252\n972 303\n2\n8 5\n32 20\n0", "2\n4 6\n5 4\n5\n789 289\n166 46\n9 4\n617 252\n972 303\n2\n8 5...
p00371 Lottery Box
A lottery is being held in a corner of the venue of the Aizu festival. Several types of balls are inside the lottery box and each type has its unique integer printed on the surfaces of the balls. An integer T is printed on the lottery box. In the lottery, you first declare two integers A and B, and draw up to M balls ...
{ "input": [], "output": [] }
{ "input": [ "3 2 7\n8\n3\n6\n5\n2 2\n3 2\n4 1\n6 1\n6 0" ], "output": [ "yes\nno\nyes\nno\nyes" ] }
{ "input": [ "3 2 7\n8\n3\n6\n5\n2 2\n3 2\n4 1\n6 1\n6 1", "3 2 7\n8\n3\n6\n5\n2 2\n5 2\n4 1\n6 1\n6 0", "3 2 7\n8\n3\n6\n5\n2 2\n3 0\n4 1\n6 1\n6 1", "3 2 7\n8\n3\n6\n5\n2 2\n2 1\n4 1\n6 0\n6 1", "3 2 7\n8\n3\n6\n5\n2 4\n2 1\n4 1\n6 0\n6 1", "3 2 7\n8\n3\n6\n5\n2 4\n2 1\n4 1\n6 0\n6 0", "...
p00588 Extraordinary Girl I
She is an extraordinary girl. She works for a library. Since she is young and cute, she is forced to do a lot of laborious jobs. The most annoying job for her is to put returned books into shelves, carrying them by a cart. The cart is large enough to carry many books, but too heavy for her. Since she is delicate, she w...
{ "input": [], "output": [] }
{ "input": [ "2\n2\nYNNNNYYY\n4\nNYNNYYNNNYNYYNNN" ], "output": [ "6\n9" ] }
{ "input": [ "2\n2\nYNNNNYYY\n2\nNYNNYYNNNYNYYNNN", "2\n2\nYYZNNNNY\n2\nYYNNYNNNNYNYYNNN", "2\n2\nYYZNNNNY\n4\nNYNNYYNNNYNYYNNN", "2\n2\nYYZNNNNY\n4\nNNNYYNYNNNYYONYN", "2\n2\nYYZNYNNN\n4\nNNNYYNYNNNYYNNYN", "2\n2\nYNNNNYYY\n3\nNYNNYYNNNYNYYNNN", "2\n2\nNNNYNZYY\n0\nNNNYYNYNNNYYNNYN", ...
p00725 Curling 2
On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. They use only a single stone. The purpose of the game is to lead the stone from the start to the goal with the minim...
{ "input": [], "output": [] }
{ "input": [ "2 1\n3 2\n6 6\n1 0 0 2 1 0\n1 1 0 0 0 0\n0 0 0 0 0 3\n0 0 0 0 0 0\n1 0 0 0 0 1\n0 1 1 1 1 1\n6 1\n1 1 2 1 1 3\n6 1\n1 0 2 1 1 3\n12 1\n2 0 1 1 1 1 1 1 1 1 1 3\n13 1\n2 0 1 1 1 1 1 1 1 1 1 1 3\n0 0" ], "output": [ "1\n4\n-1\n4\n10\n-1" ] }
{ "input": [ "2 1\n3 2\n6 6\n1 0 0 2 1 -1\n1 1 0 0 0 0\n0 0 0 0 0 3\n0 0 0 0 0 0\n1 0 0 0 0 1\n0 1 1 1 1 1\n6 1\n1 1 2 1 1 3\n6 1\n1 0 2 1 1 3\n12 1\n2 0 1 1 1 1 1 1 1 1 1 3\n13 1\n2 0 1 1 1 1 1 1 1 1 1 1 3\n0 0", "2 1\n5 2\n6 6\n1 0 0 2 1 -1\n1 1 0 0 0 0\n0 0 0 0 0 3\n0 0 0 0 0 0\n1 0 0 0 0 1\n0 1 1 1 1 1\n6...
p00865 Expected Allowance
Hideyuki is allowed by his father Ujisato some 1000 yen bills every month for his pocket money. In the first day of every month, the number of bills is decided as follows. Ujisato prepares n pieces of m-sided dice and declares the cutback k. Hideyuki rolls these dice. The number of bills given is the sum of the spots o...
{ "input": [], "output": [] }
{ "input": [ "2 6 0\n2 6 3\n3 10 9\n13 3 27\n1 2008 3\n0 0 0" ], "output": [ "7.00000000\n4.11111111\n7.71000000\n1.42902599\n1001.50298805" ] }
{ "input": [ "2 6 0\n2 6 3\n3 10 3\n13 3 27\n1 2008 3\n0 0 0", "2 6 0\n2 6 3\n3 10 3\n13 3 34\n1 2008 3\n0 0 0", "2 6 0\n2 6 4\n3 10 9\n13 3 27\n1 2008 3\n0 0 0", "2 3 0\n2 6 3\n3 10 3\n13 3 34\n1 2008 3\n0 0 0", "2 6 0\n2 6 4\n3 10 13\n13 3 27\n1 2008 3\n0 0 0", "2 4 0\n2 6 4\n3 10 13\n13 3 2...
p00996 Dice
The three dice brothers are triplets, one and the same, and three can be said to be one. Since they are triplets, they are indistinguishably similar. Such three dice brothers are A's favorite toys. Mr. A is always playing with rolling dice in a set of three. As you can see, A is a toy that he enjoys playing, but in fac...
{ "input": [], "output": [] }
{ "input": [ "4 4\n4o..\n.o3.\n.o..\n.5..", "3 3\n4o.\n4o.\n4o.", "6 10\n1xxxxxxxxx\no.......o.\nxxxx.xxxx4\nxoxx.xxxx.\nx....3xx..\nx..xxxxx.." ], "output": [ "3", "3", "34" ] }
{ "input": [ "4 4\n4o..\n.3o.\n.o..\n.5..", "6 10\n1xxxxxxxxx\no.......o/\nxxxx.xxxx4\nxoxx.xxxx.\nx....3xx..\nx..xxxxx..", "3 3\n.o4\n3o/\n4o.", "3 3\n.o4\n2o/\n4o.", "4 4\n4o..\n.3o.\n/-o.\n.5./", "10 10\nxxxxxxxxx1\no.......o/\nxxxv.xxxx4\nxoxx.xxxx.\nx....3xx..\nx..xxxxx..", "3 3\n4o.\...
p01128 Railroad Conflict
Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other. In this metropolitan area, all lines are routed by the line segment connecting the statio...
{ "input": [], "output": [] }
{ "input": [ "2\n-10 1 10 1\n4\n-6 2 -2 -2 0 1\n-6 -2 -2 2 1 0\n6 2 2 -2 0 0\n6 -2 2 2 1 1\n8 12 -7 -3\n8\n4 -5 4 -2 1 1\n4 -2 4 9 1 0\n6 9 6 14 1 1\n-7 6 7 6 0 0\n1 0 1 10 0 0\n-5 0 -5 10 0 1\n-7 0 7 0 0 1\n-1 0 -1 -5 0 1" ], "output": [ "1\n3" ] }
{ "input": [ "2\n-10 1 10 1\n4\n-6 2 -2 -2 0 1\n-6 -2 -2 2 1 0\n6 2 2 -2 0 0\n6 -2 2 2 1 1\n8 12 -7 -3\n8\n4 -5 4 -2 1 1\n4 -2 4 9 1 0\n6 9 6 14 1 1\n-5 6 7 6 0 0\n1 0 1 10 0 0\n-5 0 -5 10 0 1\n-7 0 7 0 0 1\n-1 0 -1 -5 0 1", "2\n-10 1 10 1\n4\n-6 2 -2 -2 0 1\n-6 -2 -2 2 1 0\n6 2 2 -2 0 0\n6 -2 2 2 1 1\n8 12 -...
p01267 Luck Manipulator
Nathan O. Davis is trying to capture a game and struggling to get a very rare item. This rare item can be obtained by arranging special patterns in a row on a casino slot machine. The slot machine has N reels, and pressing the button once stops the currently rotating leftmost reel. Therefore, you need to press the butt...
{ "input": [], "output": [] }
{ "input": [ "1 5 7 11 10\n10\n2 5 7 11 10\n2 4\n2 1 1 256 0\n128 255\n2 0 0 1 0\n1234 5678\n2 1 1 100 0\n99 98\n2 1 1 100 0\n99 99\n2 1 1 10000 0\n1 0\n2 1 1 10000 0\n2 1\n0 0 0 0 0" ], "output": [ "0\n3\n255\n-1\n198\n199\n10000\n-1" ] }
{ "input": [ "1 5 7 11 10\n10\n2 5 7 11 10\n2 4\n2 1 1 256 0\n128 255\n2 0 0 1 0\n1234 5678\n2 1 1 100 0\n99 98\n2 1 1 100 0\n99 99\n2 1 1 10000 0\n1 0\n2 1 2 10000 0\n2 1\n0 0 0 0 0", "1 5 7 11 10\n10\n2 5 5 11 10\n2 4\n2 1 1 256 0\n128 255\n2 0 0 1 0\n1234 5678\n2 1 1 100 0\n99 98\n2 1 1 100 0\n99 99\n2 1 1...
p01437 Infinity Maze
Dr. Fukuoka has placed a simple robot in a two-dimensional maze. It moves within the maze and never goes out of the maze as there is no exit. The maze is made up of H × W grid cells as depicted below. The upper side of the maze faces north. Consequently, the right, lower and left sides face east, south and west respec...
{ "input": [], "output": [] }
{ "input": [ "3 3 10\nE..\n.#.\n...\n5 5 19\n####.\n.....\n.#S#.\n...#.\n#.##.\n5 5 6\n#.#..\n#....\n##.#.\n#..S.\n#....\n5 4 35\n..##\n....\n.##.\n.#S.\n...#\n0 0 0", "3 3 10\nE..\n.#.\n...\n5 5 19\n.\n.....\n.#S#.\n...#.\n.##.\n5 5 6\n.#..\n....\n.#.\n..S.\n....\n5 4 35\n..##\n....\n.##.\n.#S.\n...#\n0 0 0"...
{ "input": [ "3 3 10\nE..\n.#.\n...\n5 5 19\n####.\n.....\n.#S#.\n...#.\n#.##.\n5 5 6\n#.#..\n#....\n##.#.\n#..S.\n#....\n5 4 35\n.#.#\n....\n.##.\n.#S.\n...#\n0 0 0", "3 3 19\nE..\n.#.\n...\n5 5 19\n.\n.....\n.#S#.\n...#.\n.##.\n5 5 6\n.#..\n....\n.#.\n..S.\n....\n5 4 35\n..##\n....\n.##.\n.#S.\n...#\n0 0 0"...
p01584 Divide the Water
A scientist Arthur C. McDonell is conducting a very complex chemical experiment. This experiment requires a large number of very simple operations to pour water into every column of the vessel at the predetermined ratio. Tired of boring manual work, he was trying to automate the operation. One day, he came upon the id...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p01743 Clique Coloring
There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with color i. None of the sides were painted in multiple colors. Find the mi...
{ "input": [], "output": [] }
{ "input": [ "5\n2\n3\n4\n5\n6", "2\n3\n3" ], "output": [ "12", "5" ] }
{ "input": [ "5\n2\n3\n3\n5\n6", "2\n6\n3", "2\n6\n2", "2\n5\n2", "2\n1\n2", "2\n1\n3", "5\n2\n3\n5\n5\n6", "5\n2\n3\n3\n2\n6", "2\n8\n3", "2\n5\n1", "2\n14\n2", "2\n14\n4", "2\n3\n2", "2\n14\n8", "2\n15\n2", "2\n14\n16", "2\n11\n2", "2\n14\n5", ...
p01883 Parentheses
Example Input 1 Output )(
{ "input": [], "output": [] }
{ "input": [ "1" ], "output": [ ")(" ] }
{ "input": [ "2", "4", "3", "5", "6", "9", "7", "8", "12", "22", "11", "13", "14", "17", "10", "33", "16", "23", "25", "43", "35", "15", "26", "32", "29", "55", "77", "85", "114", "61", "28", ...
p02020 Tea Party
F: Tea Party Yun decided to hold a tea party at the company. The shop sells $ N $ sets of bread, each containing $ A_1, A_2, A_3, \ dots, A_N $. Yun decided to make a sandwich by combining two breads into a pair. Yun-san is very careful, so I want to make sure that I don't have any leftover bread. Calculate how ma...
{ "input": [], "output": [] }
{ "input": [ "5\n2 3 5 6 7" ], "output": [ "10" ] }
{ "input": [ "5\n4 3 5 6 7", "5\n4 3 5 10 7", "5\n4 3 5 10 9", "5\n4 6 5 10 9", "5\n4 12 5 10 9", "5\n4 12 5 0 9", "5\n4 12 5 0 3", "5\n1 12 5 0 3", "5\n2 3 3 6 7", "5\n4 3 5 10 17", "5\n4 6 9 10 9", "5\n6 12 5 0 9", "5\n6 2 5 0 3", "5\n2 12 7 0 0", "5\n4 0 ...
p02162 AOJ50M
Problem Alice and Bob are competing in the 50m dash. However, in this world, the higher the AOJ rate is, the better, so the higher the AOJ rate wins. If there is no AOJ rate on either side, there is no comparison, so there is no choice but to compete in the 50m sprint time. In this case, the one with the shorter time ...
{ "input": [], "output": [] }
{ "input": [ "9 8 1000 999", "9 8 2849 -1", "9 8 1000 1000" ], "output": [ "Alice", "Bob", "Draw" ] }
{ "input": [ "9 8 1000 1674", "9 9 2849 -1", "9 9 2849 0", "9 8 1000 1100", "9 8 1000 3269", "9 8 1000 1101", "9 8 1000 5146", "10 9 2849 0", "9 11 1000 1101", "9 8 1000 9934", "10 9 2232 0", "9 11 1000 1100", "9 8 0000 9934", "18 9 2232 0", "9 11 1010 1100"...
p02303 Closest Pair
For given n points in metric space, find the distance of the closest points. Constraints * 2 ≤ n ≤ 100,000 * -100 ≤ x, y ≤ 100 Input n x0 y0 x1 y1 : xn-1 yn-1 The first integer n is the number of points. In the following n lines, the coordinate of the i-th point is given by two real numbers xi and yi. Each valu...
{ "input": [], "output": [] }
{ "input": [ "3\n0.0 0.0\n2.0 0.0\n1.0 1.0", "2\n0.0 0.0\n1.0 0.0" ], "output": [ "1.41421356237", "1.000000" ] }
{ "input": [ "3\n0.0 0.1148886470849706\n2.0 0.0\n1.0 1.0", "2\n0.0 0.3120297992159662\n1.0 0.0", "3\n0.0 0.1148886470849706\n2.0 0.0\n1.2700567285483473 1.0", "2\n0.0 1.093274220109409\n1.0 0.0", "3\n0.941172211407316 0.1148886470849706\n2.0 0.0\n1.2700567285483473 1.0", "2\n0.0 1.34677728877...
p02450 Permutation Enumeration
For given an integer $n$, print all permutations of $\\{1, 2, ..., n\\}$ in lexicographic order. Constraints * $1 \leq n \leq 9$ Input An integer $n$ is given in a line. Output Print each permutation in a line in order. Separate adjacency elements by a space character. Examples Input 2 Output 1 2 2 1 Inpu...
{ "input": [], "output": [] }
{ "input": [ "3", "2" ], "output": [ "1 2 3\n1 3 2\n2 1 3\n2 3 1\n3 1 2\n3 2 1", "1 2\n2 1" ] }
{ "input": [ "1", "4", "5", "4", "1", "5" ], "output": [ "1\n", "1 2 3 4\n1 2 4 3\n1 3 2 4\n1 3 4 2\n1 4 2 3\n1 4 3 2\n2 1 3 4\n2 1 4 3\n2 3 1 4\n2 3 4 1\n2 4 1 3\n2 4 3 1\n3 1 2 4\n3 1 4 2\n3 2 1 4\n3 2 4 1\n3 4 1 2\n3 4 2 1\n4 1 2 3\n4 1 3 2\n4 2 1 3\n4 2 3 1\n4 3 1 2\n4 3 2 1\n"...
anuund
Problem description You will be given a zero-indexed array A. You need to rearrange its elements in such a way that the following conditions are satisfied: A[i] ≤ A[i+1] if i is even. A[i] ≥ A[i+1] if i is odd. In other words the following inequality should hold: A[0] ≤ A[1] ≥ A[2] ≤ A[3] ≥ A[4], and so on. Operation...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n3 2\n3\n10 5 2" ], "output": [ "2 3 \n2 10 5 \n" ] }
{ "input": [ "2\n2\n3 2\n3\n9 5 2", "2\n2\n3 3\n3\n9 5 2", "2\n2\n3 3\n3\n9 5 4", "2\n2\n2 3\n3\n9 5 4", "2\n2\n2 3\n3\n9 7 4", "2\n2\n5 2\n3\n10 5 2", "2\n2\n3 1\n3\n9 5 2", "2\n2\n0 3\n3\n9 5 4", "2\n2\n2 3\n3\n11 5 4", "2\n2\n2 3\n3\n8 7 4", "2\n2\n5 2\n3\n10 5 1", "...
chrl3
Chef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the minimal number of moves. Input The first line of each test case contains a single N denoting the number of i...
{ "input": [], "output": [] }
{ "input": [ "3 \n1 2 3", "4\n4 1 2 3" ], "output": [ "1", "2" ] }
{ "input": [ "3 \n1 2 5", "4\n4 1 3 3", "3 \n5 1 0", "4\n20 -1 -2 -4", "3 \n1 2 8", "4\n4 1 5 3", "3 \n1 1 8", "4\n4 0 5 3", "3 \n1 1 16", "4\n4 -1 5 3", "3 \n2 1 16", "4\n4 -1 5 4", "3 \n2 1 3", "4\n1 -1 5 4", "3 \n2 1 5", "4\n1 -1 5 7", "3 \n2 2 5"...
etmx04
Least Distance Mr. John has a habit of implementing new programming methods. This time he needs your help to solve a problem. He needs a method such that it accepts a series of numbers (all in single digits) and returns a typical answer. The answer must be the least distance between any two ADJACENT numbers. For Exam...
{ "input": [], "output": [] }
{ "input": [ "5 7 4 9 7 2", "4 8 6 1 2 9 4" ], "output": [ "2", "1" ] }
{ "input": [ "5 7 4 13 7 2", "4 8 6 1 2 7 4", "5 8 4 13 7 2", "18 10 1 14 2 2", "15 7 1 14 8 2", "15 24 1 14 24 0", "19 24 1 14 24 0", "1 22 39 0 -4 6 0", "-3 5 -7 -21 1 -9 0", "2 8 6 1 2 7 4", "5 8 4 14 7 2", "2 8 6 1 2 7 6", "5 8 1 14 7 2", "1 8 6 1 2 7 6", ...
kttable
There are N students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of the dormitory came up with a timetable for kitchen's usage in order to avoid the conflicts: The first student starts to use the kitchen at the time 0 and should finish the cooking n...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n1 10 15\n1 10 3\n3\n10 20 30\n15 5 20" ], "output": [ "2\n1\n" ] }
{ "input": [ "2\n3\n1 10 15\n1 10 3\n3\n19 20 30\n15 5 20", "2\n3\n1 10 29\n1 10 3\n2\n17 39 30\n15 5 20", "2\n3\n1 10 29\n1 8 3\n3\n17 20 30\n15 5 20", "2\n3\n1 10 29\n1 8 3\n3\n17 32 30\n15 5 20", "2\n3\n1 4 15\n1 2 3\n3\n10 7 30\n13 13 35", "2\n3\n1 0 15\n1 3 3\n3\n10 7 30\n13 13 35", "...
pchips
Rohit loves to play poker. He has N piles of poker chips in a line. Number of chips in pile i is Ai. He wants to rearrange them such that Ai+1 = Ai + 1 for 1 ≤ i ≤ N-1 . The final piles can contain 0 chips as well. To achieve this,he can take one coin from a pile and place it in another pile.Find the minimum number o...
{ "input": [], "output": [] }
{ "input": [ "3\n5\n2 3 4 5 1\n3\n10 10 10\n4\n3 3 3 3" ], "output": [ "4\n1\n-1" ] }
{ "input": [ "3\n5\n2 3 4 5 1\n3\n10 10 10\n4\n3 5 3 3", "3\n5\n2 3 4 5 1\n3\n10 20 10\n4\n3 5 3 3", "3\n5\n1 3 4 5 1\n3\n10 20 10\n4\n3 5 3 3", "3\n5\n1 2 4 5 1\n3\n10 20 10\n4\n3 5 3 1", "3\n5\n1 2 2 5 1\n3\n10 20 6\n7\n3 5 2 1", "3\n7\n1 2 2 5 1\n3\n6 36 6\n7\n3 5 6 1", "3\n5\n2 3 4 5 1...
stacks
As every other little boy, Mike has a favorite toy to play with. Mike's favorite toy is a set of N disks. The boy likes to compose his disks in stacks, but there's one very important rule: the disks in a single stack must be ordered by their radiuses in a strictly increasing order such that the top-most disk will have ...
{ "input": [], "output": [] }
{ "input": [ "3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n14 5 13 19 17 10 18 12" ], "output": [ "3 1 1 2\n5 2 2 4 7 10\n4 5 10 12 18\n" ] }
{ "input": [ "3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n9 5 13 19 17 10 18 12", "3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n9 5 13 19 23 10 18 12", "3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 3 4 14 7 10\n8\n9 5 13 19 23 10 18 12", "3\n6\n3 4 5 1 1 2\n10\n3 2 5 5 2 3 4 14 7 3\n8\n9 5 13 19 23 10 18...
1369_C. RationalLee
Lee just became Master in Codeforces, and so, he went out to buy some gifts for his friends. He bought n integers, now it's time to distribute them between his friends rationally... Lee has n integers a_1, a_2, …, a_n in his backpack and he has k friends. Lee would like to distribute all integers in his backpack betwe...
{ "input": [], "output": [] }
{ "input": [ "3\n4 2\n1 13 7 17\n1 3\n6 2\n10 10 10 10 11 11\n3 3\n4 4\n1000000000 1000000000 1000000000 1000000000\n1 1 1 1\n" ], "output": [ "48\n42\n8000000000\n" ] }
{ "input": [ "3\n4 2\n1 13 7 0\n1 3\n6 2\n10 10 10 10 11 11\n3 3\n4 4\n1000000000 1000000000 1000000000 1000000000\n1 1 1 1\n", "3\n4 2\n1 13 7 1\n1 3\n6 2\n10 10 10 10 11 11\n3 3\n4 4\n1000000000 1000000000 1000000000 1000000000\n1 1 1 1\n", "3\n4 2\n1 13 12 1\n1 3\n6 2\n10 10 10 10 11 11\n3 3\n4 4\n1000...
1431_H. Rogue-like Game
Marina plays a new rogue-like game. In this game, there are n different character species and m different classes. The game is played in runs; for each run, Marina has to select a species and a class for her character. If she selects the i-th species and the j-th class, she will get c_{i, j} points for this run. Initi...
{ "input": [], "output": [] }
{ "input": [ "3 4 2\n0 5 7\n0 2 6 10\n2 5 5 2\n5 3 4 4\n3 4 2 4\n", "4 2 1\n0 3 9 9\n0 2\n3 3\n5 1\n1 3\n2 3\n", "3 3 5\n0 8 11\n0 0 3\n3 1 3\n1 2 1\n1 1 3\n" ], "output": [ "\n3\n", "\n2\n", "\n2\n" ] }
{ "input": [], "output": [] }
1506_E. Restoring the Permutation
A permutation is a sequence of n integers from 1 to n, in which all numbers occur exactly once. For example, [1], [3, 5, 2, 1, 4], [1, 3, 2] are permutations, and [2, 3, 2], [4, 3, 1], [0] are not. Polycarp was presented with a permutation p of numbers from 1 to n. However, when Polycarp came home, he noticed that in ...
{ "input": [], "output": [] }
{ "input": [ "4\n7\n3 3 4 4 7 7 7\n4\n1 2 3 4\n7\n3 4 5 5 5 7 7\n1\n1\n" ], "output": [ "\n3 1 4 2 7 5 6 \n3 2 4 1 7 6 5 \n1 2 3 4 \n1 2 3 4 \n3 4 5 1 2 7 6 \n3 4 5 2 1 7 6 \n1 \n1 \n" ] }
{ "input": [ "4\n7\n3 3 4 4 7 7 7\n4\n1 2 3 4\n7\n3 4 5 5 5 6 7\n1\n1\n", "4\n7\n3 3 4 4 7 7 7\n4\n1 2 3 4\n7\n2 4 5 5 5 7 7\n1\n1\n", "4\n7\n3 3 4 4 7 7 7\n4\n1 2 4 4\n7\n3 4 5 5 5 7 7\n1\n1\n", "4\n7\n3 3 4 4 7 7 7\n4\n2 2 4 4\n7\n3 4 5 5 5 7 7\n1\n1\n", "4\n7\n2 3 4 4 7 7 7\n4\n1 2 3 4\n7\n3 4 ...
76_A. Gift
The kingdom of Olympia consists of N cities and M bidirectional roads. Each road connects exactly two cities and two cities can be connected with more than one road. Also it possible that some roads connect city with itself making a loop. All roads are constantly plundered with bandits. After a while bandits became bo...
{ "input": [], "output": [] }
{ "input": [ "3 3\n2 1\n1 2 10 15\n1 2 4 20\n1 3 5 1\n" ], "output": [ "30" ] }
{ "input": [ "3 3\n1 1\n1 2 10 15\n1 2 4 20\n1 3 5 1\n", "4 3\n1 1\n1 2 10 15\n1 2 4 20\n1 3 5 1\n", "3 3\n1 1\n1 2 10 15\n1 2 4 13\n1 3 5 1\n", "3 3\n1 2\n1 1 10 15\n1 2 4 13\n1 3 5 1\n", "3 3\n1 2\n1 1 10 15\n1 2 4 8\n1 3 5 1\n", "3 3\n1 2\n1 1 10 20\n1 2 4 8\n1 3 4 1\n", "3 3\n3 1\n1 2 ...
aaryan-subsequences-and-great-xor
Aaryan went to school like any usual day, The teacher asked his crush the following question. Given an array of numbers, First she had to compute the XOR of all the subsequences that can be formed. Suppose each subsequence had their following XOR value that came out after computing -> {P[0], P[1], P[2], and so on upto...
{ "input": [], "output": [] }
{ "input": [ "4\n8 9 9 8\n\nSAMPLE" ], "output": [ "9\n" ] }
{ "input": [ "4\n8 10 9 8\n\nSAMPLE", "4\n8 1 9 8\n\nSAMPLE", "4\n8 1 18 0\n\nSAMPLE", "4\n6 1 18 2\n\nELPMAS", "4\n6 1 8 2\n\nELPMAS", "4\n4 9 9 1\n\nSAMPLE", "4\n0 1 3 0\n\nSAMPLE", "4\n0 1 4 0\n\nSAMPLE", "4\n0 1 6 0\n\nSAMPLE", "4\n0 1 6 -1\n\nSAMPLE", "4\n3 2 18 1\n\nT...
millys-rank-2
Milly is very much concern about her rank in her class. So to make her feel better , her friend Pranjul will give three numbers to her denoting N, X and Y. N represents the total number of students in the class. Now he has already described about the rank predictor algorithm that he has made for her. According to this ...
{ "input": [], "output": [] }
{ "input": [ "1\n4 1 2\n\nSAMPLE" ], "output": [ "3" ] }
{ "input": [], "output": [] }
special-knight
In the game of chess, there is a piece called the knight. A knight is special -- instead of moving in a straight line like other pieces, it jumps in an "L" shape. Specifically, a knight can jump from square (r1, c1) to (r2, c2) if and only if (r1 - r2)2 + (c1 - c2)2 = 5. In this problem, one of our knights is going to...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1 0\n4 4 1\n2 1\n\nSAMPLE" ], "output": [ "Case #1: 1\nCase #2: 2" ] }
{ "input": [], "output": [] }
p02573 AtCoder Beginner Contest 177 - Friends
There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. There is no friendship that cannot be derived from the M given facts. Ta...
{ "input": [], "output": [] }
{ "input": [ "10 4\n3 1\n4 1\n5 9\n2 6", "5 3\n1 2\n3 4\n5 1", "4 10\n1 2\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4" ], "output": [ "3", "3", "4" ] }
{ "input": [ "10 4\n3 1\n3 1\n5 9\n2 6", "4 10\n1 1\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "2 0\n1 1\n2 1\n1 6\n2 1\n1 2\n1 3\n1 4\n3 3\n2 4\n4 4", "10 4\n6 1\n3 1\n5 6\n2 6", "5 2\n1 4\n3 4\n3 1", "10 4\n6 1\n3 1\n5 9\n2 6", "4 10\n1 1\n2 1\n1 2\n2 1\n1 2\n1 3\n1 4\n1 3\n2 4\n3 4"...
p02704 AtCoder Beginner Contest 164 - I hate Matrix Construction
Given are an integer N and arrays S, T, U, and V, each of length N. Construct an N×N matrix a that satisfy the following conditions: * a_{i,j} is an integer. * 0 \leq a_{i,j} \lt 2^{64}. * If S_{i} = 0, the bitwise AND of the elements in the i-th row is U_{i}. * If S_{i} = 1, the bitwise OR of the elements in the i-th...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1\n1 0\n15 15\n15 11", "2\n0 1\n1 0\n1 1\n1 0" ], "output": [ "15 11\n15 11", "1 1\n1 0" ] }
{ "input": [ "2\n1 1\n1 0\n15 28\n15 11", "2\n0 1\n1 0\n1 1\n1 1", "2\n0 1\n-1 0\n0 0\n0 0", "2\n0 1\n-2 0\n0 1\n0 0", "2\n0 1\n-3 1\n0 1\n1 0", "2\n0 1\n1 0\n15 28\n15 11", "2\n0 1\n1 0\n1 1\n0 1", "2\n0 1\n1 0\n15 28\n5 11", "2\n0 1\n1 0\n1 1\n0 0", "2\n0 1\n1 0\n15 28\n1 11"...
p02833 AtCoder Beginner Contest 148 - Double Factorial
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N). Constraints * 0 \leq N \leq 10^{18} Input Input is given from Standard Input in the following format: ...
{ "input": [], "output": [] }
{ "input": [ "1000000000000000000", "5", "12" ], "output": [ "124999999999999995", "0", "1" ] }
{ "input": [ "1000000000010000000", "7", "10", "1000000000010001000", "1010000000010001000", "24", "1010100000010001000", "1010100000011001000", "1010100000011101000", "30", "1010100010011101000", "1010100000011100000", "1010100000010100000", "101010000001010100...
p02970 AtCoder Beginner Contest 134 - Golden Apple
There are N apple trees in a row. People say that one of them will bear golden apples. We want to deploy some number of inspectors so that each of these trees will be inspected. Each inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to the trees. An inspector ...
{ "input": [], "output": [] }
{ "input": [ "20 4", "14 3", "6 2" ], "output": [ "3", "2", "2" ] }
{ "input": [ "20 7", "0 3", "6 4", "14 2", "4 0", "28 2", "28 0", "14 1", "12 0", "23 1", "14 0", "22 0", "19 1", "11 0", "21 0", "18 0", "10 0", "20 0", "47 0", "23 0", "9 0", "27 0", "13 0", "19 0", "25 0", "15 0...
p03106 AtCoder Beginner Contest 120 - K-th Common Divisor
You are given positive integers A and B. Find the K-th largest positive integer that divides both A and B. The input guarantees that there exists such a number. Constraints * All values in input are integers. * 1 \leq A, B \leq 100 * The K-th largest positive integer that divides both A and B exists. * K \geq 1 In...
{ "input": [], "output": [] }
{ "input": [ "1 1 1", "100 50 4", "8 12 2" ], "output": [ "1", "5", "2" ] }
{ "input": [ "100 50 2", "16 12 2", "12 12 2", "100 45 2", "27 12 1", "16 24 1", "110 50 2", "12 12 3", "27 18 1", "100 50 3", "16 32 1", "132 36 1", "119 63 1", "21 63 1", "54 54 1", "182 56 1", "48 24 1", "19 114 1", "189 63 1", "117 26...
p03253 AtCoder Beginner Contest 110 - Factorization
You are given positive integers N and M. How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7. Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''. Constraints * All valu...
{ "input": [], "output": [] }
{ "input": [ "3 12", "2 6", "100000 1000000000" ], "output": [ "18", "4", "957870001" ] }
{ "input": [ "3 4", "3 6", "5 4", "3 1", "6 4", "4 12", "4 6", "100000 1000010000", "5 6", "3 2", "2 5", "8 2", "7 12", "4 2", "10 2", "8 12", "12 2", "4 8", "15 4", "9 4", "6 22", "5 2", "11 5", "100000 1001010000", "...
p03406 AtCoder Regular Contest 093 - Dark Horse
There are 2^N players, numbered 1, 2, ..., 2^N. They decided to hold a tournament. The tournament proceeds as follows: * Choose a permutation of 1, 2, ..., 2^N: p_1, p_2, ..., p_{2^N}. * The players stand in a row in the order of Player p_1, Player p_2, ..., Player p_{2^N}. * Repeat the following until there is only ...
{ "input": [], "output": [] }
{ "input": [ "4 3\n2 4 6", "3 0", "2 1\n3", "16 16\n5489 5490 5491 5492 5493 5494 5495 5497 18993 18995 18997 18999 19000 19001 19002 19003", "3 3\n3 4 7" ], "output": [ "0", "40320", "8", "816646464", "2688" ] }
{ "input": [ "3 3\n2 4 6", "3 1\n3 4 7", "3 1\n1 5 2", "0 1\n2 5 4", "1 0\n2 7 4", "5 3\n3 4 7", "3 1\n5 4 7", "3 0\n2 5 2", "5 3\n1 4 7", "6 1\n5 4 7", "5 0\n2 5 2", "7 0\n4 5 2", "8 2\n3 7 1", "8 2\n4 7 2", "2 0\n3", "3 3\n3 5 7", "5 3\n3 5 7", ...
p03569 CODE FESTIVAL 2017 qual C - Inserting 'x'
We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is ...
{ "input": [], "output": [] }
{ "input": [ "a", "xabxa", "ab", "oxxx" ], "output": [ "0", "2", "-1", "3" ] }
{ "input": [ "b", "axbax", "`b", "xxxo", "tpxt", "c", "bxbax", "b`", "yxxo", "d", "bxbbx", "ba", "oxxy", "e", "xxbbb", "bb", "oxyx", "f", "xxabb", "cb", "oxyy", "g", "xyabb", "bc", "oxzy", "h", "bbayx", "db...
p03724 AtCoder Grand Contest 014 - Unplanned Queries
Takahashi is not good at problems about trees in programming contests, and Aoki is helping him practice. First, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge. Then, Aoki gave him M queries. The i-th of them is as follows: * Increment the number written at each edge along the...
{ "input": [], "output": [] }
{ "input": [ "5 5\n1 2\n3 5\n5 1\n3 4\n2 3", "4 4\n1 2\n2 4\n1 3\n3 4" ], "output": [ "NO", "YES" ] }
{ "input": [ "5 5\n1 2\n5 5\n5 1\n3 4\n2 3", "5 1\n1 1\n6 5\n5 2\n3 4\n2 3", "5 1\n1 2\n5 5\n5 1\n3 4\n2 3", "5 1\n1 2\n6 5\n5 1\n3 4\n2 3", "5 1\n1 2\n6 5\n5 2\n3 4\n2 3", "5 1\n1 1\n6 6\n5 2\n3 4\n2 3", "5 1\n1 1\n6 6\n5 2\n3 4\n3 3", "10 1\n1 1\n6 6\n5 2\n3 4\n3 3", "10 0\n1 1\n...
p03888 CODE FESTIVAL 2016 Relay (Parallel) - Equivalent Resistance
In an electric circuit, when two resistors R_1 and R_2 are connected in parallel, the equivalent resistance R_3 can be derived from the following formula: * \frac{1}{R_1} + \frac{1}{R_2} = \frac{1}{R_3} Given R_1 and R_2, find R_3. Constraints * 1 \leq R_1, R_2 \leq 100 * R_1 and R_2 are integers. Input The inp...
{ "input": [], "output": [] }
{ "input": [ "100 99", "2 3" ], "output": [ "49.7487437186", "1.2000000000" ] }
{ "input": [ "100 113", "4 3", "100 166", "7 3", "110 166", "7 1", "110 262", "14 1", "110 86", "110 11", "110 6", "110 3", "110 99", "8 3", "110 113", "1 3", "7 2", "111 166", "111 262", "14 -1", "100 86", "110 9", "110 5", ...
p04047 AtCoder Grand Contest 001 - BBQ Easy
Snuke is having a barbeque party. At the party, he will make N servings of Skewer Meal. <image> Example of a serving of Skewer Meal He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i. Also, he has an infinite supply of ingredients. To make a serving of Skew...
{ "input": [], "output": [] }
{ "input": [ "5\n100 1 2 3 14 15 58 58 58 29", "2\n1 3 1 2" ], "output": [ "135", "3" ] }
{ "input": [ "5\n100 1 2 3 14 15 58 58 9 29", "2\n1 3 1 1", "5\n100 1 2 3 1 15 58 58 9 29", "2\n1 2 1 2", "5\n100 1 2 3 1 19 40 14 9 29", "2\n1 2 0 1", "5\n110 1 2 3 1 19 40 14 1 29", "5\n110 1 0 3 1 19 40 14 1 29", "2\n2 0 0 0", "2\n2 -1 0 0", "5\n110 0 0 3 1 19 2 13 1 29"...
p00126 Puzzle
Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number a...
{ "input": [], "output": [] }
{ "input": [ "2\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 ...
{ "input": [ "2\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 0 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n2 1 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 ...
p00259 Finite Field Calculator
The reciprocal of all non-zero real numbers is real, but the reciprocal of an integer is not necessarily an integer. This is the reason why 3/2 * 2 = 2 even though 3.0 / 2.0 * 2.0 = 3.0 in C language. However, if you consider integers with the same remainder after dividing by a prime number as the same, you can make al...
{ "input": [], "output": [] }
{ "input": [ "5: 2 - 3\n17: 1 + 3 * (2 + 3 / 5 * 2) + 7\n11: 1 / 8 - 5 - 8 * 2\n19: 8 / (2 - 3 * 7)\n1153: 10 * 3 / 7 + ( 50 + 81 / 22 ) + 11\n0:" ], "output": [ "2-3 = 4 (mod 5)\n1+3*(2+3/5*2)+7 = 4 (mod 17)\n1/8-5-8*2 = 8 (mod 11)\nNG\n10*3/7+(50+81/22)+11 = 915 (mod 1153)" ] }
{ "input": [ "5: 2 - 3\n17: 1 + 3 * (2 + 3 / 5 * 2) + 7\n11: 1 / 8 - 5 - 8 * 2\n19: 8 / (2 - 3 * 7)\n1153: 10 * 4 / 7 + ( 50 + 81 / 22 ) + 11\n0:", "5: 2 - 3\n17: 1 + 3 * (2 + 3 / 5 * 2) + 7\n11: 1 / 8 - 5 - 8 * 2\n19: 8 / (2 - 3 * 7)\n1153: 10 * 3 / 7 + ( 50 + 81 / 24 ) + 11\n0:", "5: 2 - 3\n17: 1 + 3 * ...
p00446 Card Game
problem There are the following two-player card games. * This game uses a total of 2n cards with each integer from 1 to 2n written on it. Here, n is an integer between 1 and 100. * Deal n cards to each of the two. * Put cards into play alternately one by one according to the following rules. * If there are no cards i...
{ "input": [], "output": [] }
{ "input": [ "5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n18\n4\n11\n3\n17\n5\n19\n0" ], "output": [ "3\n0\n2\n0" ] }
{ "input": [ "5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n18\n2\n11\n3\n17\n5\n19\n0", "5\n1\n7\n9\n6\n5\n10\n8\n7\n14\n18\n4\n11\n6\n17\n5\n19\n0", "5\n1\n7\n9\n6\n10\n10\n4\n7\n14\n18\n2\n11\n3\n17\n5\n19\n0", "5\n1\n7\n9\n6\n5\n10\n8\n7\n13\n18\n1\n11\n6\n17\n5\n19\n0", "5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n1...
p00637 Citation Format
To write a research paper, you should definitely follow the structured format. This format, in many cases, is strictly defined, and students who try to write their papers have a hard time with it. One of such formats is related to citations. If you refer several pages of a material, you should enumerate their page num...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 5 6\n3\n7 8 9\n0" ], "output": [ "1-3 5-6\n7-9" ] }
{ "input": [ "5\n1 1 3 5 6\n3\n7 8 9\n0", "5\n1 1 6 5 6\n3\n7 8 9\n0", "5\n1 1 6 4 6\n3\n7 8 9\n0", "5\n1 1 6 4 9\n3\n7 8 9\n0", "5\n1 1 2 4 9\n3\n7 8 9\n0", "5\n1 2 2 4 9\n3\n7 8 9\n0", "5\n1 2 2 4 9\n3\n7 14 9\n0", "5\n1 2 2 4 9\n3\n7 14 16\n0", "5\n1 2 1 4 9\n3\n7 14 16\n0", ...
p00780 Goldbach's Conjecture
Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2. This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actually holds. However, one can find such a pair of prime numbers, if an...
{ "input": [], "output": [] }
{ "input": [ "6\n10\n12\n0" ], "output": [ "1\n2\n1" ] }
{ "input": [ "6\n1\n12\n0", "6\n10\n8\n0", "6\n4\n12\n0", "6\n1\n3\n0", "6\n4\n2\n0", "6\n0\n2\n0", "6\n4\n0\n0", "6\n2\n14\n0", "6\n1\n0\n0", "6\n16\n0\n0", "6\n16\n1\n0", "6\n24\n0\n0", "6\n6\n14\n0", "6\n46\n1\n0", "6\n1\n40\n0", "6\n10\n14\n0", "...
p00913 Cubic Colonies
In AD 3456, the earth is too small for hundreds of billions of people to live in peace. Interstellar Colonization Project with Cubes (ICPC) is a project that tries to move people on the earth to space colonies to ameliorate the problem. ICPC obtained funding from governments and manufactured space colonies very quickly...
{ "input": [], "output": [] }
{ "input": [ "0 0 0 3 3 3\n###\n###\n###\n###\n###\n###\n###\n###\n###\n3 3 0 0 0 3\n#..\n###\n###\n###\n###\n###\n#.#\n###\n###\n0 0 2 2 2 2\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n0 1 2 2 1 1\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n3 2 0 2 3 2\n###\n..#\n...\n..#\n...\n.#.\n..#\n..#\n.##\n0 0 0 0 0 ...
{ "input": [ "0 0 0 3 3 3\n###\n###\n###\n###\n###\n###\n###\n###\n###\n3 3 0 0 0 3\n$..\n###\n###\n###\n###\n###\n#.#\n###\n###\n0 0 2 2 2 2\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n0 1 2 2 1 1\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n3 2 0 2 3 2\n###\n..#\n...\n..#\n...\n.#.\n..#\n..#\n.##\n0 0 0 0 0 ...
p01045 Hopping Mind
Problem Chieno and Cacao are sisters who work in the same coffee shop. The two are very close, and one day they decided to play a table game. The game uses the board of R square x C square and the rabbit TP as a piece. Each square on the board is painted white or black. First, place the TP in the lower right corner (...
{ "input": [], "output": [] }
{ "input": [ "3 3 2\n...\n...\n...", "3 3 2\n.#\n.#.\n.." ], "output": [ "Chieno", "Cacao" ] }
{ "input": [ "3 3 3\n...\n...\n...", "4 3 2\n.#\n.#.\n..", "3 3 1\n...\n...\n...", "4 3 2\n.#\n.#.\n.-", "2 3 1\n...\n...\n...", "2 3 0\n...\n...\n...", "4 3 2\n...\n...\n...", "3 3 3\n...\n...\n./.", "4 3 2\n.#\n/#.\n..", "2 2 1\n...\n...\n...", "2 3 0\n..-\n...\n...", ...
p01178 Ramen Shop
Ron is a master of a ramen shop. Recently, he has noticed some customers wait for a long time. This has been caused by lack of seats during lunch time. Customers loses their satisfaction if they waits for a long time, and even some of them will give up waiting and go away. For this reason, he has decided to increase s...
{ "input": [], "output": [] }
{ "input": [ "1 4 100\n7\n10 1 50 50\n15 2 50 50\n25 1 50 50\n35 3 50 50\n1 2 100\n5\n30 3 20 50\n40 4 40 50\n1 2 100\n5\n49 3 20 50\n60 4 50 30\n1 2 100\n5\n50 3 20 50\n60 4 50 30\n2 3 100\n4 2\n10 4 20 20\n30 2 20 20\n40 4 20 20\n0 0 0" ], "output": [ "0.7428571428571429\n0.4285714285714285\n0.554285714...
{ "input": [ "1 4 100\n7\n10 1 50 50\n15 2 50 50\n25 1 50 50\n35 3 50 50\n1 2 100\n5\n30 3 20 50\n40 0 40 50\n1 2 100\n5\n49 3 20 50\n60 4 50 30\n1 2 100\n5\n50 3 20 50\n60 4 50 30\n2 3 100\n4 2\n10 4 20 20\n30 2 20 20\n40 4 20 20\n0 0 0", "1 4 100\n7\n10 1 50 50\n15 2 50 50\n25 1 50 50\n35 3 50 50\n1 2 100\n...
p01315 Moonlight Farm
You are enthusiastic about the popular web game "Moonlight Ranch". The purpose of this game is to grow crops in the fields, sell them to earn income, and use that income to grow the ranch. You wanted to grow the field quickly. Therefore, we decided to arrange the crops that can be grown in the game based on the income...
{ "input": [], "output": [] }
{ "input": [ "5\napple 1 1 1 1 1 1 1 10 1\nbanana 1 2 2 2 2 2 1 10 1\ncarrot 1 2 2 2 2 2 1 10 2\ndurian 1 3 3 3 3 3 1 10 1\neggplant 1 3 3 3 3 3 1 100 1\n4\nenoki 1 3 3 3 3 3 1 10 1\ntomato 1 3 3 3 3 3 1 10 1\npotato 1 3 3 3 3 3 1 10 1\nonion 1 3 3 3 3 3 1 10 1\n3\na 10 1 1 1 1 1 1 10 1\nb 10 2 2 2 2 2 2 10 1\nc ...
{ "input": [ "5\napple 1 1 1 1 1 1 1 10 1\nbanana 1 2 2 2 2 2 1 10 1\ncarrot 1 2 2 2 2 2 1 10 2\ndurian 1 3 0 3 3 3 1 10 1\neggplant 1 3 3 3 3 3 1 100 1\n4\nenoki 1 3 3 3 3 3 1 10 1\ntomato 1 3 3 3 3 3 1 10 1\npotato 1 3 3 3 3 3 1 10 1\nonion 1 3 3 3 3 3 1 10 1\n3\na 10 1 1 1 1 1 1 10 1\nb 10 2 2 2 2 2 2 10 1\nc ...
p01483 Elevator
Time Limit: 8 sec / Memory Limit: 64 MB Example Input 3 3 2 1 1 2 1 1 3 1 1 1 Output 8
{ "input": [], "output": [] }
{ "input": [ "3 3 2\n1 1\n2 1 1\n3 1 1 1" ], "output": [ "8" ] }
{ "input": [ "3 3 2\n1 1\n2 1 2\n3 1 1 1", "3 3 2\n1 1\n2 1 2\n3 2 1 1", "3 1 2\n1 0\n2 1 2\n3 2 1 1", "3 3 2\n1 1\n2 1 2\n3 2 -1 1", "3 3 2\n1 1\n2 1 2\n3 2 -1 0", "3 6 2\n1 1\n2 1 2\n4 2 -1 0", "3 0 2\n1 0\n2 1 0\n3 2 1 1", "3 0 2\n1 1\n2 1 2\n3 2 -1 1", "3 6 4\n1 1\n2 0 2\n4 2 -...