name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p01812 Dark Room
A pitch-black room When I woke up, Mr. A was in a pitch-black room. Apparently, Mr. A got lost in a dungeon consisting of N rooms. You couldn't know which room A got lost in, but fortunately he got a map of the dungeon. Let's show A the way to go and lead to a bright room. It is known that M of the N rooms are pitch ...
{ "input": [], "output": [] }
{ "input": [ "4 2 2\n1 2\n2 4\n3 1\n4 2\n1 3" ], "output": [ "2" ] }
{ "input": [ "4 2 2\n1 2\n2 4\n3 1\n4 2\n1 4", "4 1 2\n1 2\n2 4\n0 1\n4 2\n1 -1", "4 0 1\n1 2\n2 6\n0 1\n4 2\n2 -1", "4 2 2\n1 2\n2 4\n0 1\n4 2\n1 4", "4 2 2\n1 2\n2 4\n0 1\n4 2\n1 0", "4 2 2\n1 2\n2 4\n0 1\n4 2\n1 -1", "4 1 1\n1 2\n2 4\n0 1\n4 2\n1 -1", "4 1 1\n1 2\n2 6\n0 1\n4 2\n1 -...
p01947 Ninja Map
Intersections of Crossing Path City are aligned to a grid. There are $N$ east-west streets which are numbered from 1 to $N$, from north to south. There are also $N$ north-south streets which are numbered from 1 to $N$, from west to east. Every pair of east-west and north-south streets has an intersection; therefore the...
{ "input": [], "output": [] }
{ "input": [ "4\n12 1\n3 8\n10 7\n13 14\n8 2\n9 12\n6 14\n11 3\n3 13\n1 10\n11 15\n4 15\n4 9\n14 10\n5 7\n2 5\n6 1\n14 5\n16 11\n15 6\n15 13\n9 6\n16 4\n13 2", "3\n1 2\n4 7\n8 6\n2 3\n8 9\n5 3\n4 6\n5 6\n7 8\n1 4\n2 6\n5 9" ], "output": [ "8 2 5 7\n3 13 14 10\n11 15 6 1\n16 4 9 12", "7 4 1\n8 6 2\...
{ "input": [ "3\n1 2\n4 7\n8 6\n2 3\n8 9\n5 3\n4 9\n5 6\n7 8\n1 4\n2 9\n5 9", "3\n2 1\n4 7\n8 6\n2 3\n8 9\n5 3\n4 6\n5 6\n7 8\n1 4\n2 6\n5 9" ], "output": [ "1 2 3 \n4 9 5 \n7 8 6 \n", "1 2 3 \n4 6 5 \n7 8 9 \n" ] }
p02096 Add
I: Add Problem Statement Mr. T has had an integer sequence of N elements a_1, a_2, ... , a_N and an integer K. Mr. T has created N integer sequences B_1, B_2, ... , B_N such that B_i has i elements. * B_{N,j} = a_j (1 \leq j \leq N) * B_{i,j} = K \times B_{i+1,j} + B_{i+1,j+1} (1\leq i \leq N-1, 1 \leq j \leq i) ...
{ "input": [], "output": [] }
{ "input": [ "2\n3 0\n1 2 3\n3 1\n1 2 3" ], "output": [ "3 2 1\n3 65536 0" ] }
{ "input": [ "2\n3 0\n1 3 3\n3 1\n1 2 3", "2\n3 0\n1 3 3\n3 1\n1 2 5", "2\n3 0\n1 3 6\n3 1\n1 2 5", "2\n3 0\n1 3 6\n3 1\n1 2 8", "2\n3 0\n1 4 3\n3 1\n1 2 3", "2\n3 1\n1 3 3\n3 1\n1 2 3", "2\n3 0\n1 3 1\n3 1\n1 2 5", "2\n3 0\n1 3 6\n3 1\n1 1 5", "2\n3 0\n1 3 5\n3 1\n1 2 8", "2\n...
p02234 Matrix Chain Multiplication
The goal of the matrix-chain multiplication problem is to find the most efficient way to multiply given $n$ matrices $M_1, M_2, M_3,...,M_n$. Write a program which reads dimensions of $M_i$, and finds the minimum number of scalar multiplications to compute the maxrix-chain multiplication $M_1M_2...M_n$. Constraints ...
{ "input": [], "output": [] }
{ "input": [ "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 25" ], "output": [ "15125" ] }
{ "input": [ "6\n10 35\n35 15\n15 5\n5 10\n10 20\n20 25", "6\n1 35\n35 15\n15 5\n5 10\n10 20\n20 25", "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 29", "6\n2 35\n35 15\n15 5\n5 10\n10 20\n20 25", "6\n2 35\n35 15\n15 5\n5 10\n10 20\n20 24", "6\n30 35\n35 15\n15 5\n5 10\n10 20\n20 27", "6\n30 35\...
p02380 Triangle
For given two sides of a triangle a and b and the angle C between them, calculate the following properties: * S: Area of the triangle * L: The length of the circumference of the triangle * h: The height of the triangle with side a as a bottom edge Input The length of a, the length of b and the angle C are given in...
{ "input": [], "output": [] }
{ "input": [ "4 3 90" ], "output": [ "6.00000000\n12.00000000\n3.00000000" ] }
{ "input": [ "4 3 130", "4 3 11", "2 3 90", "3 3 130", "4 5 11", "2 4 90", "2 3 130", "1 5 11", "2 5 90", "2 3 190", "1 3 11", "2 0 90", "3 3 190", "1 3 10", "3 0 90", "3 5 190", "1 6 10", "2 1 90", "3 5 66", "1 6 11", "2 1 164", ...
brackets
A valid parentheses sequence is a non-empty string where each character is either '(' or ')', which satisfies the following constraint: You can find a way to repeat erasing adjacent pairs of parentheses '()' until it becomes empty. For example, '(())' and '()((()()))' are valid parentheses sequences, but ')()(' an...
{ "input": [], "output": [] }
{ "input": [ "1\n()((()()))" ], "output": [ "((()))\n" ] }
{ "input": [ "1\n()(())()()", "1\n((((()()))", "1\n(()(()()))", "1\n()((()(())", "1\n()()()()()", "1\n((((((()))", "1\n((((()(())", "1\n(((((((())", "1\n((((((((()", "1\n((((((((((", "1\n(()())()()", "1\n(()(())())", "1\n((()((()))", "1\n(()(()(())", "1\n()(...
color
After a long time, Chef has finally decided to renovate his house. Chef's house has N rooms in it numbered from 1 to N. Each room is currently painted in one of the red, blue or green colors. Your are given configuration of colors of his house by a string S consisting of N characters. In this string, color red will be ...
{ "input": [], "output": [] }
{ "input": [ "3\n3\nRGR\n3\nRRR\n3\nRGB" ], "output": [ "1\n0\n2\n" ] }
{ "input": [ "3\n3\nRGR\n3\nRRR\n3\nGRB", "3\n3\nGRR\n3\nRRR\n3\nGRB", "3\n3\nRGR\n3\nRRR\n3\nRBG", "3\n3\nGRR\n3\nRRR\n3\nBRG", "3\n3\nRRG\n3\nRRR\n3\nRGB", "3\n3\nRGR\n3\nRRR\n3\nBRG", "3\n3\nRGR\n3\nRRR\n3\nBGR", "3\n3\nRRG\n3\nRRR\n3\nBRG", "3\n3\nRRG\n3\nRRR\n3\nGRB", "3\n...
gballs
Note: For Turbo C++, select "Text" as your language Problem description: ProCon Junior gives you chance to earn points for admission in IIIT Delhi. So, it is not easy to get points. If you solve this problem you are one more step closer to earn points. Solve this problem and earn points. Problem: In IIIT Delhi we play ...
{ "input": [], "output": [] }
{ "input": [ "3\n2\nAshish 2\nAyush 3\n3\nAshish 2\nAshish 4\nAyush 5\n3\nAyush 2\nAneesh 5\nAshish 3" ], "output": [ "Ayush 3\nAshish 6\nAneesh 5" ] }
{ "input": [ "3\n2\nAshish 2\nAyush 3\n3\nAshish 2\nAshish 4\nAyush 5\n1\nAyush 2\nAneesh 5\nAshish 3", "3\n2\nAshish 2\nAyush 3\n3\nhsihsA 2\nAshish 4\nAyush 5\n1\nAyush 2\nAneesh 5\nAshish 3", "3\n2\nAshish 2\nAyush 3\n3\nhsihtA 2\nAshish 4\nAyush 5\n2\nAyush 2\nAneesh 5\nAshish 1", "3\n2\nAshish 2\...
lucky9
Chef has the string s of length n consisted of digits 4 and 7. The string s is called balanced if there exits such integer x (1 ≤ x ≤ n) that the number of digits 4 in substring s[1; x) is equal to the number of digits 7 in substring s(x; n], where s[1; x) is the substring from the 1st digit to (x-1)th digit of s, and ...
{ "input": [], "output": [] }
{ "input": [ "2\n47\n4477" ], "output": [ "1\n4" ] }
{ "input": [ "2\n47\n3680", "2\n-47\n-3", "2\n110\n-74", "2\n47\n233", "2\n47\n10", "2\n35\n10", "2\n38\n10", "2\n38\n16", "2\n38\n1", "2\n38\n0", "2\n2\n0", "2\n2\n1", "2\n3\n0", "2\n3\n1", "2\n0\n1", "2\n-1\n1", "2\n-2\n1", "2\n-4\n1", "2\n...
prpalin
An integer is said to be a palindrome if it is equal to its reverse. For example, 79197 and 324423 are palindromes. In this task you will be given an integer N, 1 ≤ N ≤ 1000000. You must find the smallest integer M ≥ N such that M is a prime number and M is a palindrome. For example, if N is 31 then the answer is 1...
{ "input": [], "output": [] }
{ "input": [ "31" ], "output": [ "101\n" ] }
{ "input": [ "27", "10", "5", "126", "150", "210", "177", "375", "186", "603", "337", "843", "779", "372", "749", "38", "42", "56", "18", "12", "21", "75", "13", "11", "88", "20", "73", "25", "55", ...
tetra
Given the lengths of the edges of a tetrahedron calculate the radius of a sphere inscribed in that tetrahedron (i.e. a sphere tangent to all the faces). Input An integer t, 1 ≤ t ≤ 30, denoting the number of test cases, followed by t lines, each containing 6 integers describing the lengths of the edges of a tetrahedr...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1 1 1 1 1\n1000 999 998 5 5 6" ], "output": [ "0.2041\n1.4189" ] }
{ "input": [ "2\n1 1 1 1 1 0\n1000 999 998 5 5 6", "2\n1 1 1 1 1 1\n1000 999 998 5 5 4", "2\n1 1 1 1 1 1\n1000 999 998 4 5 6", "2\n1 1 1 0 1 1\n1000 999 998 5 5 8", "2\n1 1 1 1 0 1\n1000 999 998 9 5 6", "2\n1 1 1 0 1 1\n1000 999 998 5 5 7", "2\n1 1 1 1 1 1\n1000 999 998 5 4 4", "2\n1 0...
1170_D. Decoding of Integer Sequences
Polycarp is developing a method for transmitting n integer sequences over a network. This method should support the transmission of an arbitrary number of integer sequences; sequences can have different lengths. The sequences contain arbitrary non-negative integers. Polycarp developed the following encoding procedure:...
{ "input": [], "output": [] }
{ "input": [ "12\n3 2 1 1 7 2 4 -1 3 -1 4 -1\n", "6\n2 -1 2 -1 3 -1\n" ], "output": [ "\n3\n3 3 1 4\n2 2 7\n4 1 2 3 4\n", "\n3\n1 2\n0\n2 2 3\n" ] }
{ "input": [], "output": [] }
1250_A. Berstagram
Polycarp recently signed up to a new social network Berstagram. He immediately published n posts there. He assigned numbers from 1 to n to all posts and published them one by one. So, just after publishing Polycarp's news feed contained posts from 1 to n — the highest post had number 1, the next one had number 2, ..., ...
{ "input": [], "output": [] }
{ "input": [ "3 5\n3 2 1 3 3\n", "10 6\n7 3 5 7 3 6\n" ], "output": [ "\n1 2\n2 3\n1 3\n", "\n1 2\n2 3\n1 3\n4 7\n4 5\n6 7\n5 7\n8 8\n9 9\n10 10\n" ] }
{ "input": [], "output": [] }
1421_A. XORwice
In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game. Tzuyu gave Sana two integers a and b and a really important quest. In order to complete the quest, Sana has to output the smallest possible value of (a ⊕ x) + (b ⊕ x) for any given x, where ⊕ denotes the [bitwise XOR operation](http...
{ "input": [], "output": [] }
{ "input": [ "6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n1 1\n" ], "output": [ "10\n13\n891\n18\n6237\n0\n" ] }
{ "input": [ "6\n6 12\n4 9\n59 832\n28 14\n4925 2912\n2 1\n", "6\n6 12\n4 5\n59 832\n28 14\n4925 2912\n2 1\n", "6\n6 12\n4 2\n59 832\n28 14\n4925 2912\n2 1\n", "6\n6 12\n4 2\n90 832\n28 14\n4925 2912\n2 1\n", "6\n6 12\n4 2\n90 832\n28 8\n4925 2912\n2 1\n", "6\n6 12\n4 3\n90 832\n28 8\n4925 291...
1466_E. Apollo versus Pan
Only a few know that Pan and Apollo weren't only battling for the title of the GOAT musician. A few millenniums later, they also challenged each other in math (or rather in fast calculations). The task they got to solve is the following: Let x_1, x_2, …, x_n be the sequence of n non-negative integers. Find this value:...
{ "input": [], "output": [] }
{ "input": [ "8\n2\n1 7\n3\n1 2 4\n4\n5 5 5 5\n5\n6 2 2 1 0\n1\n0\n1\n1\n6\n1 12 123 1234 12345 123456\n5\n536870912 536870911 1152921504606846975 1152921504606846974 1152921504606846973\n" ], "output": [ "\n128\n91\n1600\n505\n0\n1\n502811676\n264880351\n" ] }
{ "input": [ "8\n2\n1 7\n3\n1 2 4\n4\n5 5 0 5\n5\n6 2 2 1 0\n1\n0\n1\n1\n6\n1 12 123 1234 12345 123456\n5\n536870912 536870911 1152921504606846975 1152921504606846974 1152921504606846973\n", "8\n2\n1 7\n3\n1 2 4\n4\n5 5 0 5\n5\n6 2 2 1 0\n1\n0\n1\n1\n6\n2 12 123 1234 12345 123456\n5\n536870912 536870911 11529...
188_F. Binary Notation
You are given a positive integer n. Output its binary notation. Input The only line of input data contains an integer n (1 ≤ n ≤ 106). Output Output the binary notation of n (without any leading zeros). Examples Input 5 Output 101 Input 101 Output 1100101 Note In the first example 5 = 1 * 22 + 0 * 21 ...
{ "input": [], "output": [] }
{ "input": [ "5\n", "101\n" ], "output": [ "101\n", "1100101\n" ] }
{ "input": [], "output": [] }
470_E. Chessboard
Chessboard is a board of n × n squares arranged in two alternating colors (black and white). Top left square is white. You are given board size n. Output an image of a chessboard, with black and white squares marked with '#' and '.' characters, respectively. Input The only line of input contains an integer n (1 ≤ n ≤...
{ "input": [], "output": [] }
{ "input": [ "4\n" ], "output": [ ".#.#\n#.#.\n.#.#\n#.#.\n" ] }
{ "input": [], "output": [] }
775_A. University Schedule
In this problem your task is to come up with a week schedule of classes in university for professors and student groups. Consider that there are 6 educational days in week and maximum number of classes per educational day is 7 (classes numerated from 1 to 7 for each educational day). It is known that in university n s...
{ "input": [], "output": [] }
{ "input": [ "3 3 1\n1 0 0\n0 1 0\n0 0 1\n", "3 1 1\n1\n1\n1\n", "5 7 10\n1 3 6 0 1 2 4\n0 3 0 6 5 1 4\n3 5 1 2 3 2 4\n2 3 1 1 4 1 2\n2 4 3 2 4 3 2\n" ], "output": [ "54\n\n1 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n0 0 0 0 0 0 \n\n0 0 0 0 0 0 \n2 0 0 0 0 0...
{ "input": [], "output": [] }
appointment-dates
Rahul's Dad is the CEO of one of the leading companies. Every time somebody seeks for an appointment he calls up his secretary and asks her whether the day is a Sunday or not. He has to keep his caller on hold and is unhappy about it. Knowing that his son Mayank knows a bit of programming he asks him to make a program...
{ "input": [], "output": [] }
{ "input": [ "2\n3 2013\n5 2010\n\nSAMPLE" ], "output": [ "3 10 17 24 31\n2 9 16 23 30" ] }
{ "input": [ "2\n3 2013\n2 2010\n\nSAMPLE", "2\n3 2013\n9 2010\n\nSAMPLE", "2\n3 2013\n2 2476\n\nSAMPLE", "2\n3 2013\n3 2476\n\nSAMELP", "2\n3 1212\n3 2476\n\nSAMELP", "2\n3 1212\n3 1275\n\nSAMELP", "2\n5 1212\n3 1275\n\nSAMELP", "2\n2 1212\n3 1275\n\nSAMELP", "2\n2 1212\n1 1275\n\...
playing-with-numbers
Sherlock and Watson are close friends. One day, they finally got bored of playing normal games. So, they came up with a new idea of playing with numbers. Since they are good at number theory, they know the fact that a decimal number "A" can be represented as sum of 2's powers. For example: 22 = 16 + 4 + 2 = 2^4...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n2\n\nSAMPLE" ], "output": [ "Sherlock\nSherlock" ] }
{ "input": [], "output": [] }
p02612 AtCoder Beginner Contest 173 - Payment
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. Constraints * 1 \leq N \leq 10000 * N is an integer. Input Input is given from Standard Input in the following for...
{ "input": [], "output": [] }
{ "input": [ "3000", "1900" ], "output": [ "0", "100" ] }
{ "input": [ "5614", "2651", "636", "975", "860", "1858", "541", "209", "1054", "89", "1861", "133", "3264", "194", "2720", "165", "4844", "277", "2049", "516", "1014", "567", "405", "530", "603", "572", "440",...
p02743 Panasonic Programming Contest 2020 - Sqrt Inequality
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? Constraints * 1 \leq a, b, c \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: a \ b \ c Output If \sqrt{a} + \sqrt{b} < \sqrt{c}, print `Yes`; otherwise, print `No`. Examples Input 2 3 9 Output No I...
{ "input": [], "output": [] }
{ "input": [ "2 3 10", "2 3 9" ], "output": [ "Yes", "No" ] }
{ "input": [ "3 3 10", "2 1 9", "3 3 14", "4 1 9", "3 3 13", "4 0 9", "3 3 0", "1 0 9", "3 3 -1", "0 0 9", "3 3 -2", "0 -1 9", "1 3 -2", "-1 -1 9", "1 5 -2", "-1 -2 9", "2 5 -2", "-1 0 9", "2 5 -1", "-2 0 9", "2 5 -3", "-2 0 5", ...
p02878 AtCoder Grand Contest 040 - Two Pieces
We have two indistinguishable pieces placed on a number line. Both pieces are initially at coordinate 0. (They can occupy the same position.) We can do the following two kinds of operations: * Choose a piece and move it to the right (the positive direction) by 1. * Move the piece with the smaller coordinate to the po...
{ "input": [], "output": [] }
{ "input": [ "5 1 3", "1000000 100000 200000", "10 4 6", "10 0 0" ], "output": [ "4", "758840509", "197", "1" ] }
{ "input": [ "5 1 1", "1010000 100000 200000", "4 4 6", "10 0 1", "1010000 100001 200000", "5 2 2", "1011000 100001 200000", "1011001 100001 200000", "0100111 001111 35243", "5 2 3", "1000000 110000 200000", "16 4 6", "7 1 2", "1010000 100001 160629", "10010...
p03012 AtCoder Beginner Contest 129 - Balance
We have N weights indexed 1 to N. The mass of the weight indexed i is W_i. We will divide these weights into two groups: the weights with indices not greater than T, and those with indices greater than T, for some integer 1 \leq T < N. Let S_1 be the sum of the masses of the weights in the former group, and S_2 be th...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3", "4\n1 3 1 1", "8\n27 23 76 2 3 5 62 52" ], "output": [ "0", "2", "2" ] }
{ "input": [ "3\n1 2 2", "4\n2 3 1 1", "8\n27 23 76 2 3 5 62 14", "3\n1 1 2", "4\n2 3 1 0", "8\n27 30 76 2 3 5 62 14", "8\n27 30 76 2 3 5 62 5", "8\n27 30 76 2 3 2 62 5", "8\n27 30 76 2 3 2 102 5", "8\n27 30 99 2 3 2 102 5", "8\n47 30 99 2 5 2 102 5", "8\n47 30 99 2 5 2...
p03152 KEYENCE Programming Contest 2019 - Double Landscape
Consider writing each of the integers from 1 to N \times M in a grid with N rows and M columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under the following conditions: * The largest among the values in the i-th row (1 \leq i \leq N) is A_i. * The largest among the value...
{ "input": [], "output": [] }
{ "input": [ "3 3\n5 9 7\n3 6 9", "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173", "2 2\n4 4\n4 4", "2 2\n4 3\n3 4" ], "output": [ "0", "343772227", "0", "2" ] }
{ "input": [ "3 3\n5 9 2\n3 6 9", "0 2\n4 3\n3 4", "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 73 178 179 167 180 176 169 182 177 175 159 173", "2 2\n6 4\n4 4", "3 3\n5 9 2\n0 6 9", "2 2\n6 4\n5 4", "0 2\n8 3\n3 4", "3 3\n5 9 2\n0 8 9", "2 2\n6 1\n5 4", ...
p03296 AtCoder Grand Contest 026 - Colorful Slimes 2
Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000. Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i. If two slimes of the same color are adjacent, they ...
{ "input": [], "output": [] }
{ "input": [ "5\n1 1 2 2 2", "3\n1 2 1", "14\n1 2 2 3 3 3 4 4 4 4 1 2 3 4", "5\n1 1 1 1 1" ], "output": [ "2", "0", "4", "2" ] }
{ "input": [ "5\n1 1 3 2 2", "3\n0 2 1", "14\n1 1 2 3 3 3 4 4 4 4 1 2 3 4", "3\n1 2 2", "14\n1 1 3 3 3 3 4 4 4 4 1 2 3 4", "14\n1 1 3 3 3 4 3 4 4 4 1 2 3 4", "5\n1 1 1 1 0", "5\n1 1 6 2 2", "5\n1 2 1 1 0", "5\n1 1 9 2 2", "3\n1 4 2", "14\n1 1 3 3 3 4 4 4 4 4 1 2 3 4", ...
p03454 AtCoder Regular Contest 090 - Number of Digits
For a positive integer n, let us define f(n) as the number of digits in base 10. You are given an integer S. Count the number of the pairs of positive integers (l, r) (l \leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the count modulo 10^9 + 7. Constraints * 1 \leq S \leq 10^8 Input Input is given fro...
{ "input": [], "output": [] }
{ "input": [ "1", "2", "123", "36018", "1000" ], "output": [ "9", "98", "460191684", "966522825", "184984484" ] }
{ "input": [ "236", "58364", "217", "112006", "77", "86941", "130", "124627", "158", "136594", "261", "69011", "378", "133460", "199", "210929", "383", "57266", "365", "112408", "730", "54217", "859", "52868", "1083", ...
p03615 AtCoder Regular Contest 082 - ConvexScore
You are given N points (x_i,y_i) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has the same set of vertices as S. All the interior angles of the polyg...
{ "input": [], "output": [] }
{ "input": [ "1\n3141 2718", "4\n0 0\n0 1\n1 0\n1 1", "5\n0 0\n0 1\n0 2\n0 3\n1 1" ], "output": [ "0", "5", "11" ] }
{ "input": [ "1\n3141 411", "4\n0 0\n0 1\n1 0\n1 2", "5\n0 0\n0 1\n0 2\n0 3\n1 2", "5\n1 0\n0 1\n0 2\n0 3\n1 2", "5\n1 0\n-1 1\n0 2\n0 3\n1 2", "1\n3490 411", "1\n3490 245", "1\n2424 245", "1\n2424 206", "1\n2424 320", "1\n4440 320", "1\n1902 320", "1\n714 320", ...
p03773 AtCoder Beginner Contest 057 - Remaining Time
Dolphin loves programming contests. Today, he will take part in a contest in AtCoder. In this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as "21 o'clock". The current time is A o'clock, and a contest will begin in exactly B hours. When will the contest begin? Answer in 24-hour time. Constrain...
{ "input": [], "output": [] }
{ "input": [ "9 12", "19 0", "23 2" ], "output": [ "21", "19", "1" ] }
{ "input": [ "9 23", "25 0", "39 2", "7 23", "25 1", "7 0", "79 2", "17 -1", "145 2", "5 0", "37 2", "62 -1", "45 -1", "0 0", "45 -2", "0 -1", "54 4", "0 -2", "-1 -2", "4 0", "83 0", "112 2", "541 1", "8 4", "52 2", ...
p03942 AtCoder Grand Contest 007 - Shik and Copying String
Shik's job is very boring. At day 0, his boss gives him a string S_0 of length N which consists of only lowercase English letters. In the i-th day after day 0, Shik's job is to copy the string S_{i-1} to a string S_i. We denote the j-th letter of S_i as S_i[j]. Shik is inexperienced in this job. In each day, when he i...
{ "input": [], "output": [] }
{ "input": [ "5\nabcde\nabcde", "5\nabcde\nbbbbb", "4\nacaa\naaca", "5\nabcde\naaacc" ], "output": [ "0", "-1", "2", "2" ] }
{ "input": [ "5\nabcde\nabdde", "4\naacb\naacb", "5\nabcde\nbbbba", "4\nbcaa\naaca", "5\nabcde\naaacb", "5\nabcde\nabddd", "5\nacbde\nbbbba", "4\nbcaa\naacb", "5\nabcde\nbcaaa", "5\nabcde\nbbddd", "5\nbcbde\nbbbba", "5\nabcde\nacaaa", "5\nabcde\nbaddd", "5\nbcbd...
p00034 Railway Lines
There is a double-track line (up and down are separate lines and pass each other everywhere). There are 11 stations on this line, including the terminal station, and each station is called by the section number shown in the figure. <image> Trains depart from both terminal stations on this line at the same time and r...
{ "input": [], "output": [] }
{ "input": [ "1,1,1,1,1,1,1,1,1,1,40,60\n1,1,1,1,1,3,3,3,3,3,50,50\n10,10,10,10,10,10,10,10,10,10,50,49" ], "output": [ "4\n7\n6" ] }
{ "input": [ "06,04,1,1,1,1,1,1,1,1,1,1\n1,1,1,1,1,3,3,3,3,3,50,50\n10,10,10,10,10,10,10,10,10,10,50,49", "1,1,1,1,1,1,1,1,1,0,40,60\n1,1,1,1,1,3,3,3,3,3,50,50\n10,10,10,10,10,10,10,10,10,10,50,49", "06,04,1,1,0,1,1,1,1,1,1,1\n1,1,1,1,1,3,3,3,3,3,50,50\n94,05,01,01,01,01,01,01,01,01,01,01", "1,1,1,1,1...
p00166 Area of Polygon
Create a program that inputs the vertex information of two polygons inscribed in one circle and outputs the magnitude relationship of their areas. Assume that each vertex of the X-side is numbered counterclockwise from 1 to X (the figure shows an example when X = 4). However, the given polygon assumes that the center ...
{ "input": [], "output": [] }
{ "input": [ "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n50\n25\n75\n0" ], "output": [ "0\n1\n2" ] }
{ "input": [ "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n50\n29\n75\n0", "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n6\n29\n75\n0", "4\n30\n84\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\...
p00322 Alphametic
Addition is easy to calculate by hand, but if some numbers are missing, is it easy to fill in the missing numbers? For example, in the following long division, if there is a condition that the numbers 1 to 9 appear only once, how many numbers will fit in the C and E squares? In this case, 8 is correct for C and 5 is co...
{ "input": [], "output": [] }
{ "input": [ "7 6 5 1 8 9 2 3 4", "-1 -1 -1 -1 -1 -1 8 4 6", "7 6 -1 1 -1 9 2 3 4", "-1 -1 -1 -1 -1 -1 -1 -1 -1" ], "output": [ "0", "12", "1", "168" ] }
{ "input": [ "7 6 5 2 8 9 2 3 4", "7 5 -1 1 -1 9 2 3 4", "7 6 -1 1 -1 14 2 3 4", "7 6 5 2 8 9 1 3 4", "5 6 -1 1 -1 14 2 3 4", "7 6 5 3 8 9 1 3 4", "7 6 5 3 8 3 1 3 4", "7 6 5 3 8 3 1 1 4", "7 6 5 3 0 3 1 1 4", "7 6 2 3 0 3 1 1 4", "7 6 0 3 0 3 1 1 4", "7 6 0 3 0 3 1 1 1...
p00492 Illumination
problem The JOI building is a combination of regular hexagons with a side of 1 meter as shown in the figure. As Christmas is approaching, JOI decided to decorate the walls of the building with illuminations. However, since it is useless to illuminate the parts that cannot be seen from the outside, we decided to decora...
{ "input": [], "output": [] }
{ "input": [ "8 4\n0 1 0 1 0 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0" ], "output": [ "64" ] }
{ "input": [ "8 4\n0 1 0 1 1 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0", "8 0\n0 1 0 1 1 1 1 1\n0 1 1 0 0 1 0 0\n1 0 1 0 1 1 1 1\n0 1 1 0 1 0 1 0", "8 1\n0 1 0 1 0 1 1 1\n0 1 1 -1 0 1 -1 1\n2 1 1 0 1 1 1 1\n0 1 1 1 1 0 0 0", "11 1\n0 1 0 1 0 1 1 1\n0 1 1 -4 0 1 -1 1\n2 1 1 0 1 1 1 1\n0 ...
p00678 KND Runs for Sweets
Problem KND is a student programmer at the University of Aizu. He is known to be a sweet tooth. He will be staying in a city for a year and wants to visit all N sweets shops in the city during that time. So I think the best place to live for the past year is the best place to go around the sweets shop. As his neighbor...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1 1\n2 2 1\n4\n1 1 3\n3 1 3\n4 2 1\n1 5 3\n0" ], "output": [ "0.70710678\n1.06066017" ] }
{ "input": [ "2\n1 1 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 2 1\n1 5 3\n0", "2\n1 2 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 2 1\n1 5 3\n0", "2\n1 2 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 2 1\n1 5 2\n0", "2\n1 3 1\n2 2 1\n4\n1 1 3\n3 1 3\n6 3 1\n1 5 3\n0", "2\n1 3 1\n2 2 1\n4\n1 1 3\n3 0 3\n6 3 1\n1 5 4\n0", "2\n1 3 1\n1 2 1...
p00821 Area of Polygons
Yoko’s math homework today was to calculate areas of polygons in the xy-plane. Vertices are all aligned to grid points (i.e. they have integer coordinates). Your job is to help Yoko, not good either at math or at computer programming, get her home- work done. A polygon is given by listing the coordinates of its vertic...
{ "input": [], "output": [] }
{ "input": [ "4\n5 -3\n1 0\n1 7\n-7 -1\n3\n5 5\n18 5\n5 10\n3\n-5 -5\n-5 -10\n-18 -10\n5\n0 0\n20 2\n11 1\n21 2\n2 0\n0" ], "output": [ "55\n41\n41\n23" ] }
{ "input": [ "4\n5 -3\n1 0\n1 7\n-7 -1\n3\n5 5\n18 5\n5 10\n3\n-7 -5\n-5 -10\n-18 -10\n5\n0 0\n20 2\n11 1\n21 2\n2 0\n0", "4\n5 -3\n1 0\n1 7\n-7 -1\n3\n5 5\n27 5\n5 10\n3\n-7 -5\n-5 -10\n-18 -10\n5\n0 0\n20 2\n11 1\n21 2\n2 0\n0", "4\n5 -3\n1 0\n1 7\n-7 -1\n3\n5 5\n27 5\n5 10\n3\n-7 -5\n-5 -10\n-18 -10\n5...
p00952 Placing Medals on a Binary Tree
Example Input 6 2 3 1 1 4 2 Output Yes Yes Yes No Yes No
{ "input": [], "output": [] }
{ "input": [ "6\n2\n3\n1\n1\n4\n2" ], "output": [ "Yes\nYes\nYes\nNo\nYes\nNo" ] }
{ "input": [ "6\n2\n3\n1\n1\n4\n1", "6\n2\n3\n2\n0\n0\n0", "6\n2\n3\n2\n1\n11\n2", "6\n4\n5\n2\n1\n4\n1", "6\n0\n3\n2\n1\n0\n1", "6\n1\n1\n1\n1\n-1\n0", "6\n2\n1\n1\n1\n4\n2", "6\n2\n1\n1\n2\n-1\n1", "6\n1\n3\n0\n1\n0\n2", "6\n4\n5\n0\n0\n4\n2", "6\n2\n0\n1\n2\n0\n1", "...
p01085 Entrance Examination
Entrance Examination The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination. The successful applicants of the examination are chosen as follows. * The score of any successful applicant is ...
{ "input": [], "output": [] }
{ "input": [ "5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n90\n80\n75\n65\n3 1 2\n5000\n4000\n3000\n4 2 3\n10000\n10000\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n68\n60\n45\n0 0 0" ], "output": [ "3\n4\n2\n2\n3\n2" ] }
{ "input": [ "5 2 4\n100\n90\n82\n70\n65\n5 2 4\n100\n90\n80\n75\n65\n3 1 2\n5000\n6502\n3000\n4 2 3\n10000\n10000\n8000\n8000\n4 2 3\n10000\n10000\n10000\n8000\n5 2 3\n100\n80\n68\n60\n45\n0 0 0", "5 2 4\n100\n90\n82\n94\n65\n5 2 4\n100\n90\n80\n144\n65\n3 1 2\n5000\n6502\n3000\n4 2 3\n10000\n10000\n8000\n80...
p01221 Two-finger Programming
Franklin Jenkins is a programmer, but he isn’t good at typing keyboards. So he always uses only ‘f’ and ‘j’ (keys on the home positions of index fingers) for variable names. He insists two characters are enough to write programs, but naturally his friends don’t agree with him: they say it makes programs too long. He a...
{ "input": [], "output": [] }
{ "input": [ "14\nVAR ga;\nVAR gb;\nIF(ga > gb) {\nVAR saa;\nVAR sab;\nIF(saa > ga) {\nsaa = sab;\n}\n}\nWHILE(gb > ga) {\nVAR sba;\nsba = ga;\nga = gb;\n}\n7\nVAR thisisthelongest;\nIF(thisisthelongest / 0) {\nVARone;\none = thisisthelongest + 1234567890123456789012345;\n}\nVAR another;\n32 = another;\n0", "...
{ "input": [ "14\nVAR ga;\nVAR gb;\nIF(ga > gb) {\nVAR saa;\nVAR sab;\nIF(saa > ga) {\nsaa = sab;\n}\n}\nWHILE(gb > ga) {\nVAR sba;\nsba = ga;\nga = gb;\n}\n7\nVAR thisisthelongest;\nIF(thisisthelongest / 0) {\nVARone;\none = thistsihelongest + 1234567890123456789012345;\n}\nVAR another;\n32 = another;\n0", "...
p01355 Nurie
N circles are drawn on the paper. The rabbit has k-colored paint and paints the paper according to the following rules. * Paint each area with one color of paint or nothing. Here, the "area" refers to the part with a finite area surrounded by a set of arcs. * Two adjacent areas cannot be painted with the same color. H...
{ "input": [], "output": [] }
{ "input": [ "2 1\n10 0 10\n20 0 10" ], "output": [ "2" ] }
{ "input": [ "2 1\n10 1 10\n20 0 10", "2 1\n15 1 17\n20 0 5", "2 2\n7 1 9\n20 0 10", "1 0\n44 6 0\n0 -2 0", "2 1\n15 1 10\n20 0 10", "2 1\n15 1 10\n20 0 5", "2 0\n15 1 17\n20 0 5", "2 0\n15 1 17\n1 0 5", "2 0\n15 1 17\n1 -1 5", "2 0\n8 1 17\n1 -1 5", "2 0\n8 1 17\n1 -1 3", ...
p01537 Code Art Online
G: Code Art Online Code Art Online (CAO) is an online RPG that advances adventures by solving various problems by programming. Since CAO was the world's first game that realized a virtual reality space, it was sold out while it was very popular, and users who purchased the game should enjoy this world. However, player...
{ "input": [], "output": [] }
{ "input": [ "3 3\n25 100 10\n8\n-10 0\n-2 2\n0 10\n2 2\n10 0\n2 -2\n0 -10\n-2 -2\n4\n30 0\n50 0\n50 40\n30 40\n3\n30 -10\n45 -70\n60 -10" ], "output": [ "3\n1\n2" ] }
{ "input": [ "3 3\n25 100 10\n8\n-10 0\n-2 0\n0 10\n2 2\n10 0\n2 -2\n0 -10\n-2 -2\n4\n30 0\n50 0\n50 40\n30 40\n3\n30 -10\n45 -70\n60 -10", "3 3\n25 101 10\n8\n-10 0\n-2 0\n0 10\n2 2\n10 -1\n2 -2\n0 -10\n-2 -2\n4\n30 0\n50 0\n50 40\n35 40\n3\n30 -10\n45 -70\n60 -10", "3 3\n50 101 13\n8\n-52 2\n-2 -1\n1 33...
p01693 Derangement
G --Derangement / Derangement Story Person D is doing research on permutations. At one point, D found a permutation class called "Derangement". "It's cool to have a perfect permutation !!! And it starts with D !!!", the person of D who had a crush on Chunibyo decided to rewrite all the permutations given to him. Pro...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 5 4" ], "output": [ "7" ] }
{ "input": [ "5\n2 1 3 5 4", "5\n2 1 0 5 4", "5\n4 1 0 5 4", "5\n4 1 0 5 6", "5\n4 0 0 5 6", "5\n4 0 0 10 6", "5\n4 0 0 10 12", "5\n4 0 0 10 3", "5\n4 0 0 11 3", "5\n4 0 0 0 3", "5\n4 0 1 0 3", "5\n7 0 1 0 3", "5\n7 0 2 0 3", "5\n7 1 2 0 3", "5\n2 1 0 1 4", ...
p01837 Longest Shortest Path
Example Input 3 2 3 1 3 1 2 2 1 2 3 1 2 Output 6.0000000
{ "input": [], "output": [] }
{ "input": [ "3 2 3 1 3\n1 2 2 1\n2 3 1 2" ], "output": [ "6.0000000" ] }
{ "input": [ "3 2 3 1 3\n1 2 4 1\n2 3 1 2", "3 2 3 1 3\n1 2 3 1\n2 3 1 2", "3 2 3 1 3\n1 2 3 2\n1 3 1 1", "3 2 6 1 3\n1 2 3 1\n2 3 1 2", "3 2 3 1 3\n1 2 2 2\n2 3 1 1", "3 2 3 1 3\n1 2 3 2\n2 3 1 2", "3 2 0 1 3\n1 2 3 2\n2 3 2 2", "3 2 3 2 3\n1 3 4 1\n2 3 1 2", "3 2 0 1 3\n1 2 1 2\n...
p01973 Censored String
G: 検閲により置換 (Censored String) Problem Statement You are given the string S, and the set of strings \mathcal P whose size is N. Now we consider applying the following operation to S: * Choose exactly one character in S, and replace it with '*'. Let s_i be a i-th character of S, S_{ij} be a consecutive substring in ...
{ "input": [], "output": [] }
{ "input": [ "brainfuck\n1\nfuck" ], "output": [ "1" ] }
{ "input": [ "brainfuck\n0\nfuck", "brainfudk\n0\nfuck", "brainfudk\n0\nfucl", "kdufniarb\n0\nfucl", "kdufniarb\n0\nfvcl", "kdufniarb\n1\nfvcl", "kdufniarb\n1\nlcvf", "kdufniarb\n1\nclvf", "brainfudk\n1\nclvf", "brainfudk\n1\nfvlc", "brainfudk\n1\nflvc", "brainfudk\n1\n...
p02119 Making Pairs
Problem Today, the high-class restaurant "Maizu Restaurant", which is completely invited, has finally opened. Only members of this restaurant have the right to invite new members, initially only the owner of the restaurant with membership number 0. Due to its luxury, the Maze Restaurant is only open for $ N $ days fr...
{ "input": [], "output": [] }
{ "input": [ "3\n0\n0\n2", "5\n0\n1\n2\n3\n4" ], "output": [ "1\n1\n2", "1\n1\n2\n2\n3" ] }
{ "input": [ "5\n0\n1\n0\n3\n4", "3\n0\n1\n2", "5\n0\n1\n1\n3\n4", "3\n0\n1\n1", "5\n0\n0\n0\n0\n4", "5\n0\n0\n1\n3\n0", "5\n0\n1\n1\n1\n1", "5\n0\n1\n1\n0\n2", "5\n0\n0\n1\n3\n4", "5\n0\n0\n2\n3\n4", "3\n0\n0\n1", "5\n0\n0\n0\n3\n4", "3\n0\n0\n0", "5\n0\n1\n0\n...
p02259 Bubble Sort
Write a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array ...
{ "input": [], "output": [] }
{ "input": [ "5\n5 3 2 4 1", "6\n5 2 4 6 1 3" ], "output": [ "1 2 3 4 5\n8", "1 2 3 4 5 6\n9" ] }
{ "input": [ "5\n7 3 2 4 1", "6\n5 1 4 6 1 3", "5\n7 3 2 3 1", "6\n6 1 4 6 1 3", "5\n7 3 2 3 0", "6\n6 1 3 6 1 3", "5\n7 3 4 3 0", "6\n8 1 3 6 1 3", "5\n7 1 4 3 0", "6\n8 1 3 6 2 3", "5\n7 1 4 3 1", "6\n8 1 3 3 2 3", "6\n1 1 3 3 2 3", "5\n4 2 4 3 1", "6\n1 1...
p02407 Reversing Numbers
Write a program which reads a sequence and prints it in the reverse order. Note 解説 Constraints * n ≤ 100 * 0 ≤ ai < 1000 Input The input is given in the following format: n a1 a2 . . . an n is the size of the sequence and ai is the ith element of the sequence. Output Print the reversed sequence in a line. P...
{ "input": [], "output": [] }
{ "input": [ "8\n3 3 4 4 5 8 7 9", "5\n1 2 3 4 5" ], "output": [ "9 7 8 5 4 4 3 3", "5 4 3 2 1" ] }
{ "input": [ "8\n3 3 4 4 5 8 7 14", "5\n1 2 3 4 9", "8\n4 3 4 4 5 8 7 14", "5\n1 4 3 4 9", "8\n0 3 4 4 5 8 7 14", "5\n1 1 3 4 9", "8\n0 1 4 4 5 8 7 14", "5\n1 0 3 4 9", "8\n0 2 4 4 5 8 7 14", "5\n1 0 3 4 12", "8\n0 2 4 4 5 0 7 14", "5\n0 0 3 4 12", "8\n0 1 4 4 5 0 7...
alpha
Tanish loves alphabets. He loves alphabets so much that he ignores all other characters. Also, whenever he is given an alphabet he gives the next alphabet in alphabetical order in same case. For example, for a-b,for d-e,for z-a. Given a string guess what would be Tanish's answer. Input The first line of the input co...
{ "input": [], "output": [] }
{ "input": [ "4\nnun123\n1234\nretA34\n^ 56az" ], "output": [ "ovo\n\nsfuB\nba" ] }
{ "input": [], "output": [] }
cheftma
Chef spent N days working really hard! He planned loads of tasks: as many as Ai tasks to do on the ith day! Chef's work was brutal, so he only managed to finish Bi tasks on the ith day. The good news is that Chef has a Time Machine! The Time Machine has K white buttons and M black buttons. Each button has a positive i...
{ "input": [], "output": [] }
{ "input": [ "1\n4 2 2 \n5 7 6 1\n3 3 1 1\n6 3\n1 4" ], "output": [ "3" ] }
{ "input": [], "output": [] }
ds7
Problem Michal Scofield and Lincon burrow are two brothers. By a murder allegation Lincon Burrow was sentenced to jail. Michal Scofield some how came to know that his brother is not guilty and he don’t have time to file case against the allegations as his brother is going to sit on death chair soon enough. So he ma...
{ "input": [], "output": [] }
{ "input": [ "2\n5\ntoioynnkpheleaigshareconhtomesnlewx\n3\nttyohhieneesiaabss" ], "output": [ "theresnoplacelikehomeonasnowynightx\nthisistheeasyoneab" ] }
{ "input": [ "2\n5\ntoioynnkpheleaigshareconhtomesnlewx\n1\nttyohhieneesiaabss", "2\n5\ntoioynnkpheleaigshareconhtomesnlewx\n1\nbtyohhieneesiaatss", "2\n5\ntoioynnkpheleaigshareconhtomesnlewx\n1\nbtzohhieneesiaatss", "2\n5\ntoioynnkpheleaigshareconhtomesnlewx\n1\nbtzohhseneesiaatis", "2\n5\nthioyn...
ketswap
You need to shuffle a series of numbers from 1 To T, inclusive. The numbers are in ascending order, you have to shuffle them using bubble sort algorithm, that is swap every time a number is greater than another in the given list in the input. A number is greater than another in the list if the number appears later than...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n2 1 3\nabac" ], "output": [ "1" ] }
{ "input": [], "output": [] }
odddiv
Little Egor likes to play with positive integers and their divisors. Bigger the number to play with, more the fun! The boy asked you to come up with an algorithm, that could play the following game: Let's define f(n) as the sum of all odd divisors of n. I.e. f(10) = 1 + 5 = 6 and f(21) = 1 + 3 + 7 + 21 = 32. The game ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 10\n42 42" ], "output": [ "45\n32\n" ] }
{ "input": [ "2\n1 7\n42 42", "2\n2 7\n42 42", "2\n2 10\n42 42", "2\n1 7\n42 71", "2\n2 7\n42 54", "2\n2 11\n42 42", "2\n1 11\n42 42", "2\n1 9\n42 42", "2\n2 4\n42 42", "2\n1 7\n42 127", "2\n3 11\n42 42", "2\n1 18\n42 42", "2\n2 4\n35 42", "2\n1 8\n42 42", "...
snape
Professor Snape has lots of potions. Bottles containing all types of potions are stacked on shelves which cover the entire wall from floor to ceiling. Professor Snape has broken his bones several times while climbing the top shelf for retrieving a potion. He decided to get a ladder for him. But he has no time to visit ...
{ "input": [], "output": [] }
{ "input": [ "3\n4 5\n10 12\n10 20" ], "output": [ "3.0 6.40312\n6.63325 15.6205\n17.3205 22.3607" ] }
{ "input": [ "3\n4 5\n10 12\n0 20", "3\n1 5\n10 12\n0 20", "3\n1 5\n10 23\n0 20", "3\n1 5\n10 23\n0 30", "3\n1 5\n8 23\n0 30", "3\n1 5\n8 23\n0 41", "3\n1 5\n8 23\n0 69", "3\n1 5\n8 23\n0 115", "3\n1 3\n8 23\n0 115", "3\n5 5\n10 12\n10 20", "3\n4 7\n10 12\n0 20", "3\n2 ...
1070_M. Algoland and Berland
Once upon a time Algoland and Berland were a single country, but those times are long gone. Now they are two different countries, but their cities are scattered on a common territory. All cities are represented as points on the Cartesian plane. Algoland consists of a cities numbered from 1 to a. The coordinates of the...
{ "input": [], "output": [] }
{ "input": [ "2\n2 3\n1 1 2\n0 0\n1 1\n1 2\n3 2\n4 0\n1 1\n1\n0 0\n0 1\n" ], "output": [ "YES\n3 1\n1 2\n2 2\n3 2\nYES\n1 1\n" ] }
{ "input": [ "2\n2 3\n1 1 2\n0 0\n1 1\n2 2\n3 2\n4 0\n1 1\n1\n0 0\n0 1\n", "2\n2 3\n1 1 2\n0 0\n1 1\n1 0\n3 2\n4 0\n1 1\n1\n0 1\n0 1\n", "2\n2 3\n1 1 2\n0 0\n1 1\n1 0\n3 0\n4 0\n1 1\n1\n0 1\n0 1\n", "2\n2 3\n1 1 2\n0 0\n1 1\n2 3\n3 2\n4 1\n1 1\n1\n0 0\n0 1\n", "2\n2 3\n1 1 2\n0 0\n1 1\n1 0\n3 2\n4...
1240_D. Stack Exterminable Arrays
Let's look at the following process: initially you have an empty stack and an array s of the length l. You are trying to push array elements to the stack in the order s_1, s_2, s_3, ... s_{l}. Moreover, if the stack is empty or the element at the top of this stack is not equal to the current element, then you just push...
{ "input": [], "output": [] }
{ "input": [ "3\n5\n2 1 1 2 2\n6\n1 2 1 1 3 2\n9\n3 1 2 2 1 6 6 3 3\n" ], "output": [ "4\n1\n8\n" ] }
{ "input": [ "3\n5\n2 1 1 2 4\n6\n1 2 1 1 3 2\n9\n3 1 2 2 1 6 6 3 3\n", "3\n5\n2 1 1 2 4\n6\n1 2 1 1 3 2\n9\n3 1 2 2 2 6 6 3 3\n", "3\n5\n2 2 1 2 4\n6\n1 2 1 1 3 2\n9\n3 1 2 2 1 6 6 3 3\n", "3\n5\n2 1 1 2 4\n6\n1 2 1 1 3 2\n9\n3 2 2 2 2 6 6 3 3\n", "3\n5\n2 1 1 2 2\n6\n1 2 1 2 3 2\n9\n3 1 2 2 1 6 ...
1282_E. The Cake Is a Lie
We are committed to the well being of all participants. Therefore, instead of the problem, we suggest you enjoy a piece of cake. Uh oh. Somebody cut the cake. We told them to wait for you, but they did it anyway. There is still some left, though, if you hurry back. Of course, before you taste the cake, you thought abo...
{ "input": [], "output": [] }
{ "input": [ "3\n6\n3 6 5\n5 2 4\n5 4 6\n6 3 1\n6\n2 5 6\n2 5 1\n4 1 2\n1 3 5\n3\n1 2 3\n" ], "output": [ "1 3 5 2 4 6 \n4 2 1 3 \n1 3 5 6 2 4 \n4 3 2 1 \n1 2 3 \n1 \n" ] }
{ "input": [ "3\n6\n3 6 5\n6 2 4\n5 4 6\n6 3 1\n6\n2 5 6\n2 5 1\n4 1 2\n1 3 5\n3\n1 2 3\n", "3\n6\n1 6 5\n6 2 4\n5 4 6\n6 3 1\n6\n2 5 6\n2 5 1\n4 1 2\n1 3 5\n3\n1 2 3\n", "3\n6\n1 6 5\n6 2 4\n5 4 6\n6 3 1\n6\n3 5 6\n2 5 1\n4 1 2\n1 3 5\n3\n1 2 3\n", "3\n6\n1 6 5\n6 2 4\n5 4 6\n6 3 1\n6\n3 5 6\n2 5 1\n...
1302_F. Keep talking and nobody explodes – easy
This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543) You have the safe lock which consists of 5 decimal digits. If you rotate some digit, it increases by one, except 9 which becomes 0. Initially, the lock contains numbe...
{ "input": [], "output": [] }
{ "input": [ "00000\n", "12345\n" ], "output": [ "\n61376\n", "\n07769\n" ] }
{ "input": [], "output": [] }
1476_G. Minimum Difference
You are given an integer array a of size n. You have to perform m queries. Each query has one of two types: * "1 l r k" — calculate the minimum value dif such that there are exist k distinct integers x_1, x_2, ..., x_k such that cnt_i > 0 (for every i ∈ [1, k]) and |cnt_i - cnt_j| ≤ dif (for every i ∈ [1, k], j ∈ ...
{ "input": [], "output": [] }
{ "input": [ "12 11\n2 1 1 2 1 1 3 2 1 1 3 3\n1 2 10 3\n1 2 11 3\n2 7 2\n1 3 9 2\n1 1 12 1\n1 1 12 4\n2 12 4\n1 1 12 4\n2 1 5\n1 3 12 2\n1 1 4 3\n" ], "output": [ "\n5\n4\n1\n0\n-1\n5\n0\n1\n" ] }
{ "input": [ "12 11\n2 1 1 2 1 1 3 2 1 1 3 3\n1 2 10 3\n1 2 11 3\n2 7 2\n1 3 9 2\n1 1 12 2\n1 1 12 4\n2 12 4\n1 1 12 4\n2 1 5\n1 3 12 2\n1 1 4 3\n", "12 11\n2 1 1 2 1 1 3 2 1 1 3 3\n1 2 10 3\n1 2 12 3\n2 7 2\n1 3 9 2\n1 1 12 1\n1 1 12 4\n2 12 4\n1 1 12 4\n2 1 5\n1 3 12 2\n1 1 4 3\n", "12 11\n2 1 1 2 1 1 3...
1527_B2. Palindrome Game (hard version)
The only difference between the easy and hard versions is that the given string s in the easy version is initially a palindrome, this condition is not always true for the hard version. A palindrome is a string that reads the same left to right and right to left. For example, "101101" is a palindrome, while "0101" is n...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n110\n2\n00\n4\n1010\n" ], "output": [ "\nALICE\nBOB\nALICE\n" ] }
{ "input": [ "3\n3\n110\n2\n00\n4\n1011\n", "3\n3\n010\n2\n00\n4\n0011\n", "3\n3\n110\n2\n00\n4\n0110\n", "3\n3\n010\n2\n00\n4\n1001\n", "3\n3\n110\n2\n00\n4\n0011\n", "3\n3\n110\n2\n00\n4\n0010\n", "3\n3\n000\n2\n00\n4\n0011\n", "3\n3\n000\n2\n00\n4\n0111\n", "3\n3\n110\n2\n00\n4\...
345_B. Triskaidekaphobia
Triskaidekaphobia is a fear of number 13. Ordinary people who suffer from this phobia feel uncomfortable around numbers 13, 130, 513 etc, but you, being a programmer, take this fear one step further. For example, consider number 7. It's ok when written in decimal, but written in base 4 it becomes 13, the dreadful numbe...
{ "input": [], "output": [] }
{ "input": [ "7\n", "100\n", "13\n" ], "output": [ "1\n", "13\n", "-1\n" ] }
{ "input": [], "output": [] }
counting-strings
Alice got a message M. It is in an alien language. A string in an alien language is said to be valid if it contains the letter a or z. Alice decided to count the number of valid substrings of the message M. Help him to do this. Two substrings are different if it occurs at different positions in the message. Input ...
{ "input": [], "output": [] }
{ "input": [ "4\nabcd\nazazaz\nabbzbba\nflkjdh\n\nSAMPLE" ], "output": [ "4\n21\n22\n0\n" ] }
{ "input": [ "4\nabcd\nazazaz\nabbzbbb\nflkjdh\n\nSAMPLE", "4\nabcd\nzazaza\nabazbbb\nflkjdh\n\nSAMPJE", "4\nabcd\nzazaza\nabazbba\nflkjdh\n\nSAMPJE", "4\ncbda\nza`zza\nbbaabaz\nkcjikh\n\nSELPIA", "4\ncbda\nza`zzb\nbbaabaz\nlcjhki\n\nAIPLES", "4\ncbda\nza`zzb\ncbaabay\nlcjhki\n\nAIPLFS", "...
finding-xor
You are given two very large numbers made up of 1 or 0 only. You have to find the digit by digit XOR of the two numbers, i.e., the i-th digit of the answer is 1 if and only if the i-th digit of the two given numbers differ otherwise the i-th digit of the answer is 0. The number of digits in both the numbers is same. I...
{ "input": [], "output": [] }
{ "input": [ "2\n01110\n01100\n010\n111\n\nSAMPLE" ], "output": [ "00010\n101\n" ] }
{ "input": [ "2\n01110\n01100\n010\n111\n\nSAMOLE", "2\n01110\n01100\n010\n011\n\nSAMOLE", "2\n01110\n01100\n010\n001\n\nSAMOLE", "2\n00110\n01100\n010\n001\n\nSAMOLE", "2\n00110\n01100\n010\n101\n\nSAMOLE", "2\n01110\n01100\n010\n101\n\nSAMOLE", "2\n01110\n01100\n011\n101\n\nELOMAS", ...
irctc
Good news , You have a chance to work in IRCTC as a software developer . Applications are required with a program for railway sites . sid of a station is a something which uniquely defines it . Given N station's sid from 1 to N and distance between any two stations , if any person wants to go from station having sid A...
{ "input": [], "output": [] }
{ "input": [ "2\n6 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1\n1 3 6\n10 10\n1 5 78\n1 8 221\n2 7 92\n2 8 159\n3 5 55\n3 6 179\n3 10 237\n4 8 205\n5 6 191\n8 10 157\n6 3 2\n\nSAMPLE" ], "output": [ "No Train Found.\n692\n6 3 5 1 8 2" ] }
{ "input": [], "output": [] }
mehta-and-the-tricky-triplets
Mehta is a forever alone and desperate guy. He has a crush on N girls of his society. He wants to impress them all and so he needs to do their task collectively.All the girls give him a number which he stores in an array named A of size N. To do their task, he has to report the number of triplets (i,j,k) in the array A...
{ "input": [], "output": [] }
{ "input": [ "5\n21\n22\n23\n24\n25\n\nSAMPLE" ], "output": [ "10" ] }
{ "input": [ "5\n21\n22\n23\n24\n25\n\nELPMAS", "5\n5\n22\n27\n24\n25\n\nELPMAS", "5\n5\n22\n27\n31\n25\n\nELPMAS", "5\n3\n11\n21\n34\n25\n\nESPNAL", "5\n63\n22\n23\n2\n3\n\nSAMPLF", "5\n21\n22\n27\n24\n25\n\nELPMAS", "5\n3\n22\n27\n31\n25\n\nELPMAS", "5\n3\n22\n27\n34\n25\n\nELPMAS", ...
our-coach-and-messi
After the huge success of Hero ISL this season our friend is planning to play in the next season. He already has a team which contains some good players but they not so good. He wants his team to qualify for the next season but the coach is worried as they don't have a good player. Being a huge a fan of Lionel Messi h...
{ "input": [], "output": [] }
{ "input": [ "3\n2 2\n3 4\n250000000 4\n\nSAMPLE" ], "output": [ "4\n81\n660156264\n" ] }
{ "input": [ "3\n1 2\n3 4\n250000000 4\n\nSAMPLE", "3\n1 2\n3 2\n250000000 4\n\nS@MPLE", "3\n1 2\n5 4\n250000000 4\n\nELPM@S", "3\n1 2\n5 4\n173743654 4\n\nELPM@S", "3\n1 1\n3 4\n173743654 4\n\nS@MPME", "3\n2 1\n3 4\n173743654 4\n\nEMPM@S", "3\n1 0\n3 8\n173743654 4\n\nS@MPME", "3\n1 0...
p02558 AtCoder Library Practice Contest - Disjoint Set Union
You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types. * `0 u v`: Add an edge (u, v). * `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise. Constraints * 1 \leq N \leq 200,000 * 1 \leq Q \leq 200,000 * 0 \leq u_i, v_i \lt N Input Input is ...
{ "input": [], "output": [] }
{ "input": [ "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3" ], "output": [ "0\n1\n0\n1" ] }
{ "input": [ "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 0 3", "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 2\n1 1 2\n0 0 2\n1 1 3", "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n0 0 3", "4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 2\n1 1 2\n0 0 2\n0 1 3", "4 7\n1 1 1\n0 0 1\n0 2 3\n1 0 2\n1 0 2\n0 0 2\n0 1 3", "...
p02689 AtCoder Beginner Contest 166 - Peaks
There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j. Obs. i is said to be good when its elevation is higher than those of all observatories that can be r...
{ "input": [], "output": [] }
{ "input": [ "6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6", "4 3\n1 2 3 4\n1 3\n2 3\n2 4" ], "output": [ "3", "2" ] }
{ "input": [ "6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 0\n4 6\n4 6", "4 3\n1 2 3 4\n1 3\n3 3\n2 4", "4 2\n2 4 3 5\n1 3\n3 3\n2 4", "4 0\n2 4 3 5\n1 3\n3 3\n4 4", "6 0\n9 6 8 1 1 1\n0 3\n3 0\n4 1\n4 2\n1 6", "6 5\n8 6 9 1 2 0\n0 3\n4 0\n4 0\n2 6\n4 6", "4 3\n1 6 3 3\n1 3\n2 2\n3 4", "6 5\n8 6 9 1 ...
p02818 AtCoder Beginner Contest 149 - Greedy Takahashi
Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times: * If Takahashi has one or more cookies, eat one of his cookies. * Otherwise, if Aoki has one or more cookies, eat one of Aoki's cookies. * If they both have no cookies, do nothing. In the end, how many cookies will Taka...
{ "input": [], "output": [] }
{ "input": [ "500000000000 500000000000 1000000000000", "2 3 3" ], "output": [ "0 0", "0 2" ] }
{ "input": [ "500000000000 274588616851 1000000000000", "2 3 1", "2 3 2", "2 3 0", "2 6 0", "4 6 0", "8 6 0", "10 6 0", "498881727339 49011419508 0000000100000", "0 6 0", "498881727339 49011419508 0000001100000", "0 9 0", "498881727339 50858735181 0000001100000", ...
p02954 AtCoder Beginner Contest 136 - Gathering Children
Given is a string S consisting of `L` and `R`. Let N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left. The character written on the leftmost square is always `R`, and the character written on the rightmost square...
{ "input": [], "output": [] }
{ "input": [ "RRLLLLRLRRLL", "RRRLLRLLRRRLLLLL", "RRLRL" ], "output": [ "0 3 3 0 0 0 1 1 0 2 2 0", "0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0", "0 1 2 1 1" ] }
{ "input": [ "RRLLRLRLLRLL", "RLRLLRLRRRRLLLLL", "RRLLLLRLRLRL", "RRRLLRLLRRLRLLLL", "RRLRLLRLLLRL", "RRLRLLRLLRLL", "RRLLLLRRLRLL", "RRRLLRLLLRRLLRLL", "RRLRRLLLLLRL", "RRRLLRLLRLRLLRLL", "RRLRLLLRLLRL", "RRLLLLRLLRRL", "RRRLLRRLLRRLLLLL", "RRLLLLRRRLLL", "...
p03090 AtCoder Grand Contest 032 - Balanced Neighbors
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved t...
{ "input": [], "output": [] }
{ "input": [ "3" ], "output": [ "2\n1 3\n2 3" ] }
{ "input": [ "0", "4", "1", "2", "000", "001", "2", "0", "1", "4", "001", "000" ], "output": [ "0\n", "4\n1 2\n1 3\n2 4\n3 4\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "4\n1 2\n1 3\n2 4\n3 4\n", "0\n", "0\n" ...
p03235 AtCoder Grand Contest 028 - High Elements
You are given P, a permutation of (1,\ 2,\ ...\ N). A string S of length N consisting of `0` and `1` is a good string when it meets the following criterion: * The sequences X and Y are constructed as follows: * First, let X and Y be empty sequences. * For each i=1,\ 2,\ ...\ N, in this order, append P_i to the end of...
{ "input": [], "output": [] }
{ "input": [ "6\n3 1 4 6 2 5", "7\n1 3 2 5 6 4 7", "5\n1 2 3 4 5", "30\n1 2 6 3 5 7 9 8 11 12 10 13 16 23 15 18 14 24 22 26 19 21 28 17 4 27 29 25 20 30" ], "output": [ "001001", "0001101", "-1", "000000000001100101010010011101" ] }
{ "input": [ "7\n1 3 2 5 6 4 2", "30\n1 2 10 3 5 7 9 8 11 12 10 13 16 23 15 18 14 24 22 26 19 21 28 17 4 27 29 25 20 30", "30\n1 2 10 3 5 7 9 8 11 12 19 13 16 23 15 18 14 24 22 26 19 7 28 17 4 27 29 25 20 30", "30\n1 2 6 2 5 7 9 8 11 12 10 13 16 23 15 18 14 24 22 26 19 21 28 17 4 27 29 25 20 30", ...
p03386 AtCoder Beginner Contest 093 - Small and Large Integers
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. Constraints * 1 \leq A \leq B \leq 10^9 * 1 \leq K \leq 100 * All values in input are integers. Input Input is give...
{ "input": [], "output": [] }
{ "input": [ "2 9 100", "3 8 2", "4 8 3" ], "output": [ "2\n3\n4\n5\n6\n7\n8\n9", "3\n4\n7\n8", "4\n5\n6\n7\n8" ] }
{ "input": [ "2 9 110", "3 4 2", "4 11 3", "2 5 110", "0 11 3", "2 6 110", "1 4 4", "0 0 3", "2 12 110", "1 1 4", "4 12 110", "4 23 110", "4 35 011", "7 35 011", "7 35 010", "7 16 010", "3 13 2", "6 8 3", "0 9 110", "3 6 2", "1 11 3",...
p03552 AtCoder Regular Contest 085 - ABS
We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i. Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they w...
{ "input": [], "output": [] }
{ "input": [ "5 1 1\n1 1 1 1 1", "3 100 1000\n10 100 100", "3 100 100\n10 1000 100", "1 1 1\n1000000000" ], "output": [ "0", "900", "900", "999999999" ] }
{ "input": [ "5 1 1\n1 0 1 1 1", "3 100 100\n8 1000 100", "5 0 0\n0 -1 1 1 1", "5 1 1\n-1 -5 3 0 2", "3 100 1001\n10 100 100", "3 101 100\n8 1000 110", "5 1 1\n-1 -5 3 -1 2", "3 100 100\n10 1001 000", "3 100 100\n10 0001 000", "3 100 100\n10 0001 100", "3 101 100\n3 1000 10...
p03707 AtCoder Grand Contest 015 - Nuske vs Phantom Thnook
Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue; if S_{i,j} is 0, the ...
{ "input": [], "output": [] }
{ "input": [ "3 4 4\n1101\n0110\n1101\n1 1 3 4\n1 1 3 1\n2 2 3 4\n1 2 2 4", "5 5 6\n11010\n01110\n10101\n11101\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 4\n3 3 3 3\n3 1 3 5\n1 1 3 4" ], "output": [ "3\n2\n2\n2", "3\n2\n1\n1\n3\n2" ] }
{ "input": [ "3 4 4\n1101\n0110\n1101\n1 1 3 4\n1 1 3 1\n2 2 3 4\n1 2 3 4", "5 5 6\n11010\n01110\n10101\n11101\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 5\n3 3 3 3\n3 1 3 5\n1 1 3 4", "5 5 6\n11010\n01110\n10101\n11101\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 5\n5 3 3 3\n3 1 3 5\n1 1 3 4", "3 4 4\n1101\n0110\n1101\n1 1 ...
p03861 AtCoder Beginner Contest 048 - Between a and b ...
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x? Constraints * 0 ≤ a ≤ b ≤ 10^{18} * 1 ≤ x ≤ 10^{18} Input The input is given from Standard Input in the following format: a b x Output Print the number of th...
{ "input": [], "output": [] }
{ "input": [ "4 8 2", "9 9 2", "1 1000000000000000000 3", "0 5 1" ], "output": [ "3", "0", "333333333333333333", "6" ] }
{ "input": [ "16 9 2", "1 1000010000000000000 3", "0 5 2", "16 9 1", "1 1000010100000000000 3", "15 9 1", "0 1000010100000000000 3", "-1 7 2", "0 1000010100000100000 3", "-2 7 2", "0 1010010100000100000 3", "-2 7 1", "-1 1010010100000100000 4", "-2 6 1", "-1...
p04027 AtCoder Regular Contest 059 - Children and Candies
12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience. There are N children in AtCoder Kindergarten, conveniently numbered 1 through N. Mr. Evi will distribute C indistinguishable candies to the children. If child i is given a candies, the child's happine...
{ "input": [], "output": [] }
{ "input": [ "3 100\n7 6 5\n9 9 9", "1 2\n1\n3", "2 3\n1 1\n1 1", "2 3\n1 1\n2 2", "4 8\n3 1 4 1\n3 1 4 1" ], "output": [ "139123417", "14", "4", "66", "421749" ] }
{ "input": [ "3 100\n7 1 5\n9 9 9", "1 2\n1\n4", "4 8\n3 1 4 1\n3 1 5 1", "3 000\n7 1 5\n9 9 9", "1 4\n1\n4", "4 8\n3 1 3 1\n3 1 5 1", "4 8\n3 1 2 1\n3 1 5 1", "4 8\n3 1 2 1\n4 1 5 1", "4 15\n3 1 2 1\n4 1 5 1", "4 30\n3 1 2 1\n4 1 5 1", "4 20\n3 1 2 1\n4 1 5 1", "4 20\n...
p00110 Alphametic
The problem of hiding a part of a formula and searching for the hidden number is called verbal arithmetic. This time, I'm dealing with an expression in which some numbers in the expression are hidden by X. Enter the following formula and create a program that outputs the result. Formula * A simple one-line addition e...
{ "input": [], "output": [] }
{ "input": [ "123+4X6=X79\n12X+4X6=X79\nXX22+89=X2XX" ], "output": [ "5\nNA\n1" ] }
{ "input": [ "123+4X6=X79\n12X+4X7=X79\nXX22+89=X2XX", "123+5X6=X79\n12X+4X7=X79\nXX22+89=X2XX", "123+5X6=X89\n12X+4X7=X79\nXX22+89=X2XX", "127+5XX=638\n1+X14X7=X59\nXX32+89=X2XX", "123+4X6=X79\n12X+4X6=X79\nXX12+89=X2XX", "1X3+426=X79\n12X+4X7=X79\nXX22+89=X2XX", "127+5X6=X39\n12X+4X7=X79...
p00244 Hot Spring Trip
Takeshi, who loves hot springs, is planning a trip to a hot spring resort on his next long vacation. I would like to travel by connecting to a long-distance bus and reach my destination with as little money as possible. Takeshi, who has savings but is unwilling to pay, decided to consult with his grandfather. The grand...
{ "input": [], "output": [] }
{ "input": [ "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 14\n2 3 10\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0" ], "output": [ "5\n0\n7" ] }
{ "input": [ "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 14\n2 3 15\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0", "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 4\n2 3 10\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0", "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 13\n1 3 9\n2 5 27\n2 3 10\n2 4 15...
p00425 Dice
The dice are placed in the orientation shown in the figure below. <image> As shown in this figure, the dice used here have 1 on the upper side and 2 on the south side, and 3 on the east side. Since the sum of the facing faces of the dice is always 7, the invisible faces are 5 on the north side, 4 on the west side, a...
{ "input": [], "output": [] }
{ "input": [ "5\nNorth\nNorth\nEast\nSouth\nWest\n8\nWest\nNorth\nLeft\nSouth\nRight\nNorth\nLeft\nEast\n0" ], "output": [ "21\n34" ] }
{ "input": [], "output": [] }
p00620 Line Puzzle
Let's solve the puzzle by programming. The numbers n x n are arranged in a grid pattern. Some of the numbers are circled and we will call them the starting point. The rules of the puzzle are as follows: * Draw one line that goes vertically and horizontally from each starting point (cannot be drawn diagonally). * Exte...
{ "input": [], "output": [] }
{ "input": [ "3\n-3 1 1\n2 -4 1\n2 1 -1\n3\n-4 1 1\n1 1 -6\n1 -5 3\n4\n-8 6 -2 1\n2 -7 -2 1\n1 -1 1 1\n1 1 1 -5\n6\n2 2 3 -7 3 2\n1 -10 1 1 3 2\n2 6 5 2 -6 1\n3 4 -23 2 2 5\n3 3 -6 2 3 7\n-7 2 3 2 -5 -13\n6\n2 2 3 -7 3 2\n1 -10 1 1 3 2\n2 6 5 2 -6 1\n3 4 -23 2 2 5\n3 3 -6 2 3 7\n-7 2 3 2 -5 -12\n0" ], "output...
{ "input": [ "3\n-3 1 1\n2 -4 1\n2 1 -1\n3\n-4 1 1\n1 1 -6\n1 -5 3\n4\n-8 6 -2 1\n2 -7 -2 1\n1 -1 1 1\n1 1 1 -5\n6\n2 2 3 -7 3 2\n1 -10 1 1 3 2\n2 6 5 2 -6 0\n3 4 -23 2 2 5\n3 3 -6 2 3 7\n-7 2 3 2 -5 -13\n6\n2 2 3 -7 3 2\n1 -10 1 1 3 2\n2 6 5 2 -6 1\n3 4 -23 2 2 5\n3 3 -6 2 3 7\n-7 2 3 2 -5 -12\n0", "3\n-3 1 ...
p00764 Chain-Confined Path
There is a chain consisting of multiple circles on a plane. The first (last) circle of the chain only intersects with the next (previous) circle, and each intermediate circle intersects only with the two neighboring circles. Your task is to find the shortest path that satisfies the following conditions. * The path co...
{ "input": [], "output": [] }
{ "input": [ "10\n802 0 10\n814 0 4\n820 1 4\n826 1 4\n832 3 5\n838 5 5\n845 7 3\n849 10 3\n853 14 4\n857 18 3\n3\n0 0 5\n8 0 5\n8 8 5\n3\n0 0 5\n7 3 6\n16 0 5\n9\n0 3 5\n8 0 8\n19 2 8\n23 14 6\n23 21 6\n23 28 6\n19 40 8\n8 42 8\n0 39 5\n11\n0 0 5\n8 0 5\n18 8 10\n8 16 5\n0 16 5\n0 24 5\n3 32 5\n10 32 5\n17 28 8\...
{ "input": [ "10\n802 0 10\n814 0 4\n820 1 4\n826 1 4\n832 3 5\n838 5 5\n845 7 3\n849 10 3\n853 14 4\n857 18 3\n3\n0 0 5\n8 0 5\n8 8 5\n3\n0 0 5\n7 3 6\n16 0 5\n9\n0 3 5\n8 0 8\n19 2 8\n23 14 6\n23 21 6\n23 28 6\n19 40 8\n8 42 8\n0 39 5\n11\n0 0 5\n8 0 5\n18 8 10\n8 16 5\n0 16 5\n0 24 5\n3 32 5\n10 32 5\n17 28 8\...
p00896 Weaker than Planned
The committee members of the Kitoshima programming contest had decided to use crypto-graphic software for their secret communication. They had asked a company, Kodai Software, to develop cryptographic software that employed a cipher based on highly sophisticated mathematics. According to reports on IT projects, many p...
{ "input": [], "output": [] }
{ "input": [ "4\nA\nAND\nCAT\nDOG\nZ XUW ZVX Z YZT.\n2\nAZ\nAY\nZA.\n2\nAA\nBB\nCC.\n16\nA\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM\nN\nO\nABCDEFGHIJKLMNO\nA B C D E F G H I J K L M N O ABCDEFGHIJKLMNO.\n0" ], "output": [ "A DOG AND A CAT.\nAZ.\n-.\nA B C D E F G H I J K L M N O ABCDEFGHIJKLMNO." ] }
{ "input": [ "4\nA\nAND\nCAT\nDOG\nZ XUW ZVX Z YZT.\n2\nAZ\nAY\nZA.\n2\nAA\nBB\nCC.\n16\nA\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM\nN\nO\nONMLKJIHGFEDCBA\nA B C D E F G H I J K L M N O ABCDEFGHIJKLMNO.\n0", "4\nA\nAND\nCAT\nDOG\nZ XUW ZVX Z YZT.\n2\nZA\nAY\nZA.\n2\nAA\nBB\nCC.\n16\nA\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK...
p01029 Yu-kun Likes Letters in the English Alphabet
Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves lowercase letters as much as programming. Yu-kun decided to write a scoring program for a new play that uses paper, circles, lines, and lowercase lett...
{ "input": [], "output": [] }
{ "input": [ "3 2\nc ? ?\n0 1\n0 2", "5 0\n? ? ? ? ?", "3 3\nc ? ?\n0 1\n0 2\n1 2", "7 6\n? a ? ? z a ?\n0 1\n0 2\n3 4\n4 5\n4 6\n5 6" ], "output": [ "caa", "aaaaa", "cab", "baaazab" ] }
{ "input": [ "1 0\n? ? ? ? ?", "3 3\nb ? ?\n0 1\n0 2\n1 2", "7 6\n? a ? ? z a ?\n1 1\n0 2\n3 4\n4 5\n4 6\n5 6", "7 6\n? a ? ? z a ?\n1 1\n0 2\n3 4\n4 5\n2 6\n5 6", "7 6\n? a ? ? z a ?\n1 0\n0 2\n2 4\n4 5\n2 6\n5 6", "7 6\n? a ? > z a ?\n1 0\n0 2\n2 4\n4 0\n2 6\n5 6", "4 2\nc ? ?\n0 1\n0 2"...
p01160 It Prefokery Pio
You are a member of a secret society named Japanese Abekobe Group, which is called J. A. G. for short. Those who belong to this society often exchange encrypted messages. You received lots of encrypted messages this morning, and you tried to decrypt them as usual. However, because you received so many and long messages...
{ "input": [], "output": [] }
{ "input": [ "YMAOKDOAMIMHAADAMMA\nLELVEEL" ], "output": [ "MADAMIMADAM\nLEVEL" ] }
{ "input": [ "AMMADAAHMIMAODKOAMY\nLELVEEL", "YMAOKDOAMIMHAADAMMA\nLEMVEEL", "YMAOKDOAMIMHAADAMMA\nLFMVEEL", "YMAOKDOAMIMHAADAMMA\nMEEVLFM", "YMAOKDOAMIMAAHDAMMA\nMEEVLFL", "YMAOKDOAMIMAAHDBMMA\nLFLVEEM", "YMAOKDOAMIMAAHDBMMA\nLLFVEEM", "YMAOKDOAMIMAAMDBHMA\nMDEVFML", "YMAOKDOAMIMA...
p01299 Neko's Treasure
Maki is a house cat. One day she fortunately came at a wonderful-looking dried fish. Since she felt not hungry on that day, she put it up in her bed. However there was a problem; a rat was living in her house, and he was watching for a chance to steal her food. To secure the fish during the time she is asleep, she deci...
{ "input": [], "output": [] }
{ "input": [ "3\n0 0 100 100\n60 100 50\n100 100 10\n80 80 50\n4\n0 0 100 100\n50 50 50\n150 50 50\n50 150 50\n150 150 50\n0" ], "output": [ "2\n0" ] }
{ "input": [ "3\n0 0 100 101\n60 100 50\n100 100 10\n80 80 50\n4\n0 0 100 100\n50 50 50\n150 50 50\n50 150 50\n150 150 50\n0", "3\n0 0 100 101\n60 100 50\n100 110 10\n25 80 50\n4\n0 0 100 100\n50 50 50\n150 50 50\n50 150 50\n150 150 50\n0", "3\n0 0 100 101\n60 100 50\n100 110 10\n25 80 50\n4\n1 0 000 100\...
p01468 Closest Segment Pair
Problem statement $ N $ Line segments $ s_1, s_2, ..., s_N $ are given. At this time, find the minimum possible value of dist $ (s_i, s_j) $, ($ 1 \ leq i, j \ leq N, i \ ne j $). dist $ (s_i, s_j) $ is * $ \ sqrt {(x_i-x_j) ^ 2 + (y_i-y_j) ^ 2} $, ($ (x_i, y_i) $ is the point above $ s_i $, $ (x_j, y_j) $ is $ s_j $...
{ "input": [], "output": [] }
{ "input": [ "6\n5 5 5 45\n7 45 19 45\n7 30 19 30\n21 34 21 44\n26 45 36 28\n45 45 26 5", "4\n2 0 2 25\n0 30 15 20\n16 20 5 15\n23 0 23 30", "11\n10 10 10 90\n10 90 35 90\n10 60 35 60\n35 60 35 90\n40 10 40 90\n37 45 60 45\n60 10 60 45\n65 10 65 90\n65 90 90 90\n65 60 90 65\n90 60 90 90", "6\n0 0 0 5\...
{ "input": [ "6\n5 5 5 45\n7 45 19 45\n7 30 19 30\n21 34 21 44\n26 45 36 14\n45 45 26 5", "4\n2 0 2 25\n0 30 15 20\n16 20 3 15\n23 0 23 30", "6\n0 0 0 5\n1 3 3 5\n6 0 6 10\n7 4 8 4\n11 1 11 3\n7 0 10 0", "6\n5 5 5 45\n7 45 19 45\n12 30 19 30\n21 34 21 44\n38 45 36 14\n45 45 37 5", "6\n0 0 0 5\n1 3...
p01628 Amidakuji
Problem Statement Mr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and always tries to save as much paper as possible. She decided to play a ghost leg with other participants to decide the team for the Aizu training camp. How to make Amidakuji for this training camp is as foll...
{ "input": [], "output": [] }
{ "input": [ "5 4\n4\n3\n1\n2", "4 3\n1\n2\n3" ], "output": [ "3", "3" ] }
{ "input": [ "6 4\n4\n3\n1\n2", "4 3\n2\n2\n4", "13 1\n7\n4\n3", "6 4\n1\n2\n1\n2", "4 3\n2\n2\n3", "5 3\n2\n2\n3", "4 3\n2\n3\n4", "4 3\n3\n3\n4", "6 4\n4\n1\n1\n2", "5 3\n4\n2\n3", "9 3\n4\n2\n3", "9 3\n4\n2\n4", "4 3\n1\n2\n2", "10 4\n4\n3\n1\n2", "7 3\n2...
p01780 Breadth-First Search by Foxpower
Example Input 4 1 1 2 Output 6
{ "input": [], "output": [] }
{ "input": [ "4\n1 1 2" ], "output": [ "6" ] }
{ "input": [ "4\n1 1 1", "4\n1 2 2", "4\n1 2 1", "4\n1 2 3", "4\n2 2 2", "4\n1 1 3", "4\n2 3 2", "4\n2 3 4", "4\n2 5 2", "4\n4 5 2", "4\n4 10 2", "4\n5 10 2", "4\n5 18 2", "4\n5 18 3", "4\n3 18 3", "4\n3 4 3", "4\n4 3 4", "4\n2 9 2", "4\n4 5 ...
p01915 AOR's Score
problem AOR Ika-chan is taking a class where grades are determined only by the score of the $ N $ report. AOR Ika-chan has $ M $ friends who are taking the same class, and if you have a report on a theme that you are not good at, you can get the same score as that friend by copying the report of a friend who is good a...
{ "input": [], "output": [] }
{ "input": [ "3 2 2\n50 65 70\n80 100 80\n90 65 45\n1 1" ], "output": [ "225" ] }
{ "input": [ "3 2 2\n50 17 70\n80 100 80\n90 65 45\n1 1", "3 2 2\n86 65 70\n80 100 80\n90 65 45\n1 1", "3 2 2\n43 17 70\n80 100 80\n90 65 45\n1 1", "3 2 2\n50 17 70\n80 000 80\n90 81 38\n2 2", "3 2 2\n50 17 23\n80 100 80\n90 65 38\n1 1", "3 2 2\n50 17 64\n80 000 80\n90 81 38\n2 2", "3 0 2\...
p02053 Hokkaido University Hard
B: Hokkaido University Hard Note Please note that the question settings are the same as question A, except for the constraints. story Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, a huge campus awaits ... "Eh ... I'm not in time for the next clas...
{ "input": [], "output": [] }
{ "input": [ "3 3\nB.B\n..B\n.BB" ], "output": [ "4" ] }
{ "input": [ "3 3\nB.B\nB..\n.BB", "2 3\nB.B\nB..\n.BB", "1 3\nB-B\n..B\n.BA", "1 1\nB-B\n..B\n.BA", "1 3\nBB.\nB..\n.AA", "3 3\nB.B\nB..\nBB.", "3 3\nB.B\nC..\nBB.", "3 3\nB/B\nC..\nBB.", "3 3\nB0B\nC..\nBB.", "3 3\nB0B\nC..\n.BB", "3 3\nB.B\n..B\n.AB", "3 3\nB.B\nB./\...
p02195 Bichrome Tree Connectivity
Bichrome Tree Connectivity Given a tree. Initially, all vertices are white. Inverting the color of the white vertices makes it black, and inverting the color of the black vertices makes it white. Handle two types of queries. The first type of query inverts the color of vertex v. The second type of query answers t...
{ "input": [], "output": [] }
{ "input": [ "10 3\n1 2\n2 5\n2 6\n1 4\n1 3\n3 7\n3 8\n3 9\n9 10\n1 3\n2 1\n2 8" ], "output": [ "5\n1" ] }
{ "input": [ "10 3\n1 2\n2 5\n2 6\n1 4\n1 3\n3 7\n3 8\n3 9\n9 10\n1 2\n2 1\n2 8", "10 3\n1 2\n2 5\n2 6\n1 4\n2 3\n3 7\n3 8\n3 9\n9 10\n1 3\n2 1\n2 8", "10 3\n1 2\n2 5\n2 6\n1 4\n1 3\n3 7\n3 8\n1 9\n9 10\n1 3\n2 1\n2 8", "10 3\n1 2\n2 5\n1 6\n1 4\n2 3\n3 7\n3 8\n3 9\n9 10\n1 3\n1 2\n2 8", "10 3\n1 ...
p02349 Range Add Query (RAQ)
Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations: * add(s, t, x): add x to as, as+1, ..., at. * get(i): output the value of ai. Note that the initial values of ai (i = 1, 2, . . . , n) are 0. Constraints * 1 ≤ n ≤ 100000 * 1 ≤ q ≤ 100000 * 1 ≤ s ≤ t ≤ n * 1 ≤ i ≤...
{ "input": [], "output": [] }
{ "input": [ "3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 2\n1 3", "4 3\n1 2\n0 1 4 1\n1 2" ], "output": [ "3\n5", "0\n1" ] }
{ "input": [ "4 3\n1 2\n0 2 4 1\n1 2", "6 3\n1 2\n0 2 4 0\n1 2", "4 3\n1 2\n0 2 4 1\n0 2", "4 3\n1 2\n0 1 4 2\n1 2", "3 5\n0 1 0 1\n0 2 3 2\n0 3 3 3\n1 2\n1 3", "6 3\n1 2\n0 1 4 -1\n1 2", "4 3\n1 2\n0 1 4 1\n1 3", "6 3\n1 2\n0 2 4 1\n1 2", "4 3\n1 2\n0 1 3 1\n1 3", "6 3\n1 4\n0...
cds003
At the legendary times of Nonsenso wars in ISM Dhanbad, there was a neck to neck competition between Barney Stinson and Sheldon Cooper. They both were on level 19. After trying too hard both of them could not decipher the nonsense, so they decided to play alongside. Sheldon Cooper had to pass a message to Barney Stinso...
{ "input": [], "output": [] }
{ "input": [ "2\n721011081081113287111114108100\n871011089911110910132116111327311010010597" ], "output": [ "Hello World\nWelcome to India" ] }
{ "input": [ "2\n170550006177585909098797116867\n871011089911110910132116111327311010010597", "2\n102014811955809394701607306997\n871011089911110910132116111327311010010597", "2\n126847783659670986194038138661\n871011089911110910132116111327311010010597", "2\n138888015603210187941440407259\n8710110899...
cw6
Ayan's favourite musical instrument is the keyboard. He practices regularly as well, you can hear him playing even at 3 or 4 in the night. Unfortunately, he got into a fight in his room and his keyboard was damaged beyond repair. However, being a rich fellow he quickly ordered another one. But this time he felt a bit a...
{ "input": [], "output": [] }
{ "input": [ "2\nE G S\nS d f" ], "output": [ "Minor\nMajor" ] }
{ "input": [], "output": [] }
icq3
Sorting is considered to be one of the most important skills to be learned in computer science and has it's applications in real product building. The problem has arised to the team of PcCube.They need to sort the set of alphanumeric strings in such a way that the positions of alphabets and numbers remains unchanged.  ...
{ "input": [], "output": [] }
{ "input": [ "1\n951f5gd3" ], "output": [ "135d5fg9" ] }
{ "input": [], "output": [] }
mriu4
Given an input sequence. You have to write a program to sort it in non decreasing order. Input First line of input T has number of test cases followed by T test cases. Each test case has two lines. First line has a number N. The second line has N space separated elements as an input sequence Output Output has T lines...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n3 4\n5\n1 4 5 8 2\n1\n7" ], "output": [ "3 4\n1 2 4 5 8\n7\n" ] }
{ "input": [ "3\n2\n3 4\n5\n1 4 0 8 2\n1\n7", "3\n2\n3 4\n5\n1 4 0 8 2\n1\n3", "3\n2\n3 4\n5\n1 4 1 8 2\n1\n3", "3\n2\n3 4\n5\n1 4 2 8 2\n1\n3", "3\n2\n3 6\n5\n1 4 5 8 2\n1\n7", "3\n2\n0 4\n5\n1 4 0 8 2\n1\n7", "3\n2\n3 2\n5\n1 4 0 8 2\n1\n3", "3\n2\n3 4\n5\n2 4 2 8 2\n1\n3", "3\n2...
righttri
Chef taught his brother Chefu about right angled triangle and its properties. Chefu says that he has understood everything about right angled triangles. Chef wants to check learning of his brother by asking the following question "Can you find a right angled triangle whose length of hypotenuse is H and its area is S?"...
{ "input": [], "output": [] }
{ "input": [ "4\n5 6\n6 10\n258303 89837245228\n616153 77878145466" ], "output": [ "3.00000 4.00000 5.00000\n-1\n-1\n285168.81767 546189.76998 616153.00000\n" ] }
{ "input": [ "4\n5 6\n6 19\n258303 89837245228\n616153 77878145466", "4\n5 8\n6 16\n258303 89837245228\n616153 77878145466", "4\n0 8\n2 15\n258303 89837245228\n616153 39166179564", "4\n1 8\n2 1\n258303 89837245228\n616153 39166179564", "4\n2 5\n1 1\n522383 60588446777\n616153 39166179564", "4\...
univmt
The University management meets every semester to discuss about the issues of the University in a round table conference. Therefore new proposals are made to the present academic curriculum. However whenever a new proposal comes from a member, all the members of the round table, except the adjacent members , throws his...
{ "input": [], "output": [] }
{ "input": [ "1\n291" ], "output": [ "41904" ] }
{ "input": [ "1\n286", "1\n500", "1\n978", "1\n449", "1\n116", "1\n156", "1\n172", "1\n338", "1\n539", "1\n157", "1\n128", "1\n170", "1\n206", "1\n284", "1\n351", "1\n236", "1\n462", "1\n79", "1\n55", "1\n78", "1\n47", "1\n85", ...
1211_E. Double Permutation Inc.
Polycarp recently became an employee of the company "Double Permutation Inc." Now he is a fan of permutations and is looking for them everywhere! A permutation in this problem is a sequence of integers p_1, p_2, ..., p_k such that every integer from 1 to k occurs exactly once in it. For example, the following sequence...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 2 1\n", "3\n1 1 1\n", "10\n3 3 2 2 5 4 1 5 4 1\n", "10\n3 9 3 1 2 1 2 4 4 4\n" ], "output": [ "\nRBBBG\n", "\nBBB\n", "\nRGRGRRRGGG\n", "\nRBGRRGGBBB\n" ] }
{ "input": [], "output": [] }
1234_C. Pipes
You are given a system of pipes. It consists of two rows, each row consists of n pipes. The top left pipe has the coordinates (1, 1) and the bottom right — (2, n). There are six types of pipes: two types of straight pipes and four types of curved pipes. Here are the examples of all six types: <image> Types of pipes ...
{ "input": [], "output": [] }
{ "input": [ "6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n54\n" ], "output": [ "YES\nYES\nYES\nNO\nYES\nNO\n" ] }
{ "input": [ "6\n7\n2323216\n1615124\n1\n3\n4\n2\n14\n24\n2\n12\n34\n3\n536\n345\n2\n46\n54\n", "6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n525\n2\n46\n54\n", "6\n7\n2323216\n1245193\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n525\n2\n46\n54\n", "6\n7\n2323216\n1245193\n1\n1\n4\n2\n13\...