name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
devclass | Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B' and 'G', where 'B' represents a boy and 'G' represents a girl.
De... | {
"input": [],
"output": []
} | {
"input": [
"8\n0\nBB\n0\nBG\n0\nBBGG\n1\nBGG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB"
],
"output": [
"-1\n0\n1\n1\n1\n3\n1\n0\n"
]
} | {
"input": [
"8\n1\nBB\n0\nBG\n0\nBBGG\n1\nBGG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB",
"8\n1\nBB\n0\nBG\n0\nBBGG\n1\nGBG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB",
"8\n0\nBB\n0\nBG\n0\nBBGG\n1\nBGG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBBG",
"8\n0\nBB\n0\nBG\n0\nBBGG\n1\nGBG\n1\nBGGB\n1\nGBBBG\n2\nBBGG\n2\nBGB",
... |
iitk2p06 | You are given e even and o odd numbers. In a single operation, you change an even to odd number or vice versa. Find out min number of operations needed to
do such that ratio of even to odd numbers becomes 2 : 3. If it is impossible to do so, output -1.
Input
The first line of the input contains an integer T denoting... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 3\n3 2\n3 3"
],
"output": [
"0\n1\n-1"
]
} | {
"input": [],
"output": []
} |
ndungeon | Nikhil has designed the following game. The game is played in a
set of rooms in a dungeon, arranged in an M × N
rectangular grid. In one of the rooms, the evil wazir has imprisoned
the princess. The noble prince is on his way to rescue the
princess.
The prince starts in the room at the top left corner of the grid,
whic... | {
"input": [],
"output": []
} | {
"input": [
"4 3 \n2 3 2\n2 5 1\n5 3 1\n3 1 1\n4 2 15"
],
"output": [
"YES\n4"
]
} | {
"input": [
"4 3 \n2 3 2\n1 5 1\n5 3 1\n3 1 1\n4 2 15",
"4 3 \n2 3 2\n1 5 1\n5 3 1\n3 2 1\n4 2 15",
"4 3 \n2 3 2\n1 5 1\n5 3 1\n3 2 1\n4 0 15",
"4 3 \n2 3 2\n1 5 1\n5 3 1\n3 1 1\n2 2 15",
"4 3 \n2 3 4\n1 5 1\n5 3 1\n3 2 1\n4 2 15",
"4 3 \n2 3 2\n1 5 1\n9 3 1\n3 2 1\n4 0 14",
"4 3 \n2 2 2\... |
saarc05 | Problem description.
Most campuses have a lot of named buildings, and as the names tend to be rather long, the class schedules
have abbreviations. At IITD, it seems that the abbreviations have become used so widely that most people
don’t even remember the full name of the building, such as SAC. To a newcomer, this can... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\nSaLvatori\nScience LibrarieS\nSSL\n3\nstudENt aeRoSpace laBoratory\nsalVAtori\nangeles\nSAL"
],
"output": [
"Data Set 1:\nData Set 2:\nstudENt aeRoSpace laBoratory\nsalVAtori"
]
} | {
"input": [],
"output": []
} |
xorsn | Problem Description:
If you know what is XOR and Binary Representation of number you can skip to problem statement.
What is a binary representation of a number ?
All computer calculations are done in binary system that is system containing only 0’s and 1’s. Number, character, images and everything is represented and s... | {
"input": [],
"output": []
} | {
"input": [
"2 \n1\n3"
],
"output": [
"1\n0"
]
} | {
"input": [
"2 \n1\n1",
"2 \n1\n0",
"2 \n1\n-2",
"2 \n0\n-2",
"2 \n-2\n-2",
"2 \n-4\n-2",
"2 \n0\n0",
"2 \n0\n1",
"2 \n-1\n2",
"2 \n-2\n2",
"2 \n-2\n1",
"2 \n-4\n0",
"2 \n-2\n-1",
"2 \n-6\n0",
"2 \n1\n2",
"2 \n-6\n2",
"2 \n-6\n5",
"2 \n-6\n6",
... |
1279_E. New Year Permutations | Yeah, we failed to make up a New Year legend for this problem.
A permutation of length n is an array of n integers such that every integer from 1 to n appears in it exactly once.
An element y of permutation p is reachable from element x if x = y, or p_x = y, or p_{p_x} = y, and so on.
The decomposition of a permut... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 3\n5 15\n4 13\n6 8\n4 2\n"
],
"output": [
"2 1 3 \n3 1 2 5 4 \n-1\n1 2 6 3 4 5 \n1 2 4 3 \n"
]
} | {
"input": [
"5\n3 3\n5 25\n4 13\n6 8\n4 2\n",
"5\n3 3\n5 25\n4 13\n6 8\n4 1\n",
"5\n3 6\n5 25\n4 13\n6 8\n4 1\n",
"5\n3 3\n5 15\n4 18\n6 8\n4 2\n",
"5\n2 3\n5 25\n4 13\n6 8\n4 2\n",
"5\n3 2\n5 25\n4 13\n6 8\n4 1\n",
"5\n3 6\n5 25\n4 13\n6 8\n8 1\n",
"5\n3 9\n5 25\n4 9\n6 8\n4 1\n",
... |
1473_C. No More Inversions | You have a sequence a with n elements 1, 2, 3, ..., k - 1, k, k - 1, k - 2, ..., k - (n - k) (k ≤ n < 2k).
Let's call as inversion in a a pair of indices i < j such that a[i] > a[j].
Suppose, you have some permutation p of size k and you build a sequence b of size n in the following manner: b[i] = p[a[i]].
Your goal... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 1\n2 2\n3 2\n4 3\n"
],
"output": [
"\n1 \n1 2 \n2 1 \n1 3 2 \n"
]
} | {
"input": [
"4\n1 1\n3 2\n3 2\n4 3\n",
"4\n1 1\n3 2\n3 2\n5 3\n",
"4\n1 1\n2 2\n3 3\n4 3\n",
"4\n1 1\n3 2\n3 2\n3 3\n",
"4\n1 1\n3 2\n3 2\n5 5\n",
"4\n1 1\n2 2\n5 3\n4 3\n",
"4\n1 1\n3 2\n2 2\n3 3\n",
"4\n1 1\n2 2\n5 3\n5 3\n",
"4\n1 1\n2 2\n5 5\n4 3\n",
"4\n1 1\n3 2\n3 3\n4 3... |
1550_C. Manhattan Subarrays | Suppose you have two points p = (x_p, y_p) and q = (x_q, y_q). Let's denote the Manhattan distance between them as d(p, q) = |x_p - x_q| + |y_p - y_q|.
Let's say that three points p, q, r form a bad triple if d(p, r) = d(p, q) + d(q, r).
Let's say that an array b_1, b_2, ..., b_m is good if it is impossible to choose... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n2 4 1 3\n5\n6 9 1 9 6\n2\n13 37\n"
],
"output": [
"10\n12\n3\n"
]
} | {
"input": [
"3\n4\n2 4 1 3\n5\n6 9 1 18 6\n2\n13 37\n",
"3\n4\n2 4 1 5\n5\n6 9 1 18 6\n2\n13 37\n",
"3\n4\n2 4 1 3\n5\n6 9 1 9 6\n2\n8 37\n",
"3\n4\n2 7 2 5\n5\n6 9 1 6 6\n2\n13 73\n",
"3\n4\n0 0 1 3\n5\n6 9 -1 2 6\n2\n8 37\n",
"3\n4\n2 4 1 3\n5\n11 9 1 9 6\n2\n8 37\n",
"3\n4\n4 4 1 3\n5\... |
mani-and-pane-1 | Mani wants to eat chocolates, but her brother Pane does not give her the chocolates easily. Pane being a mathematician wants to teach Mani an important concept. Pane makes Mani stand on an infinite straight line. He marks all integers at equal divisions on the line and places chocolates on the integer X.
Initially Man... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 10\n15758 29586685\n1000 1000000000\n\nSAMPLE"
],
"output": [
"0.956092\n0.839450\n0.999716"
]
} | {
"input": [
"3\n1 10\n15758 29586685\n1000 1000000000\n\nSAMPLE",
"3\n2 10\n15758 34034811\n1000 1000000000\n\nSAMPLE",
"3\n2 10\n15758 2047890\n1000 1000000000\n\nSAMPLE",
"3\n2 4\n15758 2047890\n1000 1000000000\n\nSAMPLE",
"3\n2 4\n13327 2047890\n1000 1000000000\n\nSAMPLE",
"3\n2 4\n1755 20... |
p02664 NOMURA Programming Competition 2020 - Postdocs | For a string S consisting of the uppercase English letters `P` and `D`, let the doctoral and postdoctoral quotient of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, s... | {
"input": [],
"output": []
} | {
"input": [
"PD?D??P",
"P?P?"
],
"output": [
"PDPDPDP",
"PDPD"
]
} | {
"input": [
"PDPD???",
"?P?P",
"DDPP???",
"??PP",
"DDPO???",
"??OP",
"DDPO?>?",
"??OO",
"?>?OPDD",
"@?OP",
"?>?PPDD",
"@?PO",
"DDPP?>?",
"@?PN",
"DDPP?>@",
"NP?@",
"DDPP??@",
"@P?N",
"@DPP??D",
"@P@N",
"D??PPD@",
"?P@N",
"D??... |
p02793 AtCoder Beginner Contest 152 - Flatten | Given are N positive integers A_1,...,A_N.
Consider positive integers B_1, ..., B_N that satisfy the following condition.
Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds.
Find the minimum possible value of B_1 + ... + B_N for such B_1,...,B_N.
Since the answer can be enormous, print t... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 3 4",
"3\n1000000 999999 999998",
"5\n12 12 12 12 12"
],
"output": [
"13",
"996989508",
"5"
]
} | {
"input": [
"3\n2 3 2",
"3\n1000000 999999 1014329",
"5\n11 12 12 12 12",
"3\n2 6 2",
"3\n1000000 999999 1246389",
"5\n11 17 12 12 12",
"3\n1 6 2",
"3\n1000000 1225154 1246389",
"5\n11 17 14 12 12",
"3\n1001000 1225154 1246389",
"5\n16 17 14 12 12",
"3\n1001000 1225154... |
p02929 Japanese Student Championship 2019 Qualification - Cell Inversion | There are 2N squares arranged from left to right. You are given a string of length 2N representing the color of each of the squares.
The color of the i-th square from the left is black if the i-th character of S is `B`, and white if that character is `W`.
You will perform the following operation exactly N times: choo... | {
"input": [],
"output": []
} | {
"input": [
"2\nBWWB",
"5\nWWWWWWWWWW",
"4\nBWBBWWWB"
],
"output": [
"4",
"0",
"288"
]
} | {
"input": [
"5\nWWVWWWWWWW",
"4\nBWWWBBWB",
"5\nWWVWWWWWWX",
"5\nWWVWWWXWWX",
"5\nWWVVWWXWWX",
"5\nWXWWWWWWWW",
"5\nWWVWWXWWWW",
"4\nBWBBWBWW",
"5\nWWVWWWWVWX",
"5\nWWVVWWXXWX",
"5\nWWWWWWWWXW",
"5\nWWWWXWWVWW",
"4\nBWBBWBWX",
"5\nWVVVWWXXWX",
"5\nWWWWWVWWX... |
p03065 Tenka1 Programmer Contest 2019 - Polynomial Divisors | You are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.
Constraints
* 0 \leq N \leq 10^4
* |a_i| \leq 10^9(0\leq i\leq N)
* a_N \neq 0
* All values in input are integers.
Input
Input is given from Standard I... | {
"input": [],
"output": []
} | {
"input": [
"2\n7\n-7\n14",
"0\n998244353"
],
"output": [
"2\n7",
"998244353"
]
} | {
"input": [
"0\n1365261696",
"0\n754892205",
"0\n663325004",
"0\n130630416",
"0\n46502294",
"0\n41442548",
"0\n15639162",
"0\n1226279",
"0\n124557",
"0\n99361",
"0\n1336",
"0\n565",
"0\n553",
"0\n587",
"0\n1081",
"0\n964",
"0\n1921",
"0\n2909",
... |
p03208 AtCoder Beginner Contest 115 - Christmas Eve | In some other world, today is Christmas Eve.
There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.
He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees shoul... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n10\n15\n11\n14\n12",
"5 3\n5\n7\n5\n7\n7"
],
"output": [
"2",
"0"
]
} | {
"input": [
"5 3\n5\n7\n10\n7\n7",
"5 3\n5\n7\n10\n0\n7",
"5 3\n8\n7\n10\n0\n7",
"3 3\n5\n7\n10\n7\n7",
"5 3\n0\n15\n11\n15\n12",
"5 3\n10\n21\n10\n0\n6",
"3 3\n10\n7\n1\n1\n5",
"5 3\n10\n21\n19\n0\n6",
"4 3\n10\n21\n19\n0\n6",
"3 3\n5\n7\n0\n1\n7",
"5 3\n0\n15\n20\n25\n12... |
p03357 AtCoder Regular Contest 097 - Sorted and Sorted | There are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball. The integer written on the i-th ball from the left (1 ≤ i ≤ 2N) is a_i, and the color of this ball is represented by... | {
"input": [],
"output": []
} | {
"input": [
"9\nW 3\nB 1\nB 4\nW 1\nB 5\nW 9\nW 2\nB 6\nW 5\nB 3\nW 8\nB 9\nW 7\nB 2\nB 8\nW 4\nW 6\nB 7",
"3\nB 1\nW 2\nB 3\nW 1\nW 3\nB 2",
"4\nB 4\nW 4\nB 3\nW 3\nB 2\nW 2\nB 1\nW 1"
],
"output": [
"41",
"4",
"18"
]
} | {
"input": [
"3\nB 1\nW 1\nB 3\nW 2\nW 3\nB 2",
"4\nB 4\nW 4\nB 2\nW 3\nB 3\nW 2\nB 1\nW 1",
"4\nB 2\nW 4\nB 3\nW 3\nB 4\nW 2\nB 1\nW 1",
"4\nB 4\nW 4\nB 3\nW 2\nB 1\nW 3\nB 2\nW 1",
"3\nB 1\nW 1\nB 2\nW 2\nW 3\nB 3",
"3\nB 1\nW 1\nB 3\nW 3\nW 2\nB 2",
"3\nB 1\nW 2\nB 2\nW 1\nW 3\nB 3",
... |
p03515 CODE FESTIVAL 2017 Elimination Tournament Round 3 (Parallel) - Black Cats Deployment | Snuke Festival 2017 will be held in a tree with N vertices numbered 1,2, ...,N. The i-th edge connects Vertex a_i and b_i, and has joyfulness c_i.
The staff is Snuke and N-1 black cats. Snuke will set up the headquarters in some vertex, and from there he will deploy a cat to each of the other N-1 vertices.
For each v... | {
"input": [],
"output": []
} | {
"input": [
"15\n6 3 2\n13 3 1\n1 13 2\n7 1 2\n8 1 1\n2 8 2\n2 12 2\n5 2 2\n2 11 2\n10 2 2\n10 9 1\n9 14 2\n4 14 1\n11 15 2",
"19\n19 14 48\n11 19 23\n17 14 30\n7 11 15\n2 19 15\n2 18 21\n19 10 43\n12 11 25\n3 11 4\n5 19 50\n4 11 19\n9 12 29\n14 13 3\n14 6 12\n14 15 14\n5 1 6\n8 18 13\n7 16 14",
"3\n1 2 ... | {
"input": [
"19\n19 14 48\n11 19 23\n17 14 30\n7 11 15\n2 19 15\n2 18 21\n19 10 43\n12 11 25\n3 11 4\n5 19 50\n4 11 19\n9 12 29\n14 13 3\n14 6 12\n14 15 17\n5 1 6\n8 18 13\n7 16 14",
"3\n1 3 10\n2 3 20",
"19\n19 14 48\n11 19 23\n17 14 30\n7 11 15\n2 19 15\n2 18 21\n19 10 43\n12 11 25\n3 11 4\n5 19 50\n4 ... |
p03678 AtCoder Regular Contest 077 - SS | We will call a string that can be obtained by concatenating two equal strings an even string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not.
For a non-empty string S, we will define f(S) as the shortest even string that can be obtained by appending one or more characters to the end of... | {
"input": [],
"output": []
} | {
"input": [
"vgxgpuamkvgxgvgxgpuamkvgxg\n1 1000000000000000000",
"xx\n1 1000000000000000000",
"abaaba\n6 10"
],
"output": [
"87167725689669676 0 0 0 0 0 282080685775825810 0 0 0 87167725689669676 0 87167725689669676 0 0 87167725689669676 0 0 0 0 87167725689669676 141040342887912905 0 141040342887... | {
"input": [
"vgxgpuamkvgxgvgxgpuamkvgxg\n1 0000000000000000000",
"xx\n2 1000000000000000000",
"abaaca\n6 10",
"vgxgpuamkvgxgvgxgpuamkvgxg\n1 0000100000000000000",
"vgxgpualkvgxgvgxgpuamkvgxg\n1 0000100000000000000",
"abaaca\n11 11",
"vgxgpualkvgxgvgxgpuamkvgxg\n1 0001100000000000000",
... |
p03833 AtCoder Regular Contest 067 - Yakiniku Restaurants | There are N barbecue restaurants along a street. The restaurants are numbered 1 through N from west to east, and the distance between restaurant i and restaurant i+1 is A_i.
Joisino has M tickets, numbered 1 through M. Every barbecue restaurant offers barbecue meals in exchange for these tickets. Restaurant i offers a... | {
"input": [],
"output": []
} | {
"input": [
"3 4\n1 4\n2 2 5 1\n1 3 3 2\n2 2 5 1",
"5 3\n1 2 3 4\n10 1 1\n1 1 1\n1 10 1\n1 1 1\n1 1 10"
],
"output": [
"11",
"20"
]
} | {
"input": [
"3 4\n1 4\n2 2 5 1\n1 3 6 2\n2 2 5 1",
"5 3\n1 2 3 4\n10 1 1\n1 1 1\n1 10 1\n1 1 1\n0 1 10",
"1 4\n1 4\n2 2 5 1\n1 3 6 2\n2 2 5 1",
"5 3\n1 2 4 4\n10 1 1\n1 1 1\n1 10 1\n1 1 1\n0 1 10",
"1 4\n1 4\n2 3 5 1\n1 3 6 2\n2 2 5 1",
"5 3\n1 2 4 4\n16 1 1\n1 1 1\n1 10 1\n1 1 1\n0 1 10",
... |
p03998 AtCoder Beginner Contest 045 - Card Game for Three (ABC Edit) | Alice, Bob and Charlie are playing Card Game for Three, as below:
* At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged.
* The players take turns. Alice goes first.
* If the cu... | {
"input": [],
"output": []
} | {
"input": [
"abcb\naacb\nbccc",
"aca\naccc\nca"
],
"output": [
"C",
"A"
]
} | {
"input": [
"abcb\naabb\nbccc",
"caa\naccc\nca",
"aaca\naabb\ncccc",
"abcb\nbbaa\nbccc",
"aacb\nbbaa\nbccc",
"aacb\nbbaa\ncccb",
"aaca\nbbaa\ncccb",
"aaca\naabb\ncccb",
"acaa\naabb\ncccc",
"acaa\nabab\ncccc",
"acaa\nabab\nbccc",
"acaa\nabab\nbcdc",
"acaa\nabbb\nbcd... |
p00086 Patrol | In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with the shogunate and other clan. However, when it came time to decide the sharing rou... | {
"input": [],
"output": []
} | {
"input": [
"1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 7\n5 6\n6 7\n5 8\n5 8\n6 8\n6 9\n7 9\n8 9\n9 2\n0 0\n1 3\n3 4\n3 4\n4 2\n0 0"
],
"output": [
"OK\nNG"
]
} | {
"input": [
"1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 7\n5 6\n6 7\n5 8\n5 8\n3 8\n6 9\n7 9\n8 9\n9 2\n0 0\n1 3\n3 4\n3 4\n4 2\n0 0",
"1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 7\n5 6\n6 7\n5 8\n1 8\n3 8\n6 9\n7 9\n8 9\n9 2\n0 0\n1 3\n3 4\n3 4\n4 2\n1 0",
"1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n3 8\n6 14\n7... |
p00218 Dividing Students | At Aizu Shingakujuku, students are divided into classes by conducting a proficiency test when they enter the cram school. The test consists of three subjects: Mathematics, English, and Japanese, and students are divided into A, B, and C classes. The level of class A is the highest and then decreases in order.
The clas... | {
"input": [],
"output": []
} | {
"input": [
"4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0"
],
"output": [
"A\nA\nB\nC\nA\nB"
]
} | {
"input": [
"4\n100 70 20\n98 86 55\n80 34 39\n65 79 65\n2\n99 81 20\n66 72 90\n0",
"4\n100 70 20\n98 86 55\n80 34 36\n65 140 65\n2\n99 81 20\n66 72 90\n0",
"4\n100 70 20\n98 86 19\n80 34 39\n65 79 65\n2\n99 75 20\n66 72 90\n0",
"4\n010 70 20\n98 86 19\n80 34 39\n65 79 65\n2\n120 81 20\n66 72 90\n0",... |
p00378 Heat Strokes | We have had record hot temperatures this summer. To avoid heat stroke, you decided to buy a quantity of drinking water at the nearby supermarket. Two types of bottled water, 1 and 0.5 liter, are on sale at respective prices there. You have a definite quantity in your mind, but are willing to buy a quantity larger than ... | {
"input": [],
"output": []
} | {
"input": [
"180 100 2400",
"200 90 2018"
],
"output": [
"460",
"450"
]
} | {
"input": [
"180 100 3257",
"12 90 2018",
"324 100 3257",
"22 90 2018",
"324 101 3257",
"21 90 2018",
"324 111 3257",
"324 111 5696",
"467 101 5696",
"467 101 10577",
"467 001 10577",
"467 011 10577",
"21 671 759",
"467 001 8304",
"467 101 8304",
"467 1... |
p00596 Dominoes Arrangement | [0, 0]
[0, 1] [1, 1]
[0, 2] [1, 2] [2, 2]
[0, 3] [1, 3] [2, 3] [3, 3]
[0, 4] [1, 4] [2, 4] [3, 4] [4, 4]
[0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5]
[0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6]
Consider the standard set of 28 western dominoes as shown in the above figure. Given a subset of the ... | {
"input": [],
"output": []
} | {
"input": [
"6\n13 23 14 24 15 25\n10\n00 01 11 02 12 22 03 13 23 33"
],
"output": [
"Yes\nNo"
]
} | {
"input": [
"6\n13 23 20 24 15 25\n10\n00 01 11 02 12 22 03 13 23 33",
"6\n13 23 20 24 11 25\n10\n00 01 11 02 12 22 03 13 23 33",
"6\n13 23 20 24 11 25\n10\n00 01 11 02 12 22 03 13 16 33",
"6\n16 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33",
"6\n13 23 14 24 15 25\n10\n00 01 11 02 12 22 03 1... |
p00732 Twirl Around | Let's think about a bar rotating clockwise as if it were a twirling baton moving on a planar surface surrounded by a polygonal wall (see Figure 1).
<image>
Figure 1. A bar rotating in a polygon
Initially, an end of the bar (called "end A") is at (0,0), and the other end (called "end B") is at (0,L) where L is the l... | {
"input": [],
"output": []
} | {
"input": [
"4.0 2.0 8\n-1 0\n5 0\n5 -2\n7 -2\n7 0\n18 0\n18 6\n-1 6\n4.0 2.0 4\n-1 0\n10 0\n10 12\n-1 12\n4.0 1.0 7\n-1 0\n2 0\n-1 -3\n-1 -8\n6 -8\n6 6\n-1 6\n4.0 2.0 6\n-1 0\n10 0\n10 3\n7 3\n7 5\n-1 5\n5.0 2.0 6\n-1 0\n2 0\n2 -4\n6 -4\n6 6\n-1 6\n6.0 1.0 8\n-1 0\n8 0\n7 2\n9 2\n8 4\n11 4\n11 12\n-1 12\n0 0 0"... | {
"input": [
"4.0 2.0 8\n-1 0\n5 0\n5 -2\n7 -2\n7 0\n18 0\n18 6\n-1 6\n4.0 2.0 4\n-1 0\n10 0\n10 12\n0 12\n4.0 1.0 7\n-1 0\n2 0\n-1 -3\n-1 -8\n6 -8\n6 6\n-1 6\n4.0 2.0 6\n-1 0\n10 0\n10 3\n7 3\n7 5\n-1 5\n5.0 2.0 6\n-1 0\n2 0\n2 -4\n6 -4\n6 6\n-1 6\n6.0 1.0 8\n-1 0\n8 0\n7 2\n9 2\n8 4\n11 4\n11 12\n-1 12\n0 0 0",... |
p00872 Common Polynomial | Math teacher Mr. Matsudaira is teaching expansion and factoring of polynomials to his students. Last week he instructed the students to write two polynomials (with a single variable x), and to report GCM (greatest common measure) of them as a homework, but he found it boring to check their answers manually. So you are ... | {
"input": [],
"output": []
} | {
"input": [
"-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\nx^3+1\nx-1\n."
],
"output": [
"x^2-2x+1\nx+5\n1"
]
} | {
"input": [
"-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\nx^4+1\nx-1\n.",
"-(x^4-3x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\nx^3+1\nx-1\n.",
"-(x^3-3x^2+3x-1)\n(x-1)^2\nx^2+10x+15\nx^2+6x+5\nx^4+1\nx-1\n.",
"-(x^3-2x^2+3x-1)\n(x-1)^2\nx^2+10x+25\nx^2+6x+5\n1^4+x\nx-2\n.",
"-(x^3-3x^2+3x-1)\n(x... |
p01003 Doragoso Ball | Problem
If you collect L pieces, Dragoso will appear and only one Dragoso ball will be fulfilled, scattered in a labyrinth. Starting from the entrance, collecting all the balls without stopping on the way, dedicating them to the altar in the labyrinth, and casting the spell as it is, Dragoso will appear and grant his ... | {
"input": [],
"output": []
} | {
"input": [
"9 14 5 10\n1 2 1\n1 4 5\n2 4 4\n2 3 3\n2 6 2\n3 6 3\n3 7 2\n4 6 5\n4 5 6\n5 8 8\n6 7 3\n7 8 1\n7 9 9\n8 9 2\n1 9\n1\n2\n5\n7\n9\n4 5 1 3\n1 2 1\n1 3 2\n2 3 2\n2 4 9\n3 4 1\n1 4\n2\n4 5 1 10\n1 2 1\n1 3 2\n2 3 2\n2 4 9\n3 4 1\n1 4\n2\n4 3 1 1\n1 2 1\n2 3 1\n3 4 1\n1 4\n1\n4 3 1 2\n1 2 1\n2 3 1\n3 4 1... | {
"input": [
"9 14 5 10\n1 2 1\n1 4 5\n2 4 4\n2 3 3\n2 6 2\n3 6 3\n3 7 2\n4 6 5\n4 5 6\n5 8 8\n6 7 3\n7 8 1\n7 9 9\n8 9 2\n1 9\n1\n2\n5\n7\n9\n4 5 1 3\n1 2 1\n1 3 2\n2 3 2\n2 4 9\n3 4 2\n1 4\n2\n4 5 1 10\n1 2 1\n1 3 2\n2 3 2\n2 4 9\n3 4 1\n1 4\n2\n4 3 1 1\n1 2 1\n2 3 1\n3 4 1\n1 4\n1\n4 3 1 2\n1 2 1\n2 3 1\n3 4 1... |
p01135 Poor Mail Forwarding | The postal system in the area where Masa lives has changed a bit. In this area, each post office is numbered consecutively from 1 to a different number, and mail delivered to a post office is intended from that post office via several post offices. Delivered to the post office. Mail "forwarding" is only done between sp... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n1 2 10\n1 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 20 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinessMailC\n2 3 1 BusinessMailB\n3 1 1 BusinessMailA\n0 0"
],
"output": [
"Greetings 25\nLoveLetter 33\n\nBusinessMailA 2\nBusinessMailB 2\nBusinessMailC 2"
]
} | {
"input": [
"4 5\n1 2 10\n1 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 13 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinessMailC\n2 3 1 BusinessMailB\n3 1 1 BusinessMailA\n0 0",
"4 5\n1 2 10\n2 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 13 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 ... |
p01274 Magic Slayer | You are in a fantasy monster-ridden world. You are a slayer fighting against the monsters with magic spells.
The monsters have hit points for each, which represent their vitality. You can decrease their hit points by your magic spells: each spell gives certain points of damage, by which monsters lose their hit points,... | {
"input": [],
"output": []
} | {
"input": [
"3\n8000 15000 30000\n3\nFlare 45 Single 8000\nMeteor 62 All 6000\nUltimate 80 All 9999\n0"
],
"output": [
"232"
]
} | {
"input": [
"3\n8000 15000 30000\n3\nFlare 45 Single 5272\nMeteor 62 All 6000\nUltimate 80 All 9999\n0",
"3\n8000 15000 30000\n3\nFlare 45 elgniS 5272\nMeteor 62 Bll 6000\nUltimate 80 All 13247\n0",
"3\n8000 15000 37775\n3\nFlare 45 Single 8000\nMeteor 62 All 6000\nUltimate 80 All 9999\n0",
"3\n8000 ... |
p01444 Sky Jump | Dr. Kay Em, a genius scientist, developed a new missile named "Ikan-no-i." This missile has N jet engines. When the i-th engine is ignited, the missile's velocity changes to (vxi, vyi) immediately.
Your task is to determine whether the missile can reach the given target point (X, Y ). The missile can be considered as ... | {
"input": [],
"output": []
} | {
"input": [
"1\n1 1\n10 -480\n2\n6 7\n5 5\n4 1\n3\n10 5\n4 4\n8 4\n2 0\n0"
],
"output": [
"Yes\nYes\nNo"
]
} | {
"input": [
"1\n1 1\n10 -480\n2\n6 7\n5 3\n4 1\n3\n10 5\n4 4\n8 4\n2 0\n0",
"1\n1 2\n10 -480\n2\n6 7\n5 2\n4 1\n3\n10 5\n4 4\n8 4\n2 0\n0",
"1\n1 1\n10 -480\n2\n6 7\n5 5\n4 1\n3\n10 5\n4 4\n8 1\n2 0\n0",
"1\n1 2\n10 -480\n2\n6 0\n5 4\n4 1\n3\n10 5\n4 4\n8 4\n2 -1\n0",
"1\n1 2\n10 -480\n2\n6 7\n5 ... |
p01593 Earn Big | Problem C: Earn Big
A group of N people is trying to challenge the following game to earn big money.
First, N participants are isolated from each other. From this point, they are not allowed to contact each other, or to leave any information for other participants. The game organizer leads each participant, one by on... | {
"input": [],
"output": []
} | {
"input": [
"2 1",
"100 50"
],
"output": [
"0.50000000",
"0.31182782"
]
} | {
"input": [
"4 1",
"110 50",
"4 0",
"010 50",
"110 89",
"110 12",
"010 4",
"010 1",
"3 2",
"3 1",
"010 6",
"010 2",
"010 3",
"011 1",
"011 2",
"15 1",
"14 1",
"7 1",
"22 2",
"22 4",
"011 6",
"100 10",
"100 9",
"011 10",
... |
p01750 Hyperrectangle | Sunuke received a d-dimensional hypercube with a side length of l1 × ... × ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and ate the part that satisfied x1 + ... + xd ≤ s. However, xi represents the i-th coordinate. If the ... | {
"input": [],
"output": []
} | {
"input": [
"5\n12\n34\n56\n78\n90\n123",
"2\n6\n3\n4"
],
"output": [
"433127538",
"15"
]
} | {
"input": [
"5\n12\n34\n56\n17\n90\n123",
"2\n6\n3\n3",
"5\n12\n34\n56\n1\n90\n123",
"5\n12\n25\n56\n1\n90\n123",
"5\n12\n25\n56\n2\n90\n123",
"5\n12\n34\n15\n17\n90\n123",
"5\n12\n43\n56\n1\n90\n123",
"5\n12\n25\n56\n1\n24\n123",
"5\n12\n25\n56\n2\n90\n218",
"5\n12\n34\n15\n1... |
p01890 Non-redundant Drive | Example
Input
5
5 8 1 3 5
1 2 4
2 3 3
2 4 3
1 5 7
Output
4 | {
"input": [],
"output": []
} | {
"input": [
"5\n5 8 1 3 5\n1 2 4\n2 3 3\n2 4 3\n1 5 7"
],
"output": [
"4"
]
} | {
"input": [
"5\n5 8 1 3 5\n1 2 4\n2 3 3\n2 4 3\n1 7 7",
"5\n5 8 1 4 5\n1 3 5\n2 3 3\n2 4 3\n1 7 6",
"5\n5 11 1 3 5\n1 2 4\n3 3 3\n1 4 3\n1 7 7",
"5\n5 8 1 3 5\n1 3 4\n2 5 3\n2 4 3\n2 12 7",
"5\n3 8 0 4 9\n2 2 2\n2 5 3\n2 4 3\n1 7 6",
"5\n5 8 1 3 5\n1 2 4\n2 3 3\n2 4 3\n1 7 6",
"5\n5 8 1 4... |
p02027 Presents | M: Presents
Mr. Shirahane prepared the following set as a surprise present for a certain devil.
* Consists of different $ K $ natural numbers less than or equal to $ N $
* No matter which pair of two values you choose from the set, one number is divisible by the other
In fact, such a set has the property of robb... | {
"input": [],
"output": []
} | {
"input": [
"6 3"
],
"output": [
"3"
]
} | {
"input": [
"6 2",
"6 4",
"8 4",
"7 1",
"8 3",
"8 2",
"14 1",
"9 1",
"15 1",
"2 1",
"5 1",
"17 1",
"4 1",
"11 2",
"3 1",
"11 1",
"20 1",
"10 1",
"25 1",
"15 2",
"20 2",
"37 1",
"16 2",
"12 2",
"31 2",
"33 4",
... |
p02169 Count Words | Problem
There are $ M $ type characters. Use them to create a string of length $ N $. How many strings are used that have $ K $ or more? Find too much divided by $ 998244353 $.
Here, the difference between two strings of length $ N $ is defined as follows.
* If the two strings are $ S = S_1S_2 \ ldots S_N $, $ T = T... | {
"input": [],
"output": []
} | {
"input": [
"7 8 3",
"1000000000000000000 1000000000000000000 1000",
"5 10 3",
"1 1 2",
"2 10 1"
],
"output": [
"5759460",
"133611974",
"9755400",
"0",
"1024"
]
} | {
"input": [
"10 8 3",
"1000000000000000000 1000000000000000000 1001",
"5 2 3",
"10 8 6",
"2 2 2",
"1 10 1",
"10 6 6",
"2 3 2",
"2 10 2",
"2 11 2",
"3 5 3",
"6 5 3",
"6 5 2",
"6 8 2",
"12 8 2",
"9 8 2",
"9 15 2",
"9 16 2",
"9 20 2",
"9 20... |
p02310 Tangent to a Circle | Find the tangent lines between a point $p$ and a circle $c$.
Constraints
* $-1,000 \leq px, py, cx, cy \leq 1,000$
* $1 \leq r \leq 1,000$
* Distance between $p$ and the center of $c$ is greater than the radius of $c$.
Input
The input is given in the following format.
$px \; py$
$cx \; cy \; r$
$px$ and $py$ repr... | {
"input": [],
"output": []
} | {
"input": [
"-3 0\n2 2 2",
"0 0\n2 2 2"
],
"output": [
"0.6206896552 3.4482758621\n2.0000000000 0.0000000000",
"0.0000000000 2.0000000000\n2.0000000000 0.0000000000"
]
} | {
"input": [
"-3 0\n3 2 2",
"-1 0\n2 2 2",
"-4 0\n3 2 2",
"1 0\n2 2 2",
"-4 -1\n3 2 2",
"1 0\n4 2 2",
"-4 -1\n2 2 2",
"-4 -1\n4 2 2",
"-4 -1\n4 2 3",
"-4 -1\n4 2 6",
"-4 -1\n8 2 6",
"-8 -1\n8 2 6",
"-8 -2\n8 2 6",
"-8 -2\n8 2 0",
"-3 1\n3 2 2",
"-1 0\n2 ... |
p02458 Multi-Set | For a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$.
* 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$.
* delete($x$): Delete all $x$ from $S$.
... | {
"input": [],
"output": []
} | {
"input": [
"10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\n0 4\n3 1 4"
],
"output": [
"1\n2\n3\n4\n2\n0\n1\n4\n1\n1\n3\n4"
]
} | {
"input": [
"10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n0 4\n3 1 4",
"10\n0 1\n0 1\n0 2\n0 0\n2 2\n1 1\n1 2\n1 3\n0 4\n3 1 4",
"10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n1 4\n3 1 4",
"10\n0 1\n0 1\n0 2\n0 5\n2 2\n1 1\n1 1\n1 3\n1 4\n3 1 4",
"10\n0 1\n0 1\n0 2\n0 -1\n2 2\n1 0\n1 2\n1 3\n0 4\n3 ... |
cccs3 | There is an infinite binary tree which has following structure:
3
/ \
6 8
/ \ / \
11 13 15 ... | {
"input": [],
"output": []
} | {
"input": [
"3\n39\n16\n70"
],
"output": [
"RIGHT\nNO\nLEFT"
]
} | {
"input": [],
"output": []
} |
cstrike3 | Shinchan is new to COUNTER STRIKE and he cannot differentiate between players of Terrorist and Counter Terrorist. Since he is new to COUNTER STRIKE so he used to kill his team members as he couldn't recognize them. Everyone got frustrated with him. One day he came up with a formula to recognize players by their user na... | {
"input": [],
"output": []
} | {
"input": [
"4\nace\nshars\nblizzard\nsak"
],
"output": [
"Counter Terrorist\nTerrorist\nCounter Terrorist\nCounter Terrorist\n"
]
} | {
"input": [
"4\nace\nshars\nalizzard\nsak",
"4\nace\nshars\ndraz{ila\nsak",
"4\ncfa\nscrgt\nazk{ldrb\nrbl",
"4\nfca\ntrgds\n`zk{rclc\nrbl",
"4\nhac\nsrcsg\n`sk{eycl\nbnn",
"4\ncbh\nsrbth\n`ry{eklc\noob",
"4\niai\n`ritu\nk`zd_ytl\nond",
"4\nibi\n_ritt\n`kzd_ytl\ndno",
"4\nbii\n_rit... |
holes | Chef wrote some text on a piece of paper and now he wants to know how many holes are in the text. What is a hole? If you think of the paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions. For example letters "A", "D", "O", "P", "R" divide the plane into two regions so... | {
"input": [],
"output": []
} | {
"input": [
"2\nCODECHEF\nDRINKEATCODE"
],
"output": [
"2\n5\n"
]
} | {
"input": [
"2\nFEHCEDOC\nDRINKEATCODE",
"2\nFEHCEEOC\nDRINKEATCODE",
"2\nCOEECHFE\nDRJNKEATBODE",
"2\nEFJEFCOB\nDRJNKEAUBODE",
"2\nEJDEFCOB\nDQJNKEATBODE",
"2\nEJDEFCOB\nCQJNKEATBODE",
"2\nEODDFCJB\nEDOBTADKNJQC",
"2\nBCJFDDOE\nDDOBTADJNJQC",
"2\nEOCDFKBD\nCPJBJDNTBPDD",
"2\n... |
mmsum | You're given an array of N integer numbers.
The maximal sum of the array is the maximal sum of the elements of a nonempty consecutive subarray of this array. For example, the maximal sum of the array [1, -2, 3, -2, 5] is 6 because the sum of the subarray [3, -2, 5] is 6 and it is impossible to achieve greater subarra... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n1 -2 3 -2 5\n2\n-1 -2"
],
"output": [
"8\n-1\n"
]
} | {
"input": [
"2\n5\n2 -2 3 -2 5\n2\n-1 -2",
"2\n5\n2 0 3 -2 5\n2\n-1 -2",
"2\n5\n1 0 3 -2 5\n2\n-1 -2",
"2\n5\n1 0 3 -2 5\n2\n0 -2",
"2\n5\n1 -1 3 -4 3\n2\n-1 -2",
"2\n5\n1 -1 3 -4 3\n2\n-2 -2",
"2\n5\n2 0 3 -2 5\n2\n0 -3",
"2\n5\n1 0 3 -4 3\n2\n-2 -2",
"2\n5\n2 0 0 -2 5\n2\n0 -3",... |
repub | On the occasion of 66^th Republic day, a young lad, Lemon Kumar (a.k.a Yaar Kumar), is revising his speech again and again to remember it. He found that some of the letters in his
speech is repeated quite often. Being very fond of programming, like the Chef, he took it as a challenge and decided to find this letter. He... | {
"input": [],
"output": []
} | {
"input": [
"1\nHappy Republic Day!!!"
],
"output": [
"p"
]
} | {
"input": [],
"output": []
} |
tux03 | Problem description
The IPL Auctions are finally over and cricket legend Rahul Dravid now wants to find the most balanced team in the league.
Each player is bought at some price X in the auction. Dravid defines the balance of each team as the largest price difference between
any 2 players in that team. The most balanc... | {
"input": [],
"output": []
} | {
"input": [
"1 \n3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 \n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 \n4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 \n5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 \n6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 \n7 14 21 28 35 42 49 56 63 70 77 84 91 98 105 \n8 16 24 32 40 48 56 64 72... | {
"input": [
"1 \n3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 \n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 \n4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 \n5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 \n6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 \n7 14 21 28 35 42 49 56 63 70 77 84 91 98 105 \n8 16 24 32 40 48 56 64 72... |
1252_F. Regular Forestation | A forestation is an act of planting a bunch of trees to grow a forest, usually to replace a forest that had been cut down. Strangely enough, graph theorists have another idea on how to make a forest, i.e. by cutting down a tree!
A tree is a graph of N nodes connected by N - 1 edges. Let u be a node in a tree U which d... | {
"input": [],
"output": []
} | {
"input": [
"13\n1 5\n1 7\n2 4\n2 8\n2 11\n3 12\n4 7\n4 12\n6 11\n7 13\n9 10\n9 12\n",
"6\n1 2\n1 3\n2 4\n3 5\n3 6\n"
],
"output": [
"\n3\n",
"\n-1\n"
]
} | {
"input": [],
"output": []
} |
1360_A. Minimal Square | Find the minimum area of a square land on which you can place two identical rectangular a × b houses. The sides of the houses should be parallel to the sides of the desired square land.
Formally,
* You are given two identical rectangles with side lengths a and b (1 ≤ a, b ≤ 100) — positive integers (you are given ... | {
"input": [],
"output": []
} | {
"input": [
"8\n3 2\n4 2\n1 1\n3 1\n4 7\n1 3\n7 4\n100 100\n"
],
"output": [
"16\n16\n4\n9\n64\n9\n64\n40000\n"
]
} | {
"input": [
"8\n3 2\n4 2\n1 1\n3 1\n4 7\n1 3\n7 4\n100 101\n",
"8\n3 2\n4 2\n1 1\n3 1\n4 7\n1 2\n7 4\n100 101\n",
"8\n3 2\n4 2\n1 1\n3 1\n1 7\n1 2\n7 4\n100 101\n",
"8\n3 2\n2 2\n1 1\n3 1\n1 11\n1 2\n7 4\n100 101\n",
"8\n3 2\n2 2\n1 1\n4 1\n2 11\n1 2\n7 4\n100 101\n",
"8\n3 2\n2 2\n1 1\n4 1\n... |
1517_E. Group Photo | In the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each of them either holds a cardboard with the letter 'C' or a cardboard with the letter 'P'.
Let C=\\{c_1,c_2,...,c_m\... | {
"input": [],
"output": []
} | {
"input": [
"3\n5\n2 1 2 1 1\n4\n9 2 2 2\n1\n998244353\n"
],
"output": [
"\n10\n7\n1\n"
]
} | {
"input": [
"3\n5\n2 1 2 1 1\n4\n11 2 2 2\n1\n998244353\n",
"3\n5\n1 1 2 1 1\n4\n11 2 2 2\n1\n998244353\n",
"3\n5\n2 2 2 1 1\n4\n11 2 2 2\n1\n998244353\n",
"3\n5\n1 1 1 1 1\n4\n11 2 3 2\n1\n998244353\n",
"3\n5\n1 1 0 1 1\n4\n11 2 2 3\n1\n998244353\n",
"3\n5\n1 1 2 1 2\n4\n11 2 2 2\n1\n9982443... |
598_E. Chocolate Bar | You have a rectangular chocolate bar consisting of n × m single squares. You want to eat exactly k squares, so you may need to break the chocolate bar.
In one move you can break any single rectangular piece of chocolate in two rectangular pieces. You can break only by lines between squares: horizontally or vertically... | {
"input": [],
"output": []
} | {
"input": [
"4\n2 2 1\n2 2 3\n2 2 2\n2 2 4\n"
],
"output": [
" 5\n 5\n 4\n ... | {
"input": [
"4\n2 2 1\n2 2 1\n2 2 2\n2 2 4\n",
"4\n2 2 2\n2 2 1\n2 2 2\n2 2 4\n",
"4\n2 2 4\n2 2 1\n2 2 2\n2 2 4\n",
"4\n2 1 1\n2 2 3\n2 2 2\n2 2 4\n",
"4\n2 1 1\n2 2 3\n2 2 2\n4 2 4\n",
"4\n2 2 2\n2 2 1\n4 2 2\n2 2 2\n",
"4\n2 1 1\n2 3 3\n2 2 2\n4 2 8\n",
"4\n2 2 1\n2 2 1\n4 2 2\n2 2... |
easy-strong-permutation | Kevin has a sequence of integers a1, a2, ..., an. Define the strength of the sequence to be
|a1 - a2| + |a2 - a3| + ... + |an-1 - an| + |an - a1|.
Kevin wants to make his sequence stronger, so he reorders his sequence into a new sequence b1, b2, ..., bn. He wants this new sequence to be as strong as possible. What is... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 4 8\n\nSAMPLE"
],
"output": [
"18"
]
} | {
"input": [],
"output": []
} |
p02638 AtCoder Grand Contest 046 - Forbidden Tournament | Given are integers N and K, and a prime number P. Find the number, modulo P, of directed graphs G with N vertices that satisfy below. Here, the vertices are distinguishable from each other.
* G is a tournament, that is, G contains no duplicated edges or self-loops, and exactly one of the edges u\to v and v\to u exists... | {
"input": [],
"output": []
} | {
"input": [
"7 3 998244353",
"50 37 998244353",
"4 3 998244353"
],
"output": [
"720",
"495799508",
"56"
]
} | {
"input": [
"7 1 998244353",
"6 3 998244353",
"5 2 998244353",
"12 6 998244353",
"3 2 998244353",
"7 6 998244353",
"1 0 998244353",
"13 6 998244353",
"3 1 998244353",
"13 9 998244353",
"7 4 998244353",
"50 35 998244353",
"9 4 998244353",
"13 11 998244353",
... |
p02769 AtCoder Beginner Contest 156 - Roaming | There is a building with n rooms, numbered 1 to n.
We can move from any room to any other room in the building.
Let us call the following event a move: a person in some room i goes to another room j~ (i \neq j).
Initially, there was one person in each room in the building.
After that, we know that there were exactl... | {
"input": [],
"output": []
} | {
"input": [
"3 2",
"200000 1000000000",
"15 6"
],
"output": [
"10",
"607923868",
"22583772"
]
} | {
"input": [
"1 2",
"15 8",
"30 6",
"4 2",
"200000 0000001000",
"4 4",
"200000 0000001001",
"5 4",
"200000 0001001001",
"90099 0001001001",
"140753 0011001000",
"135689 0011001000",
"125848 0011001000",
"111965 0011010000",
"68276 0011010000",
"86789 000... |
p02904 AtCoder Grand Contest 038 - Sorting a Segment | Snuke has a permutation (P_0,P_1,\cdots,P_{N-1}) of (0,1,\cdots,N-1).
Now, he will perform the following operation exactly once:
* Choose K consecutive elements in P and sort them in ascending order.
Find the number of permutations that can be produced as P after the operation.
Constraints
* 2 \leq N \leq 200000... | {
"input": [],
"output": []
} | {
"input": [
"10 4\n2 0 1 3 7 5 4 6 8 9",
"5 3\n0 2 1 4 3",
"4 4\n0 1 2 3"
],
"output": [
"6",
"2",
"1"
]
} | {
"input": [
"10 4\n2 0 1 2 7 5 4 6 8 9",
"5 3\n1 2 1 4 3",
"4 4\n0 1 2 4",
"5 3\n2 2 1 4 3",
"7 4\n1 0 1 2 7 5 4 6 8 9",
"8 4\n1 1 0 4",
"10 4\n2 -1 1 2 7 5 4 6 4 9",
"12 4\n-1 0 2 2 14 9 8 6 3 2",
"13 4\n1 0 0 2 7 5 4 1 3 9",
"13 4\n1 0 4 2 13 9 8 21 5 9",
"10 4\n1 0 1 2 ... |
p03039 AtCoder Beginner Contest 127 - Cell Distance | We have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.
If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is... | {
"input": [],
"output": []
} | {
"input": [
"2 2 2",
"100 100 5000",
"4 5 4"
],
"output": [
"8",
"817260251",
"87210"
]
} | {
"input": [
"100 100 4270",
"100 100 619",
"100 101 619",
"110 101 619",
"110 101 767",
"110 111 767",
"110 111 32",
"110 111 3",
"100 111 3",
"110 101 3",
"100 101 3",
"4 2 2",
"100 110 5000",
"4 5 7",
"100 100 6005",
"100 111 619",
"110 101 941",
... |
p03180 Educational DP Contest - Grouping | There are N rabbits, numbered 1, 2, \ldots, N.
For each i, j (1 \leq i, j \leq N), the compatibility of Rabbit i and j is described by an integer a_{i, j}. Here, a_{i, i} = 0 for each i (1 \leq i \leq N), and a_{i, j} = a_{j, i} for each i and j (1 \leq i, j \leq N).
Taro is dividing the N rabbits into some number of... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 10 20\n10 0 -100\n20 -100 0",
"4\n0 1000000000 1000000000 1000000000\n1000000000 0 1000000000 1000000000\n1000000000 1000000000 0 -1\n1000000000 1000000000 -1 0",
"16\n0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7\n5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9\n-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9\n-5 -9... | {
"input": [
"16\n0 5 -4 -5 -8 -4 7 2 -4 0 7 0 2 -3 7 7\n5 0 8 -9 3 5 2 -7 2 -7 0 -1 -4 1 -1 9\n-4 8 0 -9 8 9 3 1 4 9 6 6 -6 1 8 9\n-5 -9 -9 0 -7 6 4 -1 9 -3 -5 0 1 2 -4 1\n-8 3 8 -7 0 -5 -9 9 1 -9 -6 -3 -8 3 4 3\n-4 5 9 6 -5 0 -6 1 -2 2 0 -5 -2 3 1 2\n7 2 3 4 -9 -6 0 -2 -2 -9 -3 9 -2 9 2 -5\n2 -7 1 -1 9 1 -2 0 -... |
p03328 AtCoder Beginner Contest 099 - Stone Monument | In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.
It had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those towers that are not cov... | {
"input": [],
"output": []
} | {
"input": [
"54 65",
"8 13"
],
"output": [
"1",
"2"
]
} | {
"input": [
"105 65",
"8 16",
"105 88",
"105 147",
"0 1",
"196 147",
"0 2",
"96 147",
"1 2",
"96 262",
"96 336",
"96 412",
"96 590",
"96 816",
"5 1",
"64 816",
"5 0",
"64 1208",
"7 0",
"64 2323",
"7 1",
"66 2323",
"-1 1",
... |
p03484 AtCoder Regular Contest 088 - Christmas Tree | Takahashi has decided to make a Christmas Tree for the Christmas party in AtCoder, Inc.
A Christmas Tree is a tree with N vertices numbered 1 through N and N-1 edges, whose i-th edge (1\leq i\leq N-1) connects Vertex a_i and b_i.
He would like to make one as follows:
* Specify two non-negative integers A and B.
* Pr... | {
"input": [],
"output": []
} | {
"input": [
"7\n1 2\n2 3\n2 4\n4 5\n4 6\n6 7",
"10\n1 2\n2 3\n3 4\n2 5\n6 5\n6 7\n7 8\n5 9\n10 5",
"8\n1 2\n2 3\n3 4\n4 5\n5 6\n5 7\n5 8"
],
"output": [
"3 2",
"3 4",
"2 5"
]
} | {
"input": [
"7\n1 2\n2 3\n2 4\n2 5\n4 6\n6 7",
"7\n1 4\n2 3\n2 4\n4 5\n4 6\n6 7",
"7\n1 4\n2 3\n2 4\n4 5\n7 6\n6 7",
"7\n1 4\n2 3\n2 4\n1 5\n7 6\n6 7",
"7\n1 4\n2 3\n2 4\n1 5\n7 6\n6 5",
"7\n1 4\n2 3\n2 4\n4 5\n7 3\n6 3",
"7\n1 2\n2 3\n4 4\n1 5\n7 6\n6 7",
"7\n1 4\n2 3\n2 4\n1 5\n5 6\... |
p03649 AtCoder Regular Contest 079 - Decrease (Judge ver.) | We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.)
* Determine the largest element in the sequence (if there is more than... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2",
"4\n3 3 3 3",
"7\n27 0 0 0 0 0 0",
"3\n1 0 3",
"10\n1000 193 256 777 0 1 1192 1234567891011 48 425"
],
"output": [
"2",
"0",
"3",
"1",
"1234567894848"
]
} | {
"input": [
"2\n2 4",
"4\n3 3 3 2",
"10\n1000 193 256 777 0 2 1192 1234567891011 48 425",
"2\n2 7",
"10\n1000 193 256 777 0 2 1192 2138223215855 48 425",
"2\n0 7",
"10\n1000 193 256 777 0 2 2173 2138223215855 48 425",
"4\n1 6 3 4",
"10\n1000 193 256 777 0 2 2173 2532903011866 48 4... |
p03805 AtCoder Beginner Contest 054 - One-stroke Path | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges.
Here, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M).
How many different paths start from vertex 1 and vi... | {
"input": [],
"output": []
} | {
"input": [
"7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7",
"3 3\n1 2\n1 3\n2 3"
],
"output": [
"1",
"2"
]
} | {
"input": [
"7 4\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7",
"7 7\n1 3\n2 7\n3 4\n4 5\n4 1\n5 6\n6 7",
"7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n4 6\n6 7",
"7 4\n1 4\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7",
"7 7\n1 5\n2 7\n3 4\n4 5\n4 6\n4 6\n6 7",
"7 4\n1 5\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7",
"7 4\n1 5\n2 7\n3 4\n4 5\... |
p03973 CODE FESTIVAL 2016 qual B - Greedy customers | N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i.
Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product... | {
"input": [],
"output": []
} | {
"input": [
"15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9",
"3\n3\n2\n5"
],
"output": [
"18",
"3"
]
} | {
"input": [
"15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n6\n9",
"3\n3\n2\n10",
"3\n6\n2\n10",
"3\n6\n3\n10",
"3\n7\n3\n10",
"3\n7\n5\n10",
"3\n7\n9\n10",
"3\n7\n13\n10",
"15\n3\n1\n4\n1\n5\n9\n2\n11\n5\n3\n5\n8\n9\n7\n9",
"15\n3\n1\n1\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n6\n9",
"... |
p00062 What is the Bottommost? | Consider creating the following number pattern.
4 8 2 3 1 0 8 3 7 6
2 0 5 4 1 8 1 0 3
2 5 9 5 9 9 1 3
7 4 4 4 8 0 4
1 8 8 2 8 4
9 6 0 0 2
5 6 0 2
1 6 2
7 8
Five
This pattern follows the rules below.
A B
C
In the sequence of numbers, C is the ones digit of A + B. For example
9 5
Four
Now, the ones digit of 9... | {
"input": [],
"output": []
} | {
"input": [
"4823108376\n1234567890\n0123456789"
],
"output": [
"5\n6\n4"
]
} | {
"input": [
"4823108376\n2273064329\n0123456789",
"4823108376\n2314825047\n0123456789",
"4823108376\n1842094049\n0123456789",
"4823108376\n2704372300\n0123456789",
"4823108376\n2811474872\n0123456789",
"4823108376\n1472363412\n0123456789",
"4823108376\n5495669921\n0123456789",
"482310... |
p00193 Convenience Store | Convenience store Deven Eleven is planning to open its first store in Aizuwakamatsu City to expand its business. There are already many other convenience stores in Aizuwakamatsu, so the place to open a new store is likely to be the key to success. Under the premise that "customers use the convenience store closest to t... | {
"input": [],
"output": []
} | {
"input": [
"6 6\n6\n1 1\n6 1\n3 2\n3 5\n1 6\n5 6\n2\n1 3\n5 3\n6 6\n6\n3 2\n3 5\n6 1\n1 1\n1 6\n5 6\n2\n2 3\n5 3\n0 0"
],
"output": [
"4\n4"
]
} | {
"input": [
"6 6\n6\n1 1\n6 1\n3 2\n3 5\n1 6\n5 6\n2\n1 3\n5 3\n6 6\n6\n3 2\n3 5\n6 1\n1 1\n1 6\n5 6\n2\n2 3\n6 3\n0 0",
"6 6\n6\n1 1\n6 1\n3 2\n3 5\n0 6\n5 6\n2\n1 3\n2 3\n6 6\n6\n3 2\n3 5\n6 1\n1 1\n1 6\n5 6\n2\n1 3\n6 3\n0 0",
"6 6\n6\n1 1\n4 1\n3 2\n3 5\n1 6\n5 6\n2\n1 3\n5 3\n6 6\n6\n3 2\n3 5\n6 1\n... |
p00348 Sort | After entering high school, Takeko, who joined the programming club, gradually became absorbed in the fun of algorithms. Now, when I'm in the second grade, I'd like to participate in Programming Koshien.
At one point, Takeko, who learned about sorting algorithms, tried to design a sorting algorithm herself. The sort a... | {
"input": [],
"output": []
} | {
"input": [
"4\n4 3 2 1",
"6\n1 3 6 5 8 2"
],
"output": [
"6",
"10"
]
} | {
"input": [
"4\n4 3 2 0",
"6\n0 3 6 5 8 2",
"4\n0 3 2 1",
"6\n1 0 6 5 8 2",
"6\n1 5 6 4 12 0",
"4\n-1 5 0 1",
"6\n0 3 1 5 8 2",
"6\n-2 3 6 0 13 2",
"6\n-1 1 0 5 10 3",
"4\n-1 1 0 2",
"6\n1 3 6 0 8 2",
"6\n1 3 0 5 8 4",
"6\n1 3 5 -1 8 0",
"6\n-1 3 5 0 65 6",
... |
p00544 Russian Flag | problem
President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red.
Chairman K is trying to repaint some of the squares on this flag to make i... | {
"input": [],
"output": []
} | {
"input": [
"4 5\nWRWRW\nBWRWB\nWRWRW\nRWBWR"
],
"output": [
"11"
]
} | {
"input": [
"4 5\nWRWRW\nBRWWB\nWRWRW\nRWBWR",
"4 5\nWRWRW\nBWRWB\nWRWRW\nRWBWQ",
"4 5\nWQWRW\nBWRXB\nRVWRW\nWQBWQ",
"4 3\nWQWRW\nBWRXB\nRVWRW\nRWBWQ",
"4 5\nWQWRW\nBWRXC\nRVWRW\nWQBWQ",
"4 10\nWRWQW\nBWRXB\nRVWRW\nRWBWQ",
"4 0\nWQXRW\nBWRXB\nVRWRW\nRWBWQ",
"4 16\nWRWQW\nBWRXB\nRVWRW\... |
p00708 Building a Space Station | You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.
The space station is made up with a number of units, called cells. All cells are sphere-shaped, but their sizes are not necessar... | {
"input": [],
"output": []
} | {
"input": [
"3\n10.000 10.000 50.000 10.000\n40.000 10.000 50.000 10.000\n40.000 40.000 50.000 10.000\n2\n30.000 30.000 30.000 20.000\n40.000 40.000 40.000 20.000\n5\n5.729 15.143 3.996 25.837\n6.013 14.372 4.818 10.671\n80.115 63.292 84.477 15.120\n64.095 80.924 70.029 14.881\n39.472 85.116 71.369 5.553\n0"
]... | {
"input": [
"3\n10.000 10.000 50.000 10.000\n40.000 10.000 50.9661040800581 10.000\n40.000 40.000 50.000 10.000\n2\n30.000 30.000 30.000 20.000\n40.000 40.000 40.000 20.000\n5\n5.729 15.143 3.996 25.837\n6.013 14.372 4.818 10.671\n80.115 63.292 84.477 15.120\n64.095 80.924 70.029 14.881\n39.472 85.116 71.369 5.5... |
p00847 Cubic Eight-Puzzle | Let's play a puzzle using eight cubes placed on a 3 × 3 board leaving one empty square.
Faces of cubes are painted with three colors. As a puzzle step, you can roll one of the cubes to the adjacent empty square. Your goal is to make the specified color pattern visible from above by a number of such steps.
The rules o... | {
"input": [],
"output": []
} | {
"input": [
"1 2\nW W W\nE W W\nW W W\n2 1\nR B W\nR W W\nE W W\n3 3\nW B W\nB R E\nR B R\n3 3\nB W R\nB W R\nB E R\n2 1\nB B B\nB R B\nB R E\n1 1\nR R R\nW W W\nR R E\n2 1\nR R R\nB W B\nR R E\n3 2\nR R R\nW E W\nR R R\n0 0"
],
"output": [
"0\n3\n13\n23\n29\n30\n-1\n-1"
]
} | {
"input": [
"1 2\nW W W\nE W W\nW W W\n2 1\nR B W\nR W W\nE W W\n3 3\nW B W\nB R E\nR B R\n3 3\nB W R\nB W R\nB E R\n2 1\nB B B\nB R B\nB R E\n1 1\nR R R\nW W W\nR R E\n2 1\nR R R\nB W B\nR R E\n3 2\nR R R\nW E V\nR R R\n0 0",
"1 2\nW W W\nE W W\nW W W\n2 1\nR B W\nR W W\nE W W\n1 3\nW B W\nB R E\nR B R\n3 3... |
p00979 Fast Forwarding | Fast Forwarding
Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his video player.
... | {
"input": [],
"output": []
} | {
"input": [
"19"
],
"output": [
"5"
]
} | {
"input": [
"0",
"26",
"25",
"23",
"5",
"4",
"1",
"8",
"38",
"47",
"48",
"75",
"138",
"149",
"132",
"374",
"315",
"933",
"945",
"456",
"942",
"2139",
"1374",
"3723",
"18",
"14",
"7",
"2",
"3",
"12"... |
p01111 Skyscraper MinatoHarukas | Skyscraper "MinatoHarukas"
Mr. Port plans to start a new business renting one or more floors of the new skyscraper with one giga floors, MinatoHarukas. He wants to rent as many vertically adjacent floors as possible, because he wants to show advertisement on as many vertically adjacent windows as possible. The rent fo... | {
"input": [],
"output": []
} | {
"input": [
"15\n16\n2\n3\n9699690\n223092870\n847288609\n900660121\n987698769\n999999999\n0"
],
"output": [
"1 5\n16 1\n2 1\n1 2\n16 4389\n129 20995\n4112949 206\n15006 30011\n46887 17718\n163837 5994"
]
} | {
"input": [
"15\n16\n2\n3\n9699690\n116276261\n847288609\n900660121\n987698769\n999999999\n0",
"15\n16\n2\n3\n9699690\n223092870\n869854515\n900660121\n987698769\n999999999\n0",
"15\n26\n2\n3\n9699690\n223092870\n869854515\n900660121\n987698769\n999999999\n0",
"15\n26\n3\n3\n9699690\n223092870\n86985... |
p01249 Billion Million Thousand | A linguist, Nodvic Natharus Damenhof (commonly called Dr. Usoperant), invented an artificial language Usoperant in 2007. The word usoperant means ‘one which tires’. Damenhof’s goal was to create a complex and pedantic language that would remind many difficulties in universal communications. Talking in Usoperant, you sh... | {
"input": [],
"output": []
} | {
"input": [
"3\nbillion 9\nmillion 6\nthousand 3\nbillionmillionthousand\n3\noku 8\nsen 3\nman 4\nokusenman\n2\nnico 2\nvideo 4\nniconicovideo\n6\nabcd 1\nefgh 2\nabcde 4\nfgh 6\ny 8\nyy 10\nabcdefgh\n0"
],
"output": [
"Case 1: 14\nCase 2: 9\nCase 3: 10\nCase 4: 2"
]
} | {
"input": [
"3\nbillion 9\nmillion 6\nthousand 3\nbillionmillionthousand\n3\noku 15\nsen 3\nman 4\nokusenman\n2\nnico 2\nvideo 4\nniconicovideo\n6\nabcd 1\nefgh 2\nabcde 4\nfgh 6\ny 8\nyy 10\nabcdefgh\n0",
"3\nbillion 9\nmillion 6\nthousand 3\nbillionmillionthousand\n3\noku 15\nsen 3\nman 4\nokusenman\n2\nni... |
p01410 Dangerous Tower | Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to gain dexterity that never mistypes by carefully stacking blocks. Since there are many building blocks, let's build a tall tower.
There are N blocks, and the i-th (... | {
"input": [],
"output": []
} | {
"input": [
"3\n10 40\n10 40\n20 30",
"4\n1 2\n2 3\n3 4\n4 1"
],
"output": [
"80",
"11"
]
} | {
"input": [
"3\n10 40\n15 40\n20 30",
"4\n1 2\n3 3\n3 4\n4 1",
"3\n10 40\n15 40\n40 30",
"4\n1 2\n3 3\n3 7\n4 1",
"4\n2 2\n3 3\n3 7\n4 1",
"3\n10 40\n15 40\n20 32",
"4\n2 4\n3 3\n3 7\n4 1",
"3\n10 36\n15 40\n20 32",
"3\n10 42\n6 40\n20 32",
"4\n1 4\n1 3\n3 1\n1 2",
"3\n6 4... |
p01564 Do use segment tree | Given a tree with n (1 ≤ n ≤ 200,000) nodes and a list of q (1 ≤ q ≤ 100,000) queries, process the queries in order and output a value for each output query. The given tree is connected and each node on the tree has a weight wi (-10,000 ≤ wi ≤ 10,000).
Each query consists of a number ti (ti = 1, 2), which indicates th... | {
"input": [],
"output": []
} | {
"input": [
"7 5\n-8 5 5 5 5 5 5\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7\n2 3 7 0\n2 5 2 0\n2 4 3 0\n1 1 1 -1\n2 3 7 0",
"21 30\n10 0 -10 -8 5 -5 -4 -3 1 -2 8 -1 -7 2 7 6 -9 -6 3 4 9\n10 3\n3 2\n3 12\n12 4\n4 13\n4 9\n10 21\n21 1\n1 11\n11 14\n1 15\n10 6\n6 17\n6 16\n6 5\n5 18\n5 19\n10 7\n10 8\n8 20\n1 1 21 -10\n1 3 ... | {
"input": [
"21 30\n10 0 -10 -8 5 -5 -4 -3 1 -2 8 -1 -7 2 7 6 -9 -6 3 4 9\n10 3\n3 2\n3 12\n12 4\n4 13\n4 9\n10 21\n21 1\n1 11\n11 14\n1 15\n10 6\n6 17\n6 16\n6 5\n5 18\n5 19\n10 7\n10 8\n8 20\n1 1 21 -10\n1 3 19 10\n2 1 13 0\n1 4 18 8\n1 5 17 -5\n2 16 7 0\n1 6 16 5\n1 7 15 4\n2 4 20 0\n1 8 14 3\n1 9 13 -1\n2 9 ... |
p01726 Almost Same Substring | The unlucky Ikta-kun has rewritten the important character string T that he had to a different character string T'by the virus. It is known that the virus has rewritten one letter of T to a different letter. That is, T and T'are different by exactly one character. In order to restore T, Ikta prepared a document S in wh... | {
"input": [],
"output": []
} | {
"input": [
"aaaaaa\naaaaaa",
"abcbcdbc\nabc",
"baaaaaaaa\nb"
],
"output": [
"0",
"2",
"8"
]
} | {
"input": [
"aaaaaa\naaaaab",
"bbcbcdbc\nabc",
"aaaaaa\nbbaaaa",
"bbcbcdbc\nbca",
"aaaaaa\nbaaaaa",
"bbcbcdbc\nacb",
"aaaaaa\nbbaa`a",
"cbdcbcbb\nbca",
"aaaaaa\nbaba`a",
"cbdcbcbb\nbda",
"aaaaab\nbaba`a",
"ccdcbcbb\nbda",
"aaaaab\ncaba`a",
"ccdcbcbb\ndba",
... |
p01864 Travel Support | G: Travel Support-Travel Support-
story
I, Honoka Kosaka, 16 years old! I'm a student idol! !!
In order to give a live performance to convey the goodness of student idols to everyone, we invite many student idols to perform live at Akiba Stadium.
However, some live participants come from afar and it costs a lot of ... | {
"input": [],
"output": []
} | {
"input": [
"5 6\n100 80 70 60 50\n1 2 500\n2 5 100\n1 3 400\n1 4 200\n3 5 700\n4 5 800\n1\n5 3 600"
],
"output": [
"0"
]
} | {
"input": [
"5 6\n100 80 70 60 50\n1 2 500\n2 5 100\n1 3 400\n1 4 200\n3 5 700\n2 5 800\n1\n5 3 600",
"5 6\n100 80 70 60 50\n1 2 500\n2 5 101\n1 3 400\n1 4 200\n3 5 700\n4 5 800\n1\n5 3 600",
"5 6\n100 80 70 60 50\n2 2 500\n2 5 100\n1 3 400\n1 4 200\n3 5 1047\n2 5 800\n1\n5 3 600",
"5 6\n100 80 70 60... |
p02000 Bumpy Array | problem
Given the sequence $ A $ of length $ N $. The $ i $ item in $ A $ is $ A_i $. You can do the following for this sequence:
* $ 1 \ leq i \ leq N --Choose the integer i that is 1 $. Swap the value of $ A_i $ with the value of $ A_ {i + 1} $.
Find the minimum number of operations required to make $ A $ a sequ... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2 3 4 5"
],
"output": [
"2"
]
} | {
"input": [
"5\n0 2 3 4 5",
"5\n1 2 1 4 5",
"5\n0 4 3 13 4",
"5\n0 2 3 4 8",
"5\n0 2 3 4 14",
"5\n0 1 3 4 5",
"5\n0 2 3 4 2",
"5\n0 2 3 8 2",
"5\n0 2 3 13 2",
"5\n0 2 3 13 4",
"5\n0 4 3 9 4",
"5\n0 4 3 12 4",
"5\n1 4 3 12 4",
"5\n2 4 3 12 4",
"5\n2 4 3 22 4... |
p02145 Shiritori | Problem
Here is a list of strings. Let's take a break and play with shiritori. Shiritori is performed according to the following rules.
1. First of all, select one of your favorite strings from the list and exclude that string from the list.
2. Next, select one character string from the list in which the last charact... | {
"input": [],
"output": []
} | {
"input": [
"5\nyou\nate\nmy\nhum\ntoast",
"7\nshe\nsells\nsea\nshells\nby\nthe\nseashore"
],
"output": [
"e\nt\nu",
"a\ne\ny"
]
} | {
"input": [
"7\nshf\nsells\nsea\nshells\nby\nthe\nseashore",
"7\nshf\nsells\nsea\nshells\nby\nteh\nseashore",
"7\nshf\nsells\nsea\nshells\nby\nthd\nseashore",
"7\nshf\nsells\nsea\nshells\nbx\nthd\nseashore",
"7\nshf\nsells\naes\nshells\nbx\nthd\nseashore",
"7\nshf\nsells\nsea\nshells\nby\ndht... |
p02286 Treap | A binary search tree can be unbalanced depending on features of data. For example, if we insert $n$ elements into a binary search tree in ascending order, the tree become a list, leading to long search times. One of strategies is to randomly shuffle the elements to be inserted. However, we should consider to maintain t... | {
"input": [],
"output": []
} | {
"input": [
"16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 86 47\ninsert 21 12\ninsert 7 10\ninsert 6 90\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint"
],
"output": [
"1 3 6 7 14 21 35 42 80 86\n 35 6 3 1 14 7 21 80 42 86\nyes\nno\n 1 3 6 7 14 21 42 8... | {
"input": [
"16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 102 47\ninsert 21 12\ninsert 7 10\ninsert 6 90\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint",
"16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 86 47\ni... |
p02433 List | For a dynamic list $L$ of integers, perform a sequence of the following operations. $L$ has a special element called END at the end of the list and an element of $L$ is indicated by a cursor.
* insert($x$): Insert $x$ before the element indicated by the cursor. After this operation, the cursor points the inserted elem... | {
"input": [],
"output": []
} | {
"input": [
"5\n0 1\n0 2\n0 3\n1 1\n2"
],
"output": [
"3\n1"
]
} | {
"input": [
"5\n0 1\n0 2\n0 2\n1 1\n2",
"5\n0 1\n0 2\n0 2\n0 1\n2",
"5\n0 1\n0 2\n0 3\n0 1\n2",
"5\n0 1\n0 2\n0 4\n1 1\n2",
"5\n0 1\n0 2\n0 4\n0 0\n2",
"5\n0 1\n0 0\n0 2\n0 0\n2",
"5\n0 1\n0 0\n0 1\n0 0\n2",
"5\n0 1\n0 0\n0 1\n1 0\n2",
"5\n0 1\n0 -1\n0 1\n1 0\n2",
"5\n1 1\n0 -... |
anagram | Note: For Turbo C++, select "Text" as your language
Resubmit your incorrect solutions to the Debugging problems, if you were getting template errors for Java and Python.
Problem Description:
IIITD is hosting a guessing game. The game starts with a player coming up with a word (not necessarily a valid English word). Th... | {
"input": [],
"output": []
} | {
"input": [
"abcd\nfedb"
],
"output": [
"No\n"
]
} | {
"input": [
"aacd\nfedb",
"`acd\nfedb",
"_acd\nfedb",
"_ace\nfedb",
"eca_\nfedb",
"eca_\nbdef",
"ecb_\nbdef",
"ecb_\nbfed",
"ecb_\ndefb",
"_bce\ndefb",
"_bce\ndegb",
"_bce\nddgb",
"b_ce\nddgb",
"_bce\ndcgb",
"_bce\ndcbg",
"^bce\ndcbg",
"^ace\ndcbg",... |
chn15b | Petr is organizing Petr Mitrichev Contest #11. The top N coders according to codechef ratings (excluding Petr himself) agreed to participate in the contest. The participants have been ranked from 0 to N-1 according to their ratings. Petr had asked each participant to choose a coder with rating higher than himself/ hers... | {
"input": [],
"output": []
} | {
"input": [
"1\n5\n-1 -1 1 2 1"
],
"output": [
"1.5"
]
} | {
"input": [],
"output": []
} |
epi01 | This is the algorithmic version of a game that kids play in our part of the country. You will be provided with a few sticks. The length of the sticks will be in the order of powers of 2. (1,2,4,8,16,32....). You will also be given another test stick of any length. The task is to write a program that finds the minimum n... | {
"input": [],
"output": []
} | {
"input": [
"5"
],
"output": [
"2"
]
} | {
"input": [],
"output": []
} |
kjcc05 | Chef loves palindromes. Chef initially has odd number of charachters. Chef wants to create a palindrome of maximum even length using these characters.
For this Chef needs to discard one character. Help Chef find the character which needs to be discarded so that he can use the rest characters in any order to form a pali... | {
"input": [],
"output": []
} | {
"input": [
"2\n7\nabcbdca\n3\nabb"
],
"output": [
"d\na"
]
} | {
"input": [
"2\n0\nabcbdca\n3\nabb",
"2\n7\nacdbcba\n3\nabb",
"2\n0\nabcbdca\n3\naba",
"2\n0\nabcbeca\n3\ncba",
"2\n0\nbcdacaa\n3\ndbb",
"2\n1\nacdbcaa\n3\nbba",
"2\n1\nbcdacaa\n3\nbbb",
"2\n1\n`bcdaca\n3\nbba",
"2\n1\nacebbb`\n1\n`bb",
"2\n1\necabbb`\n1\n`bb",
"2\n0\nabcb... |
p1z2s | Phantasialand boasts of its famous theme park. The park is frequently visited. It is quite large park that some tourists visit it more than once to fully appreciate its offerings. One day, our Chefs decided to visit the park. There are total n Chefs, i-th of them wants to visit the park ti times.
Usually, the entry t... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 1",
"4\n1 2 3 3"
],
"output": [
"2\n",
"5\n"
]
} | {
"input": [
"2\n4 1",
"4\n1 2 5 3",
"2\n3 0",
"4\n1 2 8 3",
"4\n1 0 12 4",
"4\n1 0 12 6",
"4\n1 0 1 6",
"4\n1 0 1 7",
"4\n1 0 11 4",
"4\n1 -1 12 11",
"4\n2 0 -1 25",
"4\n1 -2 12 11",
"4\n0 -1 0 36",
"2\n25 2",
"4\n-1 -1 0 36",
"2\n39 2",
"4\n-2 -2 0... |
sprlnms | Dennis is programming a robot that is supposed to paint a horizontal line. Not being one to care much about efficiency, Dennis programs the robot to move in an anti-clockwise spiral as shown below.
0 1 10
6 7 8 9
The robot starts at position zero, then moves to position 1, then position 2 and so on. Dennis wants a... | {
"input": [],
"output": []
} | {
"input": [
"3\n0\n1\n2"
],
"output": [
"0\n1\n10\n"
]
} | {
"input": [
"3\n1\n1\n2",
"3\n1\n1\n4",
"3\n1\n0\n4",
"3\n1\n1\n8",
"3\n1\n0\n8",
"3\n1\n0\n2",
"3\n2\n0\n2",
"3\n2\n0\n4",
"3\n2\n0\n6",
"3\n0\n0\n6",
"3\n0\n0\n5",
"3\n0\n2\n2",
"3\n2\n1\n2",
"3\n1\n1\n1",
"3\n0\n0\n4",
"3\n1\n1\n10",
"3\n1\n1\n13... |
1303_D. Fill The Bag | You have a bag of size n. Also you have m boxes. The size of i-th box is a_i, where each a_i is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if n = 10 and a = [1, 1, 32] then you have to divide the box of size 32 into tw... | {
"input": [],
"output": []
} | {
"input": [
"3\n10 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8\n"
],
"output": [
"2\n-1\n0\n"
]
} | {
"input": [
"3\n8 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 1 8\n",
"3\n14 3\n1 32 1\n23 4\n16 1 4 1\n20 5\n2 1 16 2 8\n",
"3\n14 3\n1 32 1\n14 4\n16 1 4 1\n26 5\n2 1 16 2 8\n",
"3\n8 3\n1 32 1\n23 4\n16 1 4 1\n6 5\n2 1 16 1 8\n",
"3\n8 3\n1 32 1\n14 4\n16 1 4 1\n26 5\n2 1 16 2 8\n",
"3\n15 3\n... |
1346_G. Two IP Cameras | You have two IP cameras of the same model. Each camera can take photos starting from some moment of time with a fixed period. You can freely choose the starting moment but you can choose the period only as one of k values p_1, p_2, ..., p_k which are chosen by the camera's manufacturer.
You have n moments of interest ... | {
"input": [],
"output": []
} | {
"input": [
"3 5\n3 5 7\n1 4 5 7 12\n",
"3 2\n1 2 3\n1 10\n",
"3 4\n1 2 3\n5 7 9 11\n",
"3 4\n10 20 100\n2 3 4 7\n"
],
"output": [
"\nYES\n1 3\n5 7\n",
"\nYES\n1 1\n10 1\n",
"\nYES\n5 1\n5 1\n",
"\nNO\n"
]
} | {
"input": [],
"output": []
} |
1368_E. Ski Accidents | Arthur owns a ski resort on a mountain. There are n landing spots on the mountain numbered from 1 to n from the top to the foot of the mountain. The spots are connected with one-directional ski tracks. All tracks go towards the foot of the mountain, so there are no directed cycles formed by the tracks. There are at mos... | {
"input": [],
"output": []
} | {
"input": [
"2\n4 6\n1 2\n1 3\n2 3\n2 4\n3 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n"
],
"output": [
"2\n3 4 \n4\n4 5 6 7 \n"
]
} | {
"input": [
"2\n4 6\n1 2\n1 3\n2 3\n2 4\n1 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n",
"2\n4 6\n1 2\n1 3\n2 3\n3 4\n1 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n",
"2\n4 6\n1 2\n1 3\n2 3\n2 4\n1 4\n3 4\n7 6\n1 2\n1 3\n2 4\n2 5\n4 6\n3 7\n",
"2\n4 6\n1 2\n1 3\n2 3\n2 4\n1 4\n3 4\n7 6\n1 2\n1 6\n2 4\... |
1431_A. Selling Hamburgers | There are n customers in the cafeteria. Each of them wants to buy a hamburger. The i-th customer has a_i coins, and they will buy a hamburger if it costs at most a_i coins.
Suppose the cost of the hamburger is m. Then the number of coins the cafeteria earns is m multiplied by the number of people who buy a hamburger i... | {
"input": [],
"output": []
} | {
"input": [
"6\n3\n1 1 1\n3\n4 1 1\n3\n2 4 2\n8\n1 2 3 4 5 6 7 8\n1\n1000000000000\n3\n1000000000000 999999999999 1\n"
],
"output": [
"\n3\n4\n6\n20\n1000000000000\n1999999999998\n"
]
} | {
"input": [],
"output": []
} |
1478_B. Nezzar and Lucky Number | Nezzar's favorite digit among 1,…,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation.
Given q integers a_1,a_2,…,a_q, for each 1 ≤ i ≤ q Nezzar would like to know if a_i can be equal to a sum of several (one or more) lucky numbers.
Input
The first line contains a singl... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 7\n24 25 27\n10 7\n51 52 53 54 55 56 57 58 59 60\n"
],
"output": [
"\nYES\nNO\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nNO\n"
]
} | {
"input": [
"2\n3 7\n24 25 27\n10 7\n51 52 53 54 55 56 57 58 42 60\n",
"2\n3 7\n24 25 40\n10 7\n51 52 53 54 55 56 57 58 42 60\n",
"2\n3 7\n24 25 40\n10 7\n25 52 53 54 55 54 57 58 42 60\n",
"2\n3 7\n24 25 27\n10 7\n74 52 53 54 55 43 57 58 42 60\n",
"2\n3 4\n24 25 27\n10 7\n51 52 53 20 55 56 57 58 ... |
a-problem-on-string | Given a string S of length N consisting of only lower-case English alphabets, you will be asked to process Q queries over it . In each query you will be given two lower case characters X and Y. Your task is to find out the number of such substrings of the the string S which have the characters X and Y on either of its... | {
"input": [],
"output": []
} | {
"input": [
"5\naacbb\n2\na c\na b\n\nSAMPLE"
],
"output": [
"2\n4\n"
]
} | {
"input": [
"5\naacbb\n2\nb c\na b\n\nSAMPLE",
"5\naacbb\n2\na b\na b\n\nSAMPLE",
"5\naacbb\n2\nb c\na c\n\nSEMPLA",
"5\naacbb\n2\na a\na b\n\nELOLAS",
"5\naacbc\n2\na c\na b\n\nSAMPLE",
"5\naacbb\n2\nc c\na b\n\nSEMPLA",
"5\naacba\n2\nb c\na b\n\nSAMPLE",
"5\naacbb\n2\nb d\na c\n\nSE... |
bizzare-mishra | Mishra has gone bizarre these days. And therefore loves only bizzare patterns. Nowadays he has ran into a habit of not listening to many "yes" or "no" from people like Bansal. In fact he does not like strings having more than one "yes" or one "no" consecutively. Bansal sends him a string of length L containing only 'Y'... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\nYY\n2\nYN\n5\nYYNNY\n\nSAMPLE"
],
"output": [
"1\n0\n2"
]
} | {
"input": [],
"output": []
} |
crazy-painter-4 | Abhimanyu simply drew two triangles, as shown in the picture below:
He says this, Amazing painting 1.
Then he drew two more triangles, as shown in the picture below:
He says this, Amazing painting 2.
Similarly he defined Amazing painting 3, 4, 5, ..., N.
Now he starts finding the points where two lines meet or int... | {
"input": [],
"output": []
} | {
"input": [
"1\n1\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2\n\nSAMPLE"
],
"output": [
"24\n"
]
} | {
"input": [
"1\n1\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 0 1 2 3 1 2\n\nSAMPLE",
"1\n1\n1 2 3 1 2 3 1 2 3 1 2 4 2 2 3 1 2 1 0 2 0 1 5 3 1 2\n\nELPMAS",
"1\n1\n1 2 3 1 2 3 1 2 3 1 4 4 2 3 3 1 2 1 0 0 -1 1 5 3 1 2\n\nELPMAS",
"1\n1\n1 2 3 1 2 3 1 2 3 1 0 4 0 3 3 3 3 1 1 -1 -1 0 5 3 1 2\n\nELPMAS",
... |
p02566 AtCoder Library Practice Contest - Number of Substrings | You are given a string of length N. Calculate the number of distinct substrings of S.
Constraints
* 1 \leq N \leq 500,000
* S consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
S
Output
Print the answer.
Examples
Input
abcbcba
Output
21
Input
missi... | {
"input": [],
"output": []
} | {
"input": [
"abcbcba",
"aaaaa",
"ababacaca",
"mississippi"
],
"output": [
"21",
"5",
"33",
"53"
]
} | {
"input": [
"abcacbb",
"baaaa",
"aaabacacb",
"mjssissippi",
"abbacbb",
"baaba",
"mjssisrippi",
"bcacabaa`",
"mjssisripph",
"bcacabab`",
"b`cabba",
"hppirsitsjm",
"acacabab`",
"bbba`",
"`babb",
"cbaaada`a",
"mjsthspiroh",
"cbdbaab`a",
"abdaa_... |
p02697 AtCoder Beginner Contest 165 - Rotation Matching | You are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.) N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing fiel... | {
"input": [],
"output": []
} | {
"input": [
"7 3",
"4 1"
],
"output": [
"1 6\n2 5\n3 4",
"2 3"
]
} | {
"input": [
"3 1",
"8 3",
"11 5",
"20 9",
"15 7",
"24 11",
"6 1",
"5 1",
"12 5",
"19 9",
"3 1",
"6 1",
"5 1",
"11 5",
"12 5",
"19 9",
"8 3",
"20 9",
"15 7",
"16 7"
],
"output": [
"1 2\n",
"1 4\n2 3\n5 7\n",
"1 6\n2 5\n3 4... |
p02826 AtCoder Grand Contest 041 - Problem Scores | N problems have been chosen by the judges, now it's time to assign scores to them!
Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the same score, though.
Being an ICPC fan, y... | {
"input": [],
"output": []
} | {
"input": [
"3 998244353",
"96 925309799",
"6 966666661",
"2 998244353"
],
"output": [
"7",
"83779",
"66",
"3"
]
} | {
"input": [
"3 143320251",
"2 1660952267",
"6 259722551",
"1 81577459",
"8 556099089",
"0 4861465",
"9 345897173",
"157 925309799",
"10 259722551",
"4 1745284472",
"5 394143938",
"12 81577459",
"13 255726765",
"11 452537087",
"134 925309799",
"7 1522535... |
p02963 AtCoder Grand Contest 036 - Triangle | Given is an integer S. Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions:
* 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9
* The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) is S/2.
We can prove that ther... | {
"input": [],
"output": []
} | {
"input": [
"100",
"311114770564041497",
"3"
],
"output": [
"0 0 10 0 0 10",
"314159265 358979323 846264338 327950288 419716939 937510582",
"1 0 2 2 0 1"
]
} | {
"input": [
"80182456107003087",
"5",
"158461871566595116",
"10",
"186455597317386972",
"20",
"181678330976250080",
"39",
"93932089064978059",
"70",
"71578367286808432",
"93",
"3327794342327297",
"139",
"6269486129073601",
"22",
"11395687303953316",... |
p03098 AtCoder Grand Contest 031 - A Sequence of Permutations | For two permutations p and q of the integers from 1 through N, let f(p,q) be the permutation that satisfies the following:
* The p_i-th element (1 \leq i \leq N) in f(p,q) is q_i. Here, p_i and q_i respectively denote the i-th element in p and q.
You are given two permutations p and q of the integers from 1 through... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n4 5 1 2 3\n3 2 1 5 4",
"10 1000000000\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2 3 7 8 10 6 5",
"3 3\n1 2 3\n3 2 1"
],
"output": [
"4 3 2 1 5",
"7 9 4 8 2 5 1 6 10 3",
"3 2 1"
]
} | {
"input": [
"5 4\n4 5 1 2 3\n3 2 1 5 4",
"3 1\n1 2 3\n3 2 1",
"5 8\n4 5 1 2 3\n3 2 1 5 4",
"5 11\n4 5 1 2 3\n3 2 1 5 4",
"5 2\n4 5 1 2 3\n3 2 1 5 4",
"3 6\n1 2 3\n3 2 1",
"5 20\n4 5 1 2 3\n3 2 1 5 4",
"5 14\n4 5 1 2 3\n3 2 1 5 4",
"3 17\n2 1 3\n3 2 1",
"3 10\n2 1 3\n3 2 1",
... |
p03244 AtCoder Beginner Contest 111 - /\/\/\/ | A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:
* For each i = 1,2,..., n-2, a_i = a_{i+2}.
* Exactly two different numbers appear in the sequence.
You are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this sequence /\/\/\/ by replacing s... | {
"input": [],
"output": []
} | {
"input": [
"4\n3 1 3 2",
"4\n1 1 1 1",
"6\n105 119 105 119 105 119"
],
"output": [
"1",
"2",
"0"
]
} | {
"input": [
"4\n3 2 3 2",
"6\n105 119 204 119 105 119",
"4\n4 1 3 2",
"6\n105 120 54 119 105 78",
"6\n105 120 54 119 190 78",
"6\n105 119 204 119 105 78",
"4\n4 1 3 0",
"6\n105 119 54 119 105 78",
"4\n4 1 3 1",
"4\n4 1 6 1",
"4\n4 0 6 1",
"6\n1 120 54 119 190 78",
... |
p03397 AtCoder Grand Contest 022 - Median Replace | Taichi thinks a binary string X of odd length N is beautiful if it is possible to apply the following operation \frac{N-1}{2} times so that the only character of the resulting string is `1` :
* Choose three consecutive bits of X and replace them by their median. For example, we can turn `00110` into `010` by applying ... | {
"input": [],
"output": []
} | {
"input": [
"1??00",
"?0101???10???00?1???????????????0????????????1????0",
"?"
],
"output": [
"2",
"402589311",
"1"
]
} | {
"input": [
"?0101???00???00?1???????????????0????????????1????0",
"?0101???00???00?1???????????????0???????????1?????0",
"?01?1???00???00?1????????0??????0???????????1?????0",
"?0101???10????0?1???????????????0??0?????????1????0",
"?0100???00???00?1???????????????0????????????1????0",
"?0101... |
p03562 AtCoder Regular Contest 084 - XorShift | There are N non-negative integers written on a blackboard. The i-th integer is A_i.
Takahashi can perform the following two kinds of operations any number of times in any order:
* Select one integer written on the board (let this integer be X). Write 2X on the board, without erasing the selected integer.
* Select two... | {
"input": [],
"output": []
} | {
"input": [
"1 111111111111111111111111111111111111111111111111111111111111111\n1",
"4 100100\n1011\n1110\n110101\n1010110",
"4 111001100101001\n10111110\n1001000110\n100000101\n11110000011",
"3 111\n1111\n10111\n10010"
],
"output": [
"466025955",
"37",
"1843",
"4"
]
} | {
"input": [
"1 111111111111111111111111111111111111111111111111111111111110111\n1",
"4 100110\n1011\n1110\n110101\n1010110",
"4 111001100101001\n10111110\n1011000110\n100000101\n11110000011",
"3 111\n1111\n00111\n10010",
"1 111111111111111111111111011111111111111111111111111111111110111\n1",
... |
p03717 AtCoder Regular Contest 074 - RGB Sequence | There are N squares arranged in a row. The squares are numbered 1, 2, ..., N, from left to right.
Snuke is painting each square in red, green or blue. According to his aesthetic sense, the following M conditions must all be satisfied. The i-th condition is:
* There are exactly x_i different colors among squares l_i, ... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n1 3 3",
"8 10\n2 6 2\n5 5 1\n3 5 2\n4 7 3\n4 4 1\n2 3 1\n7 7 1\n1 5 2\n1 7 3\n3 4 2",
"1 3\n1 1 1\n1 1 2\n1 1 3",
"4 2\n1 3 1\n2 4 2"
],
"output": [
"6",
"108",
"0",
"6"
]
} | {
"input": [
"3 1\n0 3 3",
"8 10\n3 6 2\n5 5 1\n3 5 2\n4 7 3\n4 4 1\n2 3 1\n7 7 1\n1 5 2\n1 7 3\n3 4 2",
"1 3\n0 1 1\n1 1 2\n1 1 3",
"4 3\n1 3 1\n2 4 2",
"4 3\n1 2 1\n2 4 2",
"8 7\n3 6 2\n5 5 1\n3 5 1\n4 7 3\n4 4 1\n2 3 1\n7 7 1\n1 5 2\n1 7 3\n3 4 2",
"1 2\n-1 7 3",
"8 10\n2 12 2\n5 5 ... |
p03877 CODE FESTIVAL 2016 Grand Final - 123 Pairs | Consider all integers between 1 and 2N, inclusive. Snuke wants to divide these integers into N pairs such that:
* Each integer between 1 and 2N is contained in exactly one of the pairs.
* In exactly A pairs, the difference between the two integers is 1.
* In exactly B pairs, the difference between the two integers is ... | {
"input": [],
"output": []
} | {
"input": [
"3 1 2 0",
"600 100 200 300"
],
"output": [
"2",
"522158867"
]
} | {
"input": [
"2 1 2 0",
"986 100 200 300",
"986 110 200 300",
"986 111 200 300",
"720 111 200 591",
"3 0 2 0",
"986 010 200 300",
"399 011 200 300",
"720 111 27 300",
"1394 111 200 109",
"399 001 200 300",
"986 010 104 300",
"986 110 104 300",
"986 111 104 300",... |
p04038 AtCoder Grand Contest 002 - Leftmost Ball | Snuke loves colorful balls. He has a total of N×K balls, K in each of his favorite N colors. The colors are numbered 1 through N.
He will arrange all of the balls in a row from left to right, in arbitrary order. Then, for each of the N colors, he will paint the leftmost ball of that color into color 0, a color differe... | {
"input": [],
"output": []
} | {
"input": [
"2 3",
"2 2",
"3 1",
"2000 2000"
],
"output": [
"14",
"4",
"1",
"546381702"
]
} | {
"input": [
"2 4",
"4 2",
"2 1",
"4 3",
"3 3",
"3 5",
"4 4",
"4 5",
"-1 0",
"7 4",
"4 6",
"14 4",
"4 12",
"14 2",
"4 7",
"3 2",
"1810 2000",
"6 4",
"6 5",
"8 2",
"3 4",
"7 8",
"14 7",
"7 5",
"8 7",
"1810 1481",
... |
p00119 Taro's Obsession | A serious incident happened at Taro's house, which loves steamed buns. One of the three steamed buns offered at the Buddhist altar in the Japanese-style room was gone. When Taro, who was aiming for a snack someday, started an investigation to find the criminal, it turned out that there were many people who entered the ... | {
"input": [],
"output": []
} | {
"input": [
"6\n7\n5 2\n1 4\n3 5\n4 2\n1 6\n6 4\n3 4"
],
"output": [
"3\n5\n1\n6\n4\n2"
]
} | {
"input": [
"6\n7\n5 2\n1 4\n3 5\n8 2\n1 6\n6 4\n3 4",
"6\n7\n7 2\n1 4\n3 5\n8 2\n1 6\n6 4\n2 4",
"6\n7\n3 2\n1 4\n6 5\n3 2\n1 6\n6 4\n3 4",
"6\n7\n5 2\n1 4\n3 5\n8 2\n2 6\n6 4\n3 4",
"6\n7\n3 2\n1 4\n3 1\n4 2\n1 6\n6 4\n3 4",
"6\n7\n7 2\n1 4\n3 5\n8 2\n2 6\n6 4\n2 4",
"6\n7\n3 2\n1 4\n6 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.