name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p03475 AtCoder Beginner Contest 084 - Special Trains
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i t...
{ "input": [], "output": [] }
{ "input": [ "3\n6 5 1\n1 10 1", "4\n12 13 1\n44 17 17\n66 4096 64", "4\n12 24 6\n52 16 4\n99 2 2" ], "output": [ "12\n11\n0", "4162\n4162\n4162\n0", "187\n167\n101\n0" ] }
{ "input": [ "3\n6 6 1\n1 10 1", "4\n1 13 1\n44 17 17\n66 4096 64", "4\n11 24 6\n52 16 4\n99 2 2", "3\n6 1 1\n1 10 2", "3\n6 10 1\n1 10 1", "4\n15 24 6\n52 16 4\n99 2 2", "3\n6 6 1\n2 10 1", "4\n11 23 6\n31 16 4\n99 2 2", "3\n4 1 2\n2 10 2", "4\n1 13 1\n44 17 22\n101 4096 64", ...
p03640 AtCoder Regular Contest 080 - Grid Coloring
We have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied: * For each i (1 ≤ i ≤ N), there are exactly a_i squares painted in Color i. Here, a_1 + a_2 + ... + a_N = H W. * For each i (1 ≤ i ≤ N), the squares painted i...
{ "input": [], "output": [] }
{ "input": [ "1 1\n1\n1", "3 5\n5\n1 2 3 4 5", "2 2\n3\n2 1 1" ], "output": [ "1", "1 4 4 4 3\n2 5 4 5 3\n2 5 5 5 3", "1 1\n2 3" ] }
{ "input": [ "2 2\n2\n3 1 1", "2 1\n1\n2", "1 2\n1\n2", "2 2\n3\n1 1 2", "3 5\n5\n1 2 5 4 3", "1 4\n2\n3 1 0", "2 2\n3\n1 2 1", "2 2\n2\n2 2 1", "1 4\n3\n2 2 0", "3 5\n5\n1 2 6 4 2", "2 2\n3\n4 0 0", "2 1\n3\n0 1 1", "1 2\n3\n0 1 1", "1 2\n3\n0 2 0", "1 2\n3...
p03796 AtCoder Beginner Contest 055 - Training Camp
Snuke loves working out. He is now exercising N times. Before he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. Constraints * 1 ≤ N ≤ 10...
{ "input": [], "output": [] }
{ "input": [ "100000", "3", "10" ], "output": [ "457992974", "6", "3628800" ] }
{ "input": [ "100001", "1", "15", "110001", "21", "110011", "39", "11", "6", "4", "7", "2", "101001", "8", "18", "110000", "111011", "30", "110111", "65", "5", "101000", "12", "110100", "111010", "40", "110010"...
p03964 AtCoder Beginner Contest 046 - AtCoDeer and Election Report
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he c...
{ "input": [], "output": [] }
{ "input": [ "5\n3 10\n48 17\n31 199\n231 23\n3 2", "4\n1 1\n1 1\n1 5\n1 100", "3\n2 3\n1 1\n3 2" ], "output": [ "6930", "101", "10" ] }
{ "input": [ "5\n3 1\n48 17\n31 199\n231 23\n3 2", "4\n1 1\n1 1\n1 9\n1 100", "3\n3 3\n1 1\n3 2", "3\n4 3\n1 1\n3 1", "3\n4 3\n1 2\n3 1", "3\n2 3\n1 1\n1 2", "4\n1 2\n1 1\n1 9\n1 100", "5\n3 10\n48 28\n31 199\n319 23\n3 2", "3\n4 3\n1 1\n1 2", "5\n3 10\n48 28\n31 199\n300 23\n3...
p00055 Sequence
I have a sequence defined as follows: * All even-numbered terms are equal to the previous term multiplied by 2. * All odd-numbered terms are equal to the previous term divided by 3. Create a program that reads the first term a of this sequence and outputs the sum s (10) from the first term to the tenth term. Inp...
{ "input": [], "output": [] }
{ "input": [ "1.0\n2.0\n3.0" ], "output": [ "7.81481481\n15.62962963\n23.44444444" ] }
{ "input": [ "1.0\n2.0\n3.0275795971873247", "1.0\n2.0\n3.649719120761334", "1.0\n2.783489291479195\n3.649719120761334", "1.0\n2.783489291479195\n4.155640422734946", "1.1344311401157299\n2.783489291479195\n4.155640422734946", "1.1344311401157299\n2.783489291479195\n4.613723793797428", "1.1...
p00186 Aizu Chicken
In April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it is difficult to breed, so the production volume is small and the price is high. <image> Relative...
{ "input": [], "output": [] }
{ "input": [ "48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5680 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558 1396 187 17\n279 88677 4522 514 14\n0" ], "output": [ "28 20\n7 13\n15 33\nNA\n97 0\n12 44\nNA\nNA" ] }
{ "input": [ "48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5680 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558 1396 187 17\n279 88677 2825 514 14\n0", "48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5843 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558...
p00341 Cuboid Made with Bars
The educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, "Play with Tsukuro". This time I will make a box with sticks, but I would like to see if I can make a rectangular parallelepiped using the 12 sticks I prepared. However, the stick must not be cut or...
{ "input": [], "output": [] }
{ "input": [ "1 1 2 2 3 1 2 3 3 3 1 2", "1 1 3 4 8 9 7 3 4 5 5 5" ], "output": [ "yes", "no" ] }
{ "input": [ "1 1 2 2 3 1 1 3 3 3 1 2", "1 1 3 4 8 9 7 3 3 5 5 5", "1 0 2 2 3 1 1 3 3 3 1 2", "1 1 3 7 8 9 7 3 3 5 5 5", "0 0 2 2 3 1 1 3 3 3 1 2", "1 1 2 2 5 1 2 3 3 3 1 2", "1 1 3 4 8 9 3 3 4 5 5 5", "1 1 2 2 3 1 2 3 2 3 1 2", "1 1 3 4 8 9 7 3 3 4 5 5", "1 0 2 2 3 1 1 3 3 3 1...
p00537 Railroad Trip
Railroad Trip There are N cities in the JOI country, numbered 1, 2, ..., and N, respectively. In addition, there are N − 1 railroads, which are numbered 1, 2, ..., and N − 1, respectively. The railroad i (1 ≤ i ≤ N − 1) connects the city i and the city i + 1 in both directions. There are two ways to get on the JOI ra...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 3 2 4\n120 90 100\n110 50 80\n250 70 130" ], "output": [ "550" ] }
{ "input": [ "4 4\n1 3 2 4\n120 90 100\n110 50 80\n250 70 24", "4 4\n1 3 2 4\n120 90 100\n110 50 80\n250 75 130", "4 4\n1 3 2 4\n120 90 100\n110 50 33\n250 70 24", "4 4\n1 3 2 4\n120 90 100\n110 50 96\n250 75 130", "4 4\n1 3 2 4\n120 90 100\n110 75 33\n250 70 24", "4 4\n1 3 2 4\n120 90 100\n11...
p00699 Nets of Dice
In mathematics, some plain words have special meanings. The word "net" is one of such technical terms. In mathematics, the word "net" is sometimes used to mean a plane shape which can be folded into some solid shape. The following are a solid shape (Figure 1) and one of its net (Figure 2). <image>| <image> ---|--- Fi...
{ "input": [], "output": [] }
{ "input": [ "6\n0 0 0 0 0\n0 0 0 0 6\n0 2 4 5 3\n0 0 1 0 0\n0 0 0 0 0\n0 0 3 0 0\n0 0 2 0 0\n0 0 4 1 0\n0 0 0 5 0\n0 0 0 6 0\n0 0 0 3 0\n0 0 2 5 0\n0 4 1 0 0\n0 0 6 0 0\n0 0 0 0 0\n0 6 2 0 0\n0 0 4 0 0\n0 1 5 0 0\n0 0 3 0 0\n0 0 0 0 0\n0 0 0 0 6\n0 2 4 5 3\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 1 0\n0 0 0 0 6\n0 2 4 5 3\n...
{ "input": [ "6\n0 0 0 0 0\n0 0 0 0 6\n0 2 4 5 3\n0 0 1 0 0\n0 0 0 0 0\n0 0 3 0 0\n0 0 2 0 0\n0 0 4 1 0\n0 0 0 5 0\n0 1 0 6 0\n0 0 0 3 0\n0 0 2 5 0\n0 4 1 0 0\n0 0 6 0 0\n0 0 0 0 0\n0 6 2 0 0\n0 0 4 0 0\n0 1 5 0 0\n0 0 3 0 0\n0 0 0 0 0\n0 0 0 0 6\n0 2 4 5 3\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 1 0\n0 0 0 0 6\n0 2 4 5 3\n...
p00840 Mobile Computing
There is a mysterious planet called Yaen, whose space is 2-dimensional. There are many beautiful stones on the planet, and the Yaen people love to collect them. They bring the stones back home and make nice mobile arts of them to decorate their 2-dimensional living rooms. In their 2-dimensional world, a mobile is defi...
{ "input": [], "output": [] }
{ "input": [ "5\n1.3\n3\n1\n2\n1\n1.4\n3\n1\n2\n1\n2.0\n3\n1\n2\n1\n1.59\n4\n2\n1\n1\n3\n1.7143\n4\n1\n2\n3\n5" ], "output": [ "-1\n1.3333333333333335\n1.6666666666666667\n1.5833333333333335\n1.7142857142857142" ] }
{ "input": [ "5\n1.562976116968605\n3\n1\n2\n1\n1.4\n3\n1\n2\n1\n2.0\n3\n1\n2\n1\n1.59\n4\n2\n1\n1\n3\n1.7143\n4\n1\n2\n3\n5", "5\n1.562976116968605\n3\n1\n2\n1\n1.4\n3\n1\n2\n1\n2.0\n3\n1\n2\n1\n1.59\n4\n2\n1\n1\n3\n1.7143\n2\n1\n2\n3\n5", "5\n1.7805171573653904\n3\n1\n2\n1\n1.4\n3\n1\n2\n1\n2.0\n3\n1\n2...
p00972 Eulerian Flight Tour
Eulerian Flight Tour You have an airline route map of a certain region. All the airports in the region and all the non-stop routes between them are on the map. Here, a non-stop route is a flight route that provides non-stop flights in both ways. Named after the great mathematician Leonhard Euler, an Eulerian tour is ...
{ "input": [], "output": [] }
{ "input": [ "4 2\n1 2\n3 4" ], "output": [ "2\n1 4\n2 3" ] }
{ "input": [ "2 1\n1 2\n3 4", "3 1\n1 2\n5 7", "1 0\n1 2\n3 4", "3 1\n1 3\n-1 10", "2 1\n1 2\n2 4", "2 1\n1 2\n3 7", "2 1\n1 2\n5 4", "2 1\n1 2\n4 7", "2 1\n1 2\n4 4", "2 1\n1 2\n5 7", "2 0\n1 2\n3 4", "2 1\n1 2\n2 7", "2 0\n1 2\n4 7", "2 0\n1 2\n5 7", "2 0\...
p01104 Making Lunch Boxes
Making Lunch Boxes Taro has been hooked on making lunch boxes recently. Taro has obtained a new lunch box recipe book today, and wants to try as many of the recipes listed in the book as possible. Enough of the ingredients for all the recipes are at hand, but they all are in vacuum packs of two. If only one of them i...
{ "input": [], "output": [] }
{ "input": [ "4 3\n110\n101\n011\n110\n7 1\n1\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n00100\n00010\n6 6\n111111\n011000\n100000\n000010\n100001\n100100\n0 0" ], "output": [ "3\n6\n0\n6" ] }
{ "input": [ "4 3\n110\n101\n011\n110\n7 1\n0\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n00100\n00010\n6 6\n111111\n011000\n100000\n000010\n100001\n100100\n0 0", "4 3\n110\n101\n011\n110\n7 1\n0\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n00100\n00010\n6 6\n111111\n011000\n100000\n000011\n100001\n100100\n0 0", "4 3\...
p01241 Finding the Top RPS Player
A company “ACM Foods” is preparing for opening its chain shop in a certain area, but another company “ICPC Pizza” is also planning to set up its branch shop in the same area. In general, two competitive shops gain less incomes if they are located so close to each other. Thus, if both “ACM Foods” and “ICPC Pizza” went o...
{ "input": [], "output": [] }
{ "input": [ "2 1\n10 5\n15 10\n0 0" ], "output": [ "Case 1: 1\nCase 2: 11\nCase 3: 210" ] }
{ "input": [ "2 1\n10 5\n15 6\n0 0", "2 1\n10 5\n15 2\n0 0", "2 1\n14 5\n15 10\n0 0", "2 1\n10 2\n15 6\n0 0", "2 1\n16 5\n15 10\n0 0", "3 1\n16 10\n15 10\n0 0", "2 1\n10 5\n28 10\n0 0", "2 1\n16 5\n14 10\n0 0", "3 1\n16 10\n15 5\n0 0", "2 1\n10 5\n28 1\n0 0", "3 1\n16 4\n15...
p01403 Farey Sequence
Problem F: Farey Sequence slip likes to look at the numbers. Just looking at the remaining time while downloading the file is enough to kill the time. Such a slip was taught an interesting sequence by a friend. The definition of the sequence is as follows. The general term is expressed as Fn. Fn is an arrangement of ...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n5" ], "output": [ "5\n11" ] }
{ "input": [ "2\n5\n5", "2\n5\n2", "2\n2\n5", "2\n4\n5", "2\n2\n2", "2\n2\n7", "2\n1\n5", "2\n1\n2", "2\n3\n7", "2\n7\n5", "2\n1\n7", "2\n6\n5", "2\n1\n14", "2\n1\n4", "2\n1\n3", "2\n2\n4", "2\n2\n1", "2\n5\n9", "2\n9\n2", "2\n4\n6", ...
p01557 ReverseSort
A permutation of N numbers from 1 to N A1, A2, ……, AN is given. You can perform the operation reverse (i, j) to reverse the order of the numbers in the interval [i, j] (1 ≤ i ≤ j ≤ N) for this permutation. For example, if reverse (2, 4) is applied to [1, 2, 3, 4, 5], it becomes [1, 4, 3, 2, 5]. Calculate how many opera...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3", "5\n1 4 3 5 2", "10\n3 1 5 2 7 4 9 6 10 8", "5\n3 1 5 2 4" ], "output": [ "0", "2", "9", "4" ] }
{ "input": [ "10\n3 0 5 2 7 4 9 6 10 8", "5\n3 1 5 4 2", "3\n1 3 2", "10\n3 0 5 2 7 4 9 6 17 8", "10\n3 0 5 1 7 4 9 6 17 8", "10\n3 0 5 1 7 4 12 6 17 8", "10\n3 0 5 2 7 4 9 6 11 8", "10\n3 0 5 2 7 4 10 6 17 8", "10\n3 0 5 1 7 4 9 6 12 8", "10\n2 0 5 1 7 4 12 6 17 8", "10\n3...
p01719 Invest Master
After many years of research, Ikta has acquired the ability to predict the future! The time and money he spent on this research was enormous, but it's finally time to be rewarded. To get the money back, Ikta decided to start investing in stocks. Ikta does not currently own any shares, but owns x yen. He has invested i...
{ "input": [], "output": [] }
{ "input": [ "1 2 5\n6\n10000", "2 3 5\n4 5\n6 3\n8 5", "3 3 10\n10 9 6\n8 7 3\n7 5 1", "2 2 5\n3 2\n5 4" ], "output": [ "5", "11", "10", "9" ] }
{ "input": [ "3 3 10\n10 9 6\n14 7 3\n7 5 1", "3 3 10\n10 8 13\n14 3 4\n5 5 1", "3 3 10\n10 8 13\n14 3 4\n5 4 1", "1 2 5\n4\n10000", "2 3 5\n4 5\n6 3\n8 6", "2 2 6\n3 2\n5 4", "3 3 10\n10 9 6\n11 7 3\n7 5 1", "3 3 10\n10 4 6\n14 7 3\n7 5 1", "3 3 10\n10 8 11\n1 7 3\n7 5 1", "3 ...
p01857 Eggs
Problem statement It was a month ago. Nikunishi, an elementary school student, did not do his summer vacation homework. Therefore, the independent study decided to investigate the strength of the eggs at home. In this study, we define the strength of an egg as H when it does not crack when dropped from height H and c...
{ "input": [], "output": [] }
{ "input": [ "3\n5 1\n5 2\n1 2" ], "output": [ "5\n3\n1" ] }
{ "input": [ "3\n5 1\n5 2\n1 1", "3\n5 1\n5 2\n2 2", "3\n1 1\n5 2\n1 2", "3\n1 1\n5 2\n2 2", "3\n5 1\n8 6\n1 1", "3\n2 1\n5 2\n2 2", "3\n10 1\n8 6\n1 1", "3\n5 1\n8 3\n2 2", "3\n5 1\n15 3\n2 2", "3\n10 1\n8 4\n2 1", "3\n3 1\n15 3\n2 2", "3\n3 1\n12 3\n3 2", "3\n5 2\...
p01992 Shiritori Compression
D: Shiritori Compression problem Ebi-chan and Kana-chan did a shiritori. Ebi-chan is looking at the memo of the word that came out in Shiritori. Ebi-chan wants to remove redundant continuous subsequences from this word sequence w_1, w_2, ..., w_N until they no longer exist. The redundant continuous subsequence that ...
{ "input": [], "output": [] }
{ "input": [ "7\nbanana\nat\ntomb\nbus\nsound\ndoes\nsome" ], "output": [ "2" ] }
{ "input": [ "7\nbanana\nta\ntomb\nbus\nsound\ndoes\nsome", "7\nananab\nta\nsomb\nbus\nsound\ndoes\nsemo", "7\nbanaoa\nta\ntomb\nbus\nsound\ndoes\nsome", "7\nbanaoa\nta\nuomb\nbus\nsound\ndoes\nsome", "7\nbanaoa\nua\ntomb\nbus\nsound\ndoes\nsome", "7\nbanaoa\nua\ntomb\nbus\nspund\ndoes\nsome",...
p02138 U and U
Problem There are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called "U & U". "U & U" has a common score for $ 2 $ teams, and the goal is to work together to minimize the common score. In "U & U", everyone's phys...
{ "input": [], "output": [] }
{ "input": [ "64783 68943", "20 10", "1000000000000000000 1000000000000000000", "10 20" ], "output": [ "4", "0", "2", "1" ] }
{ "input": [ "57319 68943", "25 10", "1000000000000000000 1000000000010000000", "10 36", "105904 68943", "25 12", "1000000001000000000 1000000000010000000", "10 48", "109335 68943", "13 12", "1000001001000000000 1000000000010000000", "13 48", "49791 68943", "6 1...
p02279 Rooted Trees
A graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). <image> Fig. 1 A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertic...
{ "input": [], "output": [] }
{ "input": [ "13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0", "4\n1 3 3 2 0\n0 0\n3 0\n2 0" ], "output": [ "node 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, [...
{ "input": [ "4\n1 3 2 3 0\n0 0\n3 0\n2 0", "4\n1 3 2 3 0\n0 0\n3 0\n2 0" ], "output": [ "node 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [2, 3, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n", "node 0: parent = 1, depth = 1, l...
p02426 Bit Mask
A state with $n$ flags of ON or OFF can be represented by a sequence of bits where $0, 1, ..., n-1$ th flag corresponds to 1 (ON) or 0 (OFF). The state can be managed by the corresponding decimal integer, because the sequence of bits is a binary representation where each bit is 0 or 1. On the other hand, a mask is a s...
{ "input": [], "output": [] }
{ "input": [ "3\n3 0 1 3\n1 3\n3 0 1 2\n8\n1 0\n2 1\n3 1\n4 2\n5 2\n6 2\n7 2\n8 2" ], "output": [ "0\n1\n0\n2\n3" ] }
{ "input": [ "3\n3 0 1 3\n1 3\n3 0 0 2\n8\n1 0\n2 1\n3 1\n4 2\n5 2\n6 2\n7 2\n8 2", "3\n3 0 1 3\n0 3\n3 0 0 2\n8\n1 0\n2 1\n3 1\n4 2\n5 2\n6 2\n7 2\n8 2", "3\n3 0 1 3\n1 3\n3 0 0 2\n8\n1 0\n2 1\n3 1\n4 2\n5 1\n6 2\n7 0\n8 2", "3\n3 0 1 3\n0 3\n3 0 1 1\n8\n1 0\n2 1\n3 1\n4 2\n5 2\n6 2\n7 2\n10 2", ...
bintour
Knights' tournaments were quite popular in the Middle Ages. A lot of boys were dreaming of becoming a knight, while a lot of girls were dreaming of marrying a knight on a white horse. In this problem we consider one of these tournaments. Let's us call a tournament binary, if it runs according to the scheme described...
{ "input": [], "output": [] }
{ "input": [ "2", "1" ], "output": [ "0\n8\n16\n24", "2\n2" ] }
{ "input": [ "3", "6", "4", "5", "7", "8", "11", "10", "9", "13", "12", "14" ], "output": [ "0\n0\n0\n1152\n4608\n11520\n23040\n40320\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n440731713\n103414690\n7063...
cntsols
Little Chief loves math. Most of all, he loves equations. He can solve any equation in the whole world. Recently he found one interesting and easy equation x1^d+x2^d+x3^d ≡ m (mod N) Where x1, x2 and x3 are non negative integer numbers. But, as always, this was easy enough for him and he solved it in just a few seconds...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2 3 5\n1 2013 3 31" ], "output": [ "4\n1" ] }
{ "input": [], "output": [] }
frogv
Nobody knows, but N frogs live in Chef's garden. Now they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to K. Chef knows all P pairs of frogs, which want to send messages. Help him to define can they or not! Note : Mo...
{ "input": [], "output": [] }
{ "input": [ "5 3 3\n0 3 8 5 12\n1 2\n1 3\n2 5" ], "output": [ "Yes\nYes\nNo\n" ] }
{ "input": [ "5 3 3\n0 3 8 5 12\n1 2\n1 3\n1 5", "5 3 3\n0 3 8 8 12\n1 3\n1 3\n2 5", "5 3 3\n0 3 8 8 12\n1 2\n1 3\n2 5", "5 6 3\n0 3 8 8 12\n1 2\n1 3\n2 5", "5 3 1\n0 3 8 8 12\n1 3\n1 3\n2 5", "5 3 3\n0 3 15 8 12\n1 2\n1 3\n3 5", "5 3 3\n0 6 9 9 12\n1 3\n2 3\n2 5", "5 3 1\n1 3 1 6 12\n...
lstgrph
Mike is given an undirected graph G of N vertices and M edges. A non-negative integer Xi is assigned to the i'th vertex of G, for 1 ≤ i ≤ N. Mike was asked to assign labels to each edge of the graph so that the following condition is satisfied: Let's suppose that the j'th edge of G connects vertices Uj and Vj. Th...
{ "input": [], "output": [] }
{ "input": [ "5 4 2\n1 2 5\n1 3 9\n2 4 0\n2 5 1" ], "output": [ "1 4 8 4 5" ] }
{ "input": [ "5 4 2\n1 4 5\n1 3 9\n2 4 0\n2 5 1", "5 4 2\n1 2 5\n1 3 9\n2 4 -1\n2 5 1", "5 4 2\n1 4 5\n1 3 12\n2 4 0\n2 5 1", "5 4 2\n1 4 3\n1 3 12\n2 4 0\n2 5 1", "5 4 2\n1 2 5\n1 3 4\n2 4 0\n2 5 1", "5 4 2\n1 4 5\n1 3 1\n2 4 0\n2 5 1", "5 4 2\n1 2 5\n2 3 9\n2 4 -1\n2 5 1", "5 4 2\n1 ...
prladdu
DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers. You are given the information of DevuLand by an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that village. Otherwise, it means t...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n5 -5\n2\n-5 5\n3\n1 2 -3" ], "output": [ "5\n5\n4\n" ] }
{ "input": [ "3\n1\n5 -5\n2\n-5 5\n3\n1 2 -3", "3\n2\n5 -5\n2\n-5 5\n3\n0 3 -3", "3\n1\n5 -5\n1\n-5 5\n2\n1 3 -4", "3\n1\n5 -5\n2\n-8 8\n2\n1 2 -3", "3\n1\n5 -5\n1\n-5 5\n3\n1 2 -3", "3\n2\n5 -5\n2\n-5 5\n2\n1 2 -3", "3\n2\n5 -5\n1\n-5 5\n3\n1 2 -3", "3\n2\n5 -5\n1\n-5 5\n2\n1 2 -3", ...
tavisual
At the end of a busy day, The Chef and his assistants play a game together. The game is not just for fun but also used to decide who will have to clean the kitchen. The Chef is a Game Master, so his concern is how to manage the game but not how to win the game like his assistants do. The game requires players to find...
{ "input": [], "output": [] }
{ "input": [ "1\n5 2 3\n1 4\n3 5\n1 5" ], "output": [ "1\n" ] }
{ "input": [ "1\n5 2 3\n1 4\n3 5\n0 5", "1\n5 2 3\n1 3\n3 5\n1 5", "1\n5 2 3\n2 4\n3 5\n0 5", "1\n5 2 3\n2 4\n2 5\n0 5", "1\n5 2 3\n2 4\n2 8\n0 5", "1\n10 2 3\n1 6\n3 5\n1 5", "1\n4 2 3\n1 6\n3 9\n1 5", "1\n5 2 3\n5 4\n2 5\n0 3", "1\n5 2 3\n2 8\n2 4\n1 0", "1\n4 2 3\n1 0\n2 9\n...
1249_E. By Elevator or Stairs?
You are planning to buy an apartment in a n-floor building. The floors are numbered from 1 to n from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor. Let: * a_i for all i from 1 to n-1 be the time required to go from the i-th floor...
{ "input": [], "output": [] }
{ "input": [ "10 2\n7 6 18 6 16 18 1 17 17\n6 9 3 10 9 1 10 1 5\n", "10 1\n3 2 3 1 3 3 1 4 1\n1 2 3 4 4 1 2 1 3\n" ], "output": [ "0 7 13 18 24 35 36 37 40 45 \n", "0 2 4 7 8 11 13 14 16 17 \n" ] }
{ "input": [ "10 2\n7 6 18 6 16 18 1 17 17\n6 17 3 10 9 1 10 1 5\n", "10 1\n3 0 3 1 3 3 1 4 1\n1 2 3 4 4 1 2 1 3\n", "10 2\n7 6 18 6 16 18 2 17 17\n6 17 3 10 9 1 10 1 5\n", "10 1\n5 0 3 0 3 3 1 4 1\n1 2 3 4 4 1 2 1 3\n", "10 2\n5 0 3 0 3 3 1 4 1\n1 2 3 4 4 1 2 1 3\n", "10 2\n5 0 3 0 3 3 1 4 0\...
1333_B. Kind Anton
Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem: There are two arrays of integers a and b of length n. It turned out that array a contains only elements from the set \{-1, 0, 1\}. Anton can perform the following sequence of operations any number of ti...
{ "input": [], "output": [] }
{ "input": [ "5\n3\n1 -1 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 0\n1 41\n2\n-1 0\n-1 -41\n5\n0 1 -1 1 -1\n1 1 -1 1 -1\n" ], "output": [ "YES\nNO\nYES\nYES\nNO\n" ] }
{ "input": [ "5\n3\n1 -1 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 -1\n1 41\n2\n-1 0\n-1 -41\n5\n0 1 -1 1 -1\n1 1 -1 1 -1\n", "5\n3\n1 -1 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 -1\n2 41\n2\n-1 0\n-1 -38\n5\n0 1 -1 1 -1\n1 1 -1 1 -1\n", "5\n3\n1 0 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 0\n1 41\n2\n-1 0\n-1 -41\n5\n0 1 -1 1 -1\...
1353_E. K-periodic Garland
You are given a garland consisting of n lamps. States of the lamps are represented by the string s of length n. The i-th character of the string s_i equals '0' if the i-th lamp is turned off or '1' if the i-th lamp is turned on. You are also given a positive integer k. In one move, you can choose one lamp and change i...
{ "input": [], "output": [] }
{ "input": [ "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0\n" ], "output": [ "1\n2\n5\n4\n0\n0\n" ] }
{ "input": [ "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n0\n1 1\n0\n", "6\n9 2\n010001010\n9 5\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n0\n1 1\n0\n", "6\n9 2\n011001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n0\n1 1\n0\n", "6\n9 3\n010001010\n9 5\n111...
1463_D. Pairs
You have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements. Your goal is to obtain the set of numbers \\{b_1, b_2, ..., b_n\} as the result of taking elements ...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n" ], "output": [ "\n1\n3\n1\n" ] }
{ "input": [ "3\n1\n1\n5\n1 4 5 9 10\n2\n1 4\n", "3\n1\n1\n5\n1 4 5 9 10\n2\n2 4\n", "3\n1\n1\n5\n1 4 5 7 10\n2\n1 4\n", "3\n1\n1\n5\n1 4 5 8 10\n2\n2 4\n", "3\n1\n1\n5\n1 2 5 9 10\n2\n2 4\n", "3\n1\n1\n5\n1 2 5 9 10\n2\n1 2\n", "3\n1\n1\n5\n1 4 6 9 10\n2\n1 4\n", "3\n1\n1\n5\n1 4 5 6 ...
1512_B. Almost Rectangle
There is a square field of size n × n in which two cells are marked. These cells can be in the same row or column. You are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes. For example, if n=4 and a rectangular field looks like this (there are asterisks in ...
{ "input": [], "output": [] }
{ "input": [ "6\n4\n..*.\n....\n*...\n....\n2\n*.\n.*\n2\n.*\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n" ], "output": [ "\n*.*.\n....\n*.*.\n....\n**\n**\n**\n**\n*.*\n*.*\n...\n.....\n.**..\n.....\n.**..\n.....\n....\n....\n**..\n**..\n" ] }
{ "input": [ "6\n4\n..*.\n....\n*...\n....\n2\n*.\n.*\n2\n*.\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n", "6\n4\n..*.\n....\n...*\n....\n2\n*.\n.*\n2\n*.\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n", "6\n4\n..*.\n.....
331_B2. Shave Beaver!
The Smart Beaver has recently designed and built an innovative nanotechnologic all-purpose beaver mass shaving machine, "Beavershave 5000". Beavershave 5000 can shave beavers by families! How does it work? Very easily! There are n beavers, each of them has a unique id from 1 to n. Consider a permutation a1, a2, ..., a...
{ "input": [], "output": [] }
{ "input": [ "5\n1 3 4 2 5\n6\n1 1 5\n1 3 4\n2 2 3\n1 1 5\n2 1 5\n1 1 5\n" ], "output": [ "2\n1\n3\n5\n" ] }
{ "input": [ "5\n1 3 4 2 5\n6\n1 2 5\n1 3 4\n2 2 3\n1 1 5\n2 1 5\n1 1 5\n", "5\n1 3 4 2 5\n6\n1 1 5\n1 3 4\n2 2 3\n1 1 5\n2 2 5\n1 1 5\n", "5\n1 3 4 2 5\n6\n1 2 5\n2 3 4\n2 2 3\n1 1 5\n2 1 5\n1 1 5\n", "5\n1 3 4 2 5\n6\n1 2 5\n2 3 4\n2 2 3\n1 1 5\n2 1 5\n2 1 5\n", "5\n1 3 4 2 5\n6\n1 2 5\n1 3 4\n2...
661_F. Primes in Interval
You are given two integers a and b (a ≤ b). How many prime numbers are there on the interval from a to b, inclusive? Input The input contains two integers a and b (2 ≤ a ≤ b ≤ 1 000 000), separated by a single space. Output Output a single integer — the number of primes between a and b, inclusive. Examples Input ...
{ "input": [], "output": [] }
{ "input": [ "10 20\n", "23 23\n", "271 566\n" ], "output": [ "4\n", "1\n", "46\n" ] }
{ "input": [], "output": [] }
andrew-and-wengaluru-city
Andrew has recently moved to Wengaluru. He finds this city amazing as all the buildings of the city are of same shape. There are N buildings in a row with no space in between. Buildings may have different heights while width in other two dimensions is always 1 unit. Rain occurs very frequently in Wengaluru so Andre...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n3 2 1 4 5\n5\n1 2 3 4 5\n\nSAMPLE" ], "output": [ "3\n0\n" ] }
{ "input": [ "2\n5\n3 4 1 4 5\n5\n1 2 3 4 5\n\nSAMPLE", "2\n5\n3 4 2 4 5\n5\n1 2 3 4 5\n\nSAMPLE", "2\n5\n3 2 1 4 5\n5\n1 4 3 4 5\n\nSAMPLE", "2\n5\n2 7 2 4 5\n5\n1 2 3 4 5\n\nSAMPLE", "2\n5\n5 1 2 5 5\n5\n1 2 3 4 5\n\nSAMPLE", "2\n5\n3 2 1 4 5\n5\n1 4 3 3 4\n\nSAMPLE", "2\n5\n3 4 1 3 5\n5...
diedie
Link to Russian translation of problem There are N ants staying at the vertices of the N-regular polygon (one ant at one vertex). At some moment of time all the ants choose one of the edges their vertex is adjacent to and start walking along this edge. If two ants meet at some point of the edge they die. Please find t...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n\nSAMPLE" ], "output": [ "250000002\n" ] }
{ "input": [ "1\n6\n\nSAMPLE", "1\n8\n\nSAMPLE", "1\n7\n\nGLOMAS", "1\n3\n\nSPMALE", "1\n4\n\nGLOMAS", "1\n1\n\nFKQMAS", "1\n14\n\nR@MLPF", "1\n2\n\nFOLMAR", "1\n11\n\nGMOKAS", "1\n5\n\nNASOLG", "1\n9\n\nSAOKMG", "1\n10\n\nSAOKMG", "1\n15\n\nGMKOAS", "1\n12\n\nG...
generate-composite-numbers
In this problem you will be given a range 'n', and you are supposed to find all composite numbers within that range. Make your program efficient as time limit of the program is set to 1 second. Choose an efficient algorithm to find all the composite numbers within the range 0 to n. Input n - a single positive Integer...
{ "input": [], "output": [] }
{ "input": [ "8\n\nSAMPLE" ], "output": [ "4 6 8\n" ] }
{ "input": [ "8\n\nTAMPLE", "8\n\nTAPMLE", "8\n\nSAPMLE", "8\n\nSAPNLE", "8\n\nSNPALE", "8\n\nSNAPLE", "8\n\nELPANS", "8\n\nEKPANS", "8\n\nEKPAMS", "8\n\nEMPAKS", "8\n\nEMPASK", "8\n\nKSAPME", "8\n\nJSAPME", "8\n\nEMPASJ", "8\n\nEAPMSJ", "8\n\nEAPSMJ", ...
subpalindrome-2
For every string given as input, you need to tell us the number of subsequences of it that are palindromes (need not necessarily be distinct). Note that the empty string is not a palindrome. SAMPLE INPUT 1 aab SAMPLE OUTPUT 4 Explanation the palindromic subsequences of "aab" are: "a", "a", "b", "aa", and the metho...
{ "input": [], "output": [] }
{ "input": [ "1\naab\n\nSAMPLE" ], "output": [ "4" ] }
{ "input": [ "1\nbaa\n\nSAMPLE", "1\n`ab\n\nSAMPLE", "1\nb`b\n\nMASPLE", "1\na`b\n\nSAMPLE", "1\na`b\n\nS@MPLE", "1\na`b\n\nMASPLE", "1\nbab\n\nMASPLE", "1\nbab\n\nELPSAM", "1\nbab\n\nELPSBM", "1\nbab\n\nDLPSBM", "1\nbab\n\nMBSPLD", "1\nbab\n\nNBSPLD", "1\ncab\n\nNB...
p02605 M-SOLUTIONS Programming Contest 2020 - Air Safety
M-kun is a brilliant air traffic controller. On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude. Each of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the d...
{ "input": [], "output": [] }
{ "input": [ "8\n168 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "4\n20 30 U\n30 20 R\n20 10 D\n10 20 L", "2\n11 1 U\n11 47 D" ], "output": [ "100", "SAFE", "230" ] }
{ "input": [ "8\n285 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "4\n20 30 U\n30 20 R\n20 10 D\n19 20 L", "4\n20 9 U\n30 20 R\n20 10 D\n10 20 L", "8\n285 68 U\n70 175 R\n111 192 D\n15 123 L\n200 116 U\n0 121 R\n119 240 D\n99 107 L", "8\n285 68 U\n130 175 R\...
p02736 AtCoder Grand Contest 043 - 123 Triangle
Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows: * x_{1,j} := a_j \quad (1 \leq j \leq N) * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i) Find x_{N,1}. Constraints * 2 \leq N \leq 10^6 * a_i = 1,2,3 (1 \leq...
{ "input": [], "output": [] }
{ "input": [ "10\n2311312312", "4\n1231" ], "output": [ "0", "1" ] }
{ "input": [ "4\n2332", "4\n3121", "4\n1311", "10\n1806305381", "4\n2465", "10\n2192114600", "4\n2113", "10\n3104206232", "4\n2121", "4\n2010", "10\n2763272837", "10\n1238013900", "10\n1665759416", "10\n2224468077", "4\n1200", "10\n1876244682", "4\n2...
p02870 NIKKEI Programming Contest 2019-2 - Mirror Frame
In a two-dimensional plane, there is a square frame whose vertices are at coordinates (0,0), (N,0), (0,N), and (N,N). The frame is made of mirror glass. A ray of light striking an edge of the frame (but not a vertex) will be reflected so that the angle of incidence is equal to the angle of reflection. A ray of light st...
{ "input": [], "output": [] }
{ "input": [ "6\n?o???\n????o\n??x??\no????\n???o?", "5\no?o?\n????\no?x?\n????", "4\no?o\n???\n?x?", "9\n????o??x\n?????x??\n??o?o???\n?o?x????\n???????x\nx?o?o???\n????????\nx?????x?" ], "output": [ "32", "0", "1", "4" ] }
{ "input": [ "5\no?n?\n????\no?x?\n????", "6\n?o???\n????o\n??x??\no????\n?o???", "9\nx??o????\n?????x??\n??o?o???\n?o?x????\n???????x\nx?o?o???\n????????\nx?????x?", "5\no?n?\n????\no?x@\n????", "9\nx??o????\n?????x??\n??o?o???\n?o?x????\n???????w\nx?o?o???\n????????\nx?????x?", "5\no>o?\n???...
p03005 diverta 2019 Programming Contest 2 - Ball Distribution
Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls? Constraints * 1 \leq K \leq N \leq 100 * All values in input are intege...
{ "input": [], "output": [] }
{ "input": [ "8 5", "3 1", "3 2" ], "output": [ "3", "0", "1" ] }
{ "input": [ "9 5", "4 2", "2 2", "14 5", "2 3", "0 3", "14 3", "1 3", "14 6", "-1 3", "-2 3", "4 12", "0 9", "0 13", "0 6", "20 2", "6 5", "9 2", "25 6", "-1 6", "1 11", "9 3", "-1 13", "19 2", "5 2", "15 2", ...
p03145 AtCoder Beginner Contest 116 - Right Triangle
There is a right triangle ABC with ∠ABC=90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer. Constraints * 1 \leq |AB|,|BC|,|CA| \leq 100 * All values in input are integers. * The area of the triangl...
{ "input": [], "output": [] }
{ "input": [ "3 4 5", "45 28 53", "5 12 13" ], "output": [ "6", "630", "30" ] }
{ "input": [ "3 3 5", "45 38 53", "5 18 13", "0 3 5", "45 30 53", "5 24 13", "45 49 53", "5 13 13", "18 49 53", "1 10 1", "1 6 13", "18 97 37", "32 97 63", "1 2 7", "-1 1 0", "32 69 101", "-2 2 0", "32 49 100", "45 25 110", "75 25 110", ...
p03289 AtCoder Beginner Contest 104 - AcCepted
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions: * The initial character of S is an uppercase `A`. * There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (i...
{ "input": [], "output": [] }
{ "input": [ "AtCoCo", "Atcoder", "ACoder", "AcycliC", "AtCoder" ], "output": [ "WA", "WA", "WA", "WA", "AC" ] }
{ "input": [ "AtBoCo", "AtCoddr", "redoctA", "ACodes", "BcycliC", "etCodAr", "AtBnCo", "redpctA", "ACodds", "CilcycB", "@tBnCo", "retpcdA", "sddoCA", "BcyclhC", "AtCodds", "oCnBt@", "Adcpter", "sAdoCd", "BycclhC", "AtCoddt", "nCnBt@",...
p03445 AtCoder Petrozavodsk Contest 001 - Simple APSP Problem
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1). Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white. Let the shorte...
{ "input": [], "output": [] }
{ "input": [ "2 3\n1\n1 2", "3 3\n1\n1 1", "1000000 1000000\n1\n0 0", "4 4\n4\n0 1\n1 1\n2 1\n2 2", "2 3\n1\n1 1" ], "output": [ "16", "64", "333211937", "268", "20" ] }
{ "input": [ "2 3\n1\n0 1", "2 3\n1\n0 2", "1000000 1000000\n0\n0 0", "2 4\n1\n0 1", "2 4\n0\n0 1", "1000001 1000000\n0\n0 1", "4 4\n0\n0 1", "6 4\n0\n0 1", "11 4\n0\n0 1", "12 4\n0\n0 1", "21 4\n0\n0 2", "21 8\n0\n-1 2", "14 8\n0\n-1 2", "3 3\n1\n0 1", "4 3...
p03605 AtCoder Beginner Contest 073 - September 9
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? Constraints * 10≤N≤99 Input Input is given from Standard Input in the following format: N Output If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No...
{ "input": [], "output": [] }
{ "input": [ "29", "91", "72" ], "output": [ "Yes", "Yes", "No" ] }
{ "input": [ "1", "69", "115", "84", "0", "181", "168", "174", "304", "143", "465", "929", "109", "820", "147", "112", "19", "215", "34", "161", "8", "189", "15", "361", "17", "485", "16", "348", "3", ...
p03766 AtCoder Regular Contest 071 - Infinite Sequence
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions? * The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j. * For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j...
{ "input": [], "output": [] }
{ "input": [ "654321", "2" ], "output": [ "968545283", "4" ] }
{ "input": [ "53707", "3", "42179", "1", "69890", "4", "68941", "126548", "138065", "132361", "219101", "412635", "147547", "226036", "401978", "462799", "563821", "507124", "417069", "235764", "221196", "335918", "316839", ...
p03934 square869120Contest #3 - Sushi
Input The input is given from Standard Input in the following format: > $N \ Q$ $a_1 \ b_1$ $a_2 \ b_2$ $ : \ : $ $a_Q \ b_Q$ Output * You have to print $N$ lines. * The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$. Constraints * $3 \le N, Q \le 100,000$ *...
{ "input": [], "output": [] }
{ "input": [ "6 6\n3 5\n6 11\n1 6\n4 7\n5 2\n2 5", "9 3\n5 11\n8 4\n4 7", "5 6\n1 1\n2 1\n3 1\n1 1\n5 1\n3 1", "10 10\n10 10\n9 20\n8 30\n7 40\n6 50\n5 60\n4 70\n3 80\n2 90\n1 100" ], "output": [ "10\n10\n5\n5\n4\n2", "4\n4\n4\n4\n2\n2\n1\n1\n0", "2\n2\n1\n1\n0", "223\n123\n77\n50\...
{ "input": [ "10 6\n3 5\n6 11\n1 6\n4 7\n5 2\n2 5", "11 3\n5 11\n8 4\n4 7", "10 10\n10 10\n9 20\n8 30\n7 40\n6 50\n5 60\n4 70\n3 80\n2 137\n1 100", "10 6\n3 3\n6 11\n1 6\n4 7\n5 2\n2 5", "11 3\n3 11\n8 4\n4 7", "10 10\n10 10\n9 20\n8 30\n7 40\n6 50\n5 60\n4 70\n3 80\n2 105\n1 100", "10 6\n...
p00027 What day is today?
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29. Input The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset cons...
{ "input": [], "output": [] }
{ "input": [ "1 1\n2 29\n0 0" ], "output": [ "Thursday\nSunday" ] }
{ "input": [ "1 1\n2 26\n0 0", "2 1\n2 26\n0 0", "1 1\n3 26\n0 0", "2 1\n2 17\n0 0", "2 1\n2 18\n0 0", "2 1\n1 19\n0 0", "2 2\n2 17\n0 0", "2 2\n3 17\n0 0", "2 1\n1 17\n0 0", "2 1\n1 18\n0 0", "4 2\n3 17\n0 0", "2 2\n1 17\n0 0", "4 2\n6 17\n0 0", "4 1\n2 17\n0 0...
p00158 Collatz's Problem
For a positive integer n * If n is even, divide by 2. * If n is odd, multiply by 3 and add 1. If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also k...
{ "input": [], "output": [] }
{ "input": [ "3\n10\n0" ], "output": [ "7\n6" ] }
{ "input": [ "3\n15\n0", "3\n3\n0", "3\n11\n0", "3\n2\n0", "3\n9\n0", "3\n6\n0", "3\n1\n0", "3\n0\n0", "3\n18\n0", "3\n16\n0", "3\n4\n0", "3\n5\n0", "3\n17\n0", "3\n30\n0", "3\n22\n0", "3\n41\n0", "3\n59\n0", "3\n24\n0", "3\n7\n0", "3\n53...
p00315 Quality Management
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represent...
{ "input": [], "output": [] }
{ "input": [ "1 6\n000000\n000000\n010010\n010010\n000000\n000000", "7 8\n00100000\n00011000\n10111101\n01100110\n01000110\n10111101\n00011000\n00100100\n2\n5 3\n1 6\n1\n6 8\n3\n6 8\n3 3\n3 6\n2\n6 3\n6 6\n0\n2\n3 8\n6 8", "2 2\n00\n00\n4\n1 1\n1 2\n2 1\n2 2" ], "output": [ "1", "3", "2" ...
{ "input": [ "1 6\n000000\n000000\n010010\n011010\n000000\n000000", "1 2\n00\n00\n4\n1 1\n1 2\n2 1\n2 2", "2 0\n00\n00\n4\n1 1\n2 2\n2 1\n2 2", "7 8\n00100000\n00011000\n10111101\n01100110\n01000110\n10111101\n00011000\n00100100\n2\n5 3\n0 6\n1\n6 8\n3\n6 8\n3 3\n3 6\n2\n6 3\n6 6\n0\n2\n3 8\n6 8", ...
p00485 Shopping in JOI Kingdom
There are N towns in JOI, which are connected by M bidirectional roads. There are shopping malls in K towns, and the people go to one of those towns through the road to shop. Depending on the location of your home, you may have to travel long distances to go shopping, which is very inconvenient. To understand this sit...
{ "input": [], "output": [] }
{ "input": [ "3 3 1\n1 2 1\n2 3 1\n3 1 1\n1" ], "output": [ "2" ] }
{ "input": [ "4 3 1\n1 2 1\n2 3 1\n3 1 1\n1", "4 3 1\n1 2 1\n2 3 2\n1 1 1\n1", "4 3 1\n1 2 1\n2 3 1\n1 2 1\n2", "4 3 1\n1 2 1\n2 3 4\n1 1 1\n1", "8 3 1\n1 1 2\n2 3 4\n3 1 0\n1", "4 3 1\n1 2 2\n2 4 4\n1 1 1\n1", "4 3 1\n1 1 0\n1 3 0\n3 2 0\n1", "10 3 1\n1 2 5\n3 3 2\n3 1 1\n2", "4 3...
p00671 Live Schedule
YOKARI TAMURA is a nationally famous artist. This month YOKARI will be touring live for D days. Divide this country into C different regions when deciding on a tour schedule. YOKARI benefits from performing live in an area, which is represented by a positive integer. As a general rule, YOKARI will perform up to one liv...
{ "input": [], "output": [] }
{ "input": [ "5 5 10 2\n1 1 0 1 1\n0 9 1 0 1\n1 1 1 9 1\n1 1 9 0 1\n1 1 1 1 0\n1 1 0 1 1\n0 9 1 0 1\n1 1 1 9 1\n1 1 1 0 1\n1 1 1 1 0\n1 1 10 0\n3\n7\n1 1 5 0\n3\n6\n1 2 10 1\n6 7\n5 6\n2 1 10 1\n4\n8\n3\n7\n2 1 10 0\n4\n8\n3\n7\n2 1 5 0\n4\n8\n3\n6\n0 0 0 0" ], "output": [ "18\n3\n0\n7\n12\n8\n4" ] }
{ "input": [ "5 5 10 2\n1 1 0 1 0\n0 9 1 0 1\n1 1 1 9 1\n1 1 9 0 1\n1 1 1 1 0\n1 1 0 1 1\n0 9 1 0 1\n1 1 1 9 1\n1 1 1 0 1\n1 1 1 1 0\n1 1 10 0\n3\n7\n1 1 5 0\n3\n6\n1 2 10 1\n6 7\n5 6\n2 1 10 1\n4\n8\n3\n7\n2 1 10 0\n4\n8\n3\n7\n2 1 5 0\n4\n8\n3\n6\n0 0 0 0", "5 5 8 2\n1 1 0 1 0\n0 9 1 0 1\n1 1 1 9 1\n1 1 9 0...
p00814 Life Line
Let's play a new board game ``Life Line''. The number of the players is greater than 1 and less than 10. In this game, the board is a regular triangle in which many small regular triangles are arranged (See Figure l). The edges of each small triangle are of the same length. <image> Figure 1: The board The size of ...
{ "input": [], "output": [] }
{ "input": [ "4 4\n 2\n 2 3\n 1 0 4\n1 1 4 0\n4 5\n 2\n 2 3\n 3 0 4\n1 1 4 0\n4 1\n 2\n 2 3\n 3 0 4\n1 1 4 0\n4 1\n 1\n 1 1\n 1 1 1\n1 1 1 0\n4 2\n 1\n 1 1\n 1 1 1\n1 1 1 0\n4 1\n 0\n 2 2\n 5 0 7\n0 5 7 0\n4 2\n 0\n 0 3\n 1 0 4\n0 1 0 4\n4 3\n 0\n 3 3\n 3 2 3\n0 3 0 3\n4 2\n 0\n 3 3\n 3...
{ "input": [ "4 4\n2\n2 3\n1 0 4\n1 1 4 0\n4 5\n2\n2 3\n3 0 4\n1 1 4 0\n4 1\n2\n2 3\n3 0 4\n1 1 4 0\n4 1\n1\n1 1\n1 1 1\n1 1 1 0\n4 2\n1\n1 1\n1 1 1\n1 1 1 0\n4 1\n0\n2 2\n5 0 7\n0 5 7 0\n4 2\n0\n0 3\n1 0 4\n0 1 0 4\n4 3\n0\n3 3\n3 2 3\n0 3 0 3\n4 2\n0\n3 3\n3 2 3\n0 3 0 3\n6 1\n1\n0 2\n1 1 0\n6 7 6 8\n0 7 6 8 2\...
p00945 Min-Max Distance Game
Example Input 5 Alice 10 20 30 40 50 Output 30
{ "input": [], "output": [] }
{ "input": [ "5 Alice\n10 20 30 40 50" ], "output": [ "30" ] }
{ "input": [ "5 ecilA\n10 20 30 40 50", "5 ecilA\n0 19 30 40 50", "5 ecilA\n0 22 24 40 87", "5 ecilA\n0 22 24 43 87", "5 ecilA\n0 22 24 55 87", "5 ecilA\n0 22 24 86 87", "5 edilA\n0 22 15 86 115", "5 Alice\n10 20 12 40 50", "5 ecilA\n0 17 24 40 78", "5 Alice\n0 16 24 40 50", ...
p01078 Star
Problem Find the area of ​​a regular N / K polygon inscribed in a circle with a radius of 1. However, a regular N / K polygon is defined as "the outermost figure that takes N points on the circumference at equal intervals and connects each point every K-1". For example, a 5/2 polygon can be drawn as follows. First, ...
{ "input": [], "output": [] }
{ "input": [ "100000 3", "20 3", "7 3", "5 2" ], "output": [ "3.14159265", "2.93114293", "1.08395920", "1.12256994" ] }
{ "input": [ "100000 2", "36 3", "36 2", "100010 4", "000010 4", "001010 4", "100100 3", "33 3", "101000 2", "36 4", "001010 2", "001000 4", "110000 3", "6 3", "101000 3", "36 8", "001011 4", "001000 6", "36 15", "010010 3", "001010 7...
p01212 Mysterious Dungeons
The Kingdom of Aqua Canora Mystica is a very affluent and peaceful country, but around the kingdom, there are many evil monsters that kill people. So the king gave an order to you to kill the master monster. You came to the dungeon where the monster lived. The dungeon consists of a grid of square cells. You explored t...
{ "input": [], "output": [] }
{ "input": [ "8 3\n########\n#<A.@.a#\n########\n8 3\n########\n#<AaAa@#\n########\n8 4\n########\n#<EeEe@#\n#FG.e#.#\n########\n8 8\n########\n#mmm@ZZ#\n#mAAAbZ#\n#mABBBZ#\n#mABCCd#\n#aABCDD#\n#ZZcCD<#\n########\n0 0", "8 3\n\n<A.@.a#\n\n8 3\n\n<AaAa@#\n\n8 4\n\n<EeEe@#\nFG.e#.#\n\n8 8\n\nmmm@ZZ#\nmAAAbZ#\nm...
{ "input": [ "8 3\n\n<A.@.a#\n\n8 3\n\n#@aAaA<\n\n8 4\n\n<EeEe@#\nFG.e#.#\n\n8 8\n\nmmm@ZZ#\nmAAAbZ#\nmABBBZ#\nmABCCd#\naABCDD#\nZZcCD<#\n\n0 0", "8 3\n\n<A.@.a#\n\n8 3\n\nA@aAa#<\n\n8 4\n\n<EeEe@#\nFG.e#.#\n\n8 8\n\nmmm@ZZ#\nmAAAbZ#\nmABBBZ#\nmABCCd#\naABCDD#\nZZcCD<#\n\n0 0", "8 3\n\n<A.@.a#\n\n8 3\n\nA...
p01348 Cruel Bingo
Bingo is a party game played by many players and one game master. Each player is given a bingo card containing N2 different numbers in a N × N grid (typically N = 5). The master draws numbers from a lottery one by one during the game. Each time a number is drawn, a player marks a square with that number if it exists. T...
{ "input": [], "output": [] }
{ "input": [ "10 3\n0 0\n4 4\n1 4", "4 2\n2 3\n3 2", "4 2\n0 2\n3 1" ], "output": [ "1127", "6", "6" ] }
{ "input": [ "4 0\n2 3\n3 2", "3 0\n2 3\n3 2", "2 0\n2 2\n5 4", "10 3\n0 0\n4 8\n1 4", "6 2\n2 3\n3 2", "4 2\n0 3\n3 1", "11 2\n2 3\n3 2", "1 0\n0 2\n5 4", "11 2\n2 3\n3 1", "7 0\n0 3\n3 1", "6 0\n2 3\n5 4", "6 1\n2 5\n5 4", "4 2\n0 3\n3 0", "4 1\n2 3\n3 2", ...
p01530 XOR Cloister
Problem statement An unusual rally game is popular at KU University. The circuit, which is the setting of this game, has N rest areas and M roads, and the i-th road is between the fi-th rest area and the ti-th rest area. There is one checkpoint on every road, and if you pass the checkpoint on road i, the score of pi w...
{ "input": [], "output": [] }
{ "input": [ "5 5 3\n0 1 7\n1 2 22\n2 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4" ], "output": [ "135\n128\n128" ] }
{ "input": [ "5 5 3\n0 1 7\n1 2 22\n1 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4", "5 5 3\n0 1 7\n1 2 25\n1 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4", "5 5 3\n0 1 7\n1 2 22\n0 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4", "5 5 3\n0 1 7\n1 2 33\n0 3 128\n3 4 128\n4 2 128\n0 1\n0 0\n3 4", "5 5 3\n0 1 0\n1 2 33...
p01686 Magical Switches
Problem Statement You are given a rectangular board divided into square cells. The number of rows and columns in this board are $3$ and $3 M + 1$, respectively, where $M$ is a positive integer. The rows are numbered $1$ through $3$ from top to bottom, and the columns are numbered $1$ through $3 M + 1$ from left to rig...
{ "input": [], "output": [] }
{ "input": [ "3\n.aa.cA.Cc.\n.bb.Bb.AC.\n.cc.ac.Ab.\n1\n.Xx.\n.Yy.\n.Zz.\n6\n.Aj.fA.aW.zA.Jf.Gz.\n.gW.GW.Fw.ZJ.AG.JW.\n.bZ.jZ.Ga.Fj.gF.Za.\n9\n.ab.gh.mn.st.yz.EF.KL.QR.WA.\n.cd.ij.op.uv.AB.GH.MN.ST.XB.\n.ef.kl.qr.wx.CD.IJ.OP.UV.yz.\n2\n.AC.Mo.\n.IC.PC.\n.oA.CM.\n20\n.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.Q...
{ "input": [ "3\n.aa.cA.Cc.\n.bb.Bb.AC.\n.cc.ad.Ab.\n1\n.Xx.\n.Yy.\n.Zz.\n6\n.Aj.fA.aW.zA.Jf.Gz.\n.gW.GW.Fw.ZJ.AG.JW.\n.bZ.jZ.Ga.Fj.gF.Za.\n9\n.ab.gh.mn.st.yz.EF.KL.QR.WA.\n.cd.ij.op.uv.AB.GH.MN.ST.XB.\n.ef.kl.qr.wx.CD.IJ.OP.UV.yz.\n2\n.AC.Mo.\n.IC.PC.\n.oA.CM.\n20\n.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.QB.Q...
p01830 Delete Files
Example Input 3 y 7 y 6 n 5 Output 1
{ "input": [], "output": [] }
{ "input": [ "3\ny 7\ny 6\nn 5" ], "output": [ "1" ] }
{ "input": [ "3\ny 7\ny 2\nn 5", "3\ny 7\ny 3\nn 5", "3\ny 7\ny 3\nn 10", "3\ny 2\ny 3\nn 10", "3\ny 2\ny 6\nn 10", "3\nx 2\ny 6\nn 10", "3\ny 7\ny 11\nn 5", "3\ny 8\ny 2\nn 5", "3\ny 7\ny 6\nn 2", "3\ny 0\ny 3\nn 10", "3\ny 4\ny 3\nn 10", "3\ny 2\ny 6\nn 14", "3\ny...
p01965 Farm Village
There is a village along a road. This village has $N$ houses numbered $1$ to $N$ in order along the road. Each house has a field that can make up to two units of the crop and needs just one unit of the crop. The total cost to distribute one unit of the crop to each house is the summation of carrying costs and growing c...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n1 5", "3\n100 100\n1 2 3", "4\n1 2 3\n1 1 100 100" ], "output": [ "5", "6", "12" ] }
{ "input": [], "output": [] }
p02112 Hating Crowd
Problem Neat lives on the world line for a total of 360 days until the 30th of every month for 1 year and 12 months. In that world, N consecutive holidays with the same schedule were applied to people all over the world every year. Consecutive holidays i are consecutive Vi days starting from Mi month Di day. NEET is ...
{ "input": [], "output": [] }
{ "input": [ "1\n1 1 359 1", "2\n2 4 25 306\n1 9 7 321", "8\n2 9 297 297\n8 6 359 211\n8 16 28 288\n7 9 113 143\n3 18 315 190\n10 18 277 300\n9 5 276 88\n3 5 322 40" ], "output": [ "0", "158", "297" ] }
{ "input": [ "1\n1 1 1 1", "2\n2 4 25 104\n1 9 7 321", "2\n2 4 25 28\n1 9 13 321", "2\n2 4 4 51\n1 4 13 252", "2\n3 4 4 51\n2 4 13 335", "2\n3 4 4 51\n2 4 13 360", "2\n2 4 24 306\n1 9 7 321", "8\n2 9 297 297\n8 6 359 211\n8 16 28 233\n7 9 113 143\n3 18 315 190\n10 18 277 300\n9 5 276 8...
p02252 Fractional Knapsack Problem
You have $N$ items that you want to put them into a knapsack of capacity $W$. Item $i$ ($1 \le i \le N$) has weight $w_i$ and value $v_i$ for the weight. When you put some items into the knapsack, the following conditions must be satisfied: * The total value of the items is as large as possible. * The total weight of...
{ "input": [], "output": [] }
{ "input": [ "1 100\n100000 100000", "3 50\n60 10\n100 20\n120 30", "3 50\n60 13\n100 23\n120 33" ], "output": [ "100", "240", "210.90909091" ] }
{ "input": [ "3 50\n60 10\n110 20\n120 30", "0 50\n60 10\n110 20\n120 30", "3 14\n60 10\n100 20\n120 30", "1 50\n60 13\n100 23\n120 33", "3 50\n59 10\n110 20\n120 30", "1 100\n100001 100000", "3 8\n60 10\n100 20\n120 30", "3 50\n59 10\n010 20\n120 30", "1 38\n118 1\n010 20\n26 20",...
p02400 Circle
Write a program which calculates the area and circumference of a circle for given radius r. Constraints * 0 < r < 10000 Input A real number r is given. Output Print the area and circumference of the circle in a line. Put a single space between them. The output should not contain an absolute error greater than 10-...
{ "input": [], "output": [] }
{ "input": [ "2", "3" ], "output": [ "12.566371 12.566371", "28.274334 18.849556" ] }
{ "input": [ "4", "0", "5", "1", "6", "-1", "10", "-2", "7", "-4", "11", "-3", "17", "-5", "13", "-10", "21", "-13", "34", "-22", "39", "-8", "74", "8", "76", "-7", "149", "-6", "12", "-11", "24...
absnum
In mathematics, the absolute value (or modulus) |a| of a real number a is the numerical value of a without regard to its sign. So, for example, the absolute value of 3 is 3, and the absolute value of -3 is also 3. The absolute value of a number may be thought of as its distance from zero. Input There is a single pos...
{ "input": [], "output": [] }
{ "input": [ "4\n-9\n-4\n6\n-1" ], "output": [ "9\n4\n6\n1\n" ] }
{ "input": [ "4\n0\n-4\n6\n-1", "4\n0\n-4\n9\n-1", "4\n0\n-4\n4\n-1", "4\n-1\n-4\n4\n-1", "4\n-1\n-4\n3\n-1", "4\n-1\n-8\n3\n-1", "4\n-2\n-8\n3\n-1", "4\n-2\n-9\n3\n-1", "4\n-2\n-6\n3\n-1", "4\n0\n-6\n3\n-1", "4\n0\n-6\n2\n-1", "4\n-1\n-6\n3\n-1", "4\n-1\n-7\n3\n-1"...
chefmath
Chef's team is going to participate at the legendary math battles. One of the main task in the competition is to calculate the number of ways to create a number by adding some Chefonacci numbers. A number is called a Chefonacci number if it is an element of Chefonacci sequence defined as follows. f(0) = 1; f(1) = 2;...
{ "input": [], "output": [] }
{ "input": [ "5\n12 1\n13 1\n13 2\n13 3\n13 4" ], "output": [ "0\n1\n1\n2\n4" ] }
{ "input": [ "5\n12 1\n13 1\n13 3\n13 3\n13 4", "5\n12 1\n13 1\n13 1\n13 3\n13 4", "5\n12 1\n13 1\n6 1\n13 3\n13 4", "5\n12 1\n13 1\n6 1\n13 0\n13 4", "5\n12 1\n13 1\n6 1\n13 0\n13 7", "5\n0 1\n13 1\n6 0\n13 0\n13 2", "5\n0 1\n13 1\n3 0\n13 0\n13 0", "5\n0 1\n13 2\n3 1\n13 0\n13 0", ...
divsubs
You are given a multiset of N integers. Please find such a nonempty subset of it that the sum of the subset's elements is divisible by N. Otherwise, state that this subset doesn't exist. Input The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows....
{ "input": [], "output": [] }
{ "input": [ "1\n3\n4 6 10" ], "output": [ "1\n2" ] }
{ "input": [ "1\n3\n4 6 16", "1\n3\n4 11 3", "1\n3\n2 11 3", "1\n3\n0 6 10", "1\n3\n4 4 4", "1\n3\n2 5 1", "1\n3\n4 6 4", "1\n3\n4 6 0", "1\n3\n4 6 3", "1\n6\n4 6 16", "1\n3\n2 2 3", "1\n3\n4 4 0", "1\n3\n7 6 3", "1\n3\n4 22 3", "1\n3\n1 11 3", "1\n3\n2 ...
isd
Ilya lives in the beautiful city of Bytes lying in a hilly terrain. She loves to ride her bicycle on the hills whenever she gets a chance to do so. There are check-posts located on the hill at a unit distance from each other. The height of the check posts is given in an array A. Ilya has to visit her aunt who lives N ...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n1 3 2\n5\n1 2 3 4 5" ], "output": [ "1 \n0" ] }
{ "input": [], "output": [] }
nocoding
Coding in Sprout (a programming language) is very intuitive. Chef is giving his minions a demonstration in Sprout and wants you to help him determine if they are not too difficult for them. A program in Sprout is written using three kinds of instructions. Load Instruction: Load a value into buffer. Increment Instr...
{ "input": [], "output": [] }
{ "input": [ "2\nhelloworld\nmississippi" ], "output": [ "NO\nYES\n" ] }
{ "input": [ "2\ndlrowolleh\nmississippi", "2\nielmoworld\nmississippi", "2\nielomworld\nmisrissippi", "2\njeopmujlrd\nhqhspsrhlpj", "2\ndlrowomleh\nmississippi", "2\ndlrowomleh\nippississim", "2\ndlrowomlei\nmississippi", "2\nielomworld\nmississippi", "2\nielomworld\nmisrisshppi",...
seatstr2
Sereja has a string A consisting of n lower case English letters. Sereja calls two strings X and Y each of length n similar if they can be made equal by applying the following operation at most once in each of them. Chose any two position i, j in the string (i can be equal to j too). Swap the characters at position ...
{ "input": [], "output": [] }
{ "input": [ "2\nz\nabcd" ], "output": [ "0\n144" ] }
{ "input": [], "output": [] }
1343_E. Weights Distributing
You are given an undirected unweighted graph consisting of n vertices and m edges (which represents the map of Bertown) and the array of prices p of length m. It is guaranteed that there is a path between each pair of vertices (districts). Mike has planned a trip from the vertex (district) a to the vertex (district) b...
{ "input": [], "output": [] }
{ "input": [ "2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 7\n6 7\n" ], "output": [ "7\n12\n" ] }
{ "input": [ "2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 4\n6 7\n", "2\n4 3 2 3 4\n2 2 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 4\n6 7\n", "2\n4 3 2 3 4\n1 2 3\n1 2\n1 3\n1 4\n7 9 1 3 7\n2 10 4 8 5 6 ...
1385_F. Removing Leaves
You are given a tree (connected graph without cycles) consisting of n vertices. The tree is unrooted — it is just a connected undirected graph without cycles. In one move, you can choose exactly k leaves (leaf is such a vertex that is connected to only one another vertex) connected to the same vertex and remove them w...
{ "input": [], "output": [] }
{ "input": [ "4\n8 3\n1 2\n1 5\n7 6\n6 8\n3 1\n6 4\n6 1\n10 3\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\n4 5\n3 6\n7 4\n1 2\n1 4\n5 1\n1 2\n2 3\n4 3\n5 3\n" ], "output": [ "2\n3\n3\n4\n" ] }
{ "input": [ "4\n8 3\n1 2\n1 5\n7 6\n6 8\n3 1\n6 4\n6 1\n10 3\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\n2 5\n3 6\n7 4\n1 2\n1 4\n5 1\n1 2\n2 3\n4 3\n5 3\n", "4\n8 3\n1 2\n1 5\n7 6\n6 8\n3 1\n6 4\n6 1\n10 3\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\n4 5\n3 6\n7 4\n1 2\n1 4\n5...
1451_B. Non-Substring Subsequence
Hr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'. A query is described by a pair of integers l_i, r_i (1 ≤ l_i < r_i ≤ n). For each query, he has to determine whether there exists a good subsequence in s that is equal to the substring s[l_i… r_...
{ "input": [], "output": [] }
{ "input": [ "2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n2 3\n" ], "output": [ "\nYES\nNO\nYES\nNO\nYES\n" ] }
{ "input": [ "2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n1 3\n", "2\n6 3\n001000\n2 5\n1 3\n3 5\n4 2\n1111\n1 4\n1 3\n", "2\n6 3\n001000\n2 5\n1 3\n3 5\n4 2\n1011\n1 4\n1 3\n", "2\n6 3\n001000\n2 5\n1 3\n3 4\n4 2\n1011\n1 4\n1 3\n", "2\n6 3\n001000\n4 5\n1 3\n3 5\n4 2\n1011\n1 4\n1 3\n", "...
342_E. Xenia and Tree
Xenia the programmer has a tree consisting of n nodes. We will consider the tree nodes indexed from 1 to n. We will also consider the first node to be initially painted red, and the other nodes — to be painted blue. The distance between two tree nodes v and u is the number of edges in the shortest path between v and u...
{ "input": [], "output": [] }
{ "input": [ "5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n2 5\n1 2\n2 5\n" ], "output": [ "0\n3\n2\n" ] }
{ "input": [ "5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n2 5\n1 2\n2 1\n", "5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n2 1\n1 2\n2 1\n", "5 4\n1 2\n2 3\n2 4\n1 5\n2 1\n2 5\n1 2\n2 5\n", "5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n1 5\n1 2\n2 1\n", "5 4\n1 2\n2 3\n2 4\n1 5\n2 2\n2 5\n1 2\n2 5\n", "5 4\n1 2\n2 3\n1 4\n4 5\n2 1\n2 5\n...
530_A. Quadratic equation
You are given a quadratic equation with integer coefficients A * X2 + B * X + C = 0. It is guaranteed that A ≠ 0 and that the equation has at least one real root. Output the roots of the equation. Input The only line of input contains integers A, B and C ( - 1000 ≤ A, B, C ≤ 1000, A ≠ 0), separated by spaces. Output...
{ "input": [], "output": [] }
{ "input": [ "1 -2 1\n", "1 0 -1\n", "2 -3 1\n" ], "output": [ "1\n", "-1 1\n", "0.5 1\n" ] }
{ "input": [], "output": [] }
64_I. Sort the Table
You are given a rectangular table containing words. Each of its columns has its own name. You are also given the list of rules of sorting in form "FIELD_NAME SORT_ORDER", where SORT_ORDER is either ASC (nondescending order) or DESC (nonascending order). Rules in the list are separated by a single comma with a single sp...
{ "input": [], "output": [] }
{ "input": [ "NAME GROUP AGE\nGROUP ASC, AGE DESC\nAlex 412 19\nPeter 422 19\nSergey 412 18\nAndrey 311 18\n" ], "output": [ "Andrey 311 18\nAlex 412 19\nSergey 412 18\nPeter 422 19\n" ] }
{ "input": [], "output": [] }
containers-of-choclates-1
In Ninja World, World War is going on.. The Raikage Army and Zetsu Army are fighting each other. The war has become so fierce that, no one knows who will win. The ninjas of Leaf Village want to know who will survive finally. But leaf village ninjas are afraid of going to the battlefield. So, they made a plan. They col...
{ "input": [], "output": [] }
{ "input": [ "4\n4\n1 2\n2 3\n2 4\n2 5\n6\n2 6\n1 5\n3 4\n7 9\n5 8\n4 10\n1\n100 200\n4\n1 2\n2 3\n3 4\n4 5\n\nSAMPLE" ], "output": [ "Case 1: 4\nCase 2: 6\nCase 3: 1\nCase 4: 3" ] }
{ "input": [], "output": [] }
find-product
You have been given an array A of size N consisting of positive integers. You need to find and print the product of all the number in this array Modulo 10^9+7. Input Format: The first line contains a single integer N denoting the size of the array. The next line contains N space separated integers denoting the eleme...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5\n\nSAMPLE" ], "output": [ "120\n" ] }
{ "input": [ "5\n1 2 3 3 5\n\nSAMPLE", "5\n1 2 3 3 8\n\nSAMPLE", "5\n1 2 3 2 5\n\nELPMAS", "5\n2 2 3 3 8\n\nSAMPLE", "5\n1 2 3 2 6\n\nELPMAS", "5\n2 2 3 4 8\n\nSAMPLE", "5\n4 2 3 4 8\n\nSAMPLE", "5\n4 2 6 4 8\n\nSAMPLE", "5\n4 4 3 2 6\n\nELPMAS", "5\n6 4 3 2 6\n\nELPMAS", "...
independence-day-main-war
We always knew they were coming back. Species on Earth always had faced the problems came from outer space. We call them Alien , but for them they are travellers, who want to expand their territory. When we had defeated them years back and sent them back to their World , still with a hope and with new advanced weapon...
{ "input": [], "output": [] }
{ "input": [ "1\n10\n4.44 -7.32\n10.78 4.08\n3.69 -2.35\n-2.75 0.68\n-5.14 -0.77\n4.31 0.77\n-9.51 -7.57\n-4.22 8.92\n8.70 6.99\n-7.23 9.58\n\nSAMPLE" ], "output": [ "(0.31 , 1.30)\n" ] }
{ "input": [ "1\n10\n4.44 -7.32\n10.78 4.08\n3.69 -2.35\n-2.75 0.68\n-5.14 -0.77\n4.31 0.77\n-9.51 -7.57\n-4.22 8.92\n9.251041859002118 6.99\n-7.23 9.58\n\nSAMPLE", "1\n10\n4.44 -7.32\n10.78 4.08\n3.69 -2.35\n-2.75 0.68\n-5.14 -0.77\n4.31 0.77\n-8.700922535897872 -7.57\n-4.22 8.92\n9.251041859002118 6.99\n-7....
p02546 AtCoder Beginner Contest 179 - Plural Form
In the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters. In Taknese, the plural form of a noun is spelled based on the following rules: * If a noun's singular form does not end with `s`, append `s` to the end of the singular form. * If a noun's singular form ends with `s`...
{ "input": [], "output": [] }
{ "input": [ "box", "bus", "apple" ], "output": [ "boxs", "buses", "apples" ] }
{ "input": [ "aox", "bsu", "aeplp", "xoa", "bsv", "eaplp", "xo`", "csv", "daplp", "xp`", "crv", "d`plp", "px`", "vrc", "c`plp", "xn`", "vsc", "c_plp", "`nx", "urc", "plp_c", "`mx", "usc", "c_plq", "xm`", "utc", ...
p02677 AtCoder Beginner Contest 168 - : (Colon)
Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively. An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to ...
{ "input": [], "output": [] }
{ "input": [ "3 4 9 0", "3 4 10 40" ], "output": [ "5.00000000000000000000", "4.56425719433005567605" ] }
{ "input": [ "3 4 13 0", "3 1 10 40", "3 4 17 0", "3 1 10 59", "6 4 17 0", "3 2 10 59", "9 4 17 0", "3 2 10 89", "9 4 21 0", "3 2 1 89", "9 4 21 1", "3 3 1 89", "5 4 21 1", "3 6 1 89", "5 4 16 1", "3 6 1 158", "5 4 8 1", "1 6 1 158", "2 4 8 1...
p02805 AtCoder Beginner Contest 151 - Enclose All
Given are N points (x_i, y_i) in a two-dimensional plane. Find the minimum radius of a circle such that all the points are inside or on it. Constraints * 2 \leq N \leq 50 * 0 \leq x_i \leq 1000 * 0 \leq y_i \leq 1000 * The given N points are all different. * The values in input are all integers. Input Input is giv...
{ "input": [], "output": [] }
{ "input": [ "3\n0 0\n0 1\n1 0", "2\n0 0\n1 0", "10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9" ], "output": [ "0.707106781186497524", "0.500000000000000000", "6.726812023536805158" ] }
{ "input": [ "3\n0 0\n1 1\n1 0", "10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n5 7\n1 9", "2\n0 1\n2 0", "2\n0 2\n2 0", "3\n0 1\n0 1\n3 0", "3\n0 1\n0 2\n3 0", "2\n-1 2\n2 2", "2\n-1 2\n4 4", "2\n-1 2\n7 4", "3\n0 1\n0 0\n6 0", "2\n-1 2\n7 3", "3\n1 1\n0 0\n6 0", "...
p02941 AtCoder Grand Contest 037 - Numbers on a Circle
There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. ...
{ "input": [], "output": [] }
{ "input": [ "5\n5 6 5 2 1\n9817 1108 6890 4343 8704", "4\n1 2 3 4\n2 3 4 5", "3\n1 1 1\n13 5 7" ], "output": [ "25", "-1", "4" ] }
{ "input": [ "5\n5 6 5 2 1\n9053 1108 6890 4343 8704", "3\n1 1 1\n13 1 7", "4\n0 2 3 4\n2 3 4 5", "3\n2 1 1\n13 5 7", "5\n5 6 5 2 1\n9053 1108 6890 4343 13928", "4\n0 2 3 4\n2 2 4 5", "3\n2 1 1\n13 1 7", "5\n5 6 5 2 1\n9053 1108 6890 4343 12481", "4\n0 2 3 4\n2 0 4 5", "3\n2 1 ...
p03078 AtCoder Beginner Contest 123 - Cake 123
The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousn...
{ "input": [], "output": [] }
{ "input": [ "2 2 2 8\n4 6\n1 5\n3 8", "10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 76902...
{ "input": [ "2 2 2 1\n4 6\n1 5\n3 8", "10 10 10 20\n7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488\n1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338\n4975681328 8974383988 2882263257 64265...
p03221 AtCoder Beginner Contest 113 - ID
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each ci...
{ "input": [], "output": [] }
{ "input": [ "2 3\n1 32\n2 63\n1 12", "2 3\n2 55\n2 77\n2 99" ], "output": [ "000001000002\n000002000001\n000001000001", "000002000001\n000002000002\n000002000003" ] }
{ "input": [ "2 3\n1 55\n2 77\n2 99", "2 3\n2 32\n2 63\n1 12", "2 1\n2 55\n2 77\n2 99", "2 2\n2 55\n2 77\n2 99", "2 3\n2 55\n2 77\n2 195", "2 3\n1 32\n2 63\n1 6", "2 3\n2 39\n2 16\n1 12", "2 2\n2 55\n2 29\n2 195", "2 3\n2 96\n2 77\n2 195", "2 1\n1 16\n2 77\n2 195", "2 3\n1 ...
p03369 AtCoder Beginner Contest 095 - Something on It
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is ...
{ "input": [], "output": [] }
{ "input": [ "oxo", "xxx", "ooo" ], "output": [ "900", "700", "1000" ] }
{ "input": [ "pxo", "yxx", "opo", "oxp", "xyx", "opn", "xpo", "xzx", "npo", "opx", "yzx", "npn", "xpn", "xzy", "mpn", "npx", "wzy", "mpm", "nxp", "zwy", "npm", "mxp", "ywz", "nmp", "nxo", "yzw", "nnp", "xno...
p03531 CODE FESTIVAL 2017 Final - Full Tournament
2^N players competed in a tournament. Each player has a unique ID number from 1 through 2^N. When two players play a match, the player with the smaller ID always wins. This tournament was a little special, in which losers are not eliminated to fully rank all the players. We will call such a tournament that involves 2...
{ "input": [], "output": [] }
{ "input": [ "1\n2 1", "3\n0 3 0 6 0 0 0 8" ], "output": [ "NO", "YES\n3 4 8 6 2 1 7 5" ] }
{ "input": [ "1\n2 0", "1\n1 0", "3\n0 3 0 6 0 0 0 5", "1\n3 0", "3\n1 3 0 6 0 0 0 5", "1\n3 1", "3\n1 0 0 6 0 0 0 5", "1\n0 1", "3\n1 0 0 6 -1 0 0 5", "1\n1 1", "3\n1 0 1 6 -1 0 0 5", "3\n1 0 1 6 -2 0 0 5", "1\n0 0", "3\n1 0 0 6 -2 0 0 5", "3\n1 0 0 12 -1 0...
p03692 AtCoder Grand Contest 016 - Games on DAG
There is a directed graph G with N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i is directed from x_i to y_i. Here, x_i < y_i holds. Also, there are no multiple edges in G. Consider selecting a subset of the set of the M edges in G, and removing these edges...
{ "input": [], "output": [] }
{ "input": [ "4 2\n1 3\n2 4", "5 10\n2 4\n3 4\n2 5\n2 3\n1 2\n3 5\n1 3\n1 5\n4 5\n1 4", "3 3\n1 2\n1 3\n2 3", "2 1\n1 2" ], "output": [ "2", "816", "6", "1" ] }
{ "input": [ "4 2\n2 3\n2 4", "2 0\n1 2", "1 0\n1 2", "4 2\n1 4\n2 4", "4 0\n2 3\n2 4", "4 0\n2 3\n3 4", "1 0\n2 2", "4 0\n2 1\n3 4", "7 0\n2 1\n3 4", "7 0\n4 1\n3 4", "7 0\n4 0\n3 4", "7 0\n4 0\n3 6", "8 0\n4 0\n3 6", "3 0\n1 2", "4 0\n4 3\n2 4", "1 0\n...
p03845 AtCoder Beginner Contest 050 - Contest with Drinks Easy
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes d...
{ "input": [], "output": [] }
{ "input": [ "3\n2 1 4\n2\n1 1\n2 3", "5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13" ], "output": [ "6\n9", "19\n25\n30" ] }
{ "input": [ "3\n2 1 4\n2\n1 1\n0 3", "5\n7 2 3 10 5\n3\n4 2\n1 7\n4 13", "3\n2 1 4\n2\n1 1\n0 6", "5\n7 4 3 10 5\n3\n4 2\n1 7\n4 13", "3\n2 1 4\n2\n1 0\n2 3", "3\n2 1 4\n2\n1 0\n0 3", "5\n7 2 3 10 5\n3\n4 2\n1 7\n4 20", "3\n1 1 4\n2\n1 1\n0 6", "5\n7 4 3 10 5\n3\n4 2\n1 7\n3 13", ...
p04012 AtCoder Beginner Contest 044 - Beautiful Strings
Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercas...
{ "input": [], "output": [] }
{ "input": [ "abaccaba", "hthth" ], "output": [ "Yes", "No" ] }
{ "input": [ "ab`ccaba", "ab`cc`ba", "hthtg", "hghtt", "`b`cc`ba", "hgtth", "ab`cc`b`", "hgtuh", "`b`cc`ca", "hgsth", "`b_cc`ca", "hfsth", "`b_dc`ca", "hfsti", "`b_dc`da", "hgsti", "ad`cd_b`", "hgssi", "ad`cd_a`", "issgh", "`a_dc`da",...
p00098 Maximum Sum Sequence II
Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a...
{ "input": [], "output": [] }
{ "input": [ "3\n1 -2 3\n-4 5 6\n7 8 -9", "4\n1 3 -9 2\n2 7 -1 5\n-8 3 2 -1\n5 0 -3 1" ], "output": [ "16", "15" ] }
{ "input": [ "3\n1 -2 3\n-1 5 6\n7 8 -9", "4\n1 3 -9 2\n2 7 -1 5\n-8 3 2 -1\n5 -1 -3 1", "3\n1 -2 3\n-1 5 6\n6 8 -15", "4\n1 3 -9 0\n2 7 -1 5\n-8 3 2 -2\n3 -1 -3 1", "3\n1 -2 5\n-1 3 1\n6 8 -25", "4\n1 3 -9 0\n2 7 -1 5\n-8 3 0 -2\n3 0 -5 1", "3\n2 -4 5\n-1 3 1\n4 11 -43", "3\n3 -4 5\n-...
p00230 Ninja Climbing
Ninja Atsushi guards the town from the roof of the Ninja Building from early morning to late night every day. This Ninja Building is two adjacent buildings of the same floor, and Atsushi's daily routine is to jump between buildings and head to the rooftop for security. Because these two buildings are cleaned frequentl...
{ "input": [], "output": [] }
{ "input": [ "8\n0 0 0 2 2 2 0 0\n1 1 1 1 0 0 0 0\n4\n1 1 2 2\n0 0 2 2\n0" ], "output": [ "4\nNA" ] }
{ "input": [ "8\n0 0 0 2 2 2 0 0\n1 1 1 1 1 0 0 0\n4\n1 1 2 2\n0 0 2 2\n0", "8\n0 0 0 2 2 2 0 0\n1 1 1 1 1 0 0 0\n2\n1 1 2 2\n0 0 2 2\n0", "8\n0 0 0 2 2 2 0 0\n0 1 1 1 1 0 0 0\n2\n1 1 2 2\n0 0 2 2\n0", "8\n0 0 0 2 2 2 0 1\n1 1 1 1 0 0 0 0\n4\n1 1 2 2\n0 0 2 2\n0", "8\n0 0 0 2 2 2 0 0\n1 1 2 1 1 0 ...
p00392 Common-Prime Sort
You are now examining a unique method to sort a sequence of numbers in increasing order. The method only allows swapping of two numbers that have a common prime factor. For example, a sequence [6, 4, 2, 3, 7] can be sorted using the following steps. Step 0: 6 4 2 3 7 (given sequence) Step 1: 2 4 6 3 7 (elements 6 and 2...
{ "input": [], "output": [] }
{ "input": [ "5\n6 4 2 3 7", "7\n2 9 6 5 6 7 3" ], "output": [ "1", "0" ] }
{ "input": [ "5\n6 2 2 3 7", "5\n6 1 2 2 14", "5\n6 2 2 2 7", "5\n6 2 2 2 14", "5\n6 1 2 2 18", "5\n5 1 2 2 18", "5\n6 4 2 3 11", "7\n2 9 6 5 6 7 5", "5\n10 4 2 3 7", "5\n10 2 2 2 7", "5\n6 2 2 2 1", "5\n3 1 2 2 14", "5\n6 1 4 2 18", "5\n5 1 2 3 18", "7\n4 9...
p00608 Indian Puzzle
In the Indian Puzzle, one is intended to fill out blanks with numbers and operators in a n by n grid in order to make equalities in the grid true (See Figure 1). <image> Figure 1 A blank cell should be filled out with a number (from 0 to 9 inclusive) or an operator (+, -, ×, ÷, =), and black cells split equaliti...
{ "input": [], "output": [] }
{ "input": [ "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 3 1 4 / 8\n1 6\n8..3=2\n2\n2 +\n0 0" ], "output": [ "Yes\nNo" ] }
{ "input": [ "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 0 1 4 / 8\n1 6\n8..3=2\n2\n2 +\n0 0", "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 3 1 4 / 8\n1 6\n8..3=2\n2\n4 +\n0 0", "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 0 1 4 0 8\n1 6\n8..3=2\n2\n2 +\n0 0", "5 3\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-....
p00745 Tighten Up!
We have a flat panel with two holes. Pins are nailed on its surface. From the back of the panel, a string comes out through one of the holes to the surface. The string is then laid on the surface in a form of a polygonal chain, and goes out to the panel's back through the other hole. Initially, the string does not touc...
{ "input": [], "output": [] }
{ "input": [ "6 16\n5 4\n11 988\n474 975\n459 16\n985 12\n984 982\n242 227\n140 266\n45 410\n92 570\n237 644\n370 567\n406 424\n336 290\n756 220\n634 251\n511 404\n575 554\n726 643\n868 571\n907 403\n845 283\n10 4\n261 196\n943 289\n859 925\n56 822\n112 383\n514 0\n1000 457\n514 1000\n0 485\n233 224\n710 242\n850...
{ "input": [ "6 16\n5 4\n11 988\n474 975\n459 16\n985 12\n984 982\n242 227\n140 266\n45 410\n92 570\n237 644\n370 567\n406 424\n336 290\n756 220\n634 251\n511 404\n575 554\n726 643\n868 571\n907 403\n845 283\n10 4\n261 196\n943 289\n859 925\n56 822\n112 383\n90 0\n1000 457\n514 1000\n0 485\n233 224\n710 242\n850 ...
p00884 Membership Management
Peter is a senior manager of Agile Change Management (ACM) Inc., where each employee is a member of one or more task groups. Since ACM is agile, task groups are often reorganized and their members frequently change, so membership management is his constant headache. Peter updates the membership information whenever an...
{ "input": [], "output": [] }
{ "input": [ "2\ndevelopment:alice,bob,design,eve.\ndesign:carol,alice.\n3\none:another.\nanother:yetanother.\nyetanother:dave.\n3\nfriends:alice,bob,bestfriends,carol,fran,badcompany.\nbestfriends:eve,alice.\nbadcompany:dave,carol.\n5\na:b,c,d,e.\nb:c,d,e,f.\nc:d,e,f,g.\nd:e,f,g,h.\ne:f,g,h,i.\n4\naa:bb.\ncc:dd,...
{ "input": [ "2\ndevelopment:alice,bob,design,eve.\ndesign:carol,alice.\n3\none:another.\nanother:yetanother.\nxetanother:dave.\n3\nfriends:alice,bob,bestfriends,carol,fran,badcompany.\nbestfriends:eve,alice.\nbadcompany:dave,carol.\n5\na:b,c,d,e.\nb:c,d,e,f.\nc:d,e,f,g.\nd:e,f,g,h.\ne:f,g,h,i.\n4\naa:bb.\ncc:dd,...
p01015 J's Final Problem
Problem A mysterious dungeon is a dungeon that involves structural changes. There are various mysterious dungeons, from deep to shallow, where evil monsters live and treasures sleep. Jay is a researcher studying a mysterious dungeon. One day, when I was digging a new dungeon, it led to a very large and deep dungeon. J...
{ "input": [], "output": [] }
{ "input": [ "10 2\n9 left : 9 left\n9 right : 9 right", "4 5\n1 left : 2 right\n2 left : 3 right\n2 left : 3 left\n1 right : 3 left\n2 right : 3 right" ], "output": [ "9", "3" ] }
{ "input": [ "10 2\n8 left : 9 left\n9 right : 9 right", "3 5\n1 left : 2 right\n2 left : 3 right\n2 left : 3 left\n1 right : 3 left\n2 right : 3 right", "4 5\n1 left : 2 right\n2 left : 3 right\n4 left : 3 left\n1 right : 3 left\n2 right : 3 right", "6 0\n0 left ; 1 rjght\n2 left : 3 right\n2 tfel : ...
p01148 Princess
Princess, a Strategist Princess is a strategist English text is not available in this practice contest. A brave princess in a poor country is on an adventure to escape the castle and obtain ancient treasures. However, the area around the ancient treasure is protected by multiple guardians and cannot be reached in th...
{ "input": [], "output": [] }
{ "input": [ "4 1 1\n1 1\n1 2\n-1 2\n-1 1\n2 1 0\n0 1 0 1 2\n0 0 0" ], "output": [ "1\n1.000" ] }
{ "input": [ "4 1 1\n1 1\n1 2\n-1 2\n0 1\n2 1 0\n0 1 0 1 2\n0 0 0", "4 1 1\n1 1\n1 2\n-1 2\n-1 1\n2 1 0\n0 1 0 2 2\n0 0 0", "4 1 1\n1 1\n1 2\n-1 2\n0 1\n2 1 1\n0 1 0 1 2\n0 0 0", "4 1 1\n1 1\n1 2\n-2 2\n0 1\n2 1 1\n0 1 0 1 2\n0 0 0", "4 1 1\n1 1\n1 2\n-2 2\n0 1\n2 1 1\n0 2 0 1 2\n0 0 0", "4 1 ...
p01287 Colored Octahedra
A young boy John is playing with eight triangular panels. These panels are all regular triangles of the same size, each painted in a single color; John is forming various octahedra with them. While he enjoys his playing, his father is wondering how many octahedra can be made of these panels since he is a pseudo-mathem...
{ "input": [], "output": [] }
{ "input": [ "blue blue blue blue blue blue blue blue\nred blue blue blue blue blue blue blue\nred red blue blue blue blue blue blue" ], "output": [ "1\n1\n3" ] }
{ "input": [ "blue blue blue blue bluf blue blue blue\nred blue blue blue blue blue blue blue\nred red blue blue blue blue blue blue", "blue blue blue blue bluf clue blue blue\nred blue blue blue blue blue blue blue\nred red blue blue blue blue blue blue", "blue blue blue blue bluf cleu blue blue\nred blu...