name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
cseq
Given three positive integers N, L and R, find the number of non-decreasing sequences of size at least 1 and at most N, such that each element of the sequence lies between L and R, both inclusive. Print the answer modulo 10^6+3. Input First line of input contains T, the number of the test cases. Each of next T lines...
{ "input": [], "output": [] }
{ "input": [ "2\n1 4 5\n2 4 5" ], "output": [ "2\n5" ] }
{ "input": [], "output": [] }
hello
Chef talks a lot on his mobile phone. As a result he exhausts his talk-value (in Rokdas) very quickly. One day at a mobile recharge shop, he noticed that his service provider gives add-on plans which can lower his calling rates (Rokdas/minute). One of the plans said "Recharge for 28 Rokdas and enjoy call rates of 0.50 ...
{ "input": [], "output": [] }
{ "input": [ "4\n1.00 200 1\n1 0.50 28\n1.00 200 2\n1 0.75 40\n3 0.60 100\n1.00 50 2\n1 0.75 40\n3 0.60 100\n1.00 100 2\n3 0.50 10\n2 0.10 20" ], "output": [ "1\n2\n0\n2\n" ] }
{ "input": [ "4\n1.00 200 1\n1 0.50 28\n1.00 200 2\n1 0.75 40\n3 0.60 100\n1.00 50 2\n1 0.75 40\n3 0.60 100\n1.00 100 2\n3 0.50 10\n2 0.10 18", "4\n1.00 200 1\n1 1.2860395633010162 28\n1.00 200 2\n1 0.75 40\n3 0.60 101\n1.00 50 2\n1 0.75 65\n3 1.410429553075017 100\n1.00 100 2\n3 0.50 10\n2 0.10 18", "4\n...
mime2
Many internet protocols these days include the option of associating a media type with the content being sent. The type is usually inferred from the file extension. You are to write a program that facilitates the lookup of media types for a number of files. You will be given a table of media type associations that asso...
{ "input": [], "output": [] }
{ "input": [ "5 6\nhtml text/html\nhtm text/html\npng image/png\nsvg image/svg+xml\ntxt text/plain\nindex.html\nthis.file.has.lots.of.dots.txt\nnodotsatall\nvirus.exe\ndont.let.the.png.fool.you\ncase.matters.TXT" ], "output": [ "text/html\ntext/plain\nunknown\nunknown\nunknown\nunknown\n" ] }
{ "input": [ "5 6\nhtml tfxt/html\nhtm text/html\npng image/png\nsvg image/svg+xml\ntxt text/plain\nindex.html\nthis.file.has.lots.of.dots.txt\nnodotsatall\nvirus.exe\ndont.let.the.png.fool.you\ncase.matters.TXT", "5 6\nhtll tfxt/html\nhtm text/html\npng image/png\nsvg image/svg+xml\ntxt text/plain\nindex.htm...
rectsq
Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell some parts of his plots. The specialty of his plot is that it is rectangular in nature. Santosh comes to know that ...
{ "input": [], "output": [] }
{ "input": [ "2\n10 15\n4 6" ], "output": [ "6\n6\n" ] }
{ "input": [ "2\n10 15\n4 1", "2\n10 28\n4 1", "2\n15 28\n4 1", "2\n8 28\n4 1", "2\n8 12\n8 1", "2\n8 12\n3 1", "2\n8 12\n2 1", "2\n9 12\n2 1", "2\n9 12\n2 2", "2\n9 4\n2 2", "2\n9 4\n2 3", "2\n5 4\n2 3", "2\n8 4\n2 3", "2\n4 1\n2 3", "2\n8 15\n4 1", "2\...
tricoin
Chef belongs to a very rich family which owns many gold mines. Today, he brought N gold coins and decided to form a triangle using these coins. Isn't it strange? Chef has a unusual way of forming a triangle using gold coins, which is described as follows: He puts 1 coin in the 1^st row. then puts 2 coins in the 2^nd r...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n5\n7" ], "output": [ "2\n2\n3\n" ] }
{ "input": [ "3\n3\n5\n11", "3\n2\n5\n11", "3\n2\n9\n11", "3\n4\n9\n11", "3\n5\n9\n2", "3\n5\n5\n2", "3\n2\n5\n2", "3\n5\n5\n7", "3\n4\n9\n21", "3\n5\n15\n2", "3\n5\n5\n3", "3\n5\n7\n7", "3\n1\n17\n11", "3\n7\n9\n21", "3\n5\n7\n5", "3\n1\n5\n16", "3\...
1252_B. Cleaning Robots
The new ICPC town has N junctions (numbered from 1 to N) which are connected by N-1 roads. It is possible from one junction to go to any other junctions by going through one or more roads. To make sure all the junctions are well-maintained, the government environment agency is planning to deploy their newest advanced c...
{ "input": [], "output": [] }
{ "input": [ "6\n1 3\n2 3\n3 4\n4 5\n4 6\n", "5\n1 2\n2 3\n2 4\n4 5\n" ], "output": [ "\n5\n", "\n3\n" ] }
{ "input": [], "output": [] }
1468_N. Waste Sorting
The progress is not standing still in Berland. Recently all garbage containers in Bertown, the capital of Berland, were replaced by differentiated recycling bins, each accepting some category of waste. While this will definitely improve the ecological situation, for some citizens it's difficult to get used to the habit...
{ "input": [], "output": [] }
{ "input": [ "7\n1 2 3\n1 2 3 0 0\n2 2 3\n1 2 3 1 0\n2 2 3\n1 2 3 0 1\n1 2 5\n1 2 3 1 1\n0 0 0\n0 0 0 0 0\n0 0 4\n1 0 0 0 0\n13 37 42\n0 0 0 40 47\n" ], "output": [ "\nYES\nYES\nNO\nYES\nYES\nNO\nYES\n" ] }
{ "input": [ "7\n1 2 3\n1 2 3 0 0\n2 2 3\n0 2 3 1 0\n2 2 3\n1 2 3 0 1\n1 2 5\n1 2 3 1 1\n0 0 0\n0 0 0 0 0\n0 0 4\n1 0 0 0 0\n13 37 42\n0 0 0 40 47\n", "7\n1 2 3\n1 1 3 0 0\n2 2 5\n0 0 3 1 0\n2 2 4\n1 2 2 0 1\n1 2 5\n1 2 3 1 1\n0 0 0\n0 0 0 0 0\n0 0 4\n1 0 0 0 0\n13 37 42\n0 0 0 40 47\n", "7\n1 2 3\n1 1 3 ...
618_F. Double Knapsack
You are given two multisets A and B. Each multiset has exactly n integers each between 1 and n inclusive. Multisets may contain multiple copies of the same number. You would like to find a nonempty subset of A and a nonempty subset of B such that the sum of elements in these subsets are equal. Subsets are also multise...
{ "input": [], "output": [] }
{ "input": [ "5\n4 4 3 3 3\n2 2 2 2 5\n", "10\n10 10 10 10 10 10 10 10 10 10\n10 9 8 7 6 5 4 3 2 1\n" ], "output": [ "1\n1 \n2\n1 2 \n", "1\n1 \n1\n1 \n" ] }
{ "input": [ "10\n10 10 10 10 10 10 10 10 10 10\n10 9 8 7 8 5 4 3 2 1\n", "10\n10 10 10 10 10 10 10 10 10 10\n10 9 8 7 15 5 4 3 2 1\n", "10\n10 10 10 10 10 10 10 10 11 10\n10 9 8 7 15 5 4 3 2 1\n", "10\n10 10 10 1 10 10 10 10 11 10\n10 9 8 7 15 5 4 3 2 1\n", "10\n10 10 10 1 10 10 10 10 11 10\n10 9...
longest-increasing-path-9
There is a 2D matrix of N rows and M columns. Rows are number 1 to N from top to bottom and columns 1 to M from left to right. You are standing at (1,1). From, A [ i ] [ j ] you can move to A [ i + 1 ] [ j ] if A [ i + 1 ] [ j ] > A [ i ] [ j ]. Or, from, A [ i ] [ j ] you can move to A [ i ] [ j + 1 ] if A [ i ] [...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1\n1\n4 4\n1 2 3 4\n2 2 3 4\n3 2 3 4\n4 5 6 7\n2 2\n1 2\n3 4\n\nSAMPLE" ], "output": [ "1\n7\n3\n" ] }
{ "input": [ "3\n1 1\n1\n4 4\n1 2 5 4\n2 2 3 4\n3 2 3 4\n4 5 6 7\n2 2\n1 2\n3 4\n\nSAMPLE", "3\n1 1\n1\n4 4\n1 2 5 4\n3 2 3 4\n3 2 5 4\n4 5 6 7\n2 2\n1 2\n3 8\n\nLAMPSE", "3\n1 1\n1\n4 4\n1 2 5 4\n2 2 3 7\n3 2 3 4\n7 5 6 7\n2 2\n1 2\n3 4\n\nLAMPSE", "3\n1 1\n1\n4 4\n2 2 5 4\n2 2 5 7\n3 2 3 4\n7 5 6 7\...
problem-1-46
Karan and Akshay love challenging each other with awesome algorithmic questions. Today, Karan decided to give Akshay a relatively easy question. Karan has string s of length N consisting entirely of lowercase latin characters and he loves double palindromes (defined below). So he asks Akshay Q questions about the strin...
{ "input": [], "output": [] }
{ "input": [ "8\nabcdabcd\n2\n1 8\n3 5\n\nSAMPLE" ], "output": [ "YES\nNO" ] }
{ "input": [], "output": [] }
search-engine
Let us see how search engines work. Consider the following simple auto complete feature. When you type some characters in the text bar, the engine automatically gives best matching options among it's database. Your job is simple. Given an incomplete search text, output the best search result. Each entry in engine's da...
{ "input": [], "output": [] }
{ "input": [ "2 1\nhackerearth 10\nhackerrank 9\nhacker\n\nSAMPLE" ], "output": [ "10\n" ] }
{ "input": [ "2 1\nhackerearth 10\nhackerrank 11\nhacker\n\nSAMPLE", "2 1\nhackerearth 10\nhackerrank 20\nhacker\n\nSAMPLE", "2 1\nhackerearth 10\nhackerrank 20\nhadker\n\nSAMPLE", "1 2\nhackdrearth 10\nhackerranl 27\neadkhr\n\nSAMPLE", "2 1\nhackerearth 0\nhackerrank 21\nhacker\n\nELPMAS", "0...
terminator
Slugtera is a town where three types of people lives which are criminals , terminator and life saver . Criminals are represented by o and terminator are represented by x and saver are represented by * . So in this story x function is to kill all o but however if * comes between o and x then x is not able to kil...
{ "input": [], "output": [] }
{ "input": [ "3\noxox\nxo*oooooooo*xo\nooooooooo*xooo***xxxxooooo\n\nSAMPLE" ], "output": [ "xx\nx*oooooooo*x\nooooooooo*x***xxxx\n" ] }
{ "input": [ "3\noxox\nxo*oooooooo*xo\nooooooooo*xooo***xxxxooooo\n\nELPMAS", "3\nxoox\noo*xooooooo*xo\nooooooooo*xooo***xxxxooooo\n\nELPMAS", "3\nxoox\nox*ooooooox*oo\nooooooooo*xooo***xxxxooooo\n\nSAMPLE", "3\noxox\nxo*ooooooo*oxo\nooooooooo*xooo***xxxxooooo\n\nELPMAS", "3\nxoox\nooox*oooooo*xo\...
p02634 AtCoder Grand Contest 046 - Extension
We have a grid with A horizontal rows and B vertical columns, with the squares painted white. On this grid, we will repeatedly apply the following operation: * Assume that the grid currently has a horizontal rows and b vertical columns. Choose "vertical" or "horizontal". * If we choose "vertical", insert one row at th...
{ "input": [], "output": [] }
{ "input": [ "2 1 3 4", "31 41 59 265", "1 1 2 2" ], "output": [ "65", "387222020", "3" ] }
{ "input": [ "2 0 3 4", "54 41 59 265", "1 0 2 2", "2 0 3 0", "54 41 59 202", "1 0 2 3", "2 0 3 1", "41 41 59 202", "2 0 3 2", "50 41 59 202", "1 0 2 1", "2 0 6 2", "4 0 6 2", "4 0 6 4", "4 0 6 7", "3 0 6 7", "2 0 3 3", "31 41 59 430", "2 0 3...
p02765 AtCoder Beginner Contest 156 - Beginner
Takahashi is a member of a programming competition site, ButCoder. Each member of ButCoder is assigned two values: Inner Rating and Displayed Rating. The Displayed Rating of a member is equal to their Inner Rating if the member has participated in 10 or more contests. Otherwise, the Displayed Rating will be their Inn...
{ "input": [], "output": [] }
{ "input": [ "2 2919", "22 3051" ], "output": [ "3719", "3051" ] }
{ "input": [ "2 4162", "17 3051", "1 4162", "17 3619", "1 1703", "1 1051", "0 1051", "0 1885", "76 6963", "0 1615", "76 3451", "0 2265", "76 835", "-1 2265", "76 1018", "1 2265", "76 170", "0 503", "-1 503", "6 170", "1 503", "6 3...
p02900 AtCoder Beginner Contest 142 - Disjoint Set of Common Divisors
Given are positive integers A and B. Let us choose some number of positive common divisors of A and B. Here, any two of the chosen divisors must be coprime. At most, how many divisors can we choose? Definition of common divisor An integer d is said to be a common divisor of integers x and y when d divides both x a...
{ "input": [], "output": [] }
{ "input": [ "1 2019", "12 18", "420 660" ], "output": [ "1", "3", "4" ] }
{ "input": [ "2 2019", "420 324", "3 2019", "19 18", "19 16", "420 71", "6 2019", "19 9", "420 47", "6 949", "31 9", "411 47", "6 1591", "40 9", "411 17", "8 1591", "66 9", "442 17", "4 1591", "66 17", "313 17", "3 1591", "79 ...
p03035 AtCoder Beginner Contest 127 - Ferris Wheel
Takahashi, who is A years old, is riding a Ferris wheel. It costs B yen (B is an even number) to ride the Ferris wheel if you are 13 years old or older, but children between 6 and 12 years old (inclusive) can ride it for half the cost, and children who are 5 years old or younger are free of charge. (Yen is the currenc...
{ "input": [], "output": [] }
{ "input": [ "0 100", "30 100", "12 100" ], "output": [ "0", "100", "50" ] }
{ "input": [ "-1 100", "15 100", "6 111", "9 100", "16 110", "17 101", "25 111", "59 011", "89 001", "30 010", "9 010", "1 100", "-2 100", "17 100", "2 100", "-2 000", "2 101", "0 000", "-2 001", "3 101", "0 001", "1 001", "3 ...
p03176 Educational DP Contest - Flowers
There are N flowers arranged in a row. For each i (1 \leq i \leq N), the height and the beauty of the i-th flower from the left is h_i and a_i, respectively. Here, h_1, h_2, \ldots, h_N are all distinct. Taro is pulling out some flowers so that the following condition is met: * The heights of the remaining flowers ar...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000", "4\n3 1 4 2\n10 20 30 40", "1\n1\n10", "9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 3 5 7 5" ], "output": [ "5000000000", "60", "10", "31" ] }
{ "input": [ "5\n1 2 3 4 5\n1000000000 1000000010 1000000000 1000000000 1000000000", "4\n3 1 4 2\n10 20 2 40", "9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 5 5 7 5", "5\n1 2 3 4 5\n1000000000 1000000010 1000000000 1010000000 1000000000", "9\n4 2 5 8 3 6 1 7 9\n6 8 8 4 6 4 5 7 5", "5\n1 2 3 4 5\n1000000000...
p03324 AtCoder Beginner Contest 100 - Ringo's Favorite Numbers
Today, the memorable AtCoder Beginner Contest 100 takes place. On this occasion, Takahashi would like to give an integer to Ringo. As the name of the contest is AtCoder Beginner Contest 100, Ringo would be happy if he is given a positive integer that can be divided by 100 exactly D times. Find the N-th smallest intege...
{ "input": [], "output": [] }
{ "input": [ "2 85", "1 11", "0 5" ], "output": [ "850000", "1100", "5" ] }
{ "input": [ "2 37", "2 11", "-1 5", "2 40", "2 19", "-1 9", "2 57", "3 19", "0 9", "2 86", "0 19", "-1 2", "2 63", "-1 19", "2 71", "-1 35", "2 84", "-1 66", "1 84", "-1 43", "1 63", "-1 8", "-2 8", "1 9", "1 5", ...
p03478 AtCoder Beginner Contest 083 - Some Sums
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). Constraints * 1 \leq N \leq 10^4 * 1 \leq A \leq B \leq 36 * All input values are integers. Input Input is given from Standard Input in the following format: N A B Output Print the s...
{ "input": [], "output": [] }
{ "input": [ "10 1 2", "20 2 5", "100 4 16" ], "output": [ "13", "84", "4554" ] }
{ "input": [ "10 1 0", "20 2 6", "100 4 12", "20 3 6", "100 5 12", "20 1 6", "37 2 6", "101 3 12", "37 1 6", "37 1 9", "37 1 18", "001 1 12", "37 1 2", "37 1 3", "4 1 6", "101 -1 6", "6 -2 6", "5 -3 10", "011 2 20", "011 4 20", "100 4...
p03643 AtCoder Beginner Contest 068 - ABCxxx
This contest, AtCoder Beginner Contest, is abbreviated as ABC. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer. Constraints * 100 ≤ N ≤ 999 I...
{ "input": [], "output": [] }
{ "input": [ "999", "425", "100" ], "output": [ "ABC999", "ABC425", "ABC100" ] }
{ "input": [ "1530", "820", "110", "2825", "293", "5621", "258", "238", "411", "87", "789", "33", "415", "36", "542", "34", "205", "52", "294", "74", "105", "97", "186", "183", "292", "403", "518", "365", ...
p03801 AtCoder Regular Contest 069 - Frequency
Snuke loves constructing integer sequences. There are N piles of stones, numbered 1 through N. The pile numbered i consists of a_i stones. Snuke will construct an integer sequence s of length Σa_i, as follows: 1. Among the piles with the largest number of stones remaining, let x be the index of the pile with the sma...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2", "10\n1 2 1 3 2 4 2 5 8 1" ], "output": [ "2\n1", "10\n7\n0\n4\n0\n3\n0\n2\n3\n0" ] }
{ "input": [ "10\n1 2 2 3 2 4 2 5 8 1", "10\n1 3 2 3 2 4 2 5 8 1", "10\n1 3 2 3 2 4 4 5 8 1", "2\n1 0", "10\n1 2 1 3 2 4 1 5 8 1", "10\n1 2 1 3 2 4 2 5 8 0", "10\n1 3 2 4 2 4 2 5 8 1", "10\n1 3 2 6 2 4 4 5 8 1", "2\n1 1", "10\n1 2 1 3 2 4 1 5 8 0", "10\n1 2 0 3 2 4 2 5 8 0"...
p03969 AtCoder Regular Contest 062 - Painting Graphs with AtCoDeer
One day, AtCoDeer the deer found a simple graph (that is, a graph without self-loops and multiple edges) with N vertices and M edges, and brought it home. The vertices are numbered 1 through N and mutually distinguishable, and the edges are represented by (a_i,b_i) (1≦i≦M). He is painting each edge in the graph in one...
{ "input": [], "output": [] }
{ "input": [ "4 4 2\n1 2\n2 3\n3 1\n3 4", "5 2 3\n1 2\n4 5", "11 12 48\n3 1\n8 2\n4 9\n5 4\n1 6\n2 9\n8 3\n10 8\n4 10\n8 6\n11 7\n1 8" ], "output": [ "8", "9", "569519295" ] }
{ "input": [ "11 12 48\n3 1\n8 2\n4 9\n5 4\n1 6\n2 9\n11 3\n10 8\n4 10\n8 6\n11 7\n1 8", "5 0 3\n1 2\n4 5", "5 1 3\n1 7\n4 5", "5 1 2\n1 7\n4 5", "9 1 5\n1 7\n4 5", "9 1 6\n1 7\n4 5", "9 2 6\n1 7\n4 5", "5 1 9\n1 8\n5 1", "14 1 4\n2 10\n5 8", "27 2 0\n0 8\n5 8", "5 0 3\n1 4...
p00058 Orthogonal
Read the coordinates of four different points on the plane, $ A (x_A, y_A) $, $ B (x_B, y_B) $, $ C (x_C, y_C) $, $ D (x_D, y_D) $, and straight line $ Create a program that outputs YES if AB $ and $ CD $ are orthogonal, and NO if they are not orthogonal. Here, "straight line" does not mean a line segment. Please refer...
{ "input": [], "output": [] }
{ "input": [ "1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0\n0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0\n10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1\n2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3" ], "output": [ "YES\nNO\nNO\nYES" ] }
{ "input": [ "1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0\n0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0\n10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1\n2.5 3.5 2.5 5.324353001023156 -3.3 -2.3 6.8 -2.3", "1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0\n0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0\n10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1\n3.455765838159193 3.5 2.5 5.324353001023...
p00189 Convenient Location
Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short time to go to any office. So you decided to find the most convenient t...
{ "input": [], "output": [] }
{ "input": [ "6\n0 1 80\n1 2 20\n0 2 60\n2 3 50\n3 4 60\n1 4 90\n2\n0 1 1\n1 2 1\n0" ], "output": [ "2 240\n1 2" ] }
{ "input": [ "6\n0 1 80\n1 2 20\n0 2 60\n2 3 50\n3 4 66\n1 4 90\n2\n0 1 1\n1 2 1\n0", "6\n0 1 80\n1 2 20\n0 2 60\n2 3 50\n3 4 66\n0 4 90\n2\n0 1 1\n1 2 1\n0", "6\n0 1 80\n1 2 20\n0 2 60\n2 2 50\n3 4 66\n0 4 90\n2\n0 1 1\n1 2 1\n0", "6\n0 1 80\n1 2 20\n0 2 60\n2 2 50\n3 4 66\n1 4 90\n2\n0 1 1\n1 2 1\n0...
p00344 Cyclic Sugoroku
Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. The player chooses a square as a starting point and places his piece. Advance the pieces clockwise by the number written on th...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1 1", "8\n2 3 7 3 3 3 4 4", "3\n1 1 2" ], "output": [ "3", "6", "2" ] }
{ "input": [ "3\n2 1 1", "8\n2 3 7 3 3 1 4 4", "3\n1 1 3", "3\n1 2 3", "8\n2 4 4 0 3 4 4 4", "8\n0 3 6 0 5 4 4 4", "8\n0 3 5 1 6 0 0 4", "8\n1 1 1 2 11 1 -2 1", "3\n2 1 0", "8\n2 3 4 3 3 1 4 4", "3\n1 1 0", "8\n2 3 4 0 3 1 4 4", "3\n1 2 1", "3\n2 2 1", "8\n2...
p00540 Ball
Ball In the Kingdom of IOI, a ball will be held to celebrate the birthday of Princess JOI, the princess. N aristocrats will participate in the ball. N is an odd number. Aristocrats are numbered from 1 to N. Each aristocrat has an integer of goodness of dance, and the goodness of dance of aristocrat i (1 ≤ i ≤ N) is D...
{ "input": [], "output": [] }
{ "input": [ "7 3\n5 2\n5 5\n8 6\n6\n2\n8\n9" ], "output": [ "8" ] }
{ "input": [ "7 3\n5 2\n5 5\n4 6\n6\n2\n8\n9", "7 3\n5 2\n5 5\n8 6\n1\n2\n8\n9", "7 2\n3 2\n5 5\n8 6\n1\n7\n8\n9", "7 3\n3 2\n5 5\n11 6\n1\n13\n8\n9", "7 3\n2 1\n5 5\n11 6\n1\n13\n8\n10", "7 3\n-1 3\n1 2\n8 11\n1\n0\n15\n9", "7 3\n3 2\n3 3\n13 6\n0\n2\n8\n0", "7 3\n0 2\n5 5\n8 6\n1\n3\...
p00703 What is the Number in my Mind ?
Let us enjoy a number guess game. A number containing L digits is in my mind (where 4 <= L <= 10). You should guess what number it is. It is composed of any of the following ten digits: "0","1","2","3","4","5","6","7","8", and "9". No digits appear twice in the number. For example, when L = 4, "1234" is a legit...
{ "input": [], "output": [] }
{ "input": [ "6 4\n160348 0 4\n913286 2 3\n431289 3 1\n671283 3 3\n10 8\n3827690415 2 8\n0482691573 1 9\n1924730586 3 7\n1378490256 1 9\n6297830541 1 9\n4829531706 3 7\n4621570983 1 9\n9820147536 6 4\n4 4\n2713 0 3\n1247 2 0\n1230 1 1\n1387 2 1\n6 5\n605743 0 4\n593026 2 2\n792456 1 2\n143052 1 3\n093614 3 3\n5 2...
{ "input": [ "6 4\n160348 0 4\n913286 2 3\n431289 3 1\n738408 3 3\n10 8\n3827690415 2 8\n0482691573 1 9\n1924730586 3 7\n1378490256 1 9\n6297830541 1 9\n4829531706 3 7\n4621570983 1 9\n9820147536 6 4\n4 4\n2713 0 3\n1247 2 0\n1230 1 1\n1387 2 1\n6 5\n605743 0 4\n593026 2 2\n792456 1 2\n143052 1 3\n093614 3 3\n5 2...
p00843 Bingo
A Bingo game is played by one gamemaster and several players. At the beginning of a game, each player is given a card with M × M numbers in a matrix (See Figure 10). <image> As the game proceeds, the gamemaster announces a series of numbers one by one. Each player punches a hole in his card on the announced number, i...
{ "input": [], "output": [] }
{ "input": [ "4 3\n10 25 11 20 6 2 1 15 23\n5 21 3 12 23 17 7 26 2\n8 18 4 22 13 27 16 5 11\n19 9 24 2 11 5 14 28 16\n4 3\n12 13 20 24 28 32 15 16 17\n12 13 21 25 29 33 16 17 18\n12 13 22 26 30 34 17 18 15\n12 13 23 27 31 35 18 15 16\n4 3\n11 12 13 14 15 16 17 18 19\n21 22 23 24 25 26 27 28 29\n31 32 33 34 35 36 ...
{ "input": [ "4 3\n10 25 11 20 6 2 1 15 23\n5 21 1 12 23 17 7 26 2\n8 18 4 22 13 27 16 5 11\n19 9 24 2 11 5 14 28 16\n4 3\n12 13 20 24 28 32 15 16 17\n12 13 21 25 29 33 16 17 18\n12 13 22 26 30 34 17 18 15\n12 13 23 27 31 35 18 15 16\n4 3\n11 12 13 14 15 16 17 18 19\n21 22 23 24 25 26 27 28 29\n31 32 33 34 35 36 ...
p00975 Four-Coloring
Four-Coloring You are given a planar embedding of a connected graph. Each vertex of the graph corresponds to a distinct point with integer coordinates. Each edge between two vertices corresponds to a straight line segment connecting the two points corresponding to the vertices. As the given embedding is planar, the li...
{ "input": [], "output": [] }
{ "input": [ "5 8\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 5\n3 4\n3 5\n4 5" ], "output": [ "1\n2\n2\n1\n3" ] }
{ "input": [ "5 9\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 5\n3 4\n3 5\n4 5", "5 9\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 5\n5 4\n4 5\n4 5", "5 9\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 10\n3 4\n4 5\n4 5", "5 0\n0 0\n4 1\n0 2\n2 2\n1 0\n1 2\n1 3\n1 5\n2 4\n2 2\n3 4\n3 5\n4 5", ...
p01107 Go around the Labyrinth
Go around the Labyrinth Explorer Taro got a floor plan of a labyrinth. The floor of this labyrinth is in the form of a two-dimensional grid. Each of the cells on the floor plan corresponds to a room and is indicated whether it can be entered or not. The labyrinth has only one entrance located at the northwest corner, ...
{ "input": [], "output": [] }
{ "input": [ "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n#....\n.....\n.....\n3 8\n..#.....\n........\n.....#..\n3 5\n..#..\n.....\n..#..\n4 4\n....\n....\n..##\n..#.\n0 0" ], "output": [ "YES\nNO\nYES\nNO\nNO" ] }
{ "input": [ "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n#....\n.....\n.....\n3 8\n..#.....\n........\n.....#..\n3 5\n..#..\n-....\n..#..\n4 4\n....\n....\n..##\n..#.\n0 0", "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n#....\n../..\n.....\n3 8\n..#.....\n........\n..#.....\n3 5\n..#..\n....-\n..#..\n4 4\n....\n....\n....
p01245 Magical Dungeon
Arthur C. Malory is a wandering valiant fighter (in a game world). One day, he visited a small village and stayed overnight. Next morning, the village mayor called on him. The mayor said a monster threatened the village and requested him to defeat it. He was so kind that he decided to help saving the village. The may...
{ "input": [], "output": [] }
{ "input": [ "7 8\n0 2 3\n2 3 -20\n3 4 3\n4 1 -5\n1 5 1\n5 4 5\n1 3 2\n3 6 -2\n0 6 30\n7 8\n0 2 3\n2 3 -20\n3 4 3\n4 1 -5\n1 5 1\n5 4 5\n1 3 2\n3 6 -2\n0 6 20\n4 4\n0 1 -10\n1 2 -50\n2 1 51\n1 3 1\n0 3 20\n11 14\n0 1 -49\n1 2 1\n2 3 40\n3 1 -40\n1 4 -9\n4 5 40\n5 1 -30\n1 6 -19\n6 7 40\n7 1 -20\n1 8 -30\n8 9 40\n...
{ "input": [ "7 8\n0 2 3\n2 3 -20\n3 4 3\n4 1 -5\n1 5 1\n5 4 5\n1 3 2\n3 6 -2\n0 6 30\n7 8\n0 2 3\n2 3 -20\n3 4 3\n4 1 -5\n1 5 1\n5 4 5\n1 3 2\n3 6 -2\n0 6 20\n4 4\n0 1 -10\n1 2 -50\n2 1 51\n1 3 1\n0 3 20\n11 14\n0 1 -49\n1 2 1\n2 3 40\n3 1 -40\n1 4 -9\n4 5 40\n5 1 -30\n1 6 -19\n6 7 40\n7 1 -20\n1 8 -30\n8 9 40\n...
p01406 Custom Painting Master
Problem I: Custom paint craftsman slip likes a video of a racing game. That said, I don't like videos of cars running, but I like videos of customizing the car body with the custom paint car creation feature of this game. This is a function that allows custom painting on the car body by superimposing basic geometric f...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n17 12 7 340 180\n26 22 10 150 270\n27 13 5 100 230\n3\n0 0 8 0 90\n10 10 8 180 0\n50 50 5 180 270\n2\n10 10 5 0 270\n0 0 30 0 90" ], "output": [ "3\n2\n2" ] }
{ "input": [ "3\n3\n17 12 7 340 180\n26 22 10 150 270\n27 13 5 100 230\n3\n0 0 8 0 90\n10 10 8 180 -1\n50 50 5 180 270\n2\n10 10 5 0 270\n0 0 30 0 90", "3\n3\n17 12 7 340 44\n26 31 10 150 270\n27 13 5 100 230\n3\n0 0 8 -1 90\n10 10 8 180 -1\n50 50 5 180 270\n2\n10 10 5 0 270\n0 0 30 0 90", "3\n3\n17 12 7 ...
p01560 Enumeration
Given n integers a1, a2,…, an and n integers p1, p2,…, pn, integer m. The operation of selecting the kth integer ak with a probability of pk [%] is performed for each k (1 ≤ k ≤ n), and 0 or more and n or less integers are selected. Find the expected number of integers between 1 and m that are divisible by at least one...
{ "input": [], "output": [] }
{ "input": [ "2 15\n3 5\n50 50", "4 100\n2 3 5 7\n80 60 40 20", "4 210\n2 3 5 7\n80 60 40 20" ], "output": [ "3.75", "57.352", "119.9136" ] }
{ "input": [ "2 15\n3 5\n50 72", "4 100\n1 3 5 7\n80 60 40 20", "4 210\n2 2 5 7\n80 60 40 20", "2 15\n3 5\n32 72", "4 100\n1 3 8 7\n80 60 40 20", "2 210\n2 2 5 7\n80 60 40 20", "2 15\n3 5\n32 64", "4 100\n1 3 14 7\n80 60 40 20", "2 115\n2 2 5 7\n80 60 40 20", "2 7\n3 5\n32 64",...
p01722 Fast Division
Ikta loves fast programs. Recently, I'm trying to speed up the division program. However, it doesn't get much faster, so I thought it would be better to make it faster only for "common sense and typical" inputs. The problem Ikta is trying to solve is as follows. For a given non-negative integer n, divide p (n) − 1-dig...
{ "input": [], "output": [] }
{ "input": [ "0", "1", "2" ], "output": [ "1", "2", "1" ] }
{ "input": [ "3", "001", "000", "6", "4", "10", "5", "7", "17", "11", "12", "18", "9", "35", "15", "8", "29", "14", "41", "27", "62", "30", "25", "42", "58", "21", "83", "98", "178", "209", "375...
p01860 Shopping
C: Shopping-Shopping- story Isono's older sister, Sazoe, decided to cook dinner for Isono and Nakajima, who are playing "that" and "that". Unfortunately, there are only a few ingredients left in the refrigerator, so Sazoe decided to go shopping. Mr. Sazoe is trying to buy some ingredients, but he is so cheerful that ...
{ "input": [], "output": [] }
{ "input": [ "3 9 3 2 3\n1 2 3\n1 1 2\n2 3 1\n3 4 2\n4 1 3\n4 1 1\n5 1 1\n6 2 3\n7 2 2" ], "output": [ "6" ] }
{ "input": [ "3 9 3 2 3\n1 2 3\n1 2 2\n2 3 1\n3 4 2\n4 1 3\n4 1 1\n5 1 1\n6 2 3\n7 2 2", "3 9 6 2 3\n1 2 3\n1 2 2\n2 3 1\n3 4 2\n4 1 3\n4 1 1\n5 1 1\n6 2 2\n7 2 2", "3 9 9 2 3\n1 2 3\n1 2 2\n2 3 1\n3 0 2\n4 1 3\n4 1 1\n5 1 2\n6 2 2\n7 2 2", "3 9 6 2 3\n1 2 3\n1 2 2\n2 3 1\n3 4 3\n4 1 3\n4 1 1\n5 1 2\n...
p01995 Palindromic Subsequences
G: Palindromic Subsequences problem Given a string S consisting only of lowercase letters, find out how many subsequences of this string S are not necessarily continuous and are palindromes. Here, a subsequence that is not necessarily continuous with S is an arbitrary selection of one or more characters | S | charac...
{ "input": [], "output": [] }
{ "input": [ "acpc" ], "output": [ "5" ] }
{ "input": [ "ccpa", "cnbc", "emec", "ccoa", "aocc", "pcca", "ccao", "pcda", "ccbo", "qcda", "ccbn", "qbda", "adbq", "dnbc", "dobc", "dobd", "cobd", "dboc", "cbod", "cboe", "eobc", "cobe", "boce", "bode", "edob", "...
p02141 Donut Hole
Problem You brought a flat, holeless donut with a $ W $ horizontal $ H $ vertical $ H $ rectangle for ACPC. Place this donut on the $ 2 $ dimension plane coordinate $ (0,0) $ with the center of the donut so that the side of length H and the $ y $ axis are parallel. On the ACPC $ 1 $ day you ate a donut that was in t...
{ "input": [], "output": [] }
{ "input": [ "6000 5000 20 10 400 300", "10 10 8 8 8 8" ], "output": [ "0.75", "1" ] }
{ "input": [ "6000 5000 20 2 400 300", "6000 5000 20 2 400 204", "6000 5000 20 2 499 204", "274 5000 28 1 499 204", "274 4268 28 0 499 209", "274 8140 32 0 499 209", "274 14753 32 0 499 132", "6000 5000 20 10 400 575", "16 16 8 8 8 8", "16 18 8 8 8 8", "6000 5000 20 2 400 2...
p02282 Reconstruction of a Tree
Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree. Constraints * $1 \leq n \leq 40$ Input In the first line, an integer $n$, which is...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5\n3 2 4 1 5", "4\n1 2 3 4\n1 2 3 4" ], "output": [ "3 4 2 5 1", "4 3 2 1" ] }
{ "input": [ "4\n1 2 3 4\n2 1 3 4", "4\n2 1 3 4\n2 1 3 4", "4\n2 1 3 4\n3 1 2 4", "5\n1 2 3 4 5\n1 2 4 3 5", "4\n2 1 3 4\n1 2 3 4", "5\n1 3 2 4 5\n3 2 4 1 5", "4\n1 4 3 2\n1 2 3 4", "5\n1 2 3 4 5\n3 4 2 1 5", "4\n1 2 3 4\n1 2 4 3", "4\n2 1 3 4\n2 1 4 3", "4\n1 2 3 4\n2 1 3 ...
p02429 Enumeration of Subsets III
You are given a set $T$, which is a subset of $S$. The set $S$ consists of $0, 1, ... n-1$. Print all subsets of $T$. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a subset is calculated by bitwise OR of existing elemen...
{ "input": [], "output": [] }
{ "input": [ "4\n2 0 2" ], "output": [ "0:\n1: 0\n4: 2\n5: 0 2" ] }
{ "input": [ "4\n2 0 3", "4\n2 1 2", "4\n0 0 3", "4\n2 0 1", "4\n1 0 2", "4\n1 1 0", "4\n1 2 -2", "4\n1 3 0", "4\n2 1 3", "4\n0 0 1", "4\n0 1 3", "4\n0 1 1", "4\n0 1 5", "4\n0 1 2", "4\n0 2 1", "4\n0 1 0", "4\n0 2 0", "4\n0 0 0", "4\n0 3 0", ...
chapd
You are given two positive integers – A and B. You have to check whether A is divisible by all the prime divisors of B. Input The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. For each test case, you are given two space separated integers – A ...
{ "input": [], "output": [] }
{ "input": [ "3\n120 75\n128 16\n7 8" ], "output": [ "Yes\nYes\nNo\n" ] }
{ "input": [ "3\n120 75\n128 16\n7 11", "3\n120 137\n128 16\n7 11", "3\n53 136\n128 16\n0 11", "3\n120 16\n128 4\n4 4", "3\n215 16\n128 12\n6 4", "3\n82 199\n339 16\n1 5", "3\n120 75\n184 5\n16 18", "3\n120 75\n171 16\n0 11", "3\n53 137\n128 16\n7 11", "3\n120 75\n184 16\n7 11"...
destroy
Arrays have fallen out of Chef's good books, and he plans to destroy all arrays he possesses. He is left with the last array A, consisting of N positive integers. In order to destroy the array, he can perform the following 2 types of operations any number of times. Choose any 2 elements, say X and Y, from the given a...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n1 2\n2\n1 1\n3\n1 2 3" ], "output": [ "1\n2\n2\n" ] }
{ "input": [ "3\n2\n1 2\n2\n1 1\n3\n1 4 3", "3\n2\n0 2\n2\n1 0\n3\n1 4 3", "3\n2\n1 1\n2\n1 1\n3\n1 2 -1", "3\n2\n1 1\n2\n1 2\n3\n1 2 -1", "3\n2\n1 2\n2\n1 1\n3\n0 0 0", "3\n2\n1 4\n2\n0 1\n3\n0 0 0", "3\n2\n1 0\n2\n1 1\n3\n1 4 3", "3\n2\n1 2\n2\n1 1\n3\n1 2 0", "3\n2\n0 2\n2\n1 1\...
iitk1p11
Devu is a little boy. He does not know how to take carries while adding two numbers in decimal base. eg. He will struggle in adding numbers 83 and 19, because 3 + 9 = 12 and he needs to take a carry of 1. You are given an integer n. Can you write it in terms of sum of two positive integers such that while adding them ...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n9" ], "output": [ "NO\nYES\n" ] }
{ "input": [ "2\n1\n12", "2\n2\n7", "2\n12\n1", "2\n1\n1", "2\n1\n21", "2\n1\n11", "2\n1\n7", "2\n1\n6", "2\n4\n7", "2\n4\n9", "2\n6\n9", "2\n6\n2", "2\n7\n2", "2\n12\n2", "2\n12\n4", "2\n12\n5", "2\n11\n5", "2\n11\n4", "2\n8\n4", "2\n15\...
ncc3
Problem description: Faizaan and Sejal were playing Mathematics games. Faizaan gave Sejal three numbers: N, M and K. Sejal has to find out a number X such that X = (N^M)%K Sejal initially thought that the problem was very easy, but she soon realised that N and M were very huge numbers. Help Sejal find out X. Note: A^...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n4\n5" ], "output": [ "1" ] }
{ "input": [ "1\n2\n4\n5", "1\n2\n4\n7", "1\n2\n4\n2", "1\n2\n5\n7", "1\n2\n3\n5", "1\n-1\n1\n8", "1\n-2\n1\n8", "1\n5\n1\n7", "1\n-2\n1\n12", "1\n-3\n1\n12", "1\n-2\n4\n22", "1\n-1\n2\n-3", "1\n-2\n1\n22", "1\n-1\n19\n13", "1\n1\n2\n-4", "1\n2\n1\n-3", ...
rrstone
Roman has no idea, why this problem is called Stone. He also has no idea on how to solve the followong problem: given array of N integers A and a number K. During a turn the maximal value over all Ai is chosen, let's call it MAX. Then Ai = MAX - Ai is done for every 1 <= i <= N. Help Roman to find out how will the arra...
{ "input": [], "output": [] }
{ "input": [ "4 1\n5 -1 7 0" ], "output": [ "2 8 0 7\n" ] }
{ "input": [ "4 1\n5 -1 7 1", "4 1\n5 -1 7 2", "4 0\n5 -1 7 2", "4 0\n5 -1 7 4", "4 0\n5 -1 7 0", "4 0\n5 -1 10 0", "4 0\n5 -1 13 0", "4 1\n5 0 7 0", "4 1\n5 0 7 1", "4 1\n5 -1 7 4", "4 1\n9 -1 7 2", "4 0\n5 -1 5 0", "4 0\n5 -1 14 0", "4 2\n5 0 7 1", "4 1\n5...
wprob
Olya works as a warehouse keeper for a T-Shirt factory. Now the factory is facing hard times, so currently they produce only the T-shirts of three kinds: red, green and blue T-Shirts. All the T-shirts are stored in the containers, each of the containers contain the T-Shirts of a single colour. Now there are N container...
{ "input": [], "output": [] }
{ "input": [ "4\nrgr\nrrr\nrgb\nrgbr" ], "output": [ "1\n0\n0\n2" ] }
{ "input": [ "4\nrfr\nrrr\nrgb\nrgbr", "4\nrrf\nrrr\narg\nrfbr", "4\nrrf\nrrr\narg\nrfbq", "4\nrfr\nrrr\ngrb\nrgbr", "4\nfrr\nrrr\ngrb\nrgbr", "4\nfrr\nrrr\nbrg\nrgbr", "4\nfrr\nrrr\narg\nrgbr", "4\nrrf\nrrr\narg\nrgbr", "4\nrrf\nrrr\narg\nrfcq", "4\nrrf\nrrr\nrag\nrfcq", "...
1341_B. Nastya and Door
On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length k (k ≥ 3). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains. Mountains are described by a sequence of heights...
{ "input": [], "output": [] }
{ "input": [ "5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1\n" ], "output": [ "3 2\n2 2\n2 1\n3 1\n2 3\n" ] }
{ "input": [ "5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 -1 1\n15 7\n3 7 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1\n", "5\n8 6\n1 2 4 1 2 4 1 2\n5 3\n3 2 3 2 1\n10 4\n4 3 4 3 2 3 2 1 0 1\n15 7\n3 2 4 8 2 3 4 5 21 2 3 4 2 1 3\n7 5\n1 2 3 4 5 6 1\n", "5\n8 6\n1 2 8 1 2 4 1 2\n5 3\n3...
1472_G. Moving to the Capital
There are n cities in Berland. The city numbered 1 is the capital. Some pairs of cities are connected by a one-way road of length 1. Before the trip, Polycarp for each city found out the value of d_i — the shortest distance from the capital (the 1-st city) to the i-th city. Polycarp begins his journey in the city wit...
{ "input": [], "output": [] }
{ "input": [ "3\n\n6 7\n1 2\n1 3\n2 5\n2 4\n5 1\n3 6\n6 2\n\n2 2\n1 2\n2 1\n\n6 8\n1 2\n1 5\n2 6\n6 1\n2 3\n3 4\n4 2\n5 4\n" ], "output": [ "\n0 0 1 2 0 1 \n0 0 \n0 0 2 1 1 0 \n" ] }
{ "input": [ "3\n\n6 7\n1 2\n1 3\n2 5\n2 4\n5 1\n3 6\n6 2\n\n2 2\n1 2\n2 1\n\n6 8\n1 2\n1 5\n2 6\n6 1\n2 3\n2 4\n4 2\n5 4\n", "3\n\n6 7\n1 2\n1 3\n2 5\n2 4\n3 1\n3 6\n6 2\n\n2 2\n1 2\n2 1\n\n6 8\n1 2\n1 5\n2 6\n6 1\n2 3\n3 4\n4 2\n5 4\n", "3\n\n6 7\n1 2\n1 3\n2 5\n2 4\n3 1\n3 6\n6 2\n\n2 2\n1 2\n2 1\n\n6 ...
316_F1. Suns and Rays
Smart Beaver became interested in drawing. He draws suns. However, at some point, Smart Beaver realized that simply drawing suns is boring. So he decided to design a program that will process his drawings. You are given a picture drawn by the beaver. It will have two colors: one for the background and one for the suns ...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
600_E. Lomsat gelral
You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour c dominating in the subtree of vertex v if there are no other colours that appear in the subtree of vertex v more times than colour c. So it's possible that two or more colours will be dominating in the subtree...
{ "input": [], "output": [] }
{ "input": [ "4\n1 2 3 4\n1 2\n2 3\n2 4\n", "15\n1 2 3 1 2 3 3 1 1 3 2 2 1 2 3\n1 2\n1 3\n1 4\n1 14\n1 15\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n4 12\n4 13\n" ], "output": [ "10 9 3 4 \n", "6 5 4 3 2 3 3 1 1 3 2 2 1 2 3 \n" ] }
{ "input": [ "4\n1 2 3 4\n1 2\n2 3\n1 4\n", "4\n2 2 3 4\n1 2\n2 3\n2 4\n", "15\n1 2 3 1 2 3 3 1 1 3 2 2 1 2 3\n1 2\n1 3\n1 4\n1 14\n1 15\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n5 12\n4 13\n", "4\n1 2 3 4\n1 2\n1 3\n1 4\n", "4\n3 2 3 4\n1 2\n2 3\n2 4\n", "4\n1 2 3 4\n1 2\n1 3\n2 4\n", "4\n1 2...
717_H. Pokermon League challenge
Welcome to the world of Pokermon, yellow little mouse-like creatures, who absolutely love playing poker! Yeah, right… In the ensuing Pokermon League, there are n registered Pokermon trainers, and t existing trainer teams each of which belongs to one of two conferences. Since there is a lot of jealousy between train...
{ "input": [], "output": [] }
{ "input": [ "4 3\n1 2\n2 3\n4 1\n16\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 15\n16\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18\n16\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 18 19\n16\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 19\n" ], "output": [ "2 14 9 16\n2 1 2 1 1 2 1 2 1 1 1 1 1 2 2 1 2 1 1\n" ] }
{ "input": [ "4 3\n1 2\n2 3\n4 1\n16\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 15\n16\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18\n16\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 18 19\n16\n1 2 3 4 5 6 7 8 9 17 11 12 13 14 16 19\n", "4 3\n1 2\n2 3\n4 1\n16\n1 2 3 4 5 6 10 8 9 10 11 12 13 14 16 15\n16\n2 3 7 5 6 7 8 9 10 11 12 ...
beginners-task
Our juniors has just entered in coding community. Their first task is to find the frequency of Best numbers present in given list of elements. Best numbers are numbers which are divisible by 2. SAMPLE INPUT 2 5 1 2 3 4 5 3 1 3 5 SAMPLE OUTPUT 2 0 Explanation Number of test cases=2 1st test case, number of elements ...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n1 2 3 4 5\n3\n1 3 5\n\nSAMPLE" ], "output": [ "2\n0\n" ] }
{ "input": [ "2\n5\n1 2 3 4 5\n3\n1 5 5\n\nSAMPLE", "2\n5\n1 2 3 4 5\n3\n1 3 8\n\nSAMPLE", "2\n5\n1 2 3 4 5\n3\n1 6 8\n\nSAMPME", "2\n5\n1 3 3 4 5\n3\n1 6 9\n\nSAMPME", "2\n5\n1 3 3 4 5\n3\n2 6 9\n\nSAMPME", "2\n5\n1 3 3 5 5\n3\n2 6 9\n\nSAMPME", "2\n5\n2 2 3 4 5\n3\n1 3 8\n\nSAMPME", ...
fast-and-furious
Gandalf's army is fighting against Sauron's army and each of army has even number of N men for current war to be fought. Both of them want to finsh the war fastly . So both fought in manner that war was finished in three turns. Each turn consisting of one army shooting against enemy army furiously, all...
{ "input": [], "output": [] }
{ "input": [ "1\n2\n\nSAMPLE" ], "output": [ "1\n" ] }
{ "input": [ "1\n0\n\nSAMPLE", "1\n2\n\nSAMPLD", "1\n4\n\nSAMPLD", "1\n8\n\nSLQNAD", "1\n14\n\nDANQLS", "1\n16\n\nDANQLS", "1\n-2\n\nSAMPLC", "1\n6\n\nSLQNAD", "1\n-4\n\nDLPMAR", "1\n24\n\nDANQLS", "1\n-8\n\nCAPSML", "1\n12\n\nSAMQLE", "1\n-6\n\nALREMP", "1\n-10...
maintain-the-balance-2
Task is simple. You are provided with a string of curly brackets and you have to do the following - Print 0 if the brackets are balanced. Print k if it is unbalanced, where k is the number of actions performed to balance it. Print -1 if it cannot be balanced. Definition of a Balanced String - { } is a balanced strin...
{ "input": [], "output": [] }
{ "input": [ "4\n{ { { } .\n} { .\n{ } { } { } .\n{ } { } } .\n\nSAMPLE" ], "output": [ "1\n2\n0\n-1\n" ] }
{ "input": [ "4\n{ { { } .\n} { .\n{ } { } { } .\n{ } { } } .\n\nELPMAS", "4\n{ { { } .\n} { .\n{ } { } | } -\n{ } { } } .\n\nFLPMAS", "4\n{ { { } .\n} | -\n{ } { } { } .\n{ } { } } .\n\nASMPLE", "4\n{ { { ~ -\n} { .\n{ } { } { } .\n{ } { } } .\n\nLAMPSE", "4\n{ { { } .\n} { .\n{ { { } { } .\n{ } ...
the-job-party-1
Raman got placed in AWS. He is organizing his job party in which N number of people are invited and only K people joined the party. Ofcourse, Raman is also present in the party! K ≤ N In the party everyone starts shaking hands with everyone else. Given, any two persons shake hand exactly once. Can you tell the tota...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1\n3 2\n\nSAMPLE" ], "output": [ "1\n3\n" ] }
{ "input": [ "2\n1 1\n3 2\n\nSANPLE", "2\n1 2\n3 2\n\nSANPLE", "2\n1 2\n3 4\n\nSANPLE", "2\n1 4\n3 4\n\nSANPLE", "2\n1 7\n6 4\n\nSANPLE", "2\n1 7\n6 3\n\nSANQLE", "2\n1 8\n6 3\n\nSANQLE", "2\n1 7\n7 6\n\nSANQLE", "2\n1 0\n7 6\n\nSANQKE", "2\n1 1\n7 6\n\nSAEQKN", "2\n0 1\n7 ...
p02661 AtCoder Beginner Contest 169 - Count Median
There are N integers X_1, X_2, \cdots, X_N, and we know that A_i \leq X_i \leq B_i. Find the number of different values that the median of X_1, X_2, \cdots, X_N can take. Constraints * 2 \leq N \leq 2 \times 10^5 * 1 \leq A_i \leq B_i \leq 10^9 * All values in input are integers. Input Input is given from Standard ...
{ "input": [], "output": [] }
{ "input": [ "3\n100 100\n10 10000\n1 1000000000", "2\n1 2\n2 3" ], "output": [ "9991", "3" ] }
{ "input": [ "3\n100 100\n8 10000\n1 1000000000", "2\n1 2\n2 4", "3\n100 100\n8 11000\n1 1000000000", "2\n1 1\n2 4", "2\n1 1\n1 7", "2\n0 1\n1 7", "2\n0 1\n0 7", "3\n000 010\n8 11000\n1 1001000000", "2\n0 1\n0 8", "3\n000 010\n8 11000\n2 1001000000", "3\n000 010\n8 01000\n2...
p02790 AtCoder Beginner Contest 152 - Comparing Strings
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller? Constraints * 1 \leq a \leq 9 * 1 \leq b \leq 9 * a and b are integers. Input Input is given from Stan...
{ "input": [], "output": [] }
{ "input": [ "7 7", "4 3" ], "output": [ "7777777", "3333" ] }
{ "input": [ "7 2", "4 6", "7 4", "7 8", "5 7", "1 3", "5 2", "6 6", "6 7", "4 5", "4 4", "2 8", "3 7", "1 5", "9 2", "2 4", "1 4", "1 7", "1 6", "6 5", "6 9", "9 3", "9 7", "2 1", "1 8", "8 4", "9 4", "3 4...
p02926 AtCoder Beginner Contest 139 - Engines
E869120 is initially standing at the origin (0, 0) in a two-dimensional plane. He has N engines, which can be used as follows: * When E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the ...
{ "input": [], "output": [] }
{ "input": [ "1\n90447 91000", "2\n96000 -72000\n-72000 54000", "3\n0 10\n5 -5\n-5 -5", "10\n1 2\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20", "5\n1 1\n1 0\n0 1\n-1 0\n0 -1", "3\n0 0\n0 1\n1 0", "5\n1 1\n2 2\n3 3\n4 4\n5 5" ], "output": [ "128303.00000000000000000000000...
{ "input": [ "1\n52551 91000", "2\n96000 -130259\n-72000 54000", "3\n0 10\n5 -3\n-5 -5", "10\n1 0\n3 4\n5 6\n7 8\n9 10\n11 12\n13 14\n15 16\n17 18\n19 20", "5\n1 1\n1 0\n0 2\n-1 0\n0 -1", "3\n0 0\n0 1\n2 0", "5\n1 1\n2 2\n3 3\n4 2\n5 5", "1\n76279 91000", "2\n49801 -130259\n-72000 ...
p03061 AtCoder Beginner Contest 125 - GCD on Blackboard
There are N integers, A_1, A_2, ..., A_N, written on the blackboard. You will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written. Find the maximum possible greatest common divisor of the N integers on the blackboard afte...
{ "input": [], "output": [] }
{ "input": [ "3\n7 6 8", "2\n1000000000 1000000000", "3\n12 15 18" ], "output": [ "2", "1000000000", "6" ] }
{ "input": [ "3\n7 6 7", "2\n1000010000 1000000000", "3\n12 29 18", "2\n1000000000 1000001000", "3\n4 8 7", "2\n1001000000 1000001000", "3\n9 28 18", "3\n9 28 30", "2\n1001100000 1000001100", "2\n1101000000 1000001100", "3\n4 2 5", "2\n1101100000 1000000100", "2\n11...
p03205 AtCoder Grand Contest 029 - Construction of a tree
You are given N-1 subsets of \\{1,2,...,N\\}. Let the i-th set be E_i. Let us choose two distinct elements u_i and v_i from each set E_i, and consider a graph T with N vertices and N-1 edges, whose vertex set is \\{1,2,..,N\\} and whose edge set is (u_1,v_1),(u_2,v_2),...,(u_{N-1},v_{N-1}). Determine if T can be a tre...
{ "input": [], "output": [] }
{ "input": [ "6\n3 1 2 3\n3 2 3 4\n3 1 3 4\n3 1 2 4\n3 4 5 6", "5\n2 1 2\n3 1 2 3\n3 3 4 5\n2 4 5", "10\n5 1 2 3 4 5\n5 2 3 4 5 6\n5 3 4 5 6 7\n5 4 5 6 7 8\n5 5 6 7 8 9\n5 6 7 8 9 10\n5 7 8 9 10 1\n5 8 9 10 1 2\n5 9 10 1 2 3" ], "output": [ "-1", "1 2\n1 3\n3 4\n4 5", "1 2\n2 3\n3 4\n4 5\n...
{ "input": [ "6\n3 1 2 4\n3 2 3 4\n3 1 3 4\n3 1 2 4\n3 4 5 6", "5\n2 1 2\n3 1 2 3\n3 1 4 5\n2 4 5", "5\n2 1 2\n3 2 2 3\n3 1 4 5\n2 4 5", "10\n5 1 0 3 4 5\n5 2 3 4 5 6\n5 3 4 5 6 7\n5 4 5 6 7 8\n5 5 6 7 8 9\n5 6 7 8 9 10\n5 7 8 9 10 1\n5 8 9 10 1 2\n5 9 10 1 2 3", "5\n2 1 3\n3 2 2 3\n3 1 4 5\n2 4 5...
p03352 AtCoder Beginner Contest 097 - Exponential
You are given a positive integer X. Find the largest perfect power that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. Constraints * 1 ≤ X ≤ 1000 * X is an integer. Input Input is given from Standard Input ...
{ "input": [], "output": [] }
{ "input": [ "10", "1", "999" ], "output": [ "9", "1", "961" ] }
{ "input": [ "20", "610", "38", "159", "107", "72", "136", "217", "261", "011", "001", "7", "689", "747", "52", "83", "8", "124", "34", "235", "27", "197", "25", "1074", "324", "186", "309", "390", "126...
p03512 Code Festival Team Relay (Parallel) - Akashic Records
Consider an infinite sequence a_1, a_2, … Initially, the values of all the terms are 0, and from this state we will sequentially perform Q operations. The i-th operation (1 ≤ i ≤ Q) is as follows: * For every positive integer j, add x_i to the value of a_{j × m_i}. Find the value of the largest term after these Q o...
{ "input": [], "output": [] }
{ "input": [ "3\n10 -3\n50 4\n100 -5", "3\n2 10\n3 -20\n6 15", "5\n56 114834\n72 -149861\n100 190757\n192 -132693\n240 133108" ], "output": [ "1", "10", "438699" ] }
{ "input": [ "3\n10 -3\n50 4\n101 -5", "3\n2 18\n3 -20\n6 15", "5\n56 114834\n72 -134386\n100 190757\n192 -132693\n240 133108", "3\n10 -3\n91 4\n101 -5", "3\n18 -3\n91 4\n101 1", "5\n92 114834\n125 -176641\n100 13125\n192 -68478\n240 133108", "5\n42 114834\n125 -176641\n100 13125\n140 -684...
p03674 AtCoder Beginner Contest 066 - 11
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given s...
{ "input": [], "output": [] }
{ "input": [ "1\n1 1", "32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9", "3\n1 2 1 3" ], "output": [ "1\n1", "32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n16680...
{ "input": [ "3\n1 3 1 3", "3\n1 0 0 2", "3\n1 3 2 1", "3\n1 3 1 2", "3\n1 0 1 2", "3\n1 0 1 0", "3\n1 0 2 0", "3\n2 0 2 0", "3\n1 3 2 3", "3\n2 3 2 3", "3\n2 3 2 1", "3\n2 3 2 0", "3\n1 2 2 3", "3\n1 3 1 0", "3\n1 0 2 2", "3\n-1 0 2 0", "3\n1 3 0 0"...
p03828 AtCoder Beginner Contest 052 - Factors of Factorial
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. Constraints * 1≤N≤10^3 Input The input is given from Standard Input in the following format: N Output Print the number of the positive divisors of N!, modulo 10^9+7. Examples Input 3 Output 4 Input 6 Output 3...
{ "input": [], "output": [] }
{ "input": [ "6", "3", "1000" ], "output": [ "30", "4", "972926972" ] }
{ "input": [ "8", "0", "15", "18", "2", "4", "9", "5", "10", "7", "11", "13", "17", "23", "21", "42", "35", "38", "54", "34", "65", "30", "12", "22", "20", "26", "37", "19", "16", "14", "25", ...
p03995 CODE FESTIVAL 2016 qual A - Grid and Integers
There is a grid with R rows and C columns. We call the cell in the r-th row and c-th column (r,c). Mr. Takahashi wrote non-negative integers into N of the cells, that is, he wrote a non-negative integer a_i into (r_i,c_i) for each i (1≤i≤N). After that he fell asleep. Mr. Aoki found the grid and tries to surprise Mr....
{ "input": [], "output": [] }
{ "input": [ "2 2\n4\n1 1 0\n1 2 10\n2 1 30\n2 2 20", "2 2\n3\n1 1 0\n1 2 10\n2 1 20", "3 3\n4\n1 1 0\n1 3 10\n3 1 10\n3 3 20", "2 2\n3\n1 1 20\n1 2 10\n2 1 0", "2 3\n5\n1 1 0\n1 2 10\n1 3 20\n2 1 30\n2 3 40" ], "output": [ "No", "Yes", "Yes", "No", "No" ] }
{ "input": [ "2 4\n4\n1 1 0\n1 2 10\n2 1 30\n2 2 20", "2 2\n3\n1 1 0\n1 2 10\n2 1 22", "3 3\n4\n1 2 0\n1 3 10\n3 1 10\n3 3 20", "2 2\n3\n2 1 20\n1 2 10\n2 1 0", "2 4\n4\n1 1 0\n2 2 10\n2 1 30\n2 2 20", "3 3\n4\n1 2 1\n1 3 10\n3 1 10\n3 3 20", "3 3\n4\n1 2 1\n1 3 10\n3 2 10\n3 3 20", "3...
p00083 Era Name Transformation
Create a program that converts the date expressed in the Christian era to the Japanese calendar using the era name and outputs the date. The input is three integers, as shown in the example, in the order year, month, and day. Convert this as shown in the sample output. If the date before the Meiji era is entered, pleas...
{ "input": [], "output": [] }
{ "input": [ "2005 9 3\n1868 12 2\n1868 9 7" ], "output": [ "heisei 17 9 3\nmeiji 1 12 2\npre-meiji" ] }
{ "input": [ "2005 5 3\n1868 12 2\n1868 9 7", "2005 5 3\n1868 12 2\n1868 9 9", "2005 7 3\n1868 12 2\n1868 9 9", "2005 9 3\n1868 12 3\n1868 9 7", "2005 5 3\n1703 12 2\n1868 9 7", "2005 5 3\n411 12 2\n1868 9 9", "2005 5 6\n1703 12 2\n1868 9 7", "2005 9 3\n1868 9 3\n359 9 7", "2005 5 ...
p00215 Pachimon Creature
A popular game in a certain country, Pachimon Creature, has been remade and released in Japan. If you love games, after playing this game many times, you've come to think about how you can clear it the fastest. However, no matter how much you think about it, you didn't know the fastest way to capture it, so you decided...
{ "input": [], "output": [] }
{ "input": [ "6 6\nS.1..4\n3..5..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0" ], "output": [ "2 10\nNA" ] }
{ "input": [ "6 6\nS.1..4\n5..3..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0", "6 6\nS.1..4\n3..5..\n..4.1.\n4...5.\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0", "6 6\nS.1..4\n4..5..\n..4.1.\n4....5\n.2.32.\n5.1..G\n3 2\n...\nS.G\n0 0", "6 6\nS.1..4\n3..5..\n..4.1.\n4...5.\n.3.32.\nG..1.5\n3 2\n...\n...
p00375 Celsius and Fahrenheit
In Japan, temperature is usually expressed using the Celsius (℃) scale. In America, they used the Fahrenheit (℉) scale instead. $20$ degrees Celsius is roughly equal to $68$ degrees Fahrenheit. A phrase such as "Today’s temperature is $68$ degrees" is commonly encountered while you are in America. A value in Fahrenhei...
{ "input": [], "output": [] }
{ "input": [ "68", "50" ], "output": [ "19", "10" ] }
{ "input": [ "82", "60", "116", "85", "162", "51", "149", "96", "238", "65", "311", "558", "633", "1080", "1303", "2092", "3794", "6199", "10347", "9393", "10699", "19116", "1106", "355", "642", "390", "298", ...
p00593 JPEG Compression
The fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simple pro- gram. You are given single integer N , and you must output zigzag path on a matrix where si...
{ "input": [], "output": [] }
{ "input": [ "3\n4\n0" ], "output": [ "Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6 7\n 3 5 8 13\n 4 9 12 14\n 10 11 15 16" ] }
{ "input": [ "3\n7\n0", "3\n3\n0", "3\n0\n0", "3\n1\n0", "3\n2\n0", "3\n-1\n0", "3\n5\n0", "3\n8\n0", "3\n6\n0", "3\n9\n0", "3\n0\n-1", "3\n0\n1", "3\n0\n-2", "3\n0\n2", "3\n0\n-4", "3\n0\n-5", "3\n0\n3", "3\n0\n-3", "3\n0\n4", "3\n0\n8",...
p00729 Analyzing Login/Logout Records
You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet. You are asked to w...
{ "input": [], "output": [] }
{ "input": [ "4 2\n10\n775 1 1 1\n780 4 2 1\n790 2 1 1\n800 2 1 0\n810 3 1 1\n820 1 1 0\n825 3 1 0\n860 1 1 1\n870 4 2 0\n880 1 1 0\n1\n780 870 1\n13 15\n12\n540 12 13 1\n600 12 13 0\n650 13 15 1\n660 12 15 1\n665 11 13 1\n670 13 15 0\n675 11 13 0\n680 12 15 0\n1000 11 14 1\n1060 12 14 1\n1060 11 14 0\n1080 12 14...
{ "input": [ "4 2\n10\n775 1 1 1\n780 4 2 1\n790 2 1 1\n800 2 1 0\n810 3 1 1\n820 1 1 0\n825 3 1 0\n860 1 1 1\n870 4 2 0\n880 1 1 0\n1\n780 870 1\n13 15\n12\n540 12 13 1\n600 12 13 0\n650 13 15 1\n660 12 15 1\n665 11 13 1\n670 13 15 0\n675 11 13 0\n680 12 15 0\n1000 11 14 1\n1060 12 14 1\n1060 11 14 0\n1080 12 14...
p00869 Traveling Cube
On a small planet named Bandai, a landing party of the starship Tadamigawa discovered colorful cubes traveling on flat areas of the planet surface, which the landing party named beds. A cube appears at a certain position on a bed, travels on the bed for a while, and then disappears. After a longtime observation, a scie...
{ "input": [], "output": [] }
{ "input": [ "10 5\nkkkkkwwwww\nw#wwwrwwww\nwwwwbgwwww\nkwwmcwwwkk\nkkwywwwkkk\nrgbcmy\n10 5\nkkkkkkkkkk\nk#kkkkkkkk\nkwkkkkkwwk\nkcmyrgbwwk\nkwwwwwwwwk\ncmyrgb\n10 5\nkkkkkkkkkk\nk#kkkkkkkk\nkwkkkkkwkk\nkcmyrgbwwk\nkwwwwwwwwk\ncmyrgb\n0 0" ], "output": [ "9\n49\nunreachable" ] }
{ "input": [ "10 5\nkkkkkwwwww\nw#wwwrwwww\nwwwwbgwwww\nkwwmcwwwkk\nkkwywwwkkk\nrgbcmy\n10 5\nkkkkkkkkkk\nk#kkkkkkkk\nkwkkkkkwwk\nkcmyrgbwwk\nkwwwwwwwwk\ncmyrgb\n10 5\nkkkkkkkkkk\nk#kkkkkkkk\nkwkkkkkwkk\nkcmyrgbwwk\nkwwwwwwwwk\ncnyrgb\n0 0", "10 5\nkkkkkwwwww\nw#wwwrwwww\nwwwwbgwwww\nkwwmcwwwkk\nkkwywwwkkk\nr...
p01000 Independent Research
Problem I chose creature observation as the theme of my free study during the summer vacation and purchased a creature observation kit. This creature prefers to live in a three-dimensional grid-like space. Only one animal can be placed in each cell. It repeats birth and death every day according to the surrounding en...
{ "input": [], "output": [] }
{ "input": [ "5\n00000\n01010\n00000\n00100\n00000\n\n00000\n01010\n00000\n01010\n00000\n\n00000\n00100\n00000\n01010\n00000\n\n00000\n01010\n00000\n00100\n00000\n\n00000\n00000\n00100\n00000\n00000\n\n1 2\n2 3 4\n4\n01110\n00100\n00100\n00100\n01110\n\n01110\n10001\n10000\n10001\n01110\n\n11111\n10001\n11111\n10...
{ "input": [ "5\n00000\n01010\n00000\n00100\n00000\n\n00000\n01010\n00000\n01010\n00000\n\n00000\n00100\n00000\n01010\n00000\n\n00000\n01010\n00000\n00100\n00000\n\n00000\n00000\n00100\n00000\n00000\n\n1 2\n2 3 4\n4\n01110\n00100\n00100\n00100\n01110\n\n01110\n10001\n10000\n10001\n01110\n\n11111\n10001\n11111\n10...
p01132 Make Purse Light
Mr. Bill is shopping at the store. There are some coins in his wallet (10-yen coins, 50-yen coins, 100-yen coins, 500-yen coins), but he is now trying to consume as much of this coin as possible. In other words, by paying for the goods with an appropriate number of coins, we are trying to minimize the total number of c...
{ "input": [], "output": [] }
{ "input": [ "160\n1 1 2 0\n160\n1 0 2 10\n0" ], "output": [ "10 1\n50 1\n100 1\n\n10 1\n100 2" ] }
{ "input": [ "160\n1 1 4 0\n160\n1 0 2 10\n0", "160\n1 1 4 0\n58\n2 0 4 10\n0", "160\n1 1 4 0\n46\n2 0 4 10\n0", "160\n1 1 4 0\n160\n0 0 2 10\n0", "160\n1 1 2 0\n160\n1 -1 1 10\n0", "160\n1 1 4 0\n109\n2 0 7 10\n0", "160\n0 1 4 0\n160\n0 1 2 10\n0", "160\n1 1 4 0\n46\n2 1 1 10\n0", ...
p01271 Mirror Cave
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room. For convenience, each of the two rooms is considered to have W × H cells arranged in a grid pattern. The outside of the room is s...
{ "input": [], "output": [] }
{ "input": [ "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .%.\n4 1\nL.%. %..R\n0 0" ], "output": [ "Yes\nYes\nNo" ] }
{ "input": [ "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0", "5 5\n%#... .%.#.\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n...#L R#...\n3 2\n.L. .R#\n%.. .&.\n4 1\nL.%. %..R\n0 0", "5 5\n%#... ...#%\n.#.#. .#.#.\n.#.#. .#.#.\n.#.#. .#.#.\n......
p01441 Full Text Search
Mr. Don is an administrator of a famous quiz website named QMACloneClone. The users there can submit their own questions to the system as well as search for question texts with arbitrary queries. This search system employs bi-gram search method. The bi-gram search method introduces two phases, namely preprocessing and...
{ "input": [], "output": [] }
{ "input": [ "a\nQMAClone\nacmicpc\nabcdefgha\nabcdefgdhbi\nabcbcd", "a\nQMAClone\nacmicpc\nabcdefgha\nabcdefgdhbi\nabcbcd\n#" ], "output": [ "No Results\n9\n7\n9\n12\n6", "No Results\n9\n7\n9\n12\n6" ] }
{ "input": [ "`\nQMAClone\nacmicpc\nabcdefgha\nabcdefgdhbi\nabcbcd", "`\nQMAClone\nacmicpc\nabcdefgha\nabcdefgdibi\nabcbcd", "`\nQMAClone\nacmicpc\nabcdefhha\nabcdefgdibi\nabbbcd", "a\nRMAClone\nmcaicpc\nahgfedcba\nabcdefgdhbi\ndbcbca\n$", "`\nQLAClone\naccimpb\nabcdefhha\nbbcdefgeibi\nabcbcc", ...
p01590 Trading Ship
You are on board a trading ship as a crew. The ship is now going to pass through a strait notorious for many pirates often robbing ships. The Maritime Police has attempted to expel those pirates many times, but failed their attempts as the pirates are fairly strong. For this reason, every ship passing through the stra...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p01747 Snake
Sunake is in the form of a polygonal line consisting of n vertices (without self-intersection). First, Sunake-kun's i-th vertex is at (xi, yi). You can move continuously by translating or rotating, but you cannot deform (change the length of the polygonal line or the angle between the two line segments). y = 0 is the w...
{ "input": [], "output": [] }
{ "input": [ "4\n0 1\n1 1\n1 2\n2 2", "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 141\n19 124\n0 156\n22 183" ], "output": [ "Possible", "Impossible" ] }
{ "input": [ "4\n0 1\n1 1\n1 2\n3 2", "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 156\n22 183", "4\n0 2\n1 1\n1 2\n3 2", "11\n63 106\n87 143\n102 132\n115 169\n74 145\n41 177\n56 130\n28 102\n19 124\n0 294\n22 183", "4\n0 2\n1 1\n2 2\n3 2", "11\n63 106\n87 ...
p01887 Pipe Fitter and the Fierce Dogs
Example Input 5 5 4 6 3 2 4 2 5 2 1 4 3 4 5 4 Output 6
{ "input": [], "output": [] }
{ "input": [ "5 5 4\n6\n3 2\n4 2\n5 2\n1 4\n3 4\n5 4" ], "output": [ "6" ] }
{ "input": [ "9 5 4\n6\n3 2\n4 2\n5 2\n1 4\n3 4\n5 4", "9 5 5\n6\n3 2\n4 2\n5 2\n1 4\n3 4\n5 4", "9 5 10\n6\n3 1\n4 2\n5 2\n1 4\n3 4\n7 4", "9 5 6\n6\n3 2\n4 4\n6 1\n2 5\n3 4\n5 4", "9 7 5\n6\n3 2\n7 4\n6 1\n2 7\n3 4\n5 4", "9 5 9\n6\n3 2\n4 2\n5 2\n1 4\n3 4\n5 5", "11 5 6\n0\n10 1\n3 0\n1...
p02024 City
J: City Santa decides to deliver a present to a city. The city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel. The $ X $ th section from the north and the $ Y $ th section from the west are represented by $ (X, Y) $. Santa mov...
{ "input": [], "output": [] }
{ "input": [ "4 5 2 3" ], "output": [ "Yes" ] }
{ "input": [ "4 9 2 3", "3 1 3 12", "4 1 2 3", "2 1 2 3", "2 1 2 4", "3 1 2 4", "3 2 2 4", "3 4 2 4", "4 4 2 4", "4 3 2 4", "4 3 2 6", "3 3 2 6", "3 1 2 6", "3 1 2 12", "1 1 3 12", "1 1 3 7", "1 2 3 7", "1 2 5 7", "2 2 5 7", "2 2 0 7", ...
p02166 Cyclic Shift Sort
Problem Given a permutation of length $ N $ $ P = \\ {P_1, P_2, \ ldots, P_N \\} $ and the integer $ K $. Determine if the permutation $ P $ can be monotonically increased by repeating the following operation any number of times $ 0 $ or more. * Choose the integer $ x \ (0 \ le x \ le N-K) $. Patrol right shift aroun...
{ "input": [], "output": [] }
{ "input": [ "3 2\n1 2 3", "3 3\n3 2 1", "3 3\n2 3 1" ], "output": [ "Yes", "No", "Yes" ] }
{ "input": [ "3 2\n1 2 5", "3 1\n3 2 1", "0 3\n2 3 1", "0 4\n2 3 1", "0 3\n3 3 1", "3 2\n2 2 3", "3 2\n2 2 5", "0 3\n4 3 1", "0 4\n3 3 1", "0 3\n3 0 1", "0 2\n2 2 3", "0 2\n4 3 1", "0 3\n3 1 1", "0 2\n2 4 3", "0 2\n6 3 1", "0 3\n3 2 1", "0 2\n3 4 3",...
p02307 Circumscribed Circle of a Triangle
Write a program which prints the central coordinate ($cx$,$cy$) and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points ($x_1$, $y_1$), ($x_2$, $y_2$) and ($x_3$, $y_3$) on the plane surface. Constraints * $-10000 \leq x_i, y_i \leq 10000$ * The three points are not on the same...
{ "input": [], "output": [] }
{ "input": [ "1 -2\n3 2\n-2 0", "0 3\n4 0\n0 0" ], "output": [ "0.62500000000000000000 0.68750000000000000000 2.71353666826155124291", "2.00000000000000000000 1.50000000000000000000 2.50000000000000000000" ] }
{ "input": [ "1 -2\n1 2\n-2 0", "0 3\n4 -1\n0 0", "1 -2\n1 2\n-2 -1", "1 3\n4 -1\n0 0", "1 -3\n1 2\n-2 -1", "2 3\n4 -1\n0 0", "1 -3\n1 2\n-4 -1", "3 3\n4 -1\n0 0", "1 -3\n1 3\n-4 -1", "1 3\n4 -1\n1 0", "1 -6\n1 3\n-4 -1", "1 3\n4 0\n1 0", "1 -6\n2 3\n-4 -1", "0 ...
p02455 Set: Search
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique. * insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation. * find($x$): Report the number of $x$ in $S$ (0 or 1). Constraints * $1 \leq q \leq 200,000$ * $0 \leq ...
{ "input": [], "output": [] }
{ "input": [ "7\n0 1\n0 2\n0 3\n0 2\n0 4\n1 3\n1 10" ], "output": [ "1\n2\n3\n3\n4\n1\n0" ] }
{ "input": [ "7\n0 0\n0 2\n0 3\n0 2\n0 4\n1 3\n1 10", "7\n0 0\n0 2\n1 3\n0 2\n0 4\n1 3\n1 10", "7\n0 0\n1 2\n1 3\n0 2\n0 4\n1 3\n1 10", "7\n0 0\n1 2\n1 0\n0 1\n0 4\n1 3\n1 10", "7\n0 1\n0 2\n0 3\n0 0\n0 4\n1 3\n1 10", "7\n0 0\n1 2\n1 3\n0 0\n0 4\n1 3\n1 10", "7\n0 2\n0 2\n0 3\n0 0\n0 4\n1 ...
chbllns
Today a plane was hijacked by a maniac. All the passengers of the flight are taken as hostage. Chef is also one of them. He invited one of the passengers to play a game with him. If he loses the game, he will release all the passengers, otherwise he will kill all of them. A high risk affair it is. Chef volunteered fo...
{ "input": [], "output": [] }
{ "input": [ "2\n3 3 3\n1\n3 3 3\n2" ], "output": [ "1\n4\n" ] }
{ "input": [ "2\n6 3 3\n1\n3 3 3\n2", "2\n0 0 3\n2\n3 3 3\n2", "2\n6 0 3\n2\n3 3 3\n2", "2\n1 0 3\n1\n3 3 0\n2", "2\n0 0 3\n2\n3 3 4\n0", "2\n6 0 3\n3\n3 3 3\n2", "2\n0 0 3\n2\n3 4 0\n2", "2\n6 0 3\n3\n3 3 3\n4", "2\n1 1 3\n1\n0 3 0\n2", "2\n0 0 5\n2\n3 3 6\n4", "2\n0 1 3\n...
detdet
Consider a k x k matrix M with entries as the following: M(i, i) = 1 (Diagonal is all 1s) M(i, i+1) = 1 (Diagonal just above the main diagonal is all 1s) M(i, i-1) = -1 (Diagonal just below the main diagonal is all -1s) All the other elements of M are 0 Example for k = 4 would be: 1 1 0 0 -1 1 1 0 0 -1 1 1 0 0 -1 ...
{ "input": [], "output": [] }
{ "input": [ "5\n1\n2\n3\n4\n5" ], "output": [ "1\n3\n5\n8\n13" ] }
{ "input": [], "output": [] }
iitk2p01
Nowadays out little Chef is traveling a lot. While traveling, on one unlucky day, he lost into a mysterious country. Nearby people handed little Chef to the King for investigations. After proper investigation they found little Chef innocent. Little Chef had no money with him to return to his country Byteland, so the Ki...
{ "input": [], "output": [] }
{ "input": [ "2\n12 2\n18 3" ], "output": [ "2\n2" ] }
{ "input": [], "output": [] }
ncraas
To test a new cloud computing service, you decide to write a program that generates the Pascal Triangle in a distributed fashion. You wish to estimate the amount of network traffic that would be expected between nodes. Since the nodes exchange the computed values in base 10, you want to know the number of digits in the...
{ "input": [], "output": [] }
{ "input": [ "20\n5 2\n3 3\n5 4\n2 2\n4 1\n5 5\n2 1\n4 4\n3 1\n3 0\n1 1\n2 0\n3 2\n5 3\n4 2\n4 0\n5 1\n4 3\n1 0\n5 0" ], "output": [ "2 4\n1 1\n1 3\n1 1\n1 3\n1 1\n1 2\n1 1\n1 2\n1 1\n1 1\n1 1\n1 2\n2 4\n1 3\n1 1\n1 3\n1 3\n1 1\n1 1" ] }
{ "input": [ "20\n5 2\n3 3\n5 4\n2 2\n4 1\n5 5\n2 1\n4 4\n3 1\n3 0\n1 1\n2 0\n3 2\n5 3\n3 2\n4 0\n5 1\n4 3\n1 0\n5 0", "20\n5 2\n3 3\n5 4\n2 2\n4 1\n5 5\n2 1\n4 4\n3 1\n3 0\n2 1\n2 0\n3 2\n5 3\n3 2\n4 0\n5 1\n4 3\n1 0\n5 0", "20\n5 2\n3 3\n5 4\n2 2\n4 1\n5 5\n2 1\n4 1\n3 1\n3 0\n2 1\n2 0\n3 2\n5 3\n3 2\n4...
rrsum
Andrii is good in Math, but not in Programming. He is asking you to solve following problem: Given an integer number N and two sets of integer A and B. Let set A contain all numbers from 1 to N and set B contain all numbers from N + 1 to 2N. Multiset C contains all sums a + b such that a belongs to A and b belongs to B...
{ "input": [], "output": [] }
{ "input": [ "3 5\n6\n2\n9\n7\n5" ], "output": [ "2\n0\n1\n3\n1\n" ] }
{ "input": [ "3 5\n6\n2\n9\n10\n5", "3 5\n6\n2\n9\n7\n0", "3 5\n6\n2\n8\n7\n0", "3 5\n6\n1\n8\n10\n9", "3 5\n5\n2\n8\n10\n9", "3 5\n5\n2\n9\n7\n0", "3 5\n6\n1\n9\n6\n5", "3 5\n6\n2\n8\n5\n0", "3 5\n3\n2\n8\n10\n9", "6 5\n5\n2\n9\n7\n0", "3 5\n6\n1\n9\n6\n3", "5 5\n6\n2\...
wsc
The following is an easy game that the setter of this problem played when he was 8: A boatman, a wolf, a sheep, and a cabbage are on the bank of a river. They have a small boat that is capable of carrying the boatman and at most one other animal/item with him. However, if left alone by the boatman, the wolf can eat the...
{ "input": [], "output": [] }
{ "input": [ "2\n3 2\n1 2\n2 3\n3 3\n1 2\n2 3\n1 3" ], "output": [ "YES\nNO\n" ] }
{ "input": [ "2\n3 2\n1 2\n2 3\n3 3\n1 2\n2 3\n2 3", "2\n4 2\n1 2\n4 3\n3 3\n1 2\n3 3\n2 2", "2\n3 2\n1 2\n2 5\n3 2\n1 2\n2 3\n1 1", "2\n7 4\n1 2\n2 3\n4 3\n1 2\n2 0\n2 4", "2\n4 2\n1 2\n2 3\n3 3\n1 2\n2 3\n2 3", "2\n3 2\n1 2\n1 3\n3 3\n1 2\n2 3\n2 3", "2\n4 2\n1 2\n2 3\n3 3\n1 2\n2 3\n2 1...
1156_E. Special Segments of Permutation
You are given a permutation p of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once). Let's call some subsegment p[l, r] of this permutation special if p_l + p_r = max _{i = l}^{r} p_i. Please calculate the number of special subsegments. Input The first line contain...
{ "input": [], "output": [] }
{ "input": [ "3\n1 3 2\n", "5\n3 4 1 5 2\n" ], "output": [ "1", "2" ] }
{ "input": [ "3\n2 3 1\n", "3\n3 2 1\n", "5\n4 5 1 3 2\n", "3\n2 1 3\n", "3\n1 2 3\n", "5\n5 4 1 3 2\n", "5\n3 4 2 5 1\n", "3\n3 1 2\n" ], "output": [ "1\n", "0\n", "2\n", "0\n", "0\n", "1\n", "1\n", "0\n" ] }
1279_C. Stack of Presents
Santa has to send presents to the kids. He has a large stack of n presents, numbered from 1 to n; the topmost present has number a_1, the next present is a_2, and so on; the bottom present has number a_n. All numbers are distinct. Santa has a list of m distinct presents he has to send: b_1, b_2, ..., b_m. He will send...
{ "input": [], "output": [] }
{ "input": [ "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n3 1\n" ], "output": [ "5\n8\n" ] }
{ "input": [ "2\n3 3\n3 1 2\n3 2 1\n7 2\n4 1 7 3 4 5 6\n3 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n6 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 4 5 6\n4 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 5 7 6\n2 1\n", "2\n3 3\n3 1 2\n3 2 1\n7 2\n2 1 7 3 5 5 6\n1 2\n", "2\n3 3\n3 1 2\n3 2 1\n7 2...
1341_C. Nastya and Strange Generator
Denis was very sad after Nastya rejected him. So he decided to walk through the gateways to have some fun. And luck smiled at him! When he entered the first courtyard, he met a strange man who was selling something. Denis bought a mysterious item and it was... Random permutation generator! Denis could not believed hi...
{ "input": [], "output": [] }
{ "input": [ "5\n5\n2 3 4 5 1\n1\n1\n3\n1 3 2\n4\n4 2 3 1\n5\n1 5 2 4 3\n" ], "output": [ "Yes\nYes\nNo\nYes\nNo\n" ] }
{ "input": [ "5\n5\n2 3 4 5 1\n1\n1\n3\n1 3 2\n4\n4 3 2 1\n5\n1 5 2 4 3\n", "5\n5\n4 3 2 5 1\n1\n1\n3\n1 3 2\n4\n4 3 2 1\n5\n1 5 2 4 3\n" ], "output": [ "Yes\nYes\nNo\nYes\nNo\n", "No\nYes\nNo\nYes\nNo\n" ] }
1499_C. Minimum Grid Path
Let's say you are standing on the XY-plane at point (0, 0) and you want to reach point (n, n). You can move only in two directions: * to the right, i. e. horizontally and in the direction that increase your x coordinate, * or up, i. e. vertically and in the direction that increase your y coordinate. In othe...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n13 88\n3\n2 3 1\n5\n4 3 2 1 4\n" ], "output": [ "\n202\n13\n19\n" ] }
{ "input": [ "3\n2\n13 88\n3\n2 3 0\n5\n4 3 2 1 4\n", "3\n2\n13 88\n3\n2 3 1\n5\n4 3 3 1 4\n", "3\n2\n13 100\n3\n2 3 0\n5\n4 3 2 1 5\n", "3\n2\n13 88\n3\n2 3 1\n5\n4 3 3 2 4\n", "3\n2\n13 100\n3\n2 3 0\n5\n4 3 1 1 5\n", "3\n2\n13 88\n3\n2 3 2\n5\n4 3 3 2 4\n", "3\n2\n13 100\n3\n2 3 0\n5\n4...
1550_A. Find The Array
Let's call an array a consisting of n positive (greater than 0) integers beautiful if the following condition is held for every i from 1 to n: either a_i = 1, or at least one of the numbers a_i - 1 and a_i - 2 exists in the array as well. For example: * the array [5, 3, 1] is beautiful: for a_1, the number a_1 - 2...
{ "input": [], "output": [] }
{ "input": [ "4\n1\n8\n7\n42\n" ], "output": [ "1\n3\n3\n7\n" ] }
{ "input": [ "4\n1\n12\n7\n42\n", "4\n1\n1\n7\n42\n", "4\n1\n12\n7\n35\n", "4\n1\n3\n7\n42\n", "4\n1\n1\n7\n27\n", "4\n1\n12\n13\n35\n", "4\n1\n3\n12\n42\n", "4\n1\n2\n7\n27\n", "4\n2\n3\n7\n27\n", "4\n2\n1\n9\n27\n", "4\n1\n9\n7\n42\n", "4\n1\n10\n1\n42\n", "4\n1\n...
316_F2. Suns and Rays
Smart Beaver became interested in drawing. He draws suns. However, at some point, Smart Beaver realized that simply drawing suns is boring. So he decided to design a program that will process his drawings. You are given a picture drawn by the beaver. It will have two colors: one for the background and one for the suns ...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
coins-game
Chintu and Mintu are good friends and they have so many coins of different amount so they decided to play a game using a stack consisting of N coins. In this game, anyone can alternatively remove 1, 2 or 3 from the top, and the amount on the removed coins are added to their score. Players have to play so that they o...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n58 952 23 0 12\n5\n0 1 1 1 999\n\nSAMPLE" ], "output": [ "1033\n999" ] }
{ "input": [ "2\n5\n58 1641 23 0 12\n5\n0 1 1 1 999\n\nSAMPLE", "2\n5\n55 1641 23 0 12\n5\n0 1 1 1 999\n\nSAMPLE", "2\n5\n55 2727 23 0 12\n5\n0 1 1 1 999\n\nSAMPLE", "2\n5\n58 952 23 0 5\n5\n0 1 1 1 999\n\nSAMPLE", "2\n5\n58 1641 8 0 12\n5\n0 1 1 1 999\n\nSAMPLE", "2\n5\n55 2727 23 0 12\n5\n0 ...
quantitative-coefficient
Russian Translation Available It is very important to understand relationship between variables to draw the right conclusion from a statistical analysis. The relationship between variables determines how the right conclusions are reached. Without an understanding of this, you can fall into many pitfalls that accompany...
{ "input": [], "output": [] }
{ "input": [ "1\n3 3\n1 2 1234567\n2 3 2345678\n1 3 3456789\n\n\nSAMPLE" ], "output": [ "896631161" ] }
{ "input": [ "1\n3 3\n1 2 1234567\n2 3 2345678\n1 3 5445536\n\n\nSAMPLE", "1\n3 3\n1 2 999253\n2 3 2345678\n1 2 3456789\n\n\nSAMPLE", "1\n3 0\n1 2 999253\n2 3 2345678\n1 2 3456789\n\n\nSAMPLE", "1\n3 3\n1 2 999253\n2 1 2345678\n1 2 2643189\n\n\nSAMPLE", "1\n3 3\n1 2 999253\n2 1 2345678\n1 2 376749...
p02662 AtCoder Beginner Contest 169 - Knapsack for All Subsets
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N and another positive integer S. For a non-empty subset T of the set \\{1, 2, \ldots , N \\}, let us define f(T) as follows: * f(T) is the number of different non-empty subsets \\{x_1, x_2, \ldots , x_k \\} of T such that A_{x_1}+A_{x_2}+\cdots +A_{x_k}...
{ "input": [], "output": [] }
{ "input": [ "5 8\n9 9 9 9 9", "3 4\n2 2 4", "10 10\n3 1 4 1 5 9 2 6 5 3" ], "output": [ "0", "6", "3296" ] }
{ "input": [ "5 8\n9 15 9 9 9", "10 10\n3 1 4 1 5 9 2 4 5 3", "3 4\n2 2 1", "10 10\n3 1 7 1 5 9 2 6 5 3", "10 20\n3 1 4 1 5 9 2 4 5 3", "10 10\n3 1 7 1 5 13 2 6 5 3", "10 20\n3 1 4 1 5 9 4 4 5 3", "10 10\n3 1 7 1 10 13 2 6 5 3", "10 9\n3 1 4 1 5 9 4 4 5 3", "10 10\n3 1 7 1 13 1...
p02791 AtCoder Beginner Contest 152 - Low Elements
Given is a permutation P_1, \ldots, P_N of 1, \ldots, N. Find the number of integers i (1 \leq i \leq N) that satisfy the following condition: * For any integer j (1 \leq j \leq i), P_i \leq P_j. Constraints * 1 \leq N \leq 2 \times 10^5 * P_1, \ldots, P_N is a permutation of 1, \ldots, N. * All values in input are ...
{ "input": [], "output": [] }
{ "input": [ "8\n5 7 4 2 6 8 1 3", "4\n4 3 2 1", "6\n1 2 3 4 5 6", "5\n4 2 5 1 3", "1\n1" ], "output": [ "4", "4", "1", "3", "1" ] }
{ "input": [ "6\n1 2 3 4 5 9", "5\n3 2 5 1 3", "6\n1 2 3 0 9 9", "8\n5 14 4 2 6 8 1 3", "8\n5 7 4 2 6 8 1 0", "6\n1 2 3 3 5 9", "6\n1 2 3 6 5 9", "6\n1 2 3 6 9 9", "6\n1 4 3 4 5 6", "5\n4 2 5 1 4", "1\n0", "6\n1 2 3 4 5 4", "5\n3 2 5 0 3", "6\n1 2 2 3 5 9", ...
p02927 Japanese Student Championship 2019 Qualification - Takahashi Calendar
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 *...
{ "input": [], "output": [] }
{ "input": [ "15 40", "1 1", "12 31" ], "output": [ "10", "0", "5" ] }
{ "input": [ "15 38", "0 1", "16 38", "16 57", "16 94", "12 94", "12 28", "19 28", "6 27", "12 25", "9 48", "12 39", "26 38", "24 94", "6 42", "30 32", "14 68", "5 37", "31 48", "22 79", "21 38", "21 94", "24 51", "18 58",...
p03062 AtCoder Beginner Contest 125 - Flipping Signs
There are N integers, A_1, A_2, ..., A_N, arranged in a row in this order. You can perform the following operation on this integer sequence any number of times: Operation: Choose an integer i satisfying 1 \leq i \leq N-1. Multiply both A_i and A_{i+1} by -1. Let B_1, B_2, ..., B_N be the integer sequence after your ...
{ "input": [], "output": [] }
{ "input": [ "11\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000", "5\n10 -4 -8 -11 3", "3\n-10 5 -4" ], "output": [ "10000000000", "30", "19" ] }
{ "input": [ "11\n-1000000000 1000000000 -364513171 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000", "5\n10 -4 -8 -11 5", "3\n-10 5 0", "11\n-1000000000 1000000000 -364513171 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000100", "5\n...
p03206 AtCoder Beginner Contest 115 - Christmas Eve Eve Eve
In some other world, today is December D-th. Write a program that prints `Christmas` if D = 25, `Christmas Eve` if D = 24, `Christmas Eve Eve` if D = 23 and `Christmas Eve Eve Eve` if D = 22. Constraints * 22 \leq D \leq 25 * D is an integer. Input Input is given from Standard Input in the following format: D ...
{ "input": [], "output": [] }
{ "input": [ "25", "22" ], "output": [ "Christmas", "Christmas Eve Eve Eve" ] }
{ "input": [ "13", "18", "4", "8", "6", "0", "-1", "-2", "1", "2", "3", "7", "5", "-4", "-3", "-6", "-10", "-7", "-8", "10", "9", "11", "19", "15", "-5", "14", "12", "17", "16", "21", "-12", ...