name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
856_E. Satellites | Real Cosmic Communications is the largest telecommunication company on a far far away planet, located at the very edge of the universe. RCC launches communication satellites.
The planet is at the very edge of the universe, so its form is half of a circle. Its radius is r, the ends of its diameter are points A and B. T... | {
"input": [],
"output": []
} | {
"input": [
"5 8\n1 -5 8\n1 -4 8\n1 -3 8\n1 2 7\n3 1 3\n2 2\n3 1 3\n3 3 4\n"
],
"output": [
"NO\nYES\nYES\n"
]
} | {
"input": [
"5 8\n1 -5 8\n1 -4 8\n1 -3 8\n1 2 7\n3 1 3\n2 2\n1 1 3\n3 3 4\n",
"5 8\n1 -5 8\n1 -4 8\n1 -3 8\n1 0 7\n3 1 3\n2 2\n3 1 3\n3 3 4\n",
"5 8\n1 -5 8\n1 -4 0\n1 -3 8\n1 0 7\n3 1 3\n2 2\n3 1 3\n3 3 4\n",
"5 6\n1 -5 8\n1 -4 0\n1 -3 8\n1 0 7\n3 1 3\n2 2\n3 1 3\n3 3 4\n",
"5 6\n1 -5 8\n1 -4 8\... |
count-x | Each digit of a number is represented by a cluster of adjacent X, with spaces between neighboring clusters. The digit is determined by the number of X in the cluster. For example, the number 243 would be represented by the following pattern
-XX-XXXX-XXX-
So to represent 0 the pattern will be -- (2 dashes without a... | {
"input": [],
"output": []
} | {
"input": [
"2\n-XX-XXXX-XXX-\n-XX--XXXX---XXX-\n\nSAMPLE"
],
"output": [
"243\n204003\n"
]
} | {
"input": [
"2\n-XXXXX-X-XXX-\n-XX--XXXX---XXX-\n\nSAMPLE",
"2\n-XXXXX-X-XXX-\n-XXX---XXXX--XX-\n\nSAMPLE",
"2\n-XXX-X-XXXXX-\n-XX--XXXX---XXX-\n\nELPMAS",
"2\n-XXX-X-XXXXX-\n-XXX---XXXX--XX-\n\nELPMAS",
"2\n-XXXXX-X-XXX-\n-XXXX--XXXX---X-\n\nSALPLE",
"2\n-XX-XXXX-XXX-\n-XXX---XXXX--XX-\n\nSA... |
finding-pairs-4 | Given an array A of N numbers, find the number of distinct pairs (i, j) such that j ≥i and A[i] = A[j].
First line of the input contains number of test cases T. Each test case has two lines, first line is the number N, followed by a line consisting of N integers which are the elements of array A.
For each test case p... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n1 2 3 4\n3\n1 2 1\n5\n1 1 1 1 1\n\nSAMPLE"
],
"output": [
"4\n4\n15\n"
]
} | {
"input": [
"3\n4\n1 2 3 4\n3\n1 2 1\n5\n1 1 2 1 1\n\nSAMPLE",
"3\n4\n2 2 3 4\n3\n1 2 1\n5\n1 1 1 1 1\n\nSAMPLE",
"3\n4\n2 2 3 4\n3\n1 2 1\n5\n1 2 1 1 1\n\nSAMPLE",
"3\n4\n2 2 3 4\n3\n1 2 1\n5\n1 1 2 2 1\n\nSAMPLE",
"3\n4\n1 0 3 4\n3\n1 2 1\n5\n1 1 1 1 1\n\nSAMPLE",
"3\n4\n2 2 3 3\n3\n1 2 1\n... |
ranis-job | Rani works at sweet shop and is currently arranging sweets i.e. putting sweets in boxes. There are some boxes which contains sweets initially but they are not full. Rani have to fill boxes completely thereby minimizing the total no. of boxes.
You are given N no. of boxes, their initial amount and total capacity in gram... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n300 525 110\n350 600 115\n6\n1 200 200 199 200 200\n1000 200 200 200 200 200\n\nSAMPLE"
],
"output": [
"2\n1\n"
]
} | {
"input": [
"2\n3\n300 525 110\n350 600 91\n6\n1 200 200 199 200 200\n1000 200 200 200 200 200\n\nSAMPLE",
"2\n3\n300 525 110\n276 600 91\n6\n1 200 200 199 200 126\n1000 200 200 200 200 200\n\nSAMPLE",
"2\n3\n300 525 110\n350 600 115\n6\n1 200 353 199 200 200\n1000 200 200 200 200 200\n\nSAMPLE",
"2\... |
smart-travel-agent | Our smart travel agent, Mr. X's current assignment is to show a group of tourists a distant city. As in all countries, certain pairs of cities are connected by two-way roads. Each pair of neighboring cities has a bus service that runs only between those two cities and uses the road that directly connects them. Each bus... | {
"input": [],
"output": []
} | {
"input": [
"7 10\n1 2 30\n1 3 15\n1 4 10\n2 4 25\n2 5 60\n3 4 40\n3 6 20\n4 7 35\n5 7 20\n6 7 30\n1 7 99\n\nSAMPLE"
],
"output": [
"1 2 4 7\n5\n"
]
} | {
"input": [
"7 10\n1 2 30\n1 3 15\n1 4 10\n2 4 25\n2 5 60\n2 4 40\n3 6 20\n4 7 35\n5 7 20\n6 7 30\n1 7 99\n\nSAMPLE",
"7 10\n1 2 30\n1 3 15\n1 4 10\n2 4 25\n2 5 60\n2 4 40\n3 6 20\n4 7 35\n5 7 20\n6 7 30\n1 7 170\n\nSAMPLE",
"7 10\n1 2 30\n1 3 15\n1 4 10\n2 4 25\n2 5 60\n2 4 40\n3 6 20\n4 7 35\n5 7 20\n6... |
p02556 AtCoder Beginner Contest 178 - Dist Max | There are N points on the 2D plane, i-th of which is located on (x_i, y_i). There can be multiple points that share the same coordinate. What is the maximum possible Manhattan distance between two distinct points?
Here, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 1\n2 4\n3 2",
"2\n1 1\n1 1"
],
"output": [
"4",
"0"
]
} | {
"input": [
"3\n1 2\n2 4\n3 2",
"2\n0 1\n1 1",
"2\n0 0\n1 1",
"3\n1 2\n1 4\n3 1",
"2\n0 -1\n1 2",
"3\n0 0\n1 4\n6 1",
"3\n0 0\n2 4\n6 1",
"3\n0 0\n2 4\n9 1",
"3\n0 0\n2 5\n9 1",
"3\n-1 0\n2 5\n9 0",
"3\n-2 -1\n0 6\n9 0",
"3\n-3 -1\n0 6\n14 0",
"2\n2 0\n-3 -1",
... |
p02687 AtCoder Beginner Contest 166 - A?C | AtCoder Inc. holds a contest every Saturday.
There are two types of contests called ABC and ARC, and just one of them is held at a time.
The company holds these two types of contests alternately: an ARC follows an ABC and vice versa.
Given a string S representing the type of the contest held last week, print the str... | {
"input": [],
"output": []
} | {
"input": [
"ABC"
],
"output": [
"ARC"
]
} | {
"input": [],
"output": []
} |
p02816 AtCoder Beginner Contest 150 - Xor Shift | Given are two sequences a=\\{a_0,\ldots,a_{N-1}\\} and b=\\{b_0,\ldots,b_{N-1}\\} of N non-negative integers each.
Snuke will choose an integer k such that 0 \leq k < N and an integer x not less than 0, to make a new sequence of length N, a'=\\{a_0',\ldots,a_{N-1}'\\}, as follows:
* a_i'= a_{i+k \mod N}\ XOR \ x
F... | {
"input": [],
"output": []
} | {
"input": [
"6\n0 1 3 7 6 4\n1 5 4 6 2 3",
"3\n0 2 1\n1 2 3",
"5\n0 0 0 0 0\n2 2 2 2 2"
],
"output": [
"2 2\n5 5",
"1 3",
"0 2\n1 2\n2 2\n3 2\n4 2"
]
} | {
"input": [
"3\n0 2 1\n2 0 3",
"3\n0 2 1\n2 1 0",
"3\n0 2 0\n1 3 3",
"3\n1 0 1\n2 2 3",
"3\n0 2 1\n0 1 3",
"3\n0 0 1\n2 3 2",
"3\n1 0 1\n2 3 2",
"3\n0 1 1\n3 2 3",
"3\n1 2 1\n3 0 0",
"3\n0 1 0\n0 1 0",
"3\n1 0 1\n0 1 0",
"3\n1 0 0\n0 1 0",
"3\n0 0 0\n0 0 0",
"3... |
p02952 AtCoder Beginner Contest 136 - Uneven Numbers | Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).
Constraints
* 1 \leq N \leq 10^5
Input
Input is given from Standard Input in the following format:
N
Output
Print the number of positive integers less than ... | {
"input": [],
"output": []
} | {
"input": [
"11",
"100000",
"136"
],
"output": [
"9",
"90909",
"46"
]
} | {
"input": [
"2",
"100010",
"36",
"3",
"4",
"1",
"0",
"7",
"6",
"5",
"8",
"179",
"339",
"161",
"312",
"126",
"359",
"164",
"109",
"105",
"107",
"122",
"151",
"154",
"137",
"172",
"108",
"149",
"145",
... |
p03088 AtCoder Beginner Contest 122 - We Like AGC | You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:
* The string does not contain characters other than `A`, `C`, `G` and `T`.
* The string does not contain `AGC` as a substring.
* The condition above cannot be violated by swapping two adjacent chara... | {
"input": [],
"output": []
} | {
"input": [
"4",
"3",
"100"
],
"output": [
"230",
"61",
"388130742"
]
} | {
"input": [
"5",
"6",
"8",
"15",
"12",
"9",
"14",
"7",
"13",
"20",
"10",
"11",
"24",
"26",
"23",
"16",
"25",
"28",
"41",
"36",
"19",
"27",
"18",
"32",
"34",
"22",
"43",
"44",
"50",
"69",
"31",
... |
p03233 AtCoder Grand Contest 028 - Min Cost Cycle | We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i.
In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y).
We will consider a directed cycle in thi... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 5\n4 2\n6 3",
"6\n19 92\n64 64\n78 48\n57 33\n73 6\n95 73",
"4\n1 5\n2 6\n3 7\n4 8"
],
"output": [
"7",
"227",
"10"
]
} | {
"input": [
"3\n2 5\n4 2\n6 3",
"6\n19 92\n64 64\n78 48\n57 33\n142 6\n95 73",
"4\n1 5\n2 6\n0 7\n4 8",
"3\n1 5\n4 4\n6 3",
"6\n19 92\n64 64\n29 48\n57 33\n142 6\n95 73",
"4\n1 5\n0 6\n0 7\n4 8",
"6\n19 92\n64 64\n29 48\n57 33\n142 6\n95 15",
"4\n1 3\n0 6\n0 7\n4 8",
"6\n19 92\n64... |
p03384 AtCoder Regular Contest 095 - Permutation Tree | Takahashi has an ability to generate a tree using a permutation (p_1,p_2,...,p_n) of (1,2,...,n), in the following process:
First, prepare Vertex 1, Vertex 2, ..., Vertex N. For each i=1,2,...,n, perform the following operation:
* If p_i = 1, do nothing.
* If p_i \neq 1, let j' be the largest j such that p_j < p_i. S... | {
"input": [],
"output": []
} | {
"input": [
"15\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n4 8\n4 9\n5 10\n5 11\n6 12\n6 13\n7 14\n7 15",
"6\n1 2\n1 3\n1 4\n1 5\n5 6",
"6\n1 2\n2 3\n3 4\n1 5\n5 6"
],
"output": [
"-1",
"1 2 4 5 3 6",
"1 2 3 4 5 6"
]
} | {
"input": [
"6\n1 2\n2 3\n5 4\n1 5\n5 6",
"15\n1 2\n1 3\n2 4\n2 5\n3 6\n4 7\n4 8\n4 9\n5 10\n5 11\n6 12\n6 13\n7 14\n7 15",
"6\n1 2\n1 3\n1 4\n1 5\n4 6",
"6\n1 3\n2 6\n5 4\n1 5\n5 6",
"6\n1 2\n2 3\n5 4\n1 5\n3 6",
"6\n1 2\n1 3\n1 4\n1 5\n1 6",
"6\n1 2\n1 3\n5 4\n1 5\n5 6",
"6\n1 3\n2 ... |
p03548 AtCoder Beginner Contest 078 - ISU | We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters.
We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two... | {
"input": [],
"output": []
} | {
"input": [
"100000 1 1",
"13 3 1",
"64145 123 456",
"12 3 1",
"64146 123 456"
],
"output": [
"49999",
"3",
"109",
"2",
"110"
]
} | {
"input": [
"100010 1 1",
"8 3 1",
"64145 33 456",
"12 3 2",
"64146 123 44",
"100010 1 0",
"64145 33 653",
"64146 205 44",
"110010 1 0",
"8 3 3",
"64145 20 653",
"108320 205 44",
"111010 1 0",
"64145 20 284",
"108320 406 44",
"42988 20 284",
"189482... |
p03704 AtCoder Regular Contest 075 - Mirrored | For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.
You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?
Constraints
* D is an integer.
* 1 ≤ D < 10^9
In... | {
"input": [],
"output": []
} | {
"input": [
"63",
"864197532",
"75"
],
"output": [
"2",
"1920",
"0"
]
} | {
"input": [
"70",
"27",
"9",
"28269",
"729",
"-18",
"-45",
"-63",
"-54",
"-36",
"-495",
"72",
"-90",
"99",
"-396",
"180",
"198",
"6200730",
"-450",
"-279",
"-270",
"-297",
"-369",
"540",
"1663355059",
"76",
"1... |
p03859 AtCoder Regular Contest 065 - Shuffling | There is a string S of length N consisting of characters `0` and `1`. You will perform the following operation for each i = 1, 2, ..., m:
* Arbitrarily permute the characters within the substring of S starting at the l_i-th character from the left and extending through the r_i-th character.
Here, the sequence l_i i... | {
"input": [],
"output": []
} | {
"input": [
"11 6\n00101000110\n2 4\n2 3\n4 7\n5 6\n6 10\n10 11",
"5 2\n01001\n2 4\n3 5",
"9 3\n110111110\n1 4\n4 6\n6 9"
],
"output": [
"143",
"6",
"26"
]
} | {
"input": [
"5 2\n01001\n1 4\n3 5",
"5 2\n01001\n1 5\n3 5",
"11 6\n00101000110\n2 4\n2 3\n4 4\n5 6\n6 10\n10 11",
"5 2\n01001\n2 4\n5 5",
"9 3\n110111110\n1 4\n4 6\n6 5",
"5 2\n01000\n1 5\n3 5",
"5 2\n01001\n1 4\n5 5",
"5 2\n00000\n1 5\n3 5",
"11 6\n00101000110\n2 4\n2 3\n5 4\n5 6... |
p04024 AtCoder Grand Contest 003 - Fraction of Fractal | Snuke got a grid from his mother, as a birthday present. The grid has H rows and W columns. Each cell is painted black or white. All black cells are 4-connected, that is, it is possible to traverse from any black cell to any other black cell by just visiting black cells, where it is only allowed to move horizontally or... | {
"input": [],
"output": []
} | {
"input": [
"11 15 1000000000000000000\n.....#.........\n....###........\n....####.......\n...######......\n...#######.....\n..##.###.##....\n..##########...\n.###.....####..\n.####...######.\n\n.##..##..##..#",
"3 3 3\n.#.\n###\n#.#",
"3 3 3\n\n.#",
"3 3 3\n.#.\n\n.#"
],
"output": [
"3018119... | {
"input": [
"11 15 1000000000000000000\n.....#.........\n....###........\n....####.......\n...######......\n...#######.....\n..##.###.##....\n..##########...\n.###.....####..\n.####...######.\n\n#..##..##..##.",
"3 3 3\n.$.\n###\n#.#",
"6 3 3\n\n.#",
"11 15 1000000000000000000\n.....#.........\n....#... |
p00108 Operation of Frequency of Appearance | There is a frequency operation in the conversion operation of a finite number sequence. The conversion result of the sequence $ S = \\ {s_1, s_2, ... s_n \\} $ is a sequence of the same length. If the result is $ C = \\ {c_1, c_2, ..., c_n \\} $, then $ c_i $ represents the number of $ s_i $ in the sequence $ S $.
For... | {
"input": [],
"output": []
} | {
"input": [
"10\n4 5 1 1 4 5 12 3 5 4\n0"
],
"output": [
"3\n6 6 4 4 6 6 4 4 6 6"
]
} | {
"input": [
"10\n4 5 1 1 4 5 12 3 6 4\n0",
"10\n4 5 1 1 4 5 12 3 0 5\n0",
"10\n4 5 1 1 3 5 14 3 0 5\n0",
"10\n4 5 1 1 3 10 14 3 0 5\n0",
"10\n4 5 1 0 3 10 14 3 0 5\n0",
"10\n1 5 1 0 3 10 14 3 0 5\n0",
"10\n1 5 1 0 3 4 27 0 0 5\n0",
"10\n2 5 1 0 3 4 27 0 0 5\n0",
"10\n2 5 1 0 3 4 2... |
p00242 Input Candidates | Mobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This records frequently used words and presents words that have the entered letters as initial letters as input candidates. For example, if you usually enter the word "computer" a lot, just ente... | {
"input": [],
"output": []
} | {
"input": [
"1\nben likes bananas the best among many fruits because bananas are sweet and cheap\nb\n1\nwinners get to visit aizu and the university of aizu and make many friends as well\na\n3\nask alex about\nthe answer for the\nassignment on android apps\na\n2\nprogramming is both\na sport and an intellectual ... | {
"input": [
"1\nben likes bananas the best among many fruits because bananas are sweet and cheap\nb\n1\nwinners get to visit aizu and the university of aizu and make many friends as well\na\n3\nask alex about\nthe answer for the\nassignment on android apps\na\n2\nprogramming is both\na spprt and an intellectual ... |
p00423 Card Game | Two players, A and B, play the game using cards with numbers from 0 to 9. First, the two arrange the given n cards face down in a horizontal row. After that, the two players turn their cards face up one by one from the left, and the owner of the card with the larger number takes the two cards. At this time, the sum of ... | {
"input": [],
"output": []
} | {
"input": [
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0"
],
"output": [
"19 8\n20 0\n15 14"
]
} | {
"input": [
"3\n9 1\n5 4\n0 4\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0",
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 0\n1 8\n0",
"3\n9 1\n5 4\n1 4\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0",
"3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 0\n1 1\n0",
"3\n9 1\n5 4\n1 4\n3\n9 1\n6 4\n1 0\n3\n9 1\n5 5\... |
p00618 Course Planning for Lazy Students | The University of Aizu started a new system for taking classes in 2009. Under the new system, compulsory subjects have been abolished, and subjects can be freely selected in consideration of each course.
However, not all courses can be taken unconditionally, and in order to take a specific course, it is necessary to m... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n1 0\n3 2 0 2\n2 0\n2 0\n3 6\n1 0\n3 2 0 2\n2 0\n0 0"
],
"output": [
"2\n3"
]
} | {
"input": [
"4 4\n1 0\n3 2 0 2\n2 0\n2 0\n3 1\n1 0\n3 2 0 2\n2 0\n0 0",
"4 4\n1 0\n3 2 0 2\n2 0\n0 0\n3 1\n1 0\n3 2 0 2\n2 0\n0 0",
"4 4\n1 0\n3 2 0 2\n2 0\n2 0\n3 6\n1 0\n3 2 0 2\n4 0\n0 0",
"4 4\n1 0\n3 2 0 2\n4 0\n0 0\n3 1\n1 0\n3 2 0 2\n2 0\n0 0",
"4 4\n2 0\n3 0 -1 2\n2 1\n0 0\n3 2\n1 0\n3 2 ... |
p00762 Biased Dice | Professor Random, known for his research on randomized algorithms, is now conducting an experiment on biased dice. His experiment consists of dropping a number of dice onto a plane, one after another from a fixed position above the plane. The dice fall onto the plane or dice already there, without rotating, and may rol... | {
"input": [],
"output": []
} | {
"input": [
"4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n8\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n6\n4 6\n1 5\n2 3\n5 3\n2 4\n4 2\n0"
],
"output": [
"0 1 1 0 0 1\n1 0 0 0 1 0\n1 2 2 1 0 0\n2 3 0 0 0 0"
]
} | {
"input": [
"4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n8\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n6\n3 6\n1 5\n2 3\n5 3\n2 4\n4 2\n0",
"4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n8\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 1\n6\n4 6\n1 5\n2 3\n5 3\n2 4\n4 2\n0",
"4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n8\n4 2\n4 2\n4 2\n4 2\... |
p00894 Gift from the Goddess of Programming | The goddess of programming is reviewing a thick logbook, which is a yearly record of visitors to her holy altar of programming. The logbook also records her visits at the altar.
The altar attracts programmers from all over the world because one visitor is chosen every year and endowed with a gift of miracle programmin... | {
"input": [],
"output": []
} | {
"input": [
"14\n04/21 09:00 I 000\n04/21 09:00 I 001\n04/21 09:15 I 002\n04/21 09:30 O 001\n04/21 09:45 O 000\n04/21 10:00 O 002\n04/28 09:00 I 003\n04/28 09:15 I 000\n04/28 09:30 I 004\n04/28 09:45 O 004\n04/28 10:00 O 000\n04/28 10:15 O 003\n04/29 20:00 I 002\n04/29 21:30 O 002\n20\n06/01 09:00 I 001\n06/01 0... | {
"input": [
"14\n04/21 09:00 I 000\n04/21 09:00 I 001\n04/21 09:15 I 002\n04/21 09:30 O 001\n04/21 09:45 O 000\n04/21 10:00 O 002\n04/28 09:00 I 003\n04/28 09:15 I 000\n04/28 09:30 I 004\n04/28 09:45 O 004\n04/28 10:00 O 000\n04/28 10:15 O 003\n04/29 20:00 I 002\n04/29 21:30 O 002\n20\n06/01 09:00 I 001\n06/01 0... |
p01027 WW | Problem
In 19XX, the Allied Forces were formed in n countries. Each country belonging to the Allied Forces has set up one or more bases in the country to protect itself from the invasion of enemy forces and is on the alert. Figure 1 shows an example of an Allied country, where the rectangle represents each country and... | {
"input": [],
"output": []
} | {
"input": [
"3\nchinax 1\nok 1\naustraria 2\n6\nchinax 0 austraria 0 5\naustraria 0 chinax 0 5\naustraria 1 austraria 0 1\nok 0 austraria 0 5\naustraria 0 ok 0 5\nok 0 austraria 1 1\n2\nchinax 0\nok 0",
"2\nusso 2\ncaneda 2\n4\nusso 1 usso 0 1\nusso 0 caneda 0 10\nusso 0 caneda 1 2\ncaneda 1 caneda 0 2\n1\nu... | {
"input": [
"3\nchinax 1\nok 1\naustraria 2\n6\nchinax 0 austraria 0 5\naustraria 0 chinax 0 5\naustraria 1 austraria 0 1\nok 0 austraria 0 5\naustraria 0 ko 0 5\nok 0 austraria 1 1\n2\nchinax 0\nok 0",
"2\nusso 2\ncaneda 2\n4\nusso 1 usso 0 1\nusso 0 caneda 0 10\nusso 0 caneda 1 4\ncaneda 1 caneda 0 2\n1\nu... |
p01158 Rock Man | You were the master craftsman in the stone age, and you devoted your life to carving many varieties of tools out of natural stones. Your works have ever been displayed respectfully in many museums, even in 2006 A.D. However, most people visiting the museums do not spend so much time to look at your works. Seeing the si... | {
"input": [],
"output": []
} | {
"input": [
"3\ngu 20 pa 10\nci 20 gu 10\npa 20 ci 10\n2\ntool 20 tool 10\nproduct 1000 tool 10\n8\nfishhook 21 disk 3\nmill 14 axe 7\nboomerang 56 sundial 28\nflint 35 fishhook 5\naxe 35 flint 14\ndisk 42 disk 2\nsundial 14 disk 7\nhammer 28 mill 7\n0"
],
"ou... | {
"input": [
"3\ngu 20 pa 10\nci 20 gu 7\npa 20 ci 10\n2\ntool 20 tool 10\nproduct 1000 tool 10\n8\nfishhook 21 disk 3\nmill 14 axe 7\nboomerang 56 sundial 28\nflint 35 fishhook 5\naxe 35 flint 14\ndisk 42 disk 2\nsundial 14 disk 7\nhammer 28 mill 7\n0",
"3\ngu... |
p01297 Safe Area | Nathan O. Davis is challenging a kind of shooter game. In this game, enemies emit laser beams from outside of the screen. A laser beam is a straight line with a certain thickness. Nathan moves a circular-shaped machine within the screen, in such a way it does not overlap a laser beam. As in many shooters, the machine i... | {
"input": [],
"output": []
} | {
"input": [
"100 100 1 1\n50 0 50 100 50\n640 480 1 1\n0 0 640 480 100\n0 0 0 0"
],
"output": [
"No\nYes"
]
} | {
"input": [
"100 100 1 1\n50 0 50 100 50\n640 480 1 2\n0 0 640 480 100\n0 0 0 0",
"100 100 1 1\n62 0 50 100 50\n640 480 1 1\n0 0 640 480 100\n0 0 0 0",
"100 100 1 1\n50 0 50 100 50\n640 480 1 2\n0 0 640 480 110\n0 0 0 0",
"100 100 1 1\n76 0 50 100 50\n640 480 1 1\n0 0 640 480 100\n0 0 0 0",
"100 ... |
p01466 World Trip | Kita_masa is planning a trip around the world. This world has N countries and the country i has M_i cities. Kita_masa wants to visit every city exactly once, and return back to the starting city.
In this world, people can travel only by airplane. There are two kinds of airlines: domestic and international lines. Since... | {
"input": [],
"output": []
} | {
"input": [
"2 16\n4 4\n2 2\n1 1 1 2 1\n1 1 1 3 2\n1 1 1 4 1\n1 2 1 3 1\n1 2 1 4 2\n1 3 1 4 1\n2 1 2 2 1\n2 1 2 3 2\n2 1 2 4 1\n2 2 2 3 1\n2 2 2 4 2\n2 3 2 4 1\n1 1 2 1 1\n1 1 2 2 2\n1 2 2 1 2\n1 2 2 2 1",
"2 2\n2 1\n1 1\n1 1 1 2 1\n1 1 2 1 1",
"4 6\n1 1 1 1\n1 1 1 1\n1 1 2 1 1\n1 1 3 1 2\n1 1 4 1 1\n2 1... | {
"input": [],
"output": []
} |
p01626 MirrorLabyrinth | As a proud hero, you are finally about to reach the Demon King. However, in order to reach the throne where the Demon King is, you must clear the final map prepared by the Demon King.
In this map, everything changes like a two-dimensional plan view from the sky. Humans transform into just points on this map. The map i... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 1\n2 2\n1 2\n3\n-1 1\n-1 2\n-2 2\n1 1 2 2\n0 0 0 1\n2\n10\n1 1\n7 1\n7 5\n5 5\n5 3\n6 3\n6 2\n3 2\n3 5\n1 5\n10\n-1 1\n-1 5\n-3 5\n-3 3\n-2 3\n-2 2\n-5 2\n-5 5\n-7 5\n-7 1\n2 4 6 4\n0 0 0 1\n2\n7\n-7 0\n-5 0\n-4 3\n-3 0\n-1 0\n-1 4\n-7 4\n3\n1 0\n7 0\n7 4\n3 1 5 2\n0 0 0 1\n0"
],
"output... | {
"input": [
"2\n3\n1 1\n2 2\n1 2\n3\n-1 1\n-1 2\n-2 2\n1 1 2 2\n0 0 0 1\n2\n10\n1 1\n7 1\n7 5\n5 5\n5 3\n6 3\n6 2\n3 2\n3 5\n1 5\n10\n-1 1\n-1 5\n-3 5\n-3 3\n-2 3\n-2 2\n-5 2\n-5 5\n-7 5\n-7 1\n2 4 6 4\n0 0 0 1\n2\n7\n-7 0\n-5 0\n-4 3\n-3 0\n-1 0\n-2 4\n-7 4\n3\n1 0\n7 0\n7 4\n3 1 5 2\n0 0 0 1\n0",
"2\n3\n1 ... |
p01778 Dungeon of Cards | G: Dungeon of Cards
story
This is a wonderland hydrangea. It is said that gold and silver treasures sleep in the labyrinth of cards located in the remote area of Ajifurai. As soon as the curious Aizu Nyan heard this legend, he decided to take his friend Wi and go on a journey to the Labyrinth of Cards.
The next da... | {
"input": [],
"output": []
} | {
"input": [
"4\nD 1\nD 2\nA 3\nD 4\n4\nA 1 7\nD 4 5\nD 3 6\nB 3 3"
],
"output": [
"6"
]
} | {
"input": [
"4\nD 1\nD 2\nA 3\nD 4\n4\nA 1 7\nD 4 5\nD 3 6\nA 3 3",
"4\nD 1\nD 2\nA 2\nD 8\n4\nA 1 7\nD 4 5\nD 3 6\nA 3 3",
"4\nC 1\nD 2\nA 2\nD 8\n4\nA 1 7\nD 4 5\nD 3 6\nA 0 3",
"4\nC 1\nD 2\nA 2\nD 8\n1\nA 1 7\nD 4 5\nD 3 6\nA 0 3",
"4\nC 1\nD 2\nA 2\nD 8\n2\nA 1 7\nD 6 3\nD 3 11\nA 0 3",
... |
p01912 Jump Party | problem
A dance party with $ N $ people is held at a dance hall. The dance hall is divided into $ H $ vertical and $ W $ horizontal grids, with $ (0,0) $ in the upper left, $ r $ squares from the top, and $ c $ squares from the left. The coordinates of the grid of the eyes are expressed as $ (r, c) $. The initial posi... | {
"input": [],
"output": []
} | {
"input": [
"2 2 2\n1 0 0 1\n0 0 1 0\n0 0\n0 1"
],
"output": [
"-1"
]
} | {
"input": [
"2 2 1\n1 0 0 1\n0 0 1 0\n0 0\n0 1",
"2 2 2\n1 0 0 1\n0 0 1 0\n0 0\n1 1",
"2 2 2\n1 1 0 1\n0 0 1 1\n0 0\n1 0",
"2 2 1\n1 0 0 0\n0 0 1 0\n0 0\n0 1",
"2 2 1\n1 0 0 0\n1 0 1 0\n0 0\n0 1",
"2 4 1\n1 0 0 0\n1 0 1 0\n0 0\n0 1",
"2 4 1\n1 0 0 0\n1 1 1 0\n0 0\n0 1",
"2 4 1\n1 0 0 ... |
p02051 Misterious Buttons | Mysterious button
You decide to earn coins in a dungeon on the outskirts of town. There are N rooms in this dungeon, numbered from 1 to N. In addition, there are mysterious buttons called "coin button", "escape button", and "warp button" in the dungeon. The details of each button are as follows.
* There is exactly on... | {
"input": [],
"output": []
} | {
"input": [
"4 9\n1 2 1\n1 2 2\n1 3 1\n1 3 2\n1 3 3\n2 3 1\n2 3 2\n1 4 1\n3 4 2\n8\n1 5\n2 5\n3 5\n4 5\n1 1234567\n2 1234567\n3 1234567\n4 1234567\n4 8\n1 2 1\n1 2 1\n1 2 3\n3 4 3\n1 4 2\n2 4 1\n2 4 3\n2 4 3\n8\n1 3\n2 6\n3 8\n4 12\n1 31415926\n2 53589793\n3 23846\n4 26433832\n0 0"
],
"output": [
"1\n9\n... | {
"input": [
"4 9\n1 2 1\n1 2 2\n1 3 1\n1 3 2\n1 3 3\n2 3 1\n2 3 2\n1 4 1\n3 4 2\n8\n1 5\n2 5\n3 5\n4 5\n1 1234567\n2 1234567\n3 1234567\n4 1234567\n4 8\n1 2 1\n1 2 1\n1 2 3\n3 4 4\n1 4 2\n2 4 1\n2 4 3\n2 4 3\n8\n1 3\n2 6\n3 8\n4 12\n1 31415926\n2 53589793\n3 23846\n4 26433832\n0 0",
"4 9\n1 2 1\n1 2 2\n1 3 1... |
p02193 Range Min of Max Query | Range Min of Max Query
Given a sequence of integer pairs (a_1, b_1), (a_2, b_2), .., (a_N, b_N).
Handle two types of queries.
The first type of query adds X to a_L, a_ {L + 1}, .., a_R.
The second type of query finds the minimum values of max (a_L, b_L), max (a_ {L + 1}, b_ {L + 1}), .., max (a_R, b_R).
input
... | {
"input": [],
"output": []
} | {
"input": [
"6 6\n8 1\n6 1\n9 4\n1 5\n2 1\n1 4\n2 1 3\n1 1 3 3\n2 1 3\n2 4 6\n1 4 6 3\n2 4 6"
],
"output": [
"6\n9\n2\n4"
]
} | {
"input": [
"6 6\n8 1\n6 1\n9 4\n1 5\n2 1\n1 4\n2 1 3\n1 1 3 3\n2 1 3\n2 4 6\n1 4 7 3\n2 4 6",
"6 6\n8 1\n0 1\n9 4\n1 5\n2 1\n1 4\n2 1 3\n1 1 3 3\n2 1 3\n2 4 6\n1 4 7 3\n2 4 6",
"6 6\n8 1\n0 1\n0 4\n1 5\n2 1\n1 8\n2 1 5\n1 1 3 3\n2 1 3\n3 4 6\n1 4 7 3\n2 4 6",
"6 6\n8 1\n0 1\n0 4\n1 5\n2 1\n1 8\n2 1 ... |
p02347 Range Search (kD Tree) | The range search problem consists of a set of attributed records S to determine which records from S intersect with a given range.
For n points on a plane, report a set of points which are within in a given range. Note that you do not need to consider insert and delete operations for the set.
Constraints
* 0 ≤ n ≤ 5... | {
"input": [],
"output": []
} | {
"input": [
"6\n2 1\n2 2\n4 2\n6 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5"
],
"output": [
"0\n1\n2\n4\n\n2\n3\n5"
]
} | {
"input": [
"6\n2 1\n2 2\n4 2\n6 2\n3 6\n5 4\n2\n2 4 0 4\n4 10 2 5",
"6\n2 1\n2 2\n4 2\n6 4\n3 6\n5 4\n2\n2 4 0 4\n4 10 4 5",
"6\n2 1\n2 2\n5 1\n6 4\n3 6\n5 4\n2\n2 4 0 4\n4 10 4 5",
"6\n0 1\n2 2\n5 1\n6 4\n3 6\n5 4\n2\n2 4 0 4\n4 10 4 5",
"6\n0 1\n2 2\n5 1\n6 4\n3 2\n5 4\n2\n2 4 0 4\n4 10 4 5",
... |
cdthn | Nitesh recently discovered a new game CODATHON with the help of a very intelligent alien friend Jupiter.
In this game a student had various challenges and each challenge had infinite number of problems.
The scoring system in this game was quite different. There are 2 ways of scoring on a given problem:
If you are in t... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 4\n5 7"
],
"output": [
"5\n23"
]
} | {
"input": [],
"output": []
} |
daily | A daily train consists of N cars. Let's consider one particular car. It has 54 places numbered consecutively from 1 to 54, some of which are already booked and some are still free. The places are numbered in the following fashion:
The car is separated into 9 compartments of 6 places each, as shown in the picture. So, ... | {
"input": [],
"output": []
} | {
"input": [
"1 3\n100101110000001011000001111110010011110010010111000101\n001010000000101111100000000000000111101010101111111010\n011110011110000001010100101110001011111010001001111010",
"6 3\n100101110000001011000001111110010011110010010111000101\n001010000000101111100000000000000111101010101111111010\n0111... | {
"input": [
"6 2\n100101110000001011000001111110010011110010010111000101\n001010000000101111100000000000000111101010101111111010\n011110011110000001010100101110001011111010001001111010",
"3 2\n000000000000000001000000000000000000000000000000000000\n000000000000000000000000000000000000000000000000000000",
... |
idclove | Valentine's Day is coming and our friend Mr.IDC has fallen in love with a girl. He just could not control his feelings and went to propose her.
When he proposed her the girl gave him a challenge and asked him to solve it and the condition was if he will solve the challenge successfully then only she will accept his pro... | {
"input": [],
"output": []
} | {
"input": [
"3\n20 5\n10 2\n5 3"
],
"output": [
"40\n5\n6"
]
} | {
"input": [],
"output": []
} |
mstick | Chef Ceil has some matchsticks in his kitchen.
Detail of matchsticks:
There are N matchsticks in total. They are numbered from to 0 to N-1 inclusive. All matchsticks have same length. But they may have different rates of burning. For i^th matchstick, we denote bi as the time required for that matchstick to completely b... | {
"input": [],
"output": []
} | {
"input": [
"18\n3 4 2 1 5 7 9 7 10 5 12 3 1 1 2 1 3 2\n1\n4 10",
"1\n5\n1\n0 0",
"2\n3 5\n1\n0 1"
],
"output": [
"9.0\n",
"5.0\n",
"4.0\n"
]
} | {
"input": [
"18\n3 4 2 1 5 7 9 7 10 5 12 3 1 1 2 1 0 2\n1\n4 10",
"18\n3 4 2 1 5 7 9 14 10 5 12 3 1 1 2 1 3 2\n1\n4 10",
"2\n3 3\n1\n0 1",
"18\n5 4 2 1 5 7 9 14 10 5 12 3 1 1 2 1 3 2\n1\n4 10",
"18\n5 4 2 1 5 7 9 14 10 5 12 3 1 1 2 1 3 2\n1\n4 9",
"18\n3 4 4 0 5 10 14 7 10 17 12 4 1 0 2 2 -1 ... |
rolldeep | "I heard that you're settled down
That you found a girl and you're married now.
I heard that your dreams came true.
Guess she gave you things I didn't give to you."
Adele just got news about her old lover. She is in her study, reminiscing all the memories they shared and feeling lonely.
After some initi... | {
"input": [],
"output": []
} | {
"input": [
"((Never mind(I'll find(someone like you))))"
],
"output": [
"someone like you\n"
]
} | {
"input": [
"((Never mind(I'll find(someone like ))))uoy",
"rfveM(( mind(I'll find(someone like you))))",
"((Mewfr mind(I'll find(someone lkie you))))",
"((Mewfr mind(I'll enoemos(dnif lkie you))))",
"((Mewfr ll'I(dnim find(somennd lkie you))))",
"rfweM(( ll'I(dnim find(somennd lkie )ou)y))",... |
vogozo | On the icy planet Zorg, the Vogons are putting together a zoo. One cage will house a collection of Kubudu dragons. Unlike the limited number of blood types found in other creatures, Kubudu dragons have a large variety of blood types. Each dragon’s blood type is fixed when it is born and is given by a positive integer.
T... | {
"input": [],
"output": []
} | {
"input": [
"12 3 \n1 5 6 1 8 3 12 2 13 7 9 11"
],
"output": [
"4"
]
} | {
"input": [
"11 3 \n1 5 6 1 8 3 12 2 13 7 9 11",
"11 3 \n2 4 6 1 0 6 12 2 23 7 9 11",
"6 8 \n0 3 1 1 1 3 35 4 48 1 2 2",
"6 8 \n0 5 1 1 1 3 35 4 41 1 2 2",
"6 26 \n1 9 1 3 0 3 19 4 2 2 2 1",
"11 3 \n2 4 6 1 0 6 12 2 45 7 9 17",
"11 2 \n1 8 6 1 15 3 -1 2 13 7 9 11",
"11 2 \n2 4 6 1 10 ... |
1154_F. Shovels Shop | There are n shovels in the nearby shop. The i-th shovel costs a_i bourles.
Misha has to buy exactly k shovels. Each shovel can be bought no more than once.
Misha can buy shovels by several purchases. During one purchase he can choose any subset of remaining (non-bought) shovels and buy this subset.
There are also m ... | {
"input": [],
"output": []
} | {
"input": [
"5 1 4\n2 5 7 4 6\n5 4\n",
"9 4 8\n6 8 5 1 8 1 1 2 1\n9 2\n8 4\n5 3\n9 7\n",
"7 4 5\n2 5 4 2 6 3 1\n2 1\n6 5\n2 1\n3 1\n"
],
"output": [
"17\n",
"17\n",
"7\n"
]
} | {
"input": [
"9 4 8\n6 8 5 1 8 1 1 2 1\n9 4\n8 4\n5 3\n9 7\n",
"7 4 5\n2 5 4 2 6 3 1\n2 1\n6 8\n2 1\n3 1\n",
"7 4 5\n2 5 4 2 6 3 2\n2 1\n6 8\n2 1\n3 1\n",
"9 4 8\n6 4 5 1 8 1 1 2 1\n9 2\n8 4\n5 3\n9 7\n",
"9 4 8\n6 4 5 1 8 1 1 2 1\n9 2\n8 7\n5 3\n9 7\n",
"5 1 4\n2 5 1 4 6\n5 4\n",
"9 4 8\n... |
1211_G. King's Path | There are n cities and n-1 two-way roads in Treeland. Each road connects a pair of different cities. From any city you can drive to any other, moving only along the roads. Cities are numbered from 1 to n. Yes, of course, you recognized an undirected tree in this description.
There is exactly one flag in each city, in ... | {
"input": [],
"output": []
} | {
"input": [
"1\n7\n2 3 2 7 1 1 3\n7 1 2 3 1 2 3\n1 7\n4 1\n2 6\n2 3\n2 4\n5 4\n",
"1\n5\n1 2 2 2 2\n2 2 2 2 1\n1 2\n2 3\n3 4\n4 5\n",
"3\n4\n10 20 10 20\n20 10 20 10\n1 2\n1 3\n1 4\n2\n1000000 1000000\n1000000 1000000\n1 2\n10\n4 2 2 4 2 4 1 2 3 4\n4 2 4 4 3 2 1 2 4 2\n5 8\n6 9\n10 5\n1 10\n7 10\n3 4\n5 ... | {
"input": [],
"output": []
} |
1234_E. Special Permutations | Let's define p_i(n) as the following permutation: [i, 1, 2, ..., i - 1, i + 1, ..., n]. This means that the i-th permutation is almost identity (i.e. which maps every element to itself) permutation but the element i is on the first position. Examples:
* p_1(4) = [1, 2, 3, 4];
* p_2(4) = [2, 1, 3, 4];
* p_3(4) ... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n2 1 5 3 5\n",
"4 4\n1 2 3 4\n",
"2 10\n1 2 1 1 2 2 2 2 2 2\n"
],
"output": [
"9 8 12 6 8 ",
"3 4 6 5 ",
"3 3 "
]
} | {
"input": [
"2 10\n1 2 1 1 1 2 2 2 2 2\n",
"5 5\n3 1 5 3 5\n",
"3 10\n1 2 1 1 2 2 2 2 2 2\n",
"8 5\n3 1 5 3 5\n",
"8 5\n3 2 5 3 5\n",
"8 5\n3 2 8 3 5\n",
"8 5\n4 2 8 3 5\n",
"8 5\n4 2 8 3 6\n",
"10 5\n2 1 5 3 5\n",
"2 10\n1 2 1 1 2 2 2 1 2 2\n",
"8 5\n3 1 5 3 8\n",
"8 ... |
1297_C. Dream Team | Polycarp is the project manager in the IT-company. Right now, he needs to choose developers for his team to start a new project. The company has n developers "on the bench" (i.e not involved in other projects). Polycarp assessed the skills of each of them: a_i (-10^4 ≤ a_i ≤ 10^4) — an integer characteristic of the i-t... | {
"input": [],
"output": []
} | {
"input": [
"5\n5\n1 -1 1 -1 1\n2\n11 1\n3\n5 -3 4\n3\n5 3 -4\n5\n-1 0 3 -3 0\n"
],
"output": [
"\n2\n11101\n11\n10\n6\n111\n5\n100\n2\n10100\n"
]
} | {
"input": [],
"output": []
} |
1381_D. The Majestic Brown Tree Snake | There is an undirected tree of n vertices, connected by n-1 bidirectional edges. There is also a snake stuck inside of this tree. Its head is at vertex a and its tail is at vertex b. The snake's body occupies all vertices on the unique simple path between a and b.
The snake wants to know if it can reverse itself — tha... | {
"input": [],
"output": []
} | {
"input": [
"4\n8 4 7\n1 2\n2 3\n1 4\n4 5\n4 6\n1 7\n7 8\n4 3 2\n4 3\n1 2\n2 3\n9 3 5\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n1 8\n8 9\n16 15 12\n1 2\n2 3\n1 4\n4 5\n5 6\n6 7\n4 8\n8 9\n8 10\n10 11\n11 12\n11 13\n13 14\n10 15\n15 16\n"
],
"output": [
"YES\nNO\nNO\nYES\n"
]
} | {
"input": [
"4\n8 4 7\n1 2\n2 3\n1 4\n4 5\n4 6\n1 7\n7 8\n4 3 2\n4 3\n1 2\n2 3\n9 3 5\n1 2\n2 3\n3 4\n1 5\n5 6\n6 7\n1 8\n8 9\n16 14 12\n1 2\n2 3\n1 4\n4 5\n5 6\n6 7\n4 8\n8 9\n8 10\n10 11\n11 12\n11 13\n13 14\n10 15\n15 16\n",
"4\n8 4 7\n1 2\n2 3\n1 4\n4 5\n4 6\n1 7\n7 8\n4 3 2\n4 3\n1 2\n2 3\n9 3 5\n1 2\n2... |
1424_L. Milutin's Plums | As you all know, the plum harvesting season is on! Little Milutin had his plums planted in an orchard that can be represented as an n by m matrix. While he was harvesting, he wrote the heights of all trees in a matrix of dimensions n by m.
At night, when he has spare time, he likes to perform various statistics on his... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n13 15 10 9 15\n15 17 12 11 17\n10 12 7 6 12\n17 19 14 13 19\n16 18 13 12 18\n"
],
"output": [
"? 2 1\n? 2 2\n? 3 2\n? 3 3\n? 2 3\n? 3 4\n? 4 4\n? 4 5\n? 3 5\n? 4 1\n? 4 3\n? 1 1\n? 3 1\n? 5 3\n? 5 4\n? 5 5\n! 6\n"
]
} | {
"input": [
"5 5\n13 15 10 9 15\n15 17 12 11 17\n10 12 7 6 12\n17 19 14 13 19\n16 33 13 12 18\n",
"5 1\n13 15 14 9 15\n15 17 12 11 17\n10 12 6 6 12\n17 19 14 13 19\n16 33 13 12 18\n",
"5 1\n13 15 14 11 15\n15 17 12 11 17\n10 12 6 6 12\n17 19 14 3 19\n16 33 13 12 18\n",
"6 1\n13 15 14 11 15\n15 17 12 ... |
1497_B. M-arrays | You are given an array a_1, a_2, …, a_n consisting of n positive integers and a positive integer m.
You should divide elements of this array into some arrays. You can order the elements in the new arrays as you want.
Let's call an array m-divisible if for each two adjacent numbers in the array (two numbers on the pos... | {
"input": [],
"output": []
} | {
"input": [
"4\n6 4\n2 2 8 6 9 4\n10 8\n1 1 1 5 2 4 4 8 6 7\n1 1\n666\n2 2\n2 4\n"
],
"output": [
"\n3\n6\n1\n1\n"
]
} | {
"input": [
"4\n6 4\n1 2 8 6 9 4\n10 8\n1 1 1 5 2 4 4 8 6 7\n1 1\n666\n2 2\n2 4\n",
"4\n6 4\n1 2 8 3 9 4\n10 8\n1 1 1 5 2 4 4 8 6 7\n1 1\n666\n2 2\n2 4\n",
"4\n6 4\n1 2 8 3 11 4\n10 8\n1 1 1 5 2 4 4 8 6 13\n1 1\n666\n2 2\n2 4\n",
"4\n6 4\n1 2 8 3 11 4\n10 8\n1 1 1 5 3 4 4 8 6 13\n1 1\n666\n2 2\n2 4\n... |
1547_A. Shortest Path with Obstacle | There are three cells on an infinite 2-dimensional grid, labeled A, B, and F. Find the length of the shortest path from A to B if:
* in one move you can go to any of the four adjacent cells sharing a side;
* visiting the cell F is forbidden (it is an obstacle).
Input
The first line contains an integer t (1 ≤ ... | {
"input": [],
"output": []
} | {
"input": [
"7\n\n1 1\n3 3\n2 2\n\n2 5\n2 1\n2 3\n\n1000 42\n1000 1\n1000 1000\n\n1 10\n3 10\n2 10\n\n3 8\n7 8\n3 7\n\n2 1\n4 1\n1 1\n\n1 344\n1 10\n1 1\n"
],
"output": [
"4\n6\n41\n4\n4\n2\n334\n"
]
} | {
"input": [
"7\n\n1 1\n3 3\n2 2\n\n2 5\n2 1\n2 3\n\n1000 42\n1000 1\n1000 1000\n\n1 10\n3 10\n2 10\n\n3 8\n7 8\n3 7\n\n2 1\n4 1\n1 1\n\n1 413\n1 10\n1 1\n",
"7\n\n1 1\n3 3\n2 2\n\n2 5\n2 1\n2 3\n\n1000 42\n1010 1\n1000 1000\n\n1 10\n3 10\n2 10\n\n3 8\n7 8\n3 7\n\n2 1\n4 1\n1 1\n\n1 413\n1 10\n1 1\n",
"7\... |
basu-and-love-chemistry | Ross, Chandler and Joey are best friends. One day they went to pond and Joey suggest them to play the game "Bamboozle". In this game they have N balls with each numbered from 0-9, but first ball is numbered from 1-9. Ross tells sub-strings 'S' formed by those balls and Chandler throws S stones into the pond. At last, J... | {
"input": [],
"output": []
} | {
"input": [
"16\n\nSAMPLE"
],
"output": [
"23"
]
} | {
"input": [
"16\n\nELPMAS",
"16\n\nTAMPLE",
"16\n\nELPMAT",
"16\n\nTAMELP",
"16\n\nFLPMAT",
"16\n\nFLPTAM",
"16\n\nFLPTBM",
"16\n\nFLTPBM",
"16\n\nMBPTLF",
"16\n\nMPBTLF",
"16\n\nNPBTLF",
"16\n\nNPBTLE",
"16\n\nELTBPN",
"16\n\nEPTBLN",
"16\n\nEPTBNL",
"... |
help-ruchi-8 | Ruchi is doing her undergrad in Maths from a reputed college in New Delhi. Recently her professor gave her a problem which is baffling her for a long time. So she asks your help.
Problem is:
Given order of n x n matrix is it possible to find two matrices such that when there corresponding elements are combined in the... | {
"input": [],
"output": []
} | {
"input": [
"1\n3\n\nSAMPLE"
],
"output": [
"Yes"
]
} | {
"input": [
"1\n3\n\nSAMPKE",
"1\n2\n\nBJEQMR",
"1\n5\n\nSAMPKE",
"1\n10\n\nSAMPKE",
"1\n7\n\nSAMPKE",
"1\n12\n\nSAMPKE",
"1\n3\n\nSAMPEK",
"1\n4\n\nSAMPEK",
"1\n4\n\nSKMPEA",
"1\n4\n\nSKMPEB",
"1\n4\n\nBEPMKS",
"1\n4\n\nSKEPMB",
"1\n4\n\nSKEQMB",
"1\n8\n\nSKEQ... |
the-collatz | Many of us are familiar with collatz sequence. Know the problem is, There is a fight going between the students of the class they have splitted up into two groups the odd rulers and the even rulers. To resolve this fight sir will randomly pick up the numbers and are written on the board. Teacher stated that if the tota... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n4\n\nSAMPLE"
],
"output": [
"Even Rules\nOdd Rules\n"
]
} | {
"input": [
"2\n5\n4\n\nSAMPLE",
"2\n9\n4\n\nSAMLOE",
"2\n5\n8\n\nSBMLPE",
"2\n13\n4\n\nEAMLNS",
"2\n8\n3\n\nLSMAPE",
"2\n13\n8\n\nSNLMAE",
"2\n4\n2\n\nSBMKPE",
"2\n28\n2\n\nEPKBOT",
"2\n2\n2\n\nOTKPEB",
"2\n5\n4\n\nSAMLPE",
"2\n5\n4\n\nSAMLOE",
"2\n3\n4\n\nSANPLE",
... |
p02650 Tokio Marine & Nichido Fire Insurance Programming Contest 2020 - Triangles | In a two-dimensional plane, we have a rectangle R whose vertices are (0,0), (W,0), (0,H), and (W,H), where W and H are positive integers. Here, find the number of triangles \Delta in the plane that satisfy all of the following conditions:
* Each vertex of \Delta is a grid point, that is, has integer x- and y-coordinat... | {
"input": [],
"output": []
} | {
"input": [
"2 3 1",
"100 100 1000",
"5 4 5"
],
"output": [
"12",
"461316",
"132"
]
} | {
"input": [
"3 3 1",
"100 110 1000",
"5 4 8",
"3 3 0",
"100 101 1000",
"0 4 8",
"100 101 1001",
"101 101 1001",
"101 101 1101",
"011 110 0001",
"111 110 0001",
"111 111 0001",
"111 111 0101",
"011 111 0101",
"011 111 0111",
"011 111 0011",
"011 111 ... |
p02779 AtCoder Beginner Contest 154 - Distinct or Not | Given is a sequence of integers A_1, A_2, ..., A_N. If its elements are pairwise distinct, print `YES`; otherwise, print `NO`.
Constraints
* 2 ≤ N ≤ 200000
* 1 ≤ A_i ≤ 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N
A_1 ... A_N
Output
If the elements... | {
"input": [],
"output": []
} | {
"input": [
"6\n4 1 3 1 6 2",
"2\n10000000 10000000",
"5\n2 6 1 4 5"
],
"output": [
"NO",
"NO",
"YES"
]
} | {
"input": [
"6\n4 1 3 1 6 1",
"2\n10000100 10000000",
"5\n2 9 1 4 5",
"6\n4 1 3 1 2 1",
"2\n10000100 10001000",
"5\n2 9 1 3 5",
"6\n4 1 3 1 2 0",
"2\n10000100 10101000",
"5\n2 9 0 3 5",
"6\n4 1 3 2 2 0",
"2\n10010100 10101000",
"5\n2 4 0 3 5",
"6\n4 1 1 2 2 0",
... |
p02914 AtCoder Beginner Contest 141 - Xor Sum 3 | We have N non-negative integers: A_1, A_2, ..., A_N.
Consider painting at least one and at most N-1 integers among them in red, and painting the rest in blue.
Let the beauty of the painting be the \mbox{XOR} of the integers painted in red, plus the \mbox{XOR} of the integers painted in blue.
Find the maximum possibl... | {
"input": [],
"output": []
} | {
"input": [
"20\n1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 467386965442856573 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 61145129... | {
"input": [
"20\n1008288677408720767 539403903321871999 1044301017184589821 215886900497862655 504277496111605629 972104334925272829 792625803473366909 972333547668684797 495007025435533594 755861732751878143 1151846447448561405 467257771752201853 683930041385277311 432010719984459389 319104378117934975 61145129... |
p03050 diverta 2019 Programming Contest - DivRem Number | Snuke received a positive integer N from Takahashi. A positive integer m is called a favorite number when the following condition is satisfied:
* The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.
Find all favorite numbers and print the sum of those.
Con... | {
"input": [],
"output": []
} | {
"input": [
"8",
"1000000000000"
],
"output": [
"10",
"2499686339916"
]
} | {
"input": [
"1000010000000",
"1000011000000",
"1100011000000",
"1110011000000",
"1110011100000",
"1110011100100",
"1110111100100",
"1110111100101",
"1110111000101",
"1010111000101",
"1010111010101",
"1011111010101",
"1000111010101",
"1000101010101",
"100010... |
p03191 AtCoder Grand Contest 030 - Permutation and Minimum | There is a sequence of length 2N: A_1, A_2, ..., A_{2N}. Each A_i is either -1 or an integer between 1 and 2N (inclusive). Any integer other than -1 appears at most once in {A_i}.
For each i such that A_i = -1, Snuke replaces A_i with an integer between 1 and 2N (inclusive), so that {A_i} will be a permutation of 1, 2... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 -1 -1 3 6 -1",
"4\n7 1 8 3 5 2 6 4",
"10\n7 -1 -1 -1 -1 -1 -1 6 14 12 13 -1 15 -1 -1 -1 -1 20 -1 -1",
"20\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 34 -1 -1 -1 -1 31 -1 -1 -1 -1 -1 -1 -1 -1"
],
"output": [
"5",
"1",
"9540576",
"... | {
"input": [
"3\n1 -1 -1 3 5 -1",
"10\n7 -1 -1 -1 -1 -1 -1 6 14 12 13 -1 15 -1 -1 -1 -1 5 -1 -1",
"10\n1 -1 -1 -1 -1 -1 -1 6 14 12 13 -1 15 -1 -1 -1 -1 20 -1 -1",
"10\n7 -1 -1 -1 -1 -1 -1 6 20 12 13 -1 15 -1 -1 -1 -1 5 -1 -1",
"3\n1 -1 -1 5 6 -1",
"10\n7 -1 -1 -1 -1 -1 -1 6 14 12 13 -1 15 -1 -... |
p03338 AtCoder Beginner Contest 098 - Cut and Count | You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when ... | {
"input": [],
"output": []
} | {
"input": [
"10\naaaaaaaaaa",
"6\naabbca",
"45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir"
],
"output": [
"1",
"2",
"9"
]
} | {
"input": [
"10\naaabaaaaaa",
"6\n`abbca",
"45\ntgxgdqkyjphyzutjjtllptdfxocrylqfqjynmfbfucbir",
"45\ntgxgtqkyjfhyzutjjdllptdpxrbrylqfqjynmfbfucbio",
"45\nbnxgtqkykfhyzutjjdllptdpxrtrylqfqjygmfbftcbio",
"10\naba`ab`bbb",
"10\n`bcca_ba_`",
"45\nblxhtqkyjehxzutkjdmlpidpurtrzlbfribgmhqfzc... |
p03500 AtCoder Regular Contest 086 - Shift and Decrement | There are N non-negative integers written on the blackboard: A_1, ..., A_N.
Snuke can perform the following two operations at most K times in total in any order:
* Operation A: Replace each integer X on the blackboard with X divided by 2, rounded down to the nearest integer.
* Operation B: Replace each integer X on t... | {
"input": [],
"output": []
} | {
"input": [
"3 4\n10 13 22",
"1 100\n10",
"10 123456789012345678\n228344079825412349 478465001534875275 398048921164061989 329102208281783917 779698519704384319 617456682030809556 561259383338846380 254083246422083141 458181156833851984 502254767369499613",
"2 2\n5 7"
],
"output": [
"20",
... | {
"input": [
"1 000\n10",
"10 123456789012345678\n228344079825412349 478465001534875275 398048921164061989 329102208281783917 779698519704384319 617456682030809556 561259383338846380 254083246422083141 862407231706007219 502254767369499613",
"2 2\n5 6",
"1 010\n10",
"10 123456789012345678\n2283440... |
p03659 AtCoder Beginner Contest 067 - Splitting Pile | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.
Let th... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2 3 4 5 6",
"2\n10 -10"
],
"output": [
"1",
"20"
]
} | {
"input": [
"6\n0 2 3 4 5 6",
"2\n0 -10",
"6\n0 2 3 7 5 6",
"2\n0 -19",
"6\n-1 2 3 7 5 6",
"2\n1 -19",
"2\n1 -33",
"2\n0 -33",
"6\n1 2 3 7 8 8",
"2\n-1 -33",
"6\n1 2 3 7 8 13",
"2\n-1 -47",
"6\n1 3 3 7 8 13",
"2\n-1 -75",
"2\n-1 -32",
"6\n0 3 3 7 5 13",... |
p03815 AtCoder Beginner Contest 053 - X: Yet Another Die Game | Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° tow... | {
"input": [],
"output": []
} | {
"input": [
"7",
"149696127901"
],
"output": [
"2",
"27217477801"
]
} | {
"input": [
"14",
"86483718001",
"79402108049",
"26",
"59146214190",
"14885609983",
"4",
"19238477126",
"3123061804",
"3577561486",
"2369636804",
"0",
"3247730789",
"1112597576",
"1610699774",
"544563173",
"973659229",
"1835108767",
"8",
... |
p03984 Kyoto University Programming Contest 2016 - Coloring | Mikan's birthday is coming soon. Since Mikan likes graphs very much, Aroma decided to give her a undirected graph this year too.
Aroma bought a connected undirected graph, which consists of n vertices and n edges. The vertices are numbered from 1 to n and for each i(1 \leq i \leq n), vertex i and vartex a_i are connec... | {
"input": [],
"output": []
} | {
"input": [
"10 5\n2\n3\n4\n1\n1\n1\n2\n3\n3\n4",
"4 4\n2\n3\n4\n1",
"4 2\n2\n3\n1\n1"
],
"output": [
"926250",
"55",
"12"
]
} | {
"input": [],
"output": []
} |
p00072 Carden Lantern | Aizuwakamatsu City is known as the "City of History". About 400 years ago, the skeleton of the castle town was created by Gamo Ujisato, but after that, it became the central city of the Aizu clan 230,000 stones, whose ancestor was Hoshina Masayuki, the half-brother of Tokugawa's third shogun Iemitsu. Developed. Many to... | {
"input": [],
"output": []
} | {
"input": [
"4\n4\n0,1,1500\n0,2,2000\n1,2,600\n1,3,500\n0"
],
"output": [
"23"
]
} | {
"input": [
"4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,500\n0",
"4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,400\n0",
"4\n4\n0,1,0500\n0,2,2000\n0,2,600\n2,3,400\n0",
"4\n4\n0,1,0400\n0002,2,0\n0,2,600\n2,3,400\n0",
"4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,600\n0",
"4\n4\n0,1,0600\n0,2,2000\n0,2,600\n... |
p00204 UFO Shooting Down Operation | In 40XX, the Earth was invaded by aliens! Already most of the Earth has been dominated by aliens, leaving Tsuruga Castle Fortress as the only remaining defense base. Suppression units are approaching the Tsuruga Castle Fortress one after another.
<image>
But hope remains. The ultimate defense force weapon, the ultra... | {
"input": [],
"output": []
} | {
"input": [
"100 5\n101 101 5 5\n110 110 2 3\n-112 -100 9 11\n-208 160 82 90\n-110 108 10 2\n10 11\n15 0 5 1\n25 0 5 1\n35 0 5 1\n45 0 5 1\n55 0 5 1\n65 0 5 1\n75 0 5 1\n85 0 5 1\n95 0 5 1\n-20 0 5 20\n-30 0 500 5\n0 0"
],
"output": [
"1\n1"
]
} | {
"input": [
"100 5\n101 101 5 5\n110 110 2 3\n-112 -100 9 11\n-208 160 82 90\n-110 108 10 2\n10 11\n15 0 5 1\n25 0 5 1\n35 0 5 1\n45 0 5 1\n55 0 5 1\n65 0 5 1\n75 0 5 1\n85 0 5 1\n95 0 5 1\n-19 0 5 20\n-30 0 500 5\n0 0",
"100 5\n101 101 5 5\n110 110 2 3\n-112 -100 5 11\n-208 160 82 90\n-110 108 10 2\n10 11\n... |
p00360 Swapping Characters | You are given a string and a number k. You are suggested to generate new strings by swapping any adjacent pair of characters in the string up to k times. Write a program to report the lexicographically smallest string among them.
Input
The input is given in the following format.
s
k
The first line provides a st... | {
"input": [],
"output": []
} | {
"input": [
"pckoshien\n3",
"pckoshien\n10"
],
"output": [
"ckopshien",
"cekophsin"
]
} | {
"input": [
"kcposhien\n3",
"pckoshien\n9",
"kcooshien\n3",
"pckoshien\n16",
"kcooshien\n6",
"pckoshien\n30",
"kcooshien\n4",
"kdooshien\n4",
"kdooshien\n2",
"pckosiien\n26",
"neihsoodk\n2",
"pckosiien\n9",
"neihsoodk\n4",
"pckosiien\n4",
"kdooshien\n1",
... |
p00571 Art Exhibition | An art exhibition will be held in JOI. At the art exhibition, various works of art from all over the country will be exhibited.
N works of art were collected as candidates for the works of art to be exhibited. These works of art are numbered 1, 2, ..., N. Each work of art has a set value called size and value. The siz... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 3\n11 2\n4 5"
],
"output": [
"6"
]
} | {
"input": [
"3\n2 3\n11 2\n4 2",
"3\n2 5\n11 2\n4 2",
"3\n2 5\n11 2\n4 3",
"3\n2 9\n11 0\n4 3",
"3\n2 9\n11 0\n7 3",
"3\n2 3\n2 2\n4 5",
"3\n2 2\n11 2\n4 2",
"3\n2 5\n11 2\n4 4",
"3\n2 3\n11 0\n4 3",
"3\n0 16\n54 3\n5 1",
"3\n3 1\n17 1\n6 1",
"3\n1 12\n26 -1\n2 0",
... |
p00718 Numeral System | Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system.
The letters "m", "c", "x" and "i" correspond to 1000, 100, 10 and 1, respectively, and ... | {
"input": [],
"output": []
} | {
"input": [
"10\nxi x9i\ni 9i\nc2x2i 4c8x8i\nm2ci 4m7c9x8i\n9c9x9i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n9m8c7xi c2x8i"
],
"output": [
"3x\nx\n6cx\n5m9c9x9i\nm\n9m9c9x9i\nmi\nmi\nmx\n9m9c9x9i"
]
} | {
"input": [
"10\nxi x9i\ni 9i\nc2x2i 5c8x8i\nm2ci 4m7c9x8i\n9c9x9i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n9m8c7xi c2x8i",
"10\nxi x9i\ni 9i\nc2x2i 5c8x8i\nm2ci 4m7c9x8i\n9c8x9i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n9m8c7xi c2x8i",
"10\nxi x9i\ni 9i\nc2x2i 5c8x8i\nm2ci 3m7c9x8i\n9c8x9i i\ni 9m9c9x8i\nm i\ni m\nm9i i\n... |
p00858 Geometric Map | Your task in this problem is to create a program that finds the shortest path between two given locations on a given street map, which is represented as a collection of line segments on a plane.
<image>
Figure 4 is an example of a street map, where some line segments represent streets and the others are signs indicat... | {
"input": [],
"output": []
} | {
"input": [
"8\n1 1\n4 4\n1 1 4 1\n1 1 1 4\n3 1 3 4\n4 3 5 3\n2 4 3 5\n4 1 4 4\n3 3 2 2\n1 4 4 4\n9\n1 5\n5 1\n5 4 5 1\n1 5 1 1\n1 5 5 1\n2 3 2 4\n5 4 1 5\n3 2 2 1\n4 2 4 1\n1 1 5 1\n5 3 4 3\n11\n5 5\n1 0\n3 1 5 1\n4 3 4 2\n3 1 5 5\n2 3 2 2\n1 0 1 2\n1 2 3 4\n3 4 5 5\n1 0 5 2\n4 0 4 1\n5 5 5 1\n2 3 2 4\n0"
],
... | {
"input": [
"8\n1 1\n4 4\n1 1 4 1\n1 1 1 4\n3 1 3 4\n4 3 5 3\n2 4 3 5\n4 1 4 4\n3 3 2 2\n1 4 4 4\n9\n1 5\n5 1\n5 4 5 1\n1 5 1 1\n1 5 5 1\n2 3 2 4\n5 4 1 5\n1 2 2 1\n4 2 4 1\n1 1 5 1\n5 3 4 3\n11\n5 5\n1 0\n3 1 5 1\n4 3 4 2\n3 1 5 5\n2 3 2 2\n1 0 1 2\n1 2 3 4\n3 4 5 5\n1 0 5 2\n4 0 4 1\n5 5 5 1\n2 3 2 4\n0",
... |
p00989 Draw in Straight Lines | Draw in Straight Lines
You plan to draw a black-and-white painting on a rectangular canvas. The painting will be a grid array of pixels, either black or white. You can paint black or white lines or dots on the initially white canvas.
You can apply a sequence of the following two operations in any order.
* Painting p... | {
"input": [],
"output": []
} | {
"input": [
"3 3 1 2 3\n.#.\n###\n.#."
],
"output": [
"10"
]
} | {
"input": [
"3 0 1 2 3\n.#.\n###\n.#.",
"4 3 1 2 3\n.#.\n###\n.#.",
"1 1 2 3 1\n#-.\n\"\"!\n./#",
"1 1 2 3 2\n#-.\n\"\"!\n./#",
"1 1 1 3 4\n#-.\n\"#!\n./#",
"1 1 1 4 8\n#-.\n\"#!\n.#/",
"3 2 1 2 3\n.#.\n###\n.#.",
"1 3 1 2 3\n-#.\n###\n.#-",
"1 1 1 8 9\n#-.\n\"!#\n.\"/",
"1 1 ... |
p01121 Cube Surface Puzzle | <!--
Problem E
-->
Cube Surface Puzzle
Given a set of six pieces, "Cube Surface Puzzle" is to construct a hollow cube with filled surface. Pieces of a puzzle is made of a number of small unit cubes laid grid-aligned on a plane. For a puzzle constructing a cube of its side length n, unit cubes are on either of the f... | {
"input": [],
"output": []
} | {
"input": [
"5\n..XX.\n.XXX.\nXXXXX\nXXXXX\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n..XXX\nXXXX.\n.XXXX\n.XXXX\n...X.\n...X.\n.XXXX\nXXXX.\nXXXX.\n.X.X.\nXXX.X\n.XXXX\nXXXXX\n.XXXX\n.XXXX\nXX...\n.XXXX\nXXXXX\nXXXXX\nXX...\n5\n..XX.\n.XXX.\nXXXXX\nXXXX.\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n.XXXX\nXXXX.\n... | {
"input": [
"5\n..XX.\n.XXX.\nXXXXX\nXXXXX\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n..XXX\nXXXX.\n.XXXX\n.XXXX\n...X.\n...X.\n.XXXX\nXXXX.\nXXXX.\n.X.X.\nXXX.X\n.XXXX\nXXXXX\n.XXXX\n.XXXX\n...XX\n.XXXX\nXXXXX\nXXXXX\nXX...\n5\n..XX.\n.XXX.\nXXXXX\nXXXX.\nX....\n....X\nXXXXX\n.XXX.\n.XXX.\n.....\n.XXXX\nXXXX.\n... |
p01260 Girls' Party | Issac H. Ives hosted a party for girls. He had some nice goods and wanted to distribute them to the girls as the presents. However, there were not enough number of presents and thus he needed to decide who would take them. He held a game for that purpose.
Before the game, Issac had all the girls divided into two teams... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 GB\n3 GBGBBB\n9 BBBGBBBGGG\n9 GGBGBBGBBB\n7 GBGGGGBGGG\n3 BBBBBGBBBB"
],
"output": [
"1\n4\n4\n1\n0\n8"
]
} | {
"input": [
"6\n1 GB\n3 GBGBBB\n9 BBBGBBBGGG\n15 GGBGBBGBBB\n7 GBGGGGBGGG\n3 BBBBBGBBBB",
"6\n1 GB\n3 GBGBBB\n9 BBBGBBBGGG\n9 GGBGBBGBBB\n7 GBGGGGBGGG\n3 BBBBGBBBBB",
"6\n1 GB\n3 GBGBBB\n14 GBBGBBBGGB\n15 GGBGBBGBBB\n4 GBGGGGBGGG\n3 BBBBBGBBBB",
"6\n1 GB\n4 GBGBBB\n14 GBBGBBBGGB\n15 GGBGBBGBBB\n4 GBG... |
p01420 Marathon Match | N people run a marathon. There are M resting places on the way. For each resting place, the i-th runner takes a break with probability P_i percent. When the i-th runner takes a break, he gets rest for T_i time.
The i-th runner runs at constant speed V_i, and the distance of the marathon is L.
You are requested to com... | {
"input": [],
"output": []
} | {
"input": [
"2 1 100\n100 100 10\n0 100 1",
"2 2 50\n30 0 1\n30 50 2",
"2 2 50\n30 50 1\n30 50 2",
"3 1 100\n50 1 1\n50 1 1\n50 1 1"
],
"output": [
"0.00000000\n1.00000000",
"0.51000000\n0.49000000",
"0.28770000\n0.71230000",
"0.12500000\n0.12500000\n0.12500000"
]
} | {
"input": [
"2 1 100\n100 100 10\n0 100 0",
"2 2 50\n30 0 1\n30 50 1",
"1 2 50\n30 50 1\n30 50 2",
"3 1 100\n50 1 2\n50 1 1\n50 1 1",
"3 1 000\n7 2 2\n50 0 1\n50 1 1",
"3 1 000\n0 2 2\n50 0 1\n50 1 1",
"2 1 19\n21 50 1\n45 50 4",
"2 1 19\n21 50 0\n45 50 4",
"3 3 010\n0 2 2\n55 0 1... |
p01574 Dial Key | You are a secret agent from the Intelligence Center of Peacemaking Committee. You've just sneaked into a secret laboratory of an evil company, Automated Crime Machines.
Your mission is to get a confidential document kept in the laboratory. To reach the document, you need to unlock the door to the safe where it is kept... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n1",
"6 2\n2\n5",
"4 2\n2\n4"
],
"output": [
"Yes",
"Yes",
"No"
]
} | {
"input": [
"3 1\n0",
"6 2\n1\n6",
"6 2\n2\n6",
"3 0\n0",
"3 0\n-1",
"6 2\n4\n6",
"6 2\n5\n6",
"6 1\n5\n6",
"6 1\n3\n6",
"6 1\n3\n0",
"7 1\n3\n0",
"7 1\n3\n1",
"7 1\n5\n1",
"7 1\n5\n0",
"7 2\n5\n0",
"5 1\n1",
"6 2\n0\n5",
"4 2\n1\n4",
"6 2\n... |
p01736 Graph Automata Player | You and your grandma are playing with graph automata, which is generalization of cell automata.
A graph automaton is expressed by a graph. The vertices of the graph have a time-dependent value, which can be either 0 or 1. There is no more than one edge between any of two vertices, but self-loops might exist.
The valu... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 1\n0 1\n1\n1\n1"
],
"output": [
"0 1"
]
} | {
"input": [
"2\n1 1\n0 1\n0\n1\n1",
"2\n1 1\n0 1\n0\n1\n2",
"2\n1 1\n0 1\n1\n0\n1",
"2\n0 1\n0 1\n1\n1\n1",
"2\n0 0\n0 0\n0\n0\n0",
"2\n0 1\n0 1\n0\n1\n2",
"2\n1 2\n0 1\n1\n0\n1",
"2\n1 1\n0 1\n0\n1\n0",
"2\n1 0\n0 1\n0\n1\n0",
"2\n1 -1\n0 1\n0\n1\n0",
"2\n2 -1\n0 1\n0\n1\... |
p01876 Arai's | E: Arai's --Arai's-
problem
Arai's is a female idol group that has been popular since the school idol era. Nowadays, it is active at the world level as a large group to which many "Arai" belong. And today, it was decided to start a new project. They decided to try to further increase sales by forming several small un... | {
"input": [],
"output": []
} | {
"input": [
"3 3 4\n111\n111\n111\n111\n111\n111"
],
"output": [
"2"
]
} | {
"input": [
"3 3 4\n111\n111\n111\n111\n111\n011",
"3 3 4\n111\n111\n011\n111\n011\n111",
"3 1 4\n111\n111\n011\n111\n011\n111",
"5 0 4\n011\n111\n011\n011\n010\n111",
"5 4 2\n101\n110\n011\n111\n100\n101",
"3 3 4\n111\n111\n011\n111\n111\n111",
"3 1 4\n111\n111\n011\n111\n010\n111",
... |
p02012 Sum of QQ | You received a card with an integer $S$ and a multiplication table of infinite size. All the elements in the table are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is $A_{i,j} = i \times j$ ($i,j \geq 1$). The table has infinite size, i.e., the number of the rows and the n... | {
"input": [],
"output": []
} | {
"input": [
"25",
"5",
"1",
"83160"
],
"output": [
"10",
"4",
"1",
"5120"
]
} | {
"input": [
"18",
"9",
"0",
"10614",
"3",
"5401",
"2",
"12",
"4",
"6",
"30",
"16",
"65420",
"3315",
"36",
"64",
"32",
"4557",
"3807",
"26789",
"54",
"1584",
"20928",
"90",
"5664",
"96",
"144",
"001",
"... |
p02155 First Kiss | Problem
At the boys' school where Bit-kun attends, a Kippo game is played during the lunch break.
This school's Kippo game is famous for being a little strange.
First, prepare a $ N $ book ticket. The length of the $ i $ first ticket is $ a_i $.
The first move and the second move eat Kippo alternately.
If you eat a gr... | {
"input": [],
"output": []
} | {
"input": [
"3 5\n10 8 4",
"4 10\n3 8 5 2",
"2 25\n19 19",
"1 1\n2"
],
"output": [
"First",
"Second",
"Second",
"First"
]
} | {
"input": [
"3 5\n10 16 4",
"2 25\n3 29",
"2 25\n19 29",
"2 25\n15 29",
"3 5\n10 8 6",
"4 10\n3 8 0 2",
"1 1\n4",
"3 5\n10 16 6",
"2 30\n19 29",
"2 25\n7 29",
"2 6\n3 29",
"2 5\n10 8 6",
"4 10\n4 8 0 2",
"1 2\n4",
"3 5\n10 29 6",
"4 30\n19 29",
"2 2... |
p02296 Distance | For given two segments s1 and s2, print the distance between them.
s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.
Constraints
* 1 ≤ q ≤ 1000
* -10000 ≤ xpi, ypi ≤ 10000
* p0 ≠ p1 and p2 ≠ p3.
Input
The entire input looks like:
q (the number of queries)
1st query
2nd query
...
qth... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 0 1 0 0 1 1 1\n0 0 1 0 2 1 1 2\n-1 0 1 0 0 1 0 -1"
],
"output": [
"1.0000000000\n1.4142135624\n0.0000000000"
]
} | {
"input": [
"3\n0 0 1 0 0 1 1 1\n0 0 1 0 2 1 1 2\n-1 1 1 0 0 1 0 -1",
"3\n0 1 1 0 0 1 1 1\n-1 0 1 0 2 1 1 2\n-1 1 0 0 0 1 0 -1",
"3\n0 1 1 0 0 1 1 1\n-1 0 1 1 2 1 1 2\n-1 1 0 0 0 1 0 -1",
"3\n0 1 1 0 0 1 1 1\n-1 0 1 1 1 1 1 2\n-1 1 0 0 0 0 0 -1",
"3\n0 2 1 0 0 1 1 1\n-1 0 1 0 1 1 1 2\n-1 1 0 -1 0... |
p02443 Reverse | Write a program which reads a sequence of integers $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and reverse specified elements by a list of the following operation:
* reverse($b, e$): reverse the order of $a_b, a_{b+1}, ..., a_{e-1}$
Constraints
* $1 \leq n \leq 1,000$
* $-1,000,000,000 \leq a_i \leq 1,000,000,000$
* $1 \leq ... | {
"input": [],
"output": []
} | {
"input": [
"8\n1 2 3 4 5 6 7 8\n2\n1 6\n3 8"
],
"output": [
"1 6 5 8 7 2 3 4"
]
} | {
"input": [
"8\n1 2 3 4 5 6 7 8\n2\n1 6\n1 8",
"8\n1 1 3 4 5 6 7 8\n2\n1 6\n1 8",
"8\n1 1 3 4 5 5 7 8\n2\n1 6\n1 8",
"8\n1 4 3 4 5 6 7 8\n2\n1 6\n3 8",
"8\n1 2 3 4 5 0 7 8\n2\n1 6\n1 8",
"8\n1 1 4 4 5 6 7 8\n2\n1 6\n1 8",
"8\n1 1 3 4 7 5 7 8\n2\n1 6\n1 8",
"8\n1 4 3 4 5 6 7 8\n2\n1 6\... |
cdva1605 | The auditorium of Stanford University is made up of L*R matrix (assume each coordinate has a chair). On the occasion of an event Chef was called as a chief guest. The auditorium was filled with males (M) and females (F), occupying one chair each. Our Chef is very curious guy, so he asks the gatekeeper some queries. The... | {
"input": [],
"output": []
} | {
"input": [
"4 3 3\nMMF\nMMM\nFFM\nFFM\n2 F\n3 M\n1 M"
],
"output": [
"yes\nno\nyes"
]
} | {
"input": [],
"output": []
} |
dce04 | The Titanic ship is sinking. The nearest ship has answered the SOS call, and come to rescue the people. Everyone is anxious to get to safety. Unfortunately, the new ship may not have enough room to take everyone to safe land. This adds to the anxiety of people.
To avoid stampede, there has to be some rescue plan. You... | {
"input": [],
"output": []
} | {
"input": [
"3\n17 5 10 19\n18 2 6 10\n20 5 2 23"
],
"output": [
"2 2 13\n2 4 10\n2 2 16\n"
]
} | {
"input": [
"3\n17 5 10 19\n18 2 6 10\n20 5 4 23",
"3\n1 5 10 19\n18 2 7 10\n20 5 5 23",
"3\n1 5 10 19\n18 2 7 16\n20 5 5 34",
"3\n1 5 18 32\n18 2 8 16\n9 5 5 34",
"3\n1 5 18 56\n18 2 8 16\n6 5 5 34",
"3\n1 5 18 56\n13 2 8 16\n6 5 5 34",
"3\n2 5 18 56\n13 2 8 16\n6 5 2 34",
"3\n2 5 18... |
ignus15e | Problem description.
Tima wants to contest for Mr. Ignus. But there are many obstacles which Tima must cross to become Mr. Ignus. Tima has qualified and passed all the tests and there remains a last test for him to complete successfully. The task is as follows :
There are n judges. The ith judge have A[i] coins wi... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n1 2 3 4 5\n1\n10"
],
"output": [
"9\n10"
]
} | {
"input": [],
"output": []
} |
multisrm | Problem description.
Jojo is so good at multiplying that she can multiply two 15-digits integers within 5 seconds. After practicing for years, she decided to approach the Limca Book of Records. As a jury member you are given the task to decide if she is eligible enough for holding the record. But before you test her, y... | {
"input": [],
"output": []
} | {
"input": [
"111111\n111111"
],
"output": [
"12345654321\n"
]
} | {
"input": [
"111111\n111011",
"111111\n101111",
"111111\n110111",
"111111\n111010",
"111111\n100111",
"111111\n111110",
"111111\n100110",
"111111\n110010",
"111111\n100101",
"111111\n100010",
"111111\n101101",
"111111\n101001",
"111111\n100001",
"111111\n111001... |
rrfrnds | After IOI Ilya decided to make a business. He found a social network called "TheScorpyBook.com". It currently has N registered users. As in any social network two users can be friends. Ilya wants the world to be as connected as possible, so he wants to suggest friendship to some pairs of users. He will suggest user u ... | {
"input": [],
"output": []
} | {
"input": [
"4\n0111\n1000\n1000\n1000"
],
"output": [
"6\n"
]
} | {
"input": [
"4\n1111\n1000\n1000\n1000",
"4\n0111\n1100\n0000\n1001",
"4\n1111\n1010\n1000\n1010",
"4\n0011\n0000\n0000\n1001",
"4\n1111\n1100\n0000\n1001",
"4\n0110\n1000\n0000\n1001",
"4\n0011\n1000\n0000\n1000",
"4\n0111\n1010\n1100\n1000",
"4\n1111\n1010\n0000\n1010",
"4\n... |
window2 | After Chef successfully built a modern (L, K)-window on the attic wall he decided to expand the notion of the (L, K)-window in some other areas. Now he considers a rectangular grid that contains only zeroes and ones and has size N x M. He considers the (L, K)-window here as any submatrix of size L x K that contains onl... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 2 2 1\n11\n01\n10\n3 3 2 2\n111\n101\n111"
],
"output": [
"2\n5"
]
} | {
"input": [
"2\n3 2 1 1\n11\n01\n10\n3 3 2 2\n111\n101\n111",
"2\n3 2 1 1\n11\n01\n10\n3 3 2 2\n110\n101\n111",
"2\n3 2 1 1\n11\n01\n10\n3 3 2 2\n010\n101\n111",
"2\n3 2 1 1\n11\n01\n10\n3 3 2 2\n000\n111\n111",
"2\n3 2 1 1\n11\n01\n10\n3 3 1 2\n000\n111\n111",
"2\n3 2 2 1\n11\n01\n12\n3 3 2 ... |
1213_C. Book Reading | Polycarp is reading a book consisting of n pages numbered from 1 to n. Every time he finishes the page with the number divisible by m, he writes down the last digit of this page number. For example, if n=15 and m=5, pages divisible by m are 5, 10, 15. Their last digits are 5, 0, 5 correspondingly, their sum is 10.
You... | {
"input": [],
"output": []
} | {
"input": [
"7\n1 1\n10 1\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 13\n"
],
"output": [
"1\n45\n153\n294\n3359835\n0\n427262129093995\n"
]
} | {
"input": [
"7\n1 1\n10 2\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 13\n",
"7\n1 1\n10 2\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 16\n",
"7\n1 1\n10 2\n100 3\n1024 14\n998244353 1337\n123 144\n1234312817382646 10\n",
"7\n1 1\n10 2\n100 4\n1024 14\n998244353 1337\n12... |
1297_H. Paint the String | You are given a string s of lowercase Latin letters. It is required to paint each letter of the string in one of two colors (red or blue) so that if you write all the red letters from left to right and write all the blue letters from left to right, then the lexicographically maximum of the two written strings is lexico... | {
"input": [],
"output": []
} | {
"input": [
"5\nkotlin\ncodeforces\nabacaba\nffccgc\nyz\n"
],
"output": [
"\nRRRRBB\nRRRRRRRBBB\nRRRRBBB\nRBBBBR\nRR\n"
]
} | {
"input": [],
"output": []
} |
1362_B. Johnny and His Hobbies | Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a lot of trouble.
There is a set S containing very important number... | {
"input": [],
"output": []
} | {
"input": [
"6\n4\n1 0 2 3\n6\n10 7 14 8 3 12\n2\n0 2\n3\n1 2 3\n6\n1 4 6 10 11 12\n2\n0 1023\n"
],
"output": [
"1\n4\n2\n-1\n-1\n1023\n"
]
} | {
"input": [
"6\n4\n1 0 2 3\n6\n10 7 14 8 0 12\n2\n0 2\n3\n1 2 3\n6\n1 4 6 10 11 12\n2\n0 1023\n",
"6\n4\n1 0 2 5\n6\n10 7 14 8 0 12\n2\n0 2\n3\n1 2 3\n6\n1 4 6 10 11 12\n2\n0 1023\n",
"6\n4\n1 0 2 3\n6\n10 7 14 8 0 12\n2\n0 2\n3\n1 2 3\n6\n1 0 6 10 11 12\n2\n0 1023\n",
"6\n4\n1 0 2 6\n6\n10 7 14 8 0 ... |
1403_A. The Potion of Great Power | Once upon a time, in the Land of the Shamans, everyone lived on the Sky-High Beanstalk. Each shaman had a unique identifying number i between 0 and N-1, and an altitude value H_i, representing how high he lived above ground level. The distance between two altitudes is the absolute value of their difference.
All shaman... | {
"input": [],
"output": []
} | {
"input": [
"6 5 11 4\n2 42 1000 54 68 234\n0 1\n2 0\n3 4\n3 5\n3 5\n1 3\n5 3\n0 5\n3 0\n1 3\n3 5\n0 3 4\n3 0 8\n0 5 5\n3 0 11"
],
"output": [
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n26\n0\n1000000000\n14"
]
} | {
"input": [],
"output": []
} |
1425_C. Captain of Knights | Mr. Chanek just won the national chess tournament and got a huge chessboard of size N × M. Bored with playing conventional chess, Mr. Chanek now defines a function F(X, Y), which denotes the minimum number of moves to move a knight from square (1, 1) to square (X, Y). It turns out finding F(X, Y) is too simple, so Mr. ... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 4 5 6\n5 5 8 8\n"
],
"output": [
"27\n70\n"
]
} | {
"input": [
"2\n3 4 5 6\n5 8 8 8\n",
"2\n3 4 7 6\n5 8 8 8\n",
"2\n3 4 5 6\n5 5 4 8\n",
"2\n3 4 5 6\n5 5 8 5\n",
"2\n3 4 5 6\n5 5 14 5\n",
"2\n3 4 9 6\n5 3 4 1\n",
"2\n5 4 5 6\n5 5 4 5\n",
"2\n3 3 5 6\n5 5 8 8\n",
"2\n3 4 3 6\n5 8 8 8\n",
"2\n3 4 5 10\n5 5 8 5\n",
"2\n3 4 5... |
1498_B. Box Fitting | You are given n rectangles, each of height 1. Each rectangle's width is a power of 2 (i. e. it can be represented as 2^x for some non-negative integer x).
You are also given a two-dimensional box of width W. Note that W may or may not be a power of 2. Moreover, W is at least as large as the width of the largest recta... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 16\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n"
],
"output": [
"\n2\n3\n"
]
} | {
"input": [
"2\n5 13\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n",
"2\n5 13\n1 2 8 2 8\n6 10\n4 8 8 2 2 8\n",
"2\n5 12\n1 4 8 4 8\n6 10\n2 8 8 2 2 8\n",
"2\n5 8\n1 2 8 2 8\n6 11\n4 8 8 2 2 8\n",
"2\n5 12\n1 2 8 4 8\n6 12\n2 2 8 2 2 8\n",
"2\n5 19\n1 2 8 2 4\n6 12\n4 8 8 2 2 8\n",
"2\n5 12\n2 4 8 4 8\... |
921_01. Labyrinth-1 | You have a robot in a two-dimensional labyrinth which consists of N × M cells. Some pairs of cells adjacent by side are separated by a wall or a door. The labyrinth itself is separated from the outside with walls around it. Some labyrinth cells are the exits. In order to leave the labyrinth the robot should reach any e... | {
"input": [],
"output": []
} | {
"input": [
"1 1 30 30 1 1 1 1 1 1\n1 1 1 2\n2 2 2 3\n1 4\n9 0\n"
],
"output": [
"for-1111\n take\n open-up\n open-left\n open-right\n open-down\n move-left\n if-ok\n for-11\n move-left\n take\n open-up\n open-left\n open-right\n open-down\n end\n else\n move-right\n if-ok\n... | {
"input": [],
"output": []
} |
bbq-sticks | Our Tom is doing what he is best at, COOKING A BARBECUE for his guests. He has invited all of us, and taking the help of his apprentice to smoke the barbecues. The Tom has got BBQ sticks, each can take N fillings, and he presents N distinctly filled sticks in front his guests forming a N*N matrix
But here is the probl... | {
"input": [],
"output": []
} | {
"input": [
"4\n5\n8\n9\n12\n\nSAMPLE"
],
"output": [
"9\n65\n129\n1025\n"
]
} | {
"input": [
"4\n5\n8\n9\n12\n\nPAMSLE",
"4\n5\n8\n9\n16\n\nPAMSLE",
"4\n5\n10\n9\n16\n\nPAMSLE",
"4\n5\n10\n9\n7\n\nELSMAP",
"4\n5\n9\n9\n12\n\nSAMPLE",
"4\n5\n8\n9\n24\n\nPAMSLE",
"4\n5\n10\n17\n16\n\nPAMSLE",
"4\n5\n10\n9\n14\n\nELSMAP",
"4\n5\n9\n10\n12\n\nSAMPLE",
"4\n5\n8... |
highest-points | As the league stage of the world cup has come to its end, its time to calculate the highest points earned in the league stage by a team.
There are many teams playing in the world cup. A team is awarded 3 points for a win, 1 point for a tie and it loses 1 point if they lose a match. You have received data of N teams ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 0 1\n2 1 3\n1 1 1\n\nSAMPLE"
],
"output": [
"8\n"
]
} | {
"input": [
"3\n3 0 1\n2 1 3\n1 0 1\n\nSAMPLE",
"3\n3 1 1\n2 1 3\n1 0 1\n\nSAMPLE",
"3\n0 0 1\n2 1 0\n1 0 1\n\nSAMPLE",
"3\n3 2 1\n2 1 3\n1 0 1\n\nSAMPLE",
"3\n1 0 1\n2 1 4\n1 0 1\n\nSAMPLE",
"3\n0 0 1\n2 1 1\n1 1 1\n\nSEMPLA",
"3\n1 0 1\n2 1 4\n2 0 1\n\nSAMPLE",
"3\n1 0 1\n0 1 0\n1 0... |
magic-pass-code-1 | Problem Description
Apparently, the key that would take Alice home from her Wonderland adventure is a magic pass code hidden in numbers.
Help her find it! It's the one with the highest sum of its digits!
Input Format
Input consists of several integer n, each separated by a newline character.
Output Format
Output ... | {
"input": [],
"output": []
} | {
"input": [
"23\n496\n\nSAMPLE"
],
"output": [
"496"
]
} | {
"input": [],
"output": []
} |
sherlock-and-xor | You are given an array A1,A2...AN. You have to tell how many pairs (i, j) exist such that 1 ≤ i < j ≤ N and Ai XOR Aj is odd.
Input and Output
First line T, the number of testcases. Each testcase: first line N, followed by N integers in next line. For each testcase, print the required answer in one line. ... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 2 3\n4\n1 2 3 4\n\nSAMPLE"
],
"output": [
"2\n4\n"
]
} | {
"input": [
"2\n3\n1 2 3\n4\n1 2 3 2\n\nSAMPLE",
"2\n3\n1 2 -2\n4\n2 2 3 2\n\nASMPLE",
"2\n3\n0 2 2\n4\n1 4 3 4\n\nSAMPLE",
"2\n3\n0 2 2\n4\n2 4 3 4\n\nSAMPLE",
"2\n3\n1 2 -2\n4\n2 2 2 2\n\nASMPLE",
"2\n3\n0 0 0\n4\n2 6 0 2\n\nELPMSA",
"2\n3\n1 2 0\n4\n1 2 3 2\n\nSAMPLE",
"2\n3\n1 2 0... |
xsquare-and-coin-collection-2 | Xsquare loves to play with the coins very much. Today , he has N stacks of coins . Each stack of coins has some non zero height Hi equal to the number of coins on that stack ( considering all the coins are identical and each coin has a height of 1 unit ) .
In one move, Xsquare can select any number of consecutive sta... | {
"input": [],
"output": []
} | {
"input": [
"2\n8 1\n3 2 2 3 1 1 1 3\n8 2\n3 2 2 3 1 1 1 3\n\nSAMPLE"
],
"output": [
"3\n4\n"
]
} | {
"input": [
"2\n8 1\n3 2 2 3 1 1 1 3\n8 2\n3 2 2 3 1 2 1 3\n\nSAMPLE",
"2\n8 1\n3 2 2 3 1 1 1 3\n8 2\n3 2 2 3 1 2 1 2\n\nSAMPLE",
"2\n8 1\n3 2 2 3 1 0 1 3\n8 2\n3 2 2 3 1 2 1 2\n\nSAMPLE",
"2\n8 1\n3 2 2 3 1 0 1 1\n8 4\n3 2 2 3 1 2 1 2\n\nSAMPLE",
"2\n8 0\n3 2 2 3 1 1 1 3\n8 2\n3 2 2 3 1 1 1 3\n\... |
p02655 AtCoder Grand Contest 045 - Fragile Balls | We have N boxes numbered 1 to N, and M balls numbered 1 to M. Currently, Ball i is in Box A_i.
You can do the following operation:
* Choose a box containing two or more balls, pick up one of the balls from that box, and put it into another box.
Since the balls are very easy to break, you cannot move Ball i more th... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2 1\n2 1 1\n1 3 2",
"1 1\n1 1 1",
"2 2\n1 2 1\n2 1 1",
"5 5\n1 2 1\n2 1 1\n1 3 2\n4 5 1\n5 4 1"
],
"output": [
"3",
"0",
"-1",
"6"
]
} | {
"input": [
"6 3\n1 2 1\n2 1 1\n1 3 2",
"2 2\n1 2 1\n1 1 1",
"5 5\n1 2 1\n3 1 1\n1 3 2\n4 5 1\n5 4 1",
"5 5\n1 2 1\n3 1 1\n1 3 2\n1 5 1\n5 4 1",
"2 1\n1 1 1",
"5 5\n1 2 1\n3 1 1\n0 3 2\n1 5 1\n5 5 1",
"2 2\n1 3 1\n1 1 1",
"5 5\n1 2 1\n3 1 1\n0 3 2\n1 5 1\n5 4 1",
"5 5\n1 2 1\n3 1 ... |
p02784 AtCoder Beginner Contest 153 - Common Raccoon vs Monster | Raccoon is fighting with a monster.
The health of the monster is H.
Raccoon can use N kinds of special moves. Using the i-th move decreases the monster's health by A_i. There is no other way to decrease the monster's health.
Raccoon wins when the monster's health becomes 0 or below.
If Raccoon can win without using... | {
"input": [],
"output": []
} | {
"input": [
"211 5\n31 41 59 26 53",
"10 3\n4 5 6",
"20 3\n4 5 6",
"210 5\n31 41 59 26 53"
],
"output": [
"No",
"Yes",
"No",
"Yes"
]
} | {
"input": [
"211 5\n31 33 59 26 53",
"10 3\n4 4 6",
"20 3\n3 5 6",
"210 3\n31 41 59 26 53",
"211 5\n31 33 59 26 24",
"10 3\n4 0 6",
"20 3\n3 3 6",
"210 3\n31 55 59 26 53",
"211 9\n31 33 59 26 24",
"20 3\n4 0 6",
"20 3\n3 4 6",
"210 3\n31 34 59 26 53",
"211 9\n31 33... |
p02919 AtCoder Beginner Contest 140 - Second Sum | Given is a permutation P of \\{1, 2, \ldots, N\\}.
For a pair (L, R) (1 \le L \lt R \le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \ldots, P_R.
Find \displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} X_{L,R}.
Constraints
* 2 \le N \le 10^5
* 1 \le P_i \le N
* P_i \neq P_j (i \neq j)
* All values... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2 3 4 5",
"3\n2 3 1",
"8\n8 2 7 3 4 5 6 1"
],
"output": [
"30",
"5",
"136"
]
} | {
"input": [
"3\n1 3 2",
"3\n3 1 2",
"5\n1 3 2 4 5",
"5\n2 3 1 4 5",
"8\n8 1 7 3 4 5 6 2",
"3\n3 2 1",
"3\n2 1 3",
"3\n1 2 3",
"3\n1 3 2",
"3\n1 2 3",
"3\n3 1 2",
"3\n2 1 3",
"3\n3 2 1"
],
"output": [
"5\n",
"4\n",
"29\n",
"28\n",
"135\n",
... |
p03055 AtCoder Grand Contest 033 - Removing Coins | Takahashi and Aoki will play a game on a tree. The tree has N vertices numbered 1 to N, and the i-th of the N-1 edges connects Vertex a_i and Vertex b_i.
At the beginning of the game, each vertex contains a coin. Starting from Takahashi, he and Aoki will alternately perform the following operation:
* Choose a vertex ... | {
"input": [],
"output": []
} | {
"input": [
"7\n1 7\n7 4\n3 4\n7 5\n6 3\n2 1",
"3\n1 2\n2 3",
"6\n1 2\n2 3\n2 4\n4 6\n5 6"
],
"output": [
"First",
"First",
"Second"
]
} | {
"input": [
"3\n2 2\n2 3",
"6\n1 2\n2 1\n2 4\n4 6\n5 6",
"7\n1 7\n7 1\n3 4\n7 5\n6 3\n2 1",
"6\n1 2\n2 3\n2 4\n6 6\n5 6",
"6\n1 2\n2 1\n2 4\n4 6\n4 6",
"7\n1 7\n7 1\n3 4\n2 5\n6 3\n2 1",
"6\n1 3\n2 3\n2 4\n6 6\n5 6",
"7\n1 7\n7 1\n3 7\n2 5\n6 3\n2 1",
"6\n2 2\n2 3\n2 4\n6 6\n5 6",... |
p03199 CADDi 2018 - Square | Takahashi has an N \times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j). Particularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N).
An integer, 0 or 1, is written on M of the squares in the Takahashi's grid. Three integers a_i,b_i and c_i desc... | {
"input": [],
"output": []
} | {
"input": [
"100000 0",
"4 8\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1",
"4 5\n1 3 1\n2 4 0\n2 3 1\n4 2 1\n4 4 1",
"3 5\n1 3 1\n3 3 0\n3 1 0\n2 3 1\n3 2 1",
"3 3\n1 1 1\n3 1 0\n2 3 1"
],
"output": [
"342016343",
"4",
"32",
"0",
"8"
]
} | {
"input": [
"4 5\n1 3 0\n2 4 0\n2 3 1\n4 2 1\n4 4 1",
"2 1\n1 1 1\n3 1 0\n2 3 1",
"2 0\n1 1 0\n3 1 0\n2 3 1",
"4 0\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1",
"3 0\n1 1 1\n5 1 0\n2 6 2",
"4 1\n1 1 1\n2 2 0\n0 2 1\n1 4 0\n2 1 0\n1 3 0\n5 4 1\n4 8 1",
"3 2\n1 1 1\n2 2 0\n0 2 1... |
p03346 AtCoder Grand Contest 024 - Backfront | You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:
* Choose an element in the sequence and move it to the beginning or the end of the sequence.
Find the minimum number of op... | {
"input": [],
"output": []
} | {
"input": [
"4\n1\n3\n2\n4",
"6\n3\n2\n5\n1\n4\n6",
"8\n6\n3\n1\n2\n7\n4\n8\n5"
],
"output": [
"2",
"4",
"5"
]
} | {
"input": [
"6\n2\n3\n5\n1\n4\n6",
"8\n6\n3\n2\n1\n7\n4\n8\n5",
"4\n1\n4\n2\n3",
"6\n3\n1\n5\n2\n4\n6",
"4\n3\n1\n2\n4",
"8\n6\n3\n1\n2\n5\n4\n8\n7",
"4\n2\n4\n1\n3",
"8\n6\n3\n2\n1\n4\n7\n8\n5",
"6\n2\n5\n3\n1\n4\n6",
"8\n6\n3\n2\n1\n7\n4\n5\n8",
"4\n1\n3\n4\n2",
"8\n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.