name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p01456 Person responsible for problem description don't w
There is a directed graph consisting of N points. There is no cycle in this graph. Several stones are placed at each point. Two players play a game using this graph. Each turn comes alternately. In their turn, each player chooses vertex v and removes one or more stones placed on it. You can then freely change the numbe...
{ "input": [], "output": [] }
{ "input": [ "8 7\n6\n1\n7\n2\n5\n2\n6\n3\n1 3\n6 3\n7 4\n4 2\n1 6\n5 4\n7 5", "5 7\n295\n127\n350\n982\n426\n1 5\n3 5\n4 2\n3 1\n3 4\n5 4\n3 2", "6 5\n7\n14\n5\n11\n2\n5\n1 2\n2 3\n3 4\n4 5\n5 6" ], "output": [ "2", "1", "2" ] }
{ "input": [ "5 7\n295\n127\n350\n982\n426\n1 5\n3 5\n4 2\n3 1\n3 2\n5 4\n3 2", "12 6\n7\n14\n5\n11\n2\n5\n2 2\n4 3\n3 4\n4 5\n5 6", "5 7\n295\n127\n350\n982\n426\n1 5\n3 5\n4 2\n3 1\n3 4\n5 4\n1 2", "5 7\n295\n191\n350\n982\n426\n1 5\n3 5\n4 2\n3 1\n3 4\n5 4\n1 2", "5 7\n295\n191\n350\n1456\n426\...
p01607 Magical Circle
Magic Circle Problem Statement ~ How to draw a magic circle ~ 1. Prepare a sufficiently large and white floor. 2. Draw a circle with radii 1, 2, ..., R centered on the point at the floor coordinates (0,0). 3. Paint blue between the circle with radius 1 and the circle with radius 2, between the circle with radius 3 a...
{ "input": [], "output": [] }
{ "input": [ "4 3\n1 1\n-1 1\n-1 -1\n1 -1", "3 1\n0 0\n1 0\n0 1", "3 2\n0 0\n2 0\n0 2", "3 2\n1 -1\n1 1\n-2 0" ], "output": [ "11.707963268", "0.500000000", "8.995574288", "11.123246567" ] }
{ "input": [ "4 3\n1 1\n0 1\n-1 -1\n1 -1", "3 2\n0 0\n1 0\n0 1", "3 2\n0 -1\n2 0\n0 2", "3 2\n0 -1\n1 1\n-2 0", "4 3\n1 1\n0 2\n-1 -1\n1 -1", "3 2\n0 0\n1 0\n-1 1", "3 2\n1 -1\n1 1\n-1 0", "4 3\n1 1\n0 1\n-1 0\n1 -1", "3 2\n1 -1\n2 0\n0 2", "4 3\n1 1\n0 2\n0 -1\n1 -1", "3 3...
p01768 Shopping
Problem statement 2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},…, a_ {N−1}. Now, 2D's refrigerator doesn't contain any ingredients, so I have to go to the supermarket to buy it. At the supermarket, you can buy the material a_ {i} for the price x_ {i} yen. 2D ...
{ "input": [], "output": [] }
{ "input": [ "2\ntako 2\nyaki 1\n1\ntako yaki" ], "output": [ "2" ] }
{ "input": [ "2\ntako 2\nyaki 1\n0\ntako yaki", "2\ntako 3\nyaji 1\n-1\noakt yaki", "2\ntako 1\nyaij 1\n-2\noajt yaki", "2\ntako 1\njiay 0\n-2\nouja yakg", "2\npaks 1\naxii -1\n-3\nokua hx`j", "2\npaks 0\naxii -1\n-1\nnkua hx`j", "2\ntako 4\nyaji 1\n0\ntbko yaki", "2\ntbko 6\nyaji 1\n-...
p01902 Unbalanced Old Maid
E: Without the Devil Old Maid --Unbalanced Old Maid - story Mr. Kosaka, Mr. Sonoda, and Mr. Minami have been good friends since childhood. The three went on a school trip to Okinawa, but a typhoon came and they couldn't play in the sea, so they decided to maid out. Mr. Sonoda is strong in the game, but he is not goo...
{ "input": [], "output": [] }
{ "input": [ "1\n1 1\n3 0 1 1\n1 1" ], "output": [ "0.0" ] }
{ "input": [ "1\n1 1\n3 0 1 1\n0 1", "1\n2 0\n1 0 1 1\n1 1", "1\n1 0\n1 1 1 1\n0 1", "1\n1 1\n3 0 1 1\n0 0", "1\n1 1\n1 0 1 1\n1 1", "1\n1 1\n1 0 0 1\n1 1", "1\n1 1\n3 0 1 1\n0 2", "1\n1 1\n3 0 1 1\n0 -1", "1\n1 0\n1 0 1 1\n1 1", "1\n1 2\n3 0 1 1\n0 2", "1\n1 1\n3 0 1 1\n0 ...
p02039 Othello
problem Prepare the Othello board. The upper left is $ (1,1) $ and the lower right is $ (8,8) $. The board to be prepared here is $ (5,4) as follows. ) There is no $ black stone. ........ ........ ........ ... ox ... .... o ... ........ ........ ........ Kuroishi: x Shiraishi: o 8x8 board From this state, Black st...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1 8 8\n2 4 3 8\n8 8 8 8" ], "output": [ "48\n7\n1" ] }
{ "input": [ "3\n1 1 8 8\n2 4 3 8\n8 3 8 8", "3\n1 1 8 8\n2 3 3 8\n8 3 8 8", "3\n1 1 8 7\n2 3 3 8\n8 3 8 8", "3\n1 1 8 7\n2 3 3 4\n8 3 8 8", "3\n1 1 8 7\n2 3 3 4\n8 3 8 2", "3\n1 1 1 8\n2 3 3 8\n8 3 8 8", "3\n1 1 8 7\n2 3 3 8\n8 3 8 3", "3\n1 1 8 7\n2 3 3 6\n8 3 8 8", "3\n1 1 8 7\n...
p02183 Perfect
B: Tetris problem Consider a board consisting of a rectangle with 4 squares x 10 squares. A square of 1 square x 1 square is called a block. Tetromino is a combination of four blocks, and there are the following seven types (and those that have been rotated 90 degrees arbitrarily). <image> Now, consider the situat...
{ "input": [], "output": [] }
{ "input": [ "2 3\n##.\n.##\n2 3\n#..\n###\n1 4\n####\n2 3\n###\n.#.\n2\n####....##\n####...###\n####..####\n####...###\n###..#####\n###...####\n###...####\n###....###" ], "output": [ "Yes\nYes" ] }
{ "input": [ "2 3\n##.\n.##\n2 3\n#..\n###\n1 4\n####\n2 3\n###\n.#.\n2\n####....##\n####...###\n####..####\n###...####\n###..#####\n###...####\n###...####\n###....###", "2 3\n##.\n.##\n2 3\n..#\n###\n1 4\n####\n2 3\n###\n.#.\n2\n####....##\n####...#\"#\n####..####\n###...####\n###..#####\n###...####\n###...#...
p02325 Bitonic Traveling Salesman Problem
For given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria: * Visit the points according to the following steps: 1. It starts from the leftmost point (starting point), goes strictly from left to right, and then visits the rightmost point (turn-around point)...
{ "input": [], "output": [] }
{ "input": [ "3\n0 0\n1 1\n2 0", "5\n0 0\n1 2\n2 1\n3 2\n4 0", "4\n0 1\n1 2\n2 0\n3 1" ], "output": [ "4.82842712", "10.94427191", "7.30056308" ] }
{ "input": [ "3\n0 -1\n1 1\n2 0", "5\n-1 0\n1 2\n2 1\n3 2\n4 0", "4\n0 1\n1 2\n3 0\n3 1", "3\n0 -1\n1 2\n2 0", "4\n0 1\n1 4\n3 0\n3 1", "3\n0 -1\n1 0\n2 0", "4\n0 0\n1 4\n3 0\n3 1", "3\n0 -1\n1 0\n0 0", "4\n0 0\n1 6\n3 0\n3 1", "3\n0 0\n1 0\n0 0", "4\n0 0\n1 6\n4 0\n3 1", ...
p02470 Euler's Phi Function
For given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n. Input n An integer n (1 ≤ n ≤ 1000000000). Output The number of totatives in a line. Examples Input 6 Output 2 Input 1000000 Output 400000
{ "input": [], "output": [] }
{ "input": [ "1000000", "6" ], "output": [ "400000", "2" ] }
{ "input": [ "1000100", "5", "1000101", "1000001", "1000011", "16", "1010011", "31", "61", "59", "106", "41", "57", "21", "2", "1100000", "3", "1000111", "1001101", "1010001", "14", "1001001", "1100011", "103", "207", ...
cd1it5
Somewhere out there, there are N islands numbered from 1 to N with no network connectivity. Communication is such a pain for the islands' dwellers. So the Kings of the islands go to nearby islands and decide to connect the islands with underwater cables for bidirectional communication. Initially no islands are connecte...
{ "input": [], "output": [] }
{ "input": [ "5 7\n0 1 2\n1 2 1\n0 3 4\n1 1 4\n0 3 2\n1 2 3\n1 1 4" ], "output": [ "Yes\nNo\nYes\nYes" ] }
{ "input": [], "output": [] }
cvote
Chefs from all over the globe gather each year for an international convention. Each chef represents some country. Please, note that more than one chef can represent a country. Each of them presents their best dish to the audience. The audience then sends emails to a secret and secure mail server, with the subject bein...
{ "input": [], "output": [] }
{ "input": [ "2 2\nNewton England\nEuclid Greece\nNewton\nEuclid" ], "output": [ "England\nEuclid\n" ] }
{ "input": [ "2 2\nNewton Englaod\nEuclid Greece\nNewton\nEuclid", "2 1\nNewton Englaod\nEuclid Greece\nNewton\nEuclid", "2 1\nNewton England\nEuclid Greece\nNewton\nEuclid", "2 1\nNewton dnalgnE\nEuclid Greece\nNewton\nEuclid", "2 2\nNewton England\nEuclid Geeecr\nNewton\nEuclid", "2 1\nNewto...
icecream
Pankaj likes to eat Ice cream when he is working late into the night. Today has been yet another long day for Pankaj. So, he wants to eat ice cream now. He opens the fridge and sees that he has 2 types of containers holding the ice cream. The first container is a cone with radius r1 and height h1. There is also a hemis...
{ "input": [], "output": [] }
{ "input": [ "2\n1.00 1.00 1.00 1.00\n3.02 7.23 5.20 6.00" ], "output": [ "3.141592654 3.141592654\n126.739919445 509.691992118" ] }
{ "input": [], "output": [] }
mprob
You are given three integers A,B and C. We choose two real numbers x and y such that 0 ≤ x ≤ A and 0 ≤ y ≤ B. What is the probability that x+y≤C ? Input The first line of input contains T denoting the number of test cases. Each of the following T lines contains three space separated Integers A,B and C Output For e...
{ "input": [], "output": [] }
{ "input": [ "2\n4 10 3\n4 10 11" ], "output": [ "0.1125\n0.8875" ] }
{ "input": [], "output": [] }
retpo
Recently Chef bought a bunch of robot-waiters. And now he needs to know how much to pay for the electricity that robots use for their work. All waiters serve food from the kitchen (which is in the point (0, 0)) and carry it to some table (which is in some point (x, y)) in a shortest way. But this is a beta version of r...
{ "input": [], "output": [] }
{ "input": [ "2\n3 3\n3 4" ], "output": [ "6\n7\n" ] }
{ "input": [ "2\n3 3\n3 0", "2\n5 3\n3 0", "2\n5 3\n6 0", "2\n5 3\n6 1", "2\n5 2\n6 1", "2\n3 2\n6 1", "2\n1 2\n6 1", "2\n1 3\n6 1", "2\n0 3\n6 1", "2\n0 3\n8 1", "2\n-1 3\n8 1", "2\n-1 0\n8 1", "2\n-1 0\n2 1", "2\n0 0\n2 1", "2\n0 0\n4 1", "2\n-1 0\n4 1...
twstr
Chef Jessie has a lot of recipes with her (N). She often remembered the starting few characters of the recipe and forgot the rest. As all the great chefs do, Jessie also numbered the recipes depending on the priority. So, given the list of recipes along with their priorities answer Jessie’s queries. Jessie’s queries ar...
{ "input": [], "output": [] }
{ "input": [ "4\nflour-with-eggs 100\nchicken-ham -10\nflour-without-eggs 200\nfish-with-pepper 1100\n6\nf\nflour-with\nflour-with-\nc\nfl\nchik" ], "output": [ "fish-with-pepper\nflour-without-eggs\nflour-with-eggs\nchicken-ham\nflour-without-eggs\nNO\n" ] }
{ "input": [ "4\nflour-with-eggs 100\nchicken-ham -10\nflour-without-eggs 200\nfish-with-pepper 1100\n6\nf\nflour-with\nflour-with-\nc\nfl\nciik", "4\nflour-with-eggs 100\nchicken-ham -10\nflour-without-eggs 200\nfish-with-pepper 1100\n6\nf\nflour-with\nflour-with-\nb\nfl\nciik", "4\nflour-with-eggs 100\n...
1194_E. Count The Rectangles
There are n segments drawn on a plane; the i-th segment connects two points (x_{i, 1}, y_{i, 1}) and (x_{i, 2}, y_{i, 2}). Each segment is non-degenerate, and is either horizontal or vertical — formally, for every i ∈ [1, n] either x_{i, 1} = x_{i, 2} or y_{i, 1} = y_{i, 2} (but only one of these conditions holds). Onl...
{ "input": [], "output": [] }
{ "input": [ "5\n1 5 1 0\n0 1 5 1\n5 4 0 4\n4 2 4 0\n4 3 4 5\n", "7\n-1 4 -1 -2\n6 -1 -2 -1\n-2 3 6 3\n2 -2 2 4\n4 -1 4 3\n5 3 5 1\n5 2 1 2\n" ], "output": [ " 0\n", " 7\n" ...
{ "input": [ "5\n1 5 1 0\n0 1 5 1\n5 4 0 4\n4 2 4 0\n4 3 4 3\n", "7\n-1 4 -1 -2\n6 -1 -2 -1\n-2 3 6 3\n2 -2 2 4\n4 0 4 3\n5 3 5 1\n5 2 1 2\n", "7\n-1 4 -1 -2\n6 -1 -2 -1\n-2 3 2 3\n2 -2 2 4\n4 -1 4 3\n5 3 5 1\n5 2 1 2\n", "7\n-1 4 -1 -2\n6 -1 -2 -1\n-2 3 3 3\n2 -2 2 4\n4 0 4 3\n5 3 5 1\n5 2 1 2\n", ...
1211_B. Traveling Around the Golden Ring of Berland
The Golden Ring is the special tourist route in Berland. This route consists of n cities and the cyclic railway route. Cities are numbered from 1 to n so that: * the next city for 1 is the city 2, * the next city for 2 is the city 3, * ... * the next city for n is the city 1. Thus, the route is a cycle,...
{ "input": [], "output": [] }
{ "input": [ "3\n1 0 0\n", "3\n2 0 2\n", "5\n0 3 1 3 2\n", "5\n1000000000 1000000000 1000000000 1000000000 0\n" ], "output": [ "\n1\n", "\n6\n", "\n14\n", "\n4999999999\n" ] }
{ "input": [], "output": [] }
1252_K. Addition Robot
Adding two numbers several times is a time-consuming task, so you want to build a robot. The robot should have a string S = S_1 S_2 ... S_N of N characters on its memory that represents addition instructions. Each character of the string, S_i, is either 'A' or 'B'. You want to be able to give Q commands to the robot, ...
{ "input": [], "output": [] }
{ "input": [ "5 3\nABAAA\n2 1 5 1 1\n1 3 5\n2 2 5 0 1000000000\n" ], "output": [ "\n11 3\n0 1000000000\n" ] }
{ "input": [], "output": [] }
690_E2. Photographs (II)
Zombies seem to have become much more intelligent lately – a few have somehow wandered into the base through the automatic gate. Heidi has had to beef up security, and a new gate has been installed. Unfortunately, now the questions being asked are more complicated, and even humans have trouble answering them. Can you s...
{ "input": [], "output": [] }
{ "input": [], "output": [] }
{ "input": [], "output": [] }
email-validator
Chinna and Chinnu has recently started developing a website for their startup from scratch. But they found it difficult to validate an Email field for their login forum. Help them build one. An Email Address is of the form <username>@<hostname> <username> consists of 1 - 16 characters inclusive and contains only sma...
{ "input": [], "output": [] }
{ "input": [ "3\ncoder@mastroes.com\n999@111.blah\n1_1@h-1-g.go\n\nSAMPLE" ], "output": [ "YES\nNO\nYES" ] }
{ "input": [ "3\ncoder@mastroes.com\n999@111.blah\n1_1@hg1-g.-o\n\nSAMPLE", "3\ncoder@mastroes.com\n999@111.blah\n1_1@h-1-h.go\n\nSAMPLE", "3\ncoder@mastroer.com\n999@111b.lah\n1_1?hg0-g.-o\n\nGLQMBS", "3\ncedeq@mastroosmco.\n989@111.blah\n0_-h?g0-h.1p\n\nFLPK@S", "3\ncoder@mastroes.com\n999@111.b...
the-battle-of-panipat-4
This is 1526 A.D. Third Battle of Panipat between Babur and Ibrahim Lodi, the current ruler of India is going on. Realising that Lodi has much larger army, Babur planned to attack the cities of India to bring the moral of the soldiers of Lodi down. Now, Lodi had been ordered by his ancestors that, if he is to rule I...
{ "input": [], "output": [] }
{ "input": [ "3\n0 1\n1 2\n\nSAMPLE" ], "output": [ "7" ] }
{ "input": [], "output": [] }
p02645 Tokio Marine & Nichido Fire Insurance Programming Contest 2020 - Nickname
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. Constra...
{ "input": [], "output": [] }
{ "input": [ "naohiro", "takahashi" ], "output": [ "nao", "tak" ] }
{ "input": [ "maohiro", "sakahashi", "orihoam", "sbkahashi", "ihsahakbs", "hhsaiakbr", "anphiro", "rbkaiashh", "onphira", "rkbaiashh", "arihpno", "skbajashh", "nmpgira", "sgi`pmn", "ska^iashi", "nlp`igs", "nplgi`s", "shsai_kai", "nqlgi`s", ...
p02774 AtCoder Beginner Contest 155 - Pairs
We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list? Constraints * All values in input are integers. * 2 \leq N \leq 2 \times 1...
{ "input": [], "output": [] }
{ "input": [ "10 40\n5 4 3 2 -1 0 0 0 0 0", "4 3\n3 3 -4 -2", "30 413\n-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0...
{ "input": [ "10 40\n5 4 3 2 -1 0 -1 0 0 0", "4 3\n6 3 -4 -2", "30 413\n-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -1273635706 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626...
p02909 AtCoder Beginner Contest 141 - Weather Prediction
The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ... Given is a string S representing the weather in the town today. Predict the weather tomorrow. Constraints * S is `Sunny`, `Cloudy`, or `Rainy`. Input Input is given from Standard Input in the...
{ "input": [], "output": [] }
{ "input": [ "Rainy", "Sunny" ], "output": [ "Sunny", "Cloudy" ] }
{ "input": [], "output": [] }
p03044 AtCoder Beginner Contest 126 - Even Relation
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices p...
{ "input": [], "output": [] }
{ "input": [ "5\n2 5 2\n2 3 10\n1 3 8\n3 4 2", "3\n1 2 2\n2 3 1" ], "output": [ "1\n0\n1\n0\n1", "0\n0\n1" ] }
{ "input": [ "5\n2 5 2\n2 3 18\n1 3 8\n3 4 2", "3\n1 2 2\n2 3 0", "3\n1 2 4\n2 3 1", "3\n1 2 3\n2 3 0", "3\n1 2 3\n2 3 1", "5\n2 5 3\n2 3 18\n1 3 8\n3 4 2", "5\n2 5 3\n2 3 18\n1 3 8\n3 4 3", "5\n1 5 3\n2 3 23\n1 3 8\n3 4 2", "5\n3 5 3\n2 3 15\n1 3 8\n5 4 2", "5\n2 5 3\n2 1 18\n...
p03186 AtCoder Grand Contest 030 - Poisonous Cookies
Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in su...
{ "input": [], "output": [] }
{ "input": [ "3 1 4", "8 8 1", "5 2 9" ], "output": [ "5", "9", "10" ] }
{ "input": [ "0 1 4", "14 8 1", "9 2 9", "0 0 4", "14 8 2", "3 2 9", "11 15 2", "11 15 4", "3 0 12", "0 2 0", "11 15 0", "0 0 0", "16 5 0", "-2 0 0", "3 1 27", "-1 1 -4", "6 -2 0", "-1 -2 0", "-2 -2 -1", "-4 -2 -1", "0 -2 -4", "0 ...
p03333 AtCoder Grand Contest 025 - Interval Game
Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coordinates between L_i and R_i (inclusive). The game has N steps. The...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n3 4\n5 6", "3\n-5 1\n3 7\n-4 -2", "5\n-2 0\n-2 0\n7 8\n9 10\n-2 -1" ], "output": [ "12", "10", "34" ] }
{ "input": [ "3\n2 2\n3 4\n5 6", "3\n-10 1\n3 7\n-4 -2", "5\n-4 0\n-2 0\n7 8\n9 10\n-2 -1", "3\n2 2\n3 4\n10 6", "3\n-10 1\n5 7\n-4 -2", "3\n3 2\n3 4\n20 6", "3\n3 4\n3 4\n20 6", "3\n-10 1\n2 7\n0 -2", "3\n3 4\n3 4\n28 6", "5\n-3 0\n0 -1\n7 8\n9 11\n-1 -1", "5\n-3 0\n-1 -1\...
p03492 AtCoder Regular Contest 087 - Squirrel Migration
There is a tree with N vertices. The vertices are numbered 1 through N. The i-th edge (1 \leq i \leq N - 1) connects Vertex x_i and y_i. For vertices v and w (1 \leq v, w \leq N), we will define the distance between v and w d(v, w) as "the number of edges contained in the path v-w". A squirrel lives in each vertex of ...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n2 3", "6\n1 2\n1 3\n1 4\n2 5\n2 6", "7\n1 2\n6 3\n4 5\n1 7\n1 5\n2 3", "4\n1 2\n1 3\n1 4" ], "output": [ "3", "36", "396", "11" ] }
{ "input": [ "3\n1 2\n1 3", "6\n1 2\n1 3\n1 4\n2 5\n2 10", "6\n1 2\n1 3\n1 4\n1 5\n2 6", "7\n1 2\n6 3\n4 5\n1 7\n1 5\n2 6", "7\n1 3\n6 3\n4 5\n1 7\n1 5\n2 7", "7\n1 2\n6 1\n4 5\n1 7\n1 5\n2 3", "7\n1 3\n6 3\n4 5\n2 7\n1 5\n2 6", "7\n1 2\n6 1\n4 1\n1 7\n2 5\n2 3", "6\n1 2\n1 3\n1 4\...
p03654 AtCoder Grand Contest 018 - Tree and Hamilton Path
There is a tree with N vertices, numbered 1 through N. The i-th edge in this tree connects Vertices A_i and B_i and has a length of C_i. Joisino created a complete graph with N vertices. The length of the edge connecting Vertices u and v in this graph, is equal to the shortest distance between Vertices u and v in the ...
{ "input": [], "output": [] }
{ "input": [ "8\n2 8 8\n1 5 1\n4 8 2\n2 5 4\n3 8 6\n6 8 9\n2 7 12", "5\n1 2 5\n3 4 7\n2 3 3\n2 5 2" ], "output": [ "132", "38" ] }
{ "input": [ "8\n2 8 8\n1 5 1\n4 8 2\n2 5 4\n3 8 5\n6 8 9\n2 7 12", "5\n1 2 5\n3 4 10\n2 3 3\n2 5 2", "5\n1 3 5\n3 4 10\n2 3 3\n2 5 2", "5\n1 3 5\n2 4 20\n2 3 3\n2 5 2", "8\n2 8 8\n1 5 1\n4 8 2\n2 5 7\n3 8 6\n6 8 9\n2 7 12", "8\n2 8 8\n1 5 1\n4 8 0\n2 5 4\n3 8 5\n6 8 9\n2 7 12", "5\n1 3 4\...
p03810 AtCoder Grand Contest 010 - Decrementing
There are N integers written on a blackboard. The i-th integer is A_i, and the greatest common divisor of these integers is 1. Takahashi and Aoki will play a game using these integers. In this game, starting from Takahashi the two player alternately perform the following operation: * Select one integer on the blackbo...
{ "input": [], "output": [] }
{ "input": [ "3\n3 6 7", "4\n1 2 4 8", "5\n7 8 8 8 8" ], "output": [ "First", "First", "Second" ] }
{ "input": [ "3\n3 9 7", "4\n1 2 1 9", "4\n1 2 1 8", "5\n7 2 8 8 8", "3\n3 9 9", "3\n3 1 9", "4\n1 2 1 13", "3\n1 1 9", "4\n1 2 1 22", "3\n0 1 9", "4\n1 1 1 22", "3\n0 1 5", "4\n0 1 1 22", "4\n0 0 1 22", "4\n0 -1 1 22", "4\n0 0 1 1", "4\n0 0 1 2", ...
p03978 Kyoto University Programming Contest 2016 - Long Blackboard
There is a long blackboard with 2 rows and N columns in a classroom of Kyoto University. This blackboard is so long that it is impossible to tell which cells are already used and which unused. Recently, a blackboard retrieval device was installed at the classroom. To use this device, you type a search query that forms...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p00067 The Number of Island
There is a plan view consisting of 12 vertical and 12 horizontal squares showing the terrain. Each square is painted white or black. White represents the sea and black represents the land. When two black squares touch each other vertically or horizontally, they are said to be continuous. In this plan view, the area cre...
{ "input": [], "output": [] }
{ "input": [ "111100001111\n111000001111\n110000001111\n100000001111\n000100010000\n000000111000\n000001111100\n100011111110\n110001111100\n111000111000\n111100010000\n000000000000\n\n010001111100\n110010000010\n010010000001\n010000000001\n010000000110\n010000111000\n010000000100\n010000000010\n010000000001\n0100...
{ "input": [ "111100001111\n111000001111\n110000001111\n100000001111\n000100010000\n000000111000\n000001111100\n100011111110\n110001111100\n111000111000\n111100010000\n000000000000\n\n010001111100\n110010000010\n010010000001\n010000000001\n010000000110\n010000111000\n010000000100\n010000000010\n010000000001\n0100...
p00199 Chairs Where Demanding People Sit
The neutral city of Eyes City, in the heart of the four countries, is home to the transcontinental train Bandai. The platform has a row of chairs for passengers waiting for the Bandai, and people who enter the platform can use the chairs freely. The Bandai is cheap, fast and comfortable, so there are a constant number...
{ "input": [], "output": [] }
{ "input": [ "5 4\nA\nB\nC\nD\n5 4\nD\nC\nB\nA\n0 0" ], "output": [ "ACD#B\nDCA#B" ] }
{ "input": [ "5 4\nA\nC\nC\nD\n5 4\nD\nC\nB\nA\n0 0", "5 4\nA\nC\nC\nD\n5 4\nD\nD\nB\nA\n0 0", "5 4\nA\nC\nC\nD\n4 4\nD\nC\nB\nA\n0 0", "5 4\nA\nD\nC\nD\n5 4\nD\nD\nB\nA\n0 0", "5 4\nA\nC\nC\nD\n4 4\nD\nC\nC\nA\n0 0", "5 4\nA\nC\nB\nD\n4 4\nD\nC\nC\nA\n0 0", "5 4\nA\nC\nC\nD\n4 4\nD\nB\nB\...
p00353 Shopping
You are now in a bookshop with your friend Alice to buy a book, "The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money from Alice in case the amount you have falls short of the price. If the amount you receive from Alice s...
{ "input": [], "output": [] }
{ "input": [ "5000 3000 4500", "1000 3000 3000", "500 1000 2000" ], "output": [ "0", "2000", "NA" ] }
{ "input": [ "5000 3000 4771", "1000 3000 1844", "20 1000 2000", "1000 3000 1508", "1000 3000 2582", "1001 6683 2582", "0001 7742 2582", "0101 7742 2582", "0011 7619 2582", "1011 7619 2582", "0011 7619 2049", "0111 7619 2049", "0111 12618 3831", "0101 15626 3831...
p00560 Semiexpress
The JOI Railways is the only railway company in the Kingdom of JOI. There are $N$ stations numbered from $1$ to $N$ along a railway. Currently, two kinds of trains are operated; one is express and the other one is local. A local train stops at every station. For each $i$ ($1 \leq i < N$), by a local train, it takes $A...
{ "input": [], "output": [] }
{ "input": [ "10 3 5\n10 3 5\n30\n1\n6\n10" ], "output": [ "8" ] }
{ "input": [ "10 3 5\n10 3 3\n30\n1\n6\n10", "10 3 1\n10 3 3\n30\n1\n6\n10", "10 3 5\n10 3 3\n32\n1\n6\n10", "10 3 1\n10 3 3\n30\n1\n8\n10", "10 3 1\n10 3 0\n51\n0\n6\n10", "10 3 5\n10 3 6\n32\n2\n6\n10", "10 3 10\n10 3 6\n8\n2\n6\n10", "10 3 10\n10 3 3\n8\n2\n6\n10", "10 3 5\n10 3...
p00713 Circle and Points
You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enclose as many of the points as possible. Find how many points can be simultaneously enclosed at the maximum. A point is considered enclosed by a circle when it is inside or on the circle. <image> Fig 1. Cir...
{ "input": [], "output": [] }
{ "input": [ "3\n6.47634 7.69628\n5.16828 4.79915\n6.69533 6.20378\n6\n7.15296 4.08328\n6.50827 2.69466\n5.91219 3.86661\n5.29853 4.16097\n6.10838 3.46039\n6.34060 2.41599\n8\n7.90650 4.01746\n4.10998 4.18354\n4.67289 4.01887\n6.33885 4.28388\n4.98106 3.82728\n5.12379 5.16473\n7.84664 4.67693\n4.02776 3.87990\n20...
{ "input": [ "3\n6.47634 7.69628\n5.16828 4.79915\n6.69533 6.20378\n6\n7.15296 4.08328\n6.50827 2.69466\n5.91219 3.86661\n5.29853 4.16097\n6.10838 3.46039\n6.34060 2.41599\n8\n7.90650 4.01746\n4.10998 4.18354\n4.67289 4.01887\n6.33885 4.28388\n4.98106 3.82728\n5.12379 5.16473\n7.84664 4.67693\n4.02776 3.87990\n20...
p00853 Enjoyable Commutation
Isaac is tired of his daily trip to his ofice, using the same shortest route everyday. Although this saves his time, he must see the same scenery again and again. He cannot stand such a boring commutation any more. One day, he decided to improve the situation. He would change his route everyday at least slightly. His ...
{ "input": [], "output": [] }
{ "input": [ "5 20 10 1 5\n1 2 1\n1 3 2\n1 4 1\n1 5 3\n2 1 1\n2 3 1\n2 4 2\n2 5 2\n3 1 1\n3 2 2\n3 4 1\n3 5 1\n4 1 1\n4 2 1\n4 3 1\n4 5 2\n5 1 1\n5 2 1\n5 3 1\n5 4 1\n4 6 1 1 4\n2 4 2\n1 3 2\n1 2 1\n1 4 3\n2 3 1\n3 4 1\n3 3 5 1 3\n1 2 1\n2 3 1\n1 3 1\n0 0 0 0 0" ], "output": [ "1-2-4-3-5\n1-2-3-4\nNone" ...
{ "input": [], "output": [] }
p00984 Halting Problem
Halting Problem A unique law is enforced in the Republic of Finite Loop. Under the law, programs that never halt are regarded as viruses. Releasing such a program is a cybercrime. So, you want to make sure that your software products always halt under their normal use. It is widely known that there exists no algorith...
{ "input": [], "output": [] }
{ "input": [ "2 0\n5 1 2 1 1\n10 1 3 2 2" ], "output": [ "9" ] }
{ "input": [ "2 0\n5 1 2 1 1\n10 1 3 2 0", "1 0\n0 0 2 1 2\n10 1 3 2 0", "2 0\n5 1 2 1 2\n10 1 3 2 1", "0 3\n0 -2 1 1 2\n5 0 5 6 0", "2 -1\n0 0 3 1 1\n13 1 3 2 0", "2 0\n0 1 2 1 1\n10 1 3 2 0", "2 0\n0 0 2 1 1\n10 1 3 2 0", "2 0\n0 0 2 1 1\n14 1 3 2 0", "2 0\n0 0 2 1 2\n14 1 3 2 0"...
p01116 For Programming Excellence
For Programming Excellence A countless number of skills are required to be an excellent programmer. Different skills have different importance degrees, and the total programming competence is measured by the sum of products of levels and importance degrees of his/her skills. In this summer season, you are planning to...
{ "input": [], "output": [] }
{ "input": [ "3 10\n5 4 3\n1 2 3\n1 2\n5 2\n5 40\n10 10 10 10 8\n1 2 3 4 5\n1 1 2 3\n10 10 10 10\n5 10\n2 2 2 5 2\n2 2 2 5 2\n1 1 2 2\n2 1 2 1\n0 0" ], "output": [ "18\n108\n35" ] }
{ "input": [ "3 10\n5 4 3\n1 2 3\n1 2\n5 2\n5 40\n10 10 10 10 8\n1 2 3 4 5\n1 1 2 3\n10 10 10 10\n5 10\n2 2 2 5 2\n2 2 2 5 2\n1 1 2 2\n0 1 2 1\n0 0", "3 0\n5 4 3\n1 2 3\n1 2\n5 2\n5 40\n10 10 10 10 8\n1 2 3 4 5\n1 1 2 3\n10 10 10 10\n5 10\n2 2 2 5 2\n2 2 2 5 2\n1 1 2 2\n0 1 2 1\n0 0", "3 20\n5 4 3\n1 2 3\...
p01254 Reverse a Road
Andrew R. Klein resides in the city of Yanwoe, and goes to his working place in this city every weekday. He has been totally annoyed with the road traffic of this city. All the roads in this city are one-way, so he has to drive a longer way than he thinks he need. One day, the following thought has come up to Andrew’s...
{ "input": [], "output": [] }
{ "input": [ "4\n1 4\n4\n1 2\n2 3\n3 4\n4 1\n0" ], "output": [ "1 4" ] }
{ "input": [ "4\n1 4\n4\n1 2\n2 3\n4 4\n4 1\n0", "4\n1 3\n4\n1 2\n2 3\n4 4\n4 1\n0", "4\n1 1\n4\n1 2\n2 3\n4 4\n4 1\n0", "4\n2 3\n4\n1 2\n2 3\n4 4\n4 1\n0", "4\n2 1\n4\n1 2\n1 1\n4 2\n4 1\n0", "4\n1 4\n4\n1 2\n4 1\n2 3\n4 1\n0", "4\n1 4\n4\n1 2\n2 3\n3 4\n4 2\n0", "4\n1 2\n4\n1 1\n4 3\...
p01415 Starting Line
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 develop physical strength and judgment by running on a straight road. The rabbit is now standing at the starting line and looking out over a long, long road. There...
{ "input": [], "output": [] }
{ "input": [ "1 1 1 2 3 100\n50", "3 1 1 2 3 100\n49\n50\n51" ], "output": [ "49.500000000", "48.666666667" ] }
{ "input": [ "0 1 1 2 3 100\n50", "1 1 1 2 3 110\n50", "3 1 1 2 3 100\n49\n50\n74", "2 1 1 2 3 100\n49\n72\n74", "2 1 1 2 4 100\n49\n72\n40", "1 1 1 3 3 110\n50", "3 1 1 2 3 110\n49\n50\n51", "0 1 1 2 3 000\n50", "0 1 1 2 3 101\n97", "1 1 1 1 3 110\n50", "1 1 1 3 3 111\n50"...
p01569 Sun and Moon
In the year 20XX, mankind is hit by an unprecedented crisis. The power balance between the sun and the moon was broken by the total eclipse of the sun, and the end is looming! To save the world, the secret society called "Sun and Moon" decided to perform the ritual to balance the power of the sun and the moon called "R...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1\n0 -1", "9\n2 1\n1 -1\n1 -1\n1 -1\n1 -1\n0 1\n0 1\n0 1\n0 1" ], "output": [ "No", "Yes 2" ] }
{ "input": [ "2\n1 1\n1 -1", "9\n2 1\n1 -1\n1 -1\n1 -1\n1 -1\n0 1\n0 1\n0 2\n0 1", "9\n2 1\n1 -1\n1 -1\n1 -1\n1 -1\n0 1\n0 0\n0 2\n0 1", "2\n1 1\n1 -2", "9\n2 1\n1 -1\n1 -1\n1 -1\n2 -1\n0 1\n0 1\n0 2\n0 1", "2\n1 0\n1 -2", "9\n2 1\n1 -1\n0 -1\n1 -1\n2 -1\n0 1\n0 1\n0 2\n0 1", "2\n1 0\n...
p01731 Thread Tree
Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view. Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also called a topic) refers to a single conversation with a collection of ...
{ "input": [], "output": [] }
{ "input": [ "1\n0\nicpc" ], "output": [ "icpc" ] }
{ "input": [ "1\n0\nccpi", "1\n0\nipcc", "1\n0\njpcc", "1\n0\ncbpi", "1\n0\niocc", "1\n0\ncboi", "1\n0\ncdpi", "1\n0\njpbc", "1\n0\niodc", "1\n0\ncdip", "1\n0\njpcb", "1\n0\nccip", "1\n0\njccp", "1\n0\nhocc", "1\n0\ndbpi", "1\n0\ncbpj", "1\n0\npccj",...
p01869 28
Problem statement Cards with ranks of $ 2 $ and $ 8 $ are powerful in card game millionaires. Therefore, we call an integer consisting of only the numbers $ 2 $ and $ 8 $ in $ 10 $ decimal notation a good integer. The best integers are listed from the smallest to $ 2, 8, 22, 28, 82, 88, \ cdots $. Let $ n $ be a posi...
{ "input": [], "output": [] }
{ "input": [ "1" ], "output": [ "-1" ] }
{ "input": [ "-1", "2", "4", "8", "32", "16", "64", "128", "256", "-2", "-4", "-5", "-8", "-7", "-10", "-11", "-15", "-26", "-49", "-36", "-58", "-75", "-62", "-14", "-13", "-9", "-12", "-3", "-6", ...
p02006 Santa's Gift
Santa is going to pack gifts into a bag for a family. There are $N$ kinds of gifts. The size and the price of the $i$-th gift ($1 \leq i \leq N$) are $s_i$ and $p_i$, respectively. The size of the bag is $C$, thus Santa can pack gifts so that the total size of the gifts does not exceed $C$. Children are unhappy if they...
{ "input": [], "output": [] }
{ "input": [ "1 1 2\n1 1", "6 3 2\n1 2\n2 10\n3 5", "2 2 2\n1 1\n2 100", "200 5 5\n31 41\n59 26\n53 58\n97 93\n23 84" ], "output": [ "1\n0", "17\n24", "100\n2", "235\n284\n375\n336\n420" ] }
{ "input": [ "1 1 2\n2 1", "2 2 2\n2 1\n2 100", "18 5 5\n31 41\n59 26\n53 58\n97 93\n23 84", "18 5 9\n59 41\n59 26\n53 58\n97 93\n23 84", "18 5 9\n7 41\n59 26\n53 58\n97 93\n23 84", "30 10 9\n7 41\n59 26\n37 58\n97 93\n23 84", "30 10 9\n0 41\n59 26\n37 5\n97 93\n20 84", "31 16 9\n0 8\n...
p02150 Milk
Problem If you bring an empty bottle of $ a $ milk, you can exchange it for a new bottle of $ b $ milk. How many bottles of milk can Mr. Kawabayashi, who initially has a bottle of $ x $ milk, drink? Output the remainder after dividing by $ 1000000007 $. Constraints The input satisfies the following conditions. * $ ...
{ "input": [], "output": [] }
{ "input": [ "316250877917604 316250877917599 681260158257385", "3 1 5", "82 69 64", "3 2 5" ], "output": [ "62687552", "7", "64", "11" ] }
{ "input": [ "82 69 103", "3 2 1", "82 69 114", "3 2 0", "98 69 114", "560118409912468 316250877917599 681260158257385", "5 1 5", "82 69 30", "82 69 73", "82 78 114", "98 69 148", "560118409912468 316250877917599 21421406777778", "5 0 5", "82 69 59", "82 69 ...
p02291 Reflection
For given three points p1, p2, p, find the reflection point x of p onto p1p2. <image> Constraints * 1 ≤ q ≤ 1000 * -10000 ≤ xi, yi ≤ 10000 * p1 and p2 are not identical. Input xp1 yp1 xp2 yp2 q xp0 yp0 xp1 yp1 ... xpq−1 ypq−1 In the first line, integer coordinates of p1 and p2 are given. Then, q queries are giv...
{ "input": [], "output": [] }
{ "input": [ "0 0 3 4\n3\n2 5\n1 4\n0 3", "0 0 2 0\n3\n-1 1\n0 1\n1 1" ], "output": [ "4.2400000000 3.3200000000\n3.5600000000 2.0800000000\n2.8800000000 0.8400000000", "-1.0000000000 -1.0000000000\n0.0000000000 -1.0000000000\n1.0000000000 -1.0000000000" ] }
{ "input": [ "0 0 3 7\n3\n2 5\n1 4\n0 3", "0 0 1 0\n3\n-1 1\n0 1\n1 1", "0 0 3 7\n3\n2 5\n2 4\n0 3", "0 1 3 7\n3\n2 5\n2 4\n0 3", "0 1 3 7\n3\n1 5\n2 4\n0 3", "0 1 3 7\n3\n1 5\n4 4\n0 3", "0 0 3 7\n3\n1 5\n4 4\n0 3", "1 0 3 7\n3\n1 5\n4 4\n0 3", "1 0 3 7\n3\n1 4\n4 4\n0 3", "1 ...
p02438 Splice
For $n$ lists $L_i$ $(i = 0, 1, ..., n-1)$, perform a sequence of the following operations. * insert($t$, $x$): Insert an integer $x$ at the end of $L_t$. * dump($t$): Print all elements in $L_t$. * splice($s$, $t$): Transfer elements of $L_s$ to the end of $L_t$. $L_s$ becomes empty. In the initial state, $L_i$ $(...
{ "input": [], "output": [] }
{ "input": [ "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 1 0\n0 2 6\n1 0\n1 1\n1 2" ], "output": [ "1 2 3 4 5\n\n6" ] }
{ "input": [ "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 1 0\n0 2 9\n1 0\n1 1\n1 2", "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 2 0\n0 2 6\n1 0\n1 1\n1 2", "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 2 0\n0 2 6\n1 1\n1 1\n1 2", "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 8\n2 2 0\n0 2 6\n1 1\n1 1\n1 2", ...
anuarm
N Soldiers are lined up for a memory test. They are numbered from 0 to N-1 from left to right. In the test, there are M rounds. In each round, Captain selects one position. Soldier at that position will be numbered 0. All the soldiers to the right of selected position will be numbered one greater than the soldier to ...
{ "input": [], "output": [] }
{ "input": [ "2\n4 1\n1\n6 2\n2 3" ], "output": [ "1\n0\n1\n2\n3\n2\n1\n1 2 3\n" ] }
{ "input": [ "2\n4 1\n1\n11 2\n2 3", "2\n4 1\n1\n17 2\n2 3", "2\n3 1\n1\n17 2\n2 3", "2\n3 1\n2\n17 2\n2 3", "2\n4 1\n1\n16 2\n2 3", "2\n3 1\n1\n31 2\n2 3", "2\n3 1\n2\n14 2\n2 3", "2\n4 1\n1\n16 2\n3 3", "2\n3 1\n1\n31 2\n2 2", "2\n4 1\n1\n16 2\n6 3", "2\n3 1\n1\n31 2\n2 4...
chode
Once upon a time chef decided to learn encodings. And, obviously, he started with the easiest one (well, actually the easiest after Caesar cypher) – substitution cypher. But very soon Chef got bored with encoding/decoding, so he started thinking how to hack this cypher. He already knows some algorithm, which is not alw...
{ "input": [], "output": [] }
{ "input": [ "3\nqwrtyuipasdfgjkzxcvbnmheol\ndummy!\nbfgjklmopqrstuwxzhvnicdyea\nabcd b efgd hbi!\nqwrtyuipasdfgjkzxcvbnmheol\nDummy!" ], "output": [ "hello!\nhave a nice day!\nHello!" ] }
{ "input": [], "output": [] }
eqidlis
Did you know that Chwee kueh, a cuisine of Singapore, means water rice cake ? Its a variety of the most popular South Indian savory cake, only that we call it here idli :). The tastiest idlis are made in Chennai, by none other than our famous chef, Dexter Murugan. Being very popular, he is flown from Marina to Miami, t...
{ "input": [], "output": [] }
{ "input": [ "3\n4\n1 2 2 3\n2\n1 2\n7\n1 2 3 4 5 6 7" ], "output": [ "1\n-1\n3\n" ] }
{ "input": [ "3\n4\n1 2 2 3\n2\n1 2\n7\n1 0 3 4 5 6 7", "3\n4\n1 4 2 3\n2\n1 2\n7\n1 0 3 4 5 6 7", "3\n4\n0 2 2 3\n2\n1 2\n7\n1 2 3 4 5 6 7", "3\n4\n1 4 2 3\n2\n1 1\n20\n2 0 3 4 1 6 7", "3\n4\n1 4 0 3\n2\n1 1\n20\n2 0 3 4 1 6 7", "3\n4\n1 1 1 1\n2\n1 2\n7\n1 4 0 1 6 6 7", "3\n4\n1 4 2 3\n2...
kjcc08
Clash of clans is a very popular game. Each player in the game is allocated a base with certain hit points the player can train a limited number of troops on the base. There are three types of troops: Barbarian, Archers and Giants. The Cost of training a Barbarian is 100, an Archer is 500, and a Giant is 1500. When att...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n60", "5\n3\n2475", "9\n2\n1530" ], "output": [ "300", "7500", "3300" ] }
{ "input": [], "output": [] }
pairclst
You are given a weighted graph with N nodes and M edges. Some of the nodes are marked as special nodes. Your task is to find the shortest pairwise distance between any two different special nodes. Input The first line of the input contains three space-separated integers N, M and K denoting the number of nodes, the n...
{ "input": [], "output": [] }
{ "input": [ "5 5 3\n1 3 5\n1 2 3\n2 3 4\n3 4 1\n4 5 8\n1 5 19" ], "output": [ "7" ] }
{ "input": [ "5 5 3\n1 3 5\n1 2 3\n2 3 4\n3 4 1\n4 5 10\n1 5 19", "5 5 3\n1 3 5\n1 2 3\n2 3 0\n3 4 1\n1 5 10\n1 5 19", "5 5 3\n1 3 5\n1 2 3\n2 3 0\n3 4 1\n1 0 10\n1 5 2", "5 5 3\n1 3 5\n1 4 6\n2 5 0\n3 2 1\n1 0 4\n1 5 2", "5 5 3\n2 0 5\n1 4 6\n2 5 0\n3 2 1\n1 0 4\n1 5 2", "5 5 3\n0 0 5\n1 4 6\...
sque1
Problem description: There are students in a class fighting for a girl. As she came to know she decided that the boy will win who will help her find out specific characters present in a given string is present either "even" or "odd" number of times as asked by her. So help the boys win. Input Input description. Fir...
{ "input": [], "output": [] }
{ "input": [ "1\n5 2\naaabb\na even\nb odd" ], "output": [ "no\nno\n" ] }
{ "input": [ "1\n2 2\naaabb\na even\nb odd", "1\n2 2\naaabb\nb even\nb odd", "1\n2 1\naaabb\nb even\nb odd", "1\n5 2\naaabb\na even\na odd", "1\n3 1\naaabb\na even\nb dod", "1\n19 2\naaabb\nb even\na odd", "1\n2 2\naaabb\n` even\nb odd", "1\n2 1\naaabb\nb even\nc odd", "1\n10 2\naa...
1263_A. Sweet Problem
You have three piles of candies: red, green and blue candies: * the first pile contains only red candies and there are r candies in it, * the second pile contains only green candies and there are g candies in it, * the third pile contains only blue candies and there are b candies in it. Each day Tanya eats...
{ "input": [], "output": [] }
{ "input": [ "6\n1 1 1\n1 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8\n" ], "output": [ "1\n2\n2\n10\n5\n9\n" ] }
{ "input": [ "6\n1 1 1\n1 2 1\n4 1 1\n7 7 10\n8 1 4\n8 2 8\n", "6\n1 1 1\n1 2 1\n4 1 1\n7 7 18\n8 1 4\n8 2 8\n", "6\n1 1 1\n1 2 1\n4 1 1\n7 7 25\n8 1 4\n8 2 15\n", "6\n1 1 1\n2 2 1\n4 1 1\n7 4 10\n8 1 4\n8 2 8\n", "6\n1 1 1\n1 2 1\n4 1 1\n7 0 25\n8 1 4\n8 2 15\n", "6\n1 1 1\n2 4 1\n4 1 1\n7 4 ...
1327_G. Letters and Question Marks
You are given a string S and an array of strings [t_1, t_2, ..., t_k]. Each string t_i consists of lowercase Latin letters from a to n; S consists of lowercase Latin letters from a to n and no more than 14 question marks. Each string t_i has its cost c_i — an integer number. The value of some string T is calculated as...
{ "input": [], "output": [] }
{ "input": [ "2\na 1\na 1\n?\n", "1\na -1\n??????????????\n", "4\nabc -10\na 1\nb 1\nc 3\n?b?\n", "3\na 1\nb 3\nab 4\nab\n", "1\na -1\n?????????????\n" ], "output": [ "2", "-1", "5", "8", "0" ] }
{ "input": [ "2\nb 1\na 1\n?\n", "4\nabc -10\na 0\nb 1\nc 3\n?b?\n", "1\nb -1\n?????????????\n", "4\nabc -14\na 1\nb 1\nc 0\n?b?\n", "3\na 2\nb 3\nab 4\nab\n", "4\nabc -14\na 1\nc 1\nc 0\n?b?\n", "3\na 3\nb 3\nab 4\nab\n", "4\nabc -10\nb 0\na 1\nc 3\n?b?\n", "4\nabc -10\nb 0\na 1\n...
1346_I. Pac-Man 2.0
Polycarp is developing a new version of an old video game "Pac-Man". Though he really enjoyed playing the original game, he didn't like some aspects of it, so he decided to alter the rules a bit. In Polycarp's version, you play as Pac-Man and you have to collect pellets scattered over the game world while avoiding dan...
{ "input": [], "output": [] }
{ "input": [ "3 4 2 1\n3 1 2\n1 2\n2 1\n1 3\n3 1\n5 8\n", "5 7 4 2\n1 3 2 2 1\n2 3\n4 2\n3 4\n3 1\n1 4\n5 4\n4 5\n7 14 23 27\n", "4 4 3 3\n2 3 1 4\n3 4\n4 1\n1 2\n2 3\n13 42 1337\n" ], "output": [ "\n1\n3\n", "\n2\n6\n10\n13\n", "\n3\n13\n401\n" ] }
{ "input": [], "output": [] }
1431_C. Black Friday
There is a local shop in your area getting prepared for the great holiday of Black Friday. There are n items with prices p_1, p_2, ..., p_n on the display. They are ordered by price, so p_1 ≤ p_2 ≤ ... ≤ p_n. The shop has a prechosen discount value k. The Black Friday discount is applied in the following way: for a si...
{ "input": [], "output": [] }
{ "input": [ "5\n5 2\n1 3 4 6 7\n6 3\n1 2 3 4 5 6\n6 3\n3 3 4 4 5 5\n1 1\n7\n4 4\n1 3 3 7\n" ], "output": [ "\n7\n4\n6\n7\n1\n" ] }
{ "input": [], "output": [] }
414_D. Mashmokh and Water Tanks
Mashmokh is playing a new game. In the beginning he has k liters of water and p coins. Additionally he has a rooted tree (an undirected connected acyclic graph) that consists of m vertices. Each vertex of the tree contains a water tank that is empty in the beginning. The game begins with the fact that Mashmokh chooses...
{ "input": [], "output": [] }
{ "input": [ "10 2 1\n1 2\n1 3\n3 4\n3 5\n2 6\n6 8\n6 7\n9 8\n8 10\n", "5 1000 1000\n1 2\n1 3\n3 4\n3 5\n" ], "output": [ "2\n", "4\n" ] }
{ "input": [ "5 1000 1010\n1 2\n1 3\n3 4\n3 5\n", "10 2 2\n1 2\n1 3\n3 4\n3 5\n2 6\n6 8\n6 7\n9 8\n8 10\n", "4 1000 1000\n1 2\n1 3\n3 4\n3 5\n", "10 1 2\n1 2\n1 3\n3 4\n3 5\n2 6\n7 8\n6 7\n9 8\n8 10\n", "5 1000 1010\n1 2\n2 3\n3 4\n3 5\n", "5 1000 0010\n1 2\n2 3\n3 4\n3 5\n", "4 1001 1000\...
foo-and-exams-4
Foo was not amongst the most brilliant students of his class. So, he has some pending exams to clear. As the exams are approaching, this time he vowed to pass in all of them. This will only happen if he is not under stress. Foo's stress can be calculated using a simple function called Foo_function which depends upon th...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2 2 2 10\n2 3 5 7 1000\n\nSAMPLE" ], "output": [ "1\n7\n" ] }
{ "input": [ "2\n2 2 2 2 10\n2 3 1 7 1000\n\nSAMPLE", "2\n2 2 2 2 16\n1 3 1 7 1000\n\nSAMPKE", "2\n2 2 2 2 19\n2 7 1 7 1010\n\nSAMPLE", "2\n2 2 2 1 16\n1 4 2 7 1000\n\nSAMPKE", "2\n2 2 2 0 32\n2 8 1 0 1010\n\nSAMPLE", "2\n2 2 2 2 36\n2 6 1 7 1011\n\nELPMBS", "2\n2 2 2 2 3\n2 3 5 12 1100\n\...
milly-and-chocolates-again
Milly and Pranjul are playing a game in which Pranjul will give an index of a chocolate. Then, Milly has to tell him the box number in which that chocolate is in. There are N such boxes and Ci chocolates are there in i^th the box. Description of index is given below : Suppose there are A1, A2 … AN chocolates in 1^st, ...
{ "input": [], "output": [] }
{ "input": [ "2\n2 3\n2\n2\n4\n\nSAMPLE" ], "output": [ "1\n2\n" ] }
{ "input": [ "2\n2 3\n2\n3\n4\n\nSAMPLE", "2\n2 3\n2\n2\n1\n\nSAMPLE", "2\n2 3\n1\n2\n4\n\nSAMPLE", "2\n1 3\n1\n2\n4\n\nSAMPLE", "2\n3 3\n2\n2\n4\n\nSAMPLE", "2\n1 3\n2\n2\n1\n\nSEMOLA", "2\n2 3\n2\n3\n4\n\nSAMQLE", "2\n2 3\n2\n2\n1\n\nSEMPLA", "2\n0 3\n2\n2\n1\n\nSEMPLA", "2\n...
sonya-wants-more-equal-numbers-icpc-3
Pussycat Sonya has an array A consisting of N integers. She can replace some adjacent elements Ai and Ai+1 by their sum. Sonya can perform this operation any number of times she wants. What is the maximal number of elements with the same value Sonya can get and what are the values it could be? Input: The first line of...
{ "input": [], "output": [] }
{ "input": [ "6\n11 5 6 2 8 10\n\nSAMPLE" ], "output": [ "2\n8 10 11 16" ] }
{ "input": [ "6\n11 8 6 2 8 10\n\nSAMPLE", "6\n11 15 6 2 8 13\n\nSAMPLE", "6\n11 15 6 2 15 13\n\nSAMPLE", "6\n11 13 6 2 15 13\n\nSAMPLE", "6\n11 13 6 2 24 13\n\nELQMAS", "6\n11 8 6 2 24 13\n\nELQMAS", "6\n11 4 6 2 24 13\n\nELQMAS", "6\n11 4 6 0 24 13\n\nELQMAS", "6\n11 4 7 0 24 13\...
p02568 AtCoder Library Practice Contest - Range Affine Range Sum
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types. * `0 l r b c`: For each i = l, l+1, \dots, {r - 1}, set a_i \gets b \times a_i + c. * `1 l r`: Print \sum_{i = l}^{r - 1} a_i \bmod 998244353. Constraints * 1 \leq N, Q \leq 500000 * 0 \leq a_i, c < 998244353 * 1 \le...
{ "input": [], "output": [] }
{ "input": [ "5 7\n1 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 1 3 102 103\n1 2 5\n0 2 5 104 105\n1 0 5" ], "output": [ "15\n404\n41511\n4317767" ] }
{ "input": [ "5 7\n1 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 1 5 102 103\n1 2 5\n0 2 5 104 105\n1 0 5", "5 7\n1 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 2 5 102 103\n1 2 5\n0 2 5 104 105\n1 0 5", "5 7\n2 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 1 5 102 103\n1 2 5\n0 2 5 104 105\n1 0 5", "5 7\n2 2 3 4 5\...
p02699 AtCoder Beginner Contest 164 - Sheep and Wolves
There are S sheep and W wolves. If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep. If the wolves will attack the sheep, print `unsafe`; otherwise, print `safe`. Constraints * 1 \leq S \leq 100 * 1 \leq W \leq 100 Input Input is given from Standard Input in the fol...
{ "input": [], "output": [] }
{ "input": [ "4 5", "100 2", "10 10" ], "output": [ "unsafe", "safe", "unsafe" ] }
{ "input": [ "1 5", "101 2", "5 10", "1 6", "111 2", "8 10", "0 6", "111 0", "11 10", "-1 6", "111 -1", "6 10", "-1 9", "101 -1", "3 10", "-1 7", "001 -1", "5 14", "0 7", "001 0", "1 14", "0 10", "101 0", "1 19", "0 8"...
p02828 AtCoder Grand Contest 041 - Histogram Rooks
Let us consider a grid of squares with N rows and N columns. Arbok has cut out some part of the grid so that, for each i = 1, 2, \ldots, N, the bottommost h_i squares are remaining in the i-th column from the left. Now, he wants to place rooks into some of the remaining squares. A rook is a chess piece that occupies o...
{ "input": [], "output": [] }
{ "input": [ "10\n4 7 4 8 4 6 8 2 3 6", "3\n2 1 2", "2\n2 2", "4\n1 2 4 1" ], "output": [ "263244071", "17", "11", "201" ] }
{ "input": [ "10\n4 7 4 9 4 6 8 2 3 6", "3\n3 1 2", "4\n2 2 4 1", "4\n2 2 1 1", "10\n4 7 4 9 4 6 8 2 3 2", "4\n2 3 4 1", "4\n2 2 1 2", "10\n4 7 4 9 4 6 8 1 3 2", "4\n2 2 2 2", "10\n4 7 4 8 4 6 8 2 3 9", "2\n1 2", "4\n2 2 4 2", "4\n4 2 4 1", "10\n4 7 4 9 4 6 8 2 ...
p02965 AtCoder Grand Contest 036 - GP 2
We have a sequence of N integers: x=(x_0,x_1,\cdots,x_{N-1}). Initially, x_i=0 for each i (0 \leq i \leq N-1). Snuke will perform the following operation exactly M times: * Choose two distinct indices i, j (0 \leq i,j \leq N-1,\ i \neq j). Then, replace x_i with x_i+2 and x_j with x_j+1. Find the number of differe...
{ "input": [], "output": [] }
{ "input": [ "3 2", "100000 50000", "10 10", "2 2" ], "output": [ "19", "3463133", "211428932", "3" ] }
{ "input": [ "100001 50000", "5 10", "0 2", "100001 27098", "5 7", "101001 27098", "6 7", "101000 27098", "3 7", "101000 9586", "3 10", "101000 14296", "2 10", "101000 4853", "101000 3325", "101001 3325", "101001 365", "101011 365", "101011 1...
p03100 AtCoder Grand Contest 031 - Walk on Graph
You are given a connected graph with N vertices and M edges. The vertices are numbered 1 to N. The i-th edge is an undirected edge of length C_i connecting Vertex A_i and Vertex B_i. Additionally, an odd number MOD is given. You will be given Q queries, which should be processed. The queries take the following form: ...
{ "input": [], "output": [] }
{ "input": [ "3 2 2 2019\n1 2 1\n2 3 2\n1 3 5\n1 3 4", "1 2 3 25\n1 1 1\n1 1 2\n1 1 13\n1 1 6\n1 1 14", "10 15 10 15\n1 2 1\n2 3 6\n3 4 6\n2 5 1\n5 6 1\n4 7 6\n1 8 11\n2 9 6\n5 10 11\n9 10 11\n3 6 1\n2 5 1\n2 7 11\n9 10 11\n5 6 11\n1 3 5\n9 8 3\n7 7 7\n7 10 13\n4 1 10\n9 3 12\n10 10 14\n9 2 1\n6 6 5\n8 8 ...
{ "input": [ "3 2 2 2019\n1 2 1\n2 3 2\n1 5 5\n1 3 4", "1 2 3 25\n1 1 1\n1 1 1\n1 1 13\n1 1 6\n1 1 14", "10 15 10 15\n1 2 1\n2 3 6\n3 4 6\n2 5 1\n5 6 1\n4 7 6\n1 8 11\n2 9 6\n5 10 11\n9 10 11\n3 6 1\n2 5 1\n2 7 11\n9 10 11\n5 6 11\n1 3 5\n9 8 3\n7 7 7\n7 10 13\n4 1 10\n9 3 12\n10 20 14\n9 2 1\n6 6 5\n8 8 ...
p03248 AtCoder Regular Contest 103 - Tr/ee
You are given a string s of length n. Does a tree with n vertices that satisfies the following conditions exist? * The vertices are numbered 1,2,..., n. * The edges are numbered 1,2,..., n-1, and Edge i connects Vertex u_i and v_i. * If the i-th character in s is `1`, we can have a connected component of size i by rem...
{ "input": [], "output": [] }
{ "input": [ "1110", "1111", "1010" ], "output": [ "1 2\n2 3\n3 4", "-1", "1 2\n1 3\n1 4" ] }
{ "input": [ "1011", "0111", "1000", "1100", "0011", "1001", "0100", "0110", "0001", "0101", "0010", "1101", "0000", "0111", "1011", "0010", "0101", "0011", "0000", "0100", "1001", "1100", "0110", "1101", "1000", "...
p03399 AtCoder Beginner Contest 092 - Traveling Budget
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimu...
{ "input": [], "output": [] }
{ "input": [ "549\n817\n715\n603", "555\n555\n400\n200", "600\n300\n220\n420" ], "output": [ "1152", "755", "520" ] }
{ "input": [ "549\n838\n715\n603", "555\n312\n400\n200", "600\n548\n220\n420", "549\n838\n715\n182", "555\n312\n400\n206", "600\n548\n220\n156", "600\n548\n220\n118", "549\n838\n115\n182", "555\n134\n728\n206", "600\n548\n220\n176", "555\n12\n728\n206", "600\n548\n220\n...
p03564 AtCoder Beginner Contest 076 - Addition and Multiplication
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the min...
{ "input": [], "output": [] }
{ "input": [ "10\n10", "4\n3" ], "output": [ "76", "10" ] }
{ "input": [ "10\n17", "4\n4", "10\n15", "4\n7", "10\n11", "4\n2", "10\n14", "4\n0", "10\n24", "4\n-1", "10\n9", "4\n-2", "10\n4", "4\n-4", "10\n1", "4\n-5", "10\n2", "4\n-3", "4\n1", "10\n-1", "4\n6", "10\n-2", "4\n11", "...
p03719 AtCoder Beginner Contest 061 - Between Two Integers
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. Constraints * -100≤A,B,C≤100 * A, B and C are all integers. Input Input is given from Standard Input in the following format: A B C Output If the condition is satisfied, print `Yes`; otherwise, print `No`. ...
{ "input": [], "output": [] }
{ "input": [ "6 5 4", "2 2 2", "1 3 2" ], "output": [ "No", "Yes", "Yes" ] }
{ "input": [ "7 5 4", "-1 2 -1", "2 0 2", "1 0 2", "7 5 3", "2 -1 2", "1 1 2", "7 3 3", "2 -1 0", "1 1 0", "7 1 3", "2 0 0", "2 1 0", "7 1 4", "2 1 -1", "2 0 1", "7 0 4", "2 2 -1", "2 1 2", "7 -1 4", "2 2 -2", "4 1 2", "7 -1 1...
p03879 CODE FESTIVAL 2016 Grand Final(Parallel) - Inscribed Bicycle
Snuke received a triangle as a birthday present. The coordinates of the three vertices were (x_1, y_1), (x_2, y_2), and (x_3, y_3). He wants to draw two circles with the same radius inside the triangle such that the two circles do not overlap (but they may touch). Compute the maximum possible radius of the circles. C...
{ "input": [], "output": [] }
{ "input": [ "3 1\n1 5\n4 9", "0 0\n1 1\n2 0" ], "output": [ "0.889055514217", "0.292893218813" ] }
{ "input": [ "3 1\n1 5\n1 9", "0 -1\n1 1\n2 0", "3 1\n1 5\n1 15", "0 -1\n1 1\n1 0", "3 2\n1 5\n1 15", "-1 -1\n1 1\n1 0", "3 2\n2 5\n1 15", "-1 -1\n1 1\n2 0", "3 4\n2 5\n1 15", "-1 0\n1 1\n2 0", "3 6\n2 5\n1 15", "-2 0\n1 1\n2 0", "3 6\n2 5\n1 16", "-2 1\n1 1\n2 ...
p04040 AtCoder Regular Contest 058 - Iroha and a Grid
We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there ...
{ "input": [], "output": [] }
{ "input": [ "2 3 1 1", "100000 100000 99999 99999", "100000 100000 44444 55555", "10 7 3 4" ], "output": [ "2", "1", "738162020", "3570" ] }
{ "input": [ "10 7 6 4", "10 8 6 4", "17 8 6 4", "17 8 6 6", "2 4 1 1", "100000 100000 99999 72298", "100000 100000 43938 55555", "10 13 6 4", "17 8 5 6", "3 4 1 1", "100000 100000 99999 39553", "100000 100000 43938 63714", "10 13 9 4", "19 8 5 6", "100000 1...
p00121 Seven Puzzle
The 7 puzzle consists of 8 square cards and a frame that fits them snugly. Each card is numbered 0, 1, 2, ..., 7 to distinguish them from each other. You can arrange two cards vertically and four cards horizontally in the frame. 7 When you start the puzzle, first put all the cards in the frame. Only 0 cards in the fra...
{ "input": [], "output": [] }
{ "input": [ "0 1 2 3 4 5 6 7\n1 0 2 3 4 5 6 7\n7 6 5 4 3 2 1 0" ], "output": [ "0\n1\n28" ] }
{ "input": [ "1 0 2 3 4 5 6 7\n1 0 2 3 4 5 6 7\n7 6 5 4 3 2 1 0", "0 1 2 3 4 5 6 7\n0 1 2 3 4 5 6 7\n7 6 5 4 3 2 1 0", "1 0 2 3 4 5 6 7\n1 0 2 3 4 5 6 7\n7 6 5 4 3 2 1 0" ], "output": [ "1\n1\n28\n", "0\n0\n28\n", "1\n1\n28\n" ] }
p00254 All Numbers Lead to 6174
Do the following for a four-digit number N consisting of numbers 0-9. 1. Let L be the number obtained as a result of arranging the numerical values ​​of each of the N digits in descending order. 2. Let S be the number obtained as a result of arranging the numerical values ​​of each of the N digits in ascending order. ...
{ "input": [], "output": [] }
{ "input": [ "6174\n2012\n3333\n0000" ], "output": [ "0\n3\nNA" ] }
{ "input": [ "6174\n3985\n3333\n0000", "6174\n1779\n3333\n0000", "6174\n1779\n2211\n0000", "6174\n2012\n3078\n0000", "6174\n3985\n5889\n0000", "6174\n2012\n3639\n0000", "6174\n1794\n3333\n0000", "6174\n1779\n1275\n0000", "6174\n1289\n3078\n0000", "6174\n3985\n4510\n0000", "...
p00440 Longest Steps
problem There are n cards with one integer from 1 to n and one blank card. Of these n + 1 cards, k cards are given, but 1 ≤ k ≤ n. You can write one integer from 1 to n on a blank card. I want to make a continuous sequence of integers as long as possible with just a given card. Write a program that outputs the maximu...
{ "input": [], "output": [] }
{ "input": [ "7 5\n6\n2\n4\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0" ], "output": [ "2\n4" ] }
{ "input": [ "7 5\n6\n2\n4\n7\n1\n7 5\n5\n2\n0\n4\n7\n0 0", "7 5\n6\n2\n4\n7\n1\n7 5\n5\n2\n0\n1\n7\n0 0", "9 5\n6\n2\n4\n7\n1\n7 5\n5\n2\n1\n4\n7\n0 0", "14 5\n6\n0\n4\n7\n1\n7 5\n5\n2\n0\n4\n7\n0 0", "7 5\n6\n2\n3\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0", "7 5\n6\n2\n4\n7\n0\n25 5\n5\n2\n0\n1\n7\n0 0...
p00631 Split Up!
Brave Ponta and his best friend, Brave Gonta, have come to Luida's bar in search of friends to embark on an epic adventure. There are many warriors, monks and wizards in the tavern who are itching to go on an adventure. Gonta, who is kind-hearted, cared for Ponta and said, "You can choose your friends first." On the ...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5\n4\n2 3 5 7\n0" ], "output": [ "1\n1" ] }
{ "input": [ "5\n1 2 3 4 5\n4\n2 3 5 10\n0", "5\n1 2 3 4 5\n4\n1 3 5 10\n0", "5\n1 2 3 4 5\n4\n1 3 4 10\n0", "5\n1 3 3 4 5\n4\n2 3 5 7\n0", "5\n1 2 3 4 4\n4\n1 3 4 10\n0", "5\n1 3 3 4 5\n4\n2 3 5 10\n0", "5\n1 2 3 4 5\n4\n0 3 5 11\n0", "5\n1 4 3 4 20\n19\n1 3 4 10\n0", "5\n1 2 3 4 ...
p00775 Vampire
Vampire Mr. C is a vampire. If he is exposed to the sunlight directly, he turns into ash. Nevertheless, last night, he attended to the meeting of Immortal and Corpse Programmers Circle, and he has to go home in the near dawn. Fortunately, there are many tall buildings around Mr. C's home, and while the sunlight is blo...
{ "input": [], "output": [] }
{ "input": [ "2 3\n-2 -1 3\n0 1 3\n2 3 3\n2 2\n-2 0 4\n0 2 3\n2 6\n-3 3 1\n-2 3 2\n-1 3 3\n0 3 4\n1 3 5\n2 3 6\n2 6\n-3 3 1\n-3 2 2\n-3 1 3\n-3 0 4\n-3 -1 5\n-3 -2 6\n0 0" ], "output": [ "0.0000\n3.0000\n2.2679\n2.2679" ] }
{ "input": [ "2 3\n-3 -1 3\n0 1 3\n2 3 3\n2 2\n-2 0 4\n0 2 3\n2 6\n-3 3 1\n-2 3 2\n-1 3 3\n0 3 4\n1 3 5\n2 3 6\n2 6\n-3 3 1\n-3 2 2\n-3 1 3\n-3 0 4\n-3 -1 5\n-3 -2 6\n0 0", "2 3\n-3 -1 3\n0 1 3\n2 3 3\n2 2\n-2 0 4\n0 2 5\n2 6\n-3 3 1\n-2 3 2\n-1 3 3\n0 3 4\n1 3 5\n2 3 6\n2 6\n-3 3 1\n-3 2 2\n-3 1 3\n-3 0 4\n-...
p00906 One-Dimensional Cellular Automaton
There is a one-dimensional cellular automaton consisting of N cells. Cells are numbered from 0 to N − 1. Each cell has a state represented as a non-negative integer less than M. The states of cells evolve through discrete time steps. We denote the state of the i-th cell at time t as S(i, t). The state at time t + 1 is...
{ "input": [], "output": [] }
{ "input": [ "5 4 1 3 2 0\n0 1 2 0 1\n5 7 1 3 2 1\n0 1 2 0 1\n5 13 1 3 2 11\n0 1 2 0 1\n5 5 2 0 1 100\n0 1 2 0 1\n6 6 0 2 3 1000\n0 1 2 0 1 4\n20 1000 0 2 3 1000000000\n0 1 2 0 1 0 1 2 0 1 0 1 2 0 1 0 1 2 0 1\n30 2 1 0 1 1000000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\n30 2 1 1 1 100000000...
{ "input": [ "5 4 1 3 2 0\n0 1 2 0 1\n5 7 1 3 2 0\n0 1 2 0 1\n5 13 1 3 2 11\n0 1 2 0 1\n5 5 2 0 1 100\n0 1 2 0 1\n6 6 0 2 3 1000\n0 1 2 0 1 4\n20 1000 0 2 3 1000000000\n0 1 2 0 1 0 1 2 0 1 0 1 2 0 1 0 1 2 0 1\n30 2 1 0 1 1000000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0\n30 2 1 1 1 100000000...
p01040 Friday the 13th
Problem "Ritsumeikan University Competitive Programming Camp" will be held this year as well. I am very much looking forward to this annual training camp. However, I couldn't stand my desires and splurged before the training camp, so I couldn't afford it. So I decided to use the cheapest Seishun 18 Ticket to get to Mi...
{ "input": [], "output": [] }
{ "input": [ "2015 3 13 2015 3 13", "2015 2 14 2015 3 15", "1234 5 6 789012345678901234 5 6" ], "output": [ "1", "1", "1357101234567708000" ] }
{ "input": [ "2015 3 2 2015 3 13", "1045 2 14 2015 3 15", "1234 5 4 789012345678901234 5 6", "2015 3 3 2015 2 13", "2015 3 6 3448 2 13", "2015 2 6 3448 3 13", "2015 2 6 3516 3 13", "3203 2 2 3516 3 13", "1045 2 14 2015 3 5", "1045 4 14 3098 3 13", "1045 4 20 3641 3 13", ...
p01173 Dig or Climb
Benjamin Forest VIII is a king of a country. One of his best friends Nod lives in a village far from his castle. Nod gets seriously sick and is on the verge of death. Benjamin orders his subordinate Red to bring good medicine for him as soon as possible. However, there is no road from the castle to the village. Therefo...
{ "input": [], "output": [] }
{ "input": [ "3\n2 1\n0 0\n50 50\n100 0\n3\n1 1\n0 0\n50 50\n100 0\n3\n1 2\n0 0\n50 50\n100 0\n3\n2 1\n0 0\n100 100\n150 50\n6\n1 2\n0 0\n50 50\n100 0\n150 0\n200 50\n250 0\n0" ], "output": [ "70.710678\n100.000000\n50.000000\n106.066017\n150.000000" ] }
{ "input": [ "3\n2 1\n0 0\n50 50\n100 0\n3\n1 1\n0 0\n50 50\n100 0\n3\n1 2\n0 0\n50 50\n100 0\n3\n2 1\n0 0\n100 100\n150 50\n6\n1 2\n0 0\n50 50\n100 -1\n150 0\n200 50\n250 0\n0", "3\n2 1\n0 0\n50 50\n100 0\n3\n1 1\n0 0\n50 50\n100 0\n3\n1 2\n0 0\n50 50\n100 0\n3\n2 1\n0 0\n100 100\n150 50\n6\n1 2\n0 0\n50 50\...
p01309 A Book Shop With a Frequent Greetings
Natsume loves big cats. One day, Natsume was invited by the stray cats she was always close to to go to the mysterious bookstore where the cats were open. When I heard that the bookstore sells books with many pictures of cats, Natsume decided to follow her happily. I didn't know Natsume, but the bookstore that was tak...
{ "input": [], "output": [] }
{ "input": [ "4\n3 3 5\n0 0\n10 0\n40 40\n40 90\n4 5 10\n100 100\n50 100\n50 150\n100 50\n100 150\n4 60 10\n100 100\n90 100\n110 100\n100 90\n100 110\n4 60 10\n100 100\n80 100\n110 100\n100 80\n100 110" ], "output": [ "9\n0\n60\nYou're always welcome!" ] }
{ "input": [ "4\n3 3 5\n0 0\n10 0\n40 40\n40 90\n4 5 10\n100 100\n50 100\n50 150\n100 50\n100 150\n4 60 10\n100 100\n90 100\n110 100\n100 90\n100 110\n4 60 10\n100 000\n80 100\n110 100\n100 80\n100 110", "4\n3 3 5\n0 0\n17 0\n40 40\n40 90\n4 5 10\n100 100\n50 100\n50 150\n100 50\n100 150\n4 60 10\n100 100\n90...
p01478 Sort
Problem statement There is a permutation with $ 1,2, ..., N $ sorted. I want to select two different numbers $ i $, $ j $ and replace them repeatedly to make them sorted (in the order of $ 1,2, ..., N $). Every time you replace the numbers $ i $, $ j $, you need $ c_ {i, j} $. Let $ f (p) $ be the minimum cost requir...
{ "input": [], "output": [] }
{ "input": [ "3\n0 1 3\n1 0 8\n3 8 0" ], "output": [ "5" ] }
{ "input": [ "3\n0 1 3\n1 0 12\n3 8 0", "3\n0 2 3\n2 1 30\n3 14 0", "3\n0 1 3\n1 0 8\n3 11 0", "3\n0 1 3\n1 1 12\n3 8 0", "3\n0 1 3\n1 1 12\n3 5 0", "3\n0 1 3\n1 0 13\n3 8 0", "3\n0 1 3\n1 0 8\n3 21 0", "3\n0 1 3\n1 1 12\n3 8 1", "3\n0 1 3\n1 0 8\n3 8 1", "3\n1 1 3\n1 0 13\n3 8...
p01638 Pie Chart is as easy as pie.
ICPC World Finals Day 3 On that day, Mr. Tee was investigating the percentage of language used within the team. Unusually, our team does not unify the languages ​​used. Research has shown that two are using C ++ and one is using Java. Now, let's make this a pie chart (pie chart). pie1.png Oh, it looks like Java isn'...
{ "input": [], "output": [] }
{ "input": [ "r x y n\np" ], "output": [ "71 156" ] }
{ "input": [], "output": [] }
p01790 Balanced Paths
Example Input 2 () 1 2 Output 1
{ "input": [], "output": [] }
{ "input": [ "2\n()\n1 2" ], "output": [ "1" ] }
{ "input": [ "2\n)(\n1 2", "2\n((\n1 2", "2\n((\n2 1", "2\n))\n1 2", "2\n)(\n2 1", "2\n()\n2 1", "2\n)(\n6 2", "2\n)(\n7 2", "2\n()\n6 2", "2\n(*\n6 2", "2\n(*\n5 2", "2\n)'\n6 2", "2\n)(\n7 8", "2\n)'\n8 2", "2\n((\n6 2", "2\n()\n7 8", "2\n)'\n9 2",...
p01925 Quiz
quiz You are the director of a quiz show. N people will appear in the quiz show as answerers, each numbered from 1 to N. Questions will be M + 1 questions, and each question is numbered from 1 to M + 1. Questions are given in numerical order, and points are given only to the person who answers correctly first by pres...
{ "input": [], "output": [] }
{ "input": [ "3 2\n5 2 1 3\n8 2 2 3\n2 3\n8 2 1 2\n3 1 1\n5 1 2\n2 5\n100 1 1\n100 1 1\n100 1 1\n100 1 1\n100 1 1\n3 4\n5 1 1\n5 1 2\n100 2 1 3\n100 2 2 3\n0 0" ], "output": [ "14\n11\n501\n196" ] }
{ "input": [ "3 2\n5 2 1 3\n8 2 2 3\n2 3\n8 2 1 2\n3 1 1\n5 1 2\n2 5\n100 1 1\n000 1 1\n100 1 1\n100 1 1\n100 1 1\n3 4\n5 1 1\n5 1 2\n100 2 1 3\n100 2 2 3\n0 0", "3 2\n5 2 1 3\n8 2 2 3\n2 3\n8 2 1 2\n3 1 1\n5 1 2\n2 5\n100 1 1\n000 1 1\n100 1 1\n100 1 1\n100 1 1\n3 4\n5 1 1\n5 1 2\n101 2 1 3\n100 2 2 3\n0 0",...
p02063 Is Greedy Optimal?
D: Is greed the best? story In Japan, where there are 1, 5, 10, 50, 100, 500 yen coins, it is known that the number of coins can be minimized by using as many coins as possible when paying a certain amount. .. If the amount of coins is different from that of Japan, it is not always possible to minimize it by paying ...
{ "input": [], "output": [] }
{ "input": [ "4 6" ], "output": [ "8" ] }
{ "input": [ "2 6", "6 7", "5 7", "10 11", "4 5", "9 64", "8 11", "7 9", "7 16", "10 31", "14 61", "23 64", "17 31", "23 70", "12 49", "24 78", "45 78", "68 78", "16 75", "3 4", "16 102", "5 11", "8 17", "9 37", "10 45...
p02205 Calculation Training
Tashizan Hikizan (Calculation Training) square1001 You gave E869120 two numbers, $ A $ and $ B $, as birthday presents. E869120 You decided to use these two numbers for calculation training. Specifically, E869120 does the following for these numbers exactly $ N $ times: * Replace $ A $ with $ A-B $ on odd-numbered ...
{ "input": [], "output": [] }
{ "input": [ "3\n3 4" ], "output": [ "-4 3" ] }
{ "input": [ "3\n4 4", "3\n4 3", "3\n5 3", "3\n9 3", "3\n7 3", "3\n0 3", "3\n0 5", "3\n0 6", "3\n0 0", "3\n1 0", "3\n-1 0", "3\n-2 0", "3\n0 -1", "3\n-1 -1", "3\n-1 -2", "3\n-1 -3", "3\n-1 -6", "3\n-2 -6", "3\n-2 -10", "3\n-2 -15", "3...
p02359 The Maximum Number of Customers
$N$ persons visited a restaurant. The restaurant is open from 0 to $T$. The $i$-th person entered the restaurant at $l_i$ and left at $r_i$. Find the maximum number of persons during the business hours. Constraints * $ 1 \leq N \leq 10^5 $ * $ 1 \leq T \leq 10^5 $ * $ 0 \leq l_i < r_i \leq T $ Input The input is gi...
{ "input": [], "output": [] }
{ "input": [ "2 2\n0 1\n1 2", "6 10\n0 2\n1 3\n2 6\n3 8\n4 10\n5 10" ], "output": [ "1", "4" ] }
{ "input": [ "2 4\n0 1\n1 2", "2 10\n0 2\n1 3\n2 6\n3 8\n4 10\n5 10", "0 10\n0 2\n1 3\n2 6\n3 8\n4 10\n5 10", "6 16\n0 2\n1 3\n2 6\n3 8\n4 10\n5 10", "6 16\n0 2\n1 3\n2 6\n0 8\n8 15\n5 10", "2 2\n0 0\n1 2", "2 4\n0 1\n1 3", "0 10\n0 2\n1 3\n2 8\n3 8\n4 10\n5 10", "0 10\n0 2\n1 4\n2...
admag
Aditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle of cards each having a sorted list (in ascending order) of some distinct integers written on it. The integers in all the lists are between 1 and N. Note that the s...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n4" ], "output": [ "1\n3\n" ] }
{ "input": [ "2\n1\n3", "2\n2\n4", "2\n2\n8", "2\n4\n4", "2\n2\n7", "2\n4\n8", "2\n2\n13", "2\n8\n8", "2\n2\n26", "2\n5\n8", "2\n1\n26", "2\n1\n8", "2\n1\n41", "2\n8\n3", "2\n6\n4", "2\n3\n7", "2\n4\n13", "2\n2\n2", "2\n1\n2", "2\n5\n6", ...
chefsq
Chef has a sequence of N numbers. He like a sequence better if the sequence contains his favorite sequence as a substring. Given the sequence and his favorite sequence(F) check whether the favorite sequence is contained in the sequence Input The first line will contain the number of test cases and are followed by t...
{ "input": [], "output": [] }
{ "input": [ "2\n6\n1 2 3 4 5 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15" ], "output": [ "Yes\nNo\n" ] }
{ "input": [ "2\n6\n1 2 3 4 7 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15", "2\n6\n1 1 3 4 7 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15", "2\n6\n1 2 3 4 5 6\n3\n2 3 4\n6\n22 5 1 33 1 4\n2\n4 15", "2\n6\n0 2 3 4 7 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15", "2\n6\n1 2 5 4 5 6\n3\n2 3 4\n6\n22 5 1 33 1 4\n2\n4 ...
dragnxor
Did you ever hear about 'Dragon Food' ? Its used to refer to the chocolates bought for your loved ones :). Po offers dragon food to master Shifu, who is a famous cook in the valley of food. In return, Shifu hands over the dragon scroll to Po, which is said to hold the ingredients of the secret recipe. To open the drago...
{ "input": [], "output": [] }
{ "input": [ "3\n3 5 4\n5 0 1\n4 3 7" ], "output": [ "7\n16\n14\n" ] }
{ "input": [ "3\n3 5 4\n2 0 1\n4 3 7", "3\n3 5 4\n2 0 1\n4 3 12", "3\n3 5 4\n2 0 1\n4 3 0", "3\n3 5 4\n10 0 1\n4 3 7", "3\n3 5 4\n2 1 1\n4 3 12", "3\n3 5 4\n1 0 1\n4 3 6", "3\n3 5 4\n10 0 1\n3 3 7", "3\n3 5 0\n2 0 1\n4 3 7", "3\n3 5 4\n2 1 1\n6 3 12", "3\n3 5 4\n10 0 1\n3 4 7",...
jntuv1
Problem description.   JNTU College is conducting an Warmup contest for students to bring out their approaches of solving a problem. A Challenged B that he could not solve the problem.So help B in solving the problem. Given a series of numbers with only 3 and 4.Your task is very simple i.e.. find the nth...
{ "input": [], "output": [] }
{ "input": [ "5" ], "output": [ "43" ] }
{ "input": [], "output": [] }
nukes
There are K nuclear reactor chambers labelled from 0 to K-1. Particles are bombarded onto chamber 0. The particles keep collecting in the chamber 0. However if at any time, there are more than N particles in a chamber, a reaction will cause 1 particle to move to the immediate next chamber(if current chamber is 0, then ...
{ "input": [], "output": [] }
{ "input": [ "3 1 3" ], "output": [ "1 1 0\n" ] }
{ "input": [ "3 1 1", "3 1 5", "1 1 3", "6 1 5", "1 2 2", "0 2 2", "0 2 4", "0 3 7", "1 3 7", "3 1 4", "1 1 6", "6 1 4", "2 2 2", "0 2 1", "0 3 6", "2 3 7", "1 3 11", "1 3 17", "0 4 17", "0 1 3", "10 1 5", "2 2 3", "1 1 4", ...
simpstat
Sergey has made N measurements. Now, he wants to know the average value of the measurements made. In order to make the average value a better representative of the measurements, before calculating the average, he wants first to remove the highest K and the lowest K measurements. After that, he will calculate the averag...
{ "input": [], "output": [] }
{ "input": [ "3\n5 1\n2 9 -10 25 1\n5 0\n2 9 -10 25 1\n3 1\n1 1 1" ], "output": [ "4.000000\n5.400000\n1.000000\n" ] }
{ "input": [ "3\n5 2\n2 9 -10 25 1\n5 0\n2 9 -10 25 1\n3 1\n1 1 1", "3\n5 1\n2 9 -10 14 1\n5 0\n2 9 -10 25 1\n3 1\n1 1 1", "3\n5 2\n1 9 -10 25 1\n5 0\n2 9 -10 25 1\n3 0\n1 1 1", "3\n5 2\n1 9 -10 25 1\n5 0\n2 9 -10 25 0\n3 0\n1 1 1", "3\n5 1\n0 9 -10 19 1\n5 0\n2 9 -10 25 1\n3 1\n0 1 1", "3\n5 ...
1428_G2. Lucky Numbers (Hard Version)
This is the hard version of the problem. The only difference is in the constraint on q. You can make hacks only if all versions of the problem are solved. Zookeeper has been teaching his q sheep how to write and how to add. The i-th sheep has to write exactly k non-negative integers with the sum n_i. Strangely, sheep...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3 4 5 6\n2\n57\n63\n" ], "output": [ "11\n8\n" ] }
{ "input": [ "3\n1 2 3 4 5 6\n2\n57\n72\n", "3\n1 0 0 4 5 0\n2\n57\n72\n", "3\n0 0 -1 0 16 1\n2\n57\n72\n", "3\n1 2 3 4 5 0\n2\n57\n75\n", "3\n1 2 0 4 5 0\n2\n52\n72\n", "3\n1 0 0 4 5 1\n1\n57\n72\n", "3\n0 1 -1 0 16 2\n2\n57\n72\n", "3\n1 1 0 0 16 2\n2\n57\n72\n", "3\n1 2 3 4 5 2\...
530_G. Levenshtein distance
Levenshtein distance between two strings of letters is calculated as the minimal total cost of a sequence of edit actions that converts one of the strings into the other one. The allowed edit actions are: * substitution: the cost of substituting one letter with another is equal to the difference of index numbers of ...
{ "input": [], "output": [] }
{ "input": [ "arc\nbug\n", "dome\ndrone\n" ], "output": [ "8\n", "19\n" ] }
{ "input": [], "output": [] }
biased-chandan
Chandan is an extremely biased person, and he dislikes people who fail to solve all the problems in the interview he takes for hiring people. There are n people on a day who came to be interviewed by Chandan. Chandan rates every candidate from 0 to 10. He has to output the total ratings of all the people who came in ...
{ "input": [], "output": [] }
{ "input": [ "5\n2\n3\n0\n7\n0\n\nSAMPLE" ], "output": [ "2\n" ] }
{ "input": [ "5\n2\n3\n0\n7\n0\n\nSBMPLE", "5\n1\n3\n0\n7\n0\n\nSAMPLE", "5\n2\n3\n0\n1\n1\n\nSBMPLE", "5\n1\n3\n1\n7\n0\n\nSAMOLE", "5\n1\n3\n2\n7\n0\n\nSAMOLE", "5\n2\n4\n1\n1\n1\n\nSBMPLE", "5\n2\n4\n1\n1\n0\n\nSBMPLE", "5\n4\n3\n1\n7\n0\n\nELOMAS", "5\n2\n7\n1\n1\n1\n\nSBMPLE",...
find-the-triangle-3
You are given N sticks, the length of the i^th stick being ai . As your professor is very interested in triangles he gives you a problem: From the N given sticks, choose 3 sticks that form a triangle. If there are many such triangles , choose the sticks in such a way such that the perimeter of the triangle formed is ma...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n2 3 2 4 6\n3\n2 99 101\n\nSAMPLE" ], "output": [ "3 4 6\n-1\n" ] }
{ "input": [ "2\n5\n2 3 2 4 6\n3\n3 99 101\n\nSAMPLE", "2\n5\n2 3 2 4 6\n3\n3 42 101\n\nSAMPLE", "2\n5\n2 5 2 4 6\n3\n3 83 111\n\nSAMOLE", "2\n5\n2 3 2 8 6\n3\n3 83 101\n\nSAMOLE", "2\n5\n2 3 2 6 6\n3\n3 83 111\n\nSAMOLE", "2\n5\n2 3 2 3 6\n3\n3 99 001\n\nSAMPLE", "2\n5\n2 10 2 4 6\n3\n3 8...
ones-and-zeros-and-minus-ones
Level 3 Given an array a of size n containing only 0,-1,and 1, x = number of 1's in a[l,r] (in subarray from l to r) y = number of -1's in a[l,r] (in subarray from l to r) For any sub array [l,r] function f is defined as follows if(y == 0) f([l,r]) = 0; else f([l,r]) = x / y; Your goal is determine the maximu...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n1 1\n3\n1 1 -1\n\nSAMPLE" ], "output": [ "0/1\n2/1\n" ] }
{ "input": [ "2\n2\n1 1\n3\n1 0 -1\n\nSAMPLE", "2\n2\n1 1\n3\n1 1 -1\n\nASMPLE", "2\n2\n0 1\n3\n0 0 -1\n\nSEMPLA", "2\n2\n1 -1\n3\n1 0 -1\n\nSBMPLE", "2\n2\n1 -1\n3\n2 0 -1\n\nSBMPLE", "2\n2\n0 1\n3\n1 0 -1\n\nSAMPLE", "2\n2\n0 1\n3\n1 0 -1\n\nELPMAS", "2\n2\n0 1\n3\n1 0 -1\n\nELPMBS",...
range-query
Since chandu_don is busy in talking to his girlfriend,he wants you to solve a problem for him requiring range queries.The problem is as follows:- Given an array of N integers we have to answer Q queries on the array. Each Query is of the format X Y val where we have to output number of integers between X to Y index i...
{ "input": [], "output": [] }
{ "input": [ "5\n2 3 1 4 2\n3\n0 4 2\n1 4 2\n0 4 7\n\nSAMPLE" ], "output": [ "2\n1\n0\n" ] }
{ "input": [ "5\n2 3 1 4 2\n2\n0 4 2\n1 4 2\n0 4 7\n\nSAMPLE", "5\n2 3 2 4 2\n3\n0 4 2\n1 4 2\n0 4 7\n\nSAMPLE", "5\n2 3 3 4 2\n3\n0 4 2\n1 4 2\n0 4 7\n\nSAMPLE", "5\n2 0 1 4 1\n2\n0 4 2\n1 4 2\n0 3 7\n\nSAMPLE", "5\n1 3 1 4 2\n2\n0 4 2\n1 4 1\n0 1 7\n\nSAMPLE", "5\n2 0 1 4 1\n2\n0 4 3\n1 4 3\...