name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
cw1
While Tom Cruise(Cage) fighting in the movie "Edge of Tomorrow", he finds himself in a modern lab, where he needs to kill the brain of a mutant species Omega. The DNA of the Omega is made up of characters of A, T, G and C like ours. He has certain enzymes which will cut and remove certain parts of this DNA. The mutant ...
{ "input": [], "output": [] }
{ "input": [ "3\nATGCATGCATCGACTCAGCATCAGCATCGACTA\nTG\nGC\nAT", "2\nATACGCATGACGATGCATGCAGCAT\nATA\nGC" ], "output": [ "ACACCGACTCACACGACTA\n", "CATGACGATATAAT\n" ] }
{ "input": [ "3\nATGCATGCATCGACTCAGCATCAGCATCGACTA\nTH\nGC\nAT", "2\nATACGCATGACGATGCATGCAGCAT\nTAA\nGC", "3\nATGCATGCATCGACTCAGCATCAGCATCGACTA\nTH\nGC\nTA", "2\nTACGACGTACGTAGCAGTACGCATA\nTAA\nGC", "3\nATGCATGCATCGACTCAGCATCAGCATCGACTA\nTH\nGC\nT@", "3\nATGCTAGCATCGACTCAGCATCAGCATCGACTA\nTH\n...
icq1
The success of IEEE code-quest depends on number of times the factor is present in a given string.Help core members to find them  Factor of string is defined as a substring.In this case it's '01'. Input First line of input contains an integer T, denoting the number of test cases. Then follows description of T cases.Ea...
{ "input": [], "output": [] }
{ "input": [ "1\n1001010100001" ], "output": [ "4\n" ] }
{ "input": [ "1\n1001010110001", "1\n1001010110000", "1\n1001011110000", "1\n0101101101001", "1\n1100100000000", "1\n1111110000000", "1\n0101010101010", "1\n1001011110001", "1\n1101011110001", "1\n1111011110001", "1\n1111011100001", "1\n1101011100001", "1\n010101110...
mqry
One day maths teacher gave the following task for the students, only upon completion students will be taken out for a school fun trip. First you are a given a list of n numbers and q queries. For each query you are given two indices x and y , you have to report the between the maximum number and minimum number whose in...
{ "input": [], "output": [] }
{ "input": [ "5 2\n1 2 3 4 5\n1 2\n4 4" ], "output": [ "1\n0" ] }
{ "input": [ "5 2\n1 2 3 4 5\n2 2\n4 4", "5 2\n0 1 3 0 5\n1 2\n4 4", "5 2\n0 1 5 0 5\n1 2\n4 4", "5 2\n1 0 3 4 5\n0 2\n4 4", "5 2\n0 0 6 4 5\n0 2\n4 7", "5 1\n0 0 6 4 1\n0 2\n4 7", "5 1\n-1 0 6 4 1\n0 2\n4 7", "5 1\n-1 0 11 4 1\n0 2\n4 7", "5 2\n-1 0 11 2 1\n0 2\n4 7", "5 2\n-2...
reverse
Sometimes mysteries happen. Chef found a directed graph with N vertices and M edges in his kitchen! The evening was boring and chef has nothing else to do, so to entertain himself, Chef thought about a question "What is the minimum number of edges he needs to reverse in order to have at least one path from vertex 1 to...
{ "input": [], "output": [] }
{ "input": [ "7 7\n1 2 \n3 2\n3 4\n7 4\n6 2\n5 6\n7 5" ], "output": [ "2\n" ] }
{ "input": [ "7 7\n1 2 \n4 2\n3 4\n7 4\n6 2\n5 6\n7 5", "9 7\n1 2 \n4 2\n3 4\n7 4\n6 2\n5 6\n7 5", "7 7\n1 2 \n3 2\n2 4\n7 4\n6 2\n5 6\n7 5", "7 7\n1 2 \n3 2\n2 4\n4 4\n6 2\n5 6\n7 5", "8 7\n1 4 \n2 2\n3 4\n7 4\n6 2\n4 8\n7 6", "7 7\n1 2 \n3 2\n3 4\n7 4\n6 2\n5 6\n5 5", "7 7\n1 2 \n3 2\n3 ...
twtclose
Little kids, Jack and Evan like playing their favorite game Glass-and-Stone. Today they want to play something new and came across Twitter on their father's laptop. They saw it for the first time but were already getting bored to see a bunch of sentences having at most 140 characters each. The only thing they liked to...
{ "input": [], "output": [] }
{ "input": [ "3 6\nCLICK 1\nCLICK 2\nCLICK 3\nCLICK 2\nCLOSEALL\nCLICK 1" ], "output": [ "1\n2\n3\n2\n0\n1\n" ] }
{ "input": [ "5 6\nCLICK 1\nCLICK 2\nCLICK 3\nCLICK 2\nCLOSEALL\nCLICK 1", "5 6\nCLICK 1\nCLICK 1\nCLICK 3\nCLICK 2\nCLOSEALL\nCLICK 1", "5 6\nCLICK 1\nCLICK 2\nCLICK 2\nCLICK 2\nCLOSEALL\nCLICK 1", "5 6\nCLICK 1\nCLICK 2\nCLICK 3\nCLICK 4\nCLOSEALL\nCLICK 1", "5 6\nCLICK 1\nCLICK 2\nCLICK 2\nCLIC...
1211_C. Ice Cream
Summer in Berland lasts n days, the price of one portion of ice cream on the i-th day is c_i. Over the summer, Tanya wants to eat exactly k portions of ice cream. At the same time, on the i-th day, she decided that she would eat at least a_i portions, but not more than b_i (a_i ≤ b_i) portions. In other words, let d_i ...
{ "input": [], "output": [] }
{ "input": [ "3 7\n3 5 6\n0 3 4\n3 3 3\n", "1 45000\n40000 50000 100000\n", "3 100\n2 10 50\n50 60 16\n20 21 25\n", "4 12\n2 5 1\n1 2 2\n2 3 7\n3 10 4\n" ], "output": [ "\n31\n", "\n4500000000\n", "\n-1\n", "\n35\n" ] }
{ "input": [], "output": [] }
1252_L. Road Construction
There are N cities in the country of Numbata, numbered from 1 to N. Currently, there is no road connecting them. Therefore, each of these N cities proposes a road candidate to be constructed. City i likes to connect with city A_i, so city i proposes to add a direct bidirectional road connecting city i and city A_i. It...
{ "input": [], "output": [] }
{ "input": [ "4 5\n2 2 1 2\n3 2 2 3\n4 2 3 4\n2 2 4 5\n1 2 3 4 5\n", "4 5\n2 2 10 20\n3 2 2 3\n4 2 3 4\n2 2 4 5\n1 2 3 4 5\n" ], "output": [ "\n1 2\n2 3\n3 4\n0 0\n4 2\n", "\n-1\n" ] }
{ "input": [], "output": [] }
1519_C. Berland Regional
Polycarp is an organizer of a Berland ICPC regional event. There are n universities in Berland numbered from 1 to n. Polycarp knows all competitive programmers in the region. There are n students: the i-th student is enrolled at a university u_i and has a programming skill s_i. Polycarp has to decide on the rules now....
{ "input": [], "output": [] }
{ "input": [ "4\n7\n1 2 1 2 1 2 1\n6 8 3 1 5 1 5\n10\n1 1 1 2 2 2 2 3 3 3\n3435 3014 2241 2233 2893 2102 2286 2175 1961 2567\n6\n3 3 3 3 3 3\n5 9 6 7 9 7\n1\n1\n3083\n" ], "output": [ "\n29 28 26 19 0 0 0 \n24907 20705 22805 9514 0 0 0 0 0 0 \n43 43 43 32 38 43 \n3083 \n" ] }
{ "input": [ "4\n7\n1 2 1 2 1 2 1\n6 8 3 1 5 1 5\n10\n1 1 1 2 2 2 2 3 3 3\n3435 3014 2241 2233 2893 2102 2286 2175 1961 2567\n6\n3 3 3 3 3 3\n5 9 6 7 9 7\n1\n1\n313\n", "4\n7\n1 2 1 2 1 2 1\n6 8 3 1 5 1 9\n10\n1 1 1 2 2 2 2 3 3 3\n3435 3014 2241 2233 2893 2102 2286 2175 1961 2567\n6\n3 3 3 3 3 3\n5 9 6 7 9 7\...
315_C. Sereja and Contest
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the...
{ "input": [], "output": [] }
{ "input": [ "5 0\n5 3 4 1 2\n", "10 -10\n5 5 1 7 5 1 2 4 9 2\n" ], "output": [ "2\n3\n4\n", "2\n4\n5\n7\n8\n9\n" ] }
{ "input": [ "5 0\n5 5 4 1 2\n", "10 -10\n5 5 1 7 4 1 2 4 9 2\n", "10 0\n5 5 1 7 4 1 2 4 9 2\n", "10 -10\n5 5 1 0 5 1 2 4 9 2\n", "5 0\n5 5 4 0 2\n", "10 -10\n5 5 1 7 4 1 0 4 9 2\n", "10 -12\n5 5 1 0 5 1 2 4 9 2\n", "10 -10\n5 5 1 0 4 1 0 4 9 2\n", "10 0\n5 9 1 12 0 2 2 4 12 1\n", ...
balanced-strings
Balance strings, by definition, are the strings that contain all the characters of the alphabet, from a to z, equal no of times. eg- abcdefghijklmnopqrstuvwxyz is a balanced string, aabb is not. Input: First line contains number of test cases T. Each test case contains a string S which made up of only lowercase charac...
{ "input": [], "output": [] }
{ "input": [ "2\ncodemyca\nabcdefghijklmnopqrstuvwxyz\n\nSAMPLE" ], "output": [ "No\nYes\n" ] }
{ "input": [ "2\ncodemyba\nabcdefghijklmnopqrstuvwxyz\n\nSAMPLE", "2\ncodemyba\nabcdefghijklmnopqrstuvwxyz\n\nELPMAS", "2\ncodmeyba\nabcdefghijklmnopqrstuvwxyz\n\nELPMAS", "2\ncodemyaa\nabcdefghijklmnopqrstuvwxyz\n\nSAMPLE", "2\ncodemyba\nzyxwvutsrqponmlkjihgfedcba\n\nELPMAS", "2\ncodmeyba\nzy...
lucky-sequence
Lets call a string which is composed of only 4 and 7 a Lucky String. For example, 47, 444, 44744 are all Lucky Strings of length 2, 3 and 5 respectively, while 45, 767 are not Lucky Strings. Now, consider a sorted list of all the Lucky Strings that can be formed where the sorting is done by the following rule: A stri...
{ "input": [], "output": [] }
{ "input": [ "3\n1\n5\n11\n\nSAMPLE" ], "output": [ "4\n74\n744" ] }
{ "input": [ "3\n1\n6\n11\n\nSAMPLE", "3\n1\n6\n17\n\nSAMPLE", "3\n2\n6\n17\n\nSAMPLE", "3\n2\n7\n17\n\nSAMPLF", "3\n2\n7\n28\n\nSAMPLF", "3\n2\n7\n33\n\nTAMPMF", "3\n3\n7\n33\n\nTAMPMF", "3\n1\n7\n33\n\nTAMPMF", "3\n1\n7\n27\n\nTAMPMF", "3\n1\n3\n27\n\nTAMPMF", "3\n1\n3\n3...
navi-and-beer-1
Navi is at the Beer Bar where he has ordered N beers. After seeing his love with the beers, Bar's Manager has decided to make as much money as they can by asking Navi to pay K * i^3 Rupees for the i^th beer. But Navi has only M Rupees in his purse. So you are required to lent him some money so that he can still be abl...
{ "input": [], "output": [] }
{ "input": [ "1\n2 2 10\n\nSAMPLE" ], "output": [ "8\n" ] }
{ "input": [ "1\n2 3 10\n\nSAMPLE", "1\n2 1 10\n\nSAMPLE", "1\n2 3 19\n\nSAMPLE", "1\n4 2 19\n\nMASPLE", "1\n4 4 19\n\nAMRPLE", "1\n3 4 19\n\nAMRPKE", "1\n3 4 1\n\nKMRPAE", "1\n3 8 1\n\nKMRPAE", "1\n4 8 1\n\nKMRPAE", "1\n4 5 1\n\nKMRPAE", "1\n4 6 1\n\nKMRPAE", "1\n4 6 0...
problem-of-bilocation
Anurag is posed with a very serious problem. He will be in London during the summers from days [ a,b ] for an internship. But he also wants to attend the ACM-ICPC World Finals with his team to be held in Thailand during [ c,d ] days. The opening ceremony for the World Finals will be held on c day. He found out that it ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 14 15 20 2\n13 14 15 20 3\n\nSAMPLE" ], "output": [ "13\nSTAY IN LONDON\n" ] }
{ "input": [ "2\n1 14 15 20 2\n13 14 29 20 3\n\nSAMPLE", "2\n1 14 15 20 2\n13 27 29 20 3\n\nSAMPLE", "2\n1 14 15 20 2\n13 49 1 20 3\n\nSAMPLE", "2\n1 25 24 20 2\n13 49 1 34 3\n\nSAMPLE", "2\n1 6 24 20 2\n26 30 2 34 1\n\nSAMPLE", "2\n-1 1 27 42 1\n24 17 3 35 0\n\nSAMPLE", "2\n1 25 24 20 0\n...
p02646 Tokio Marine & Nichido Fire Insurance Programming Contest 2020 - Tag
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch ...
{ "input": [], "output": [] }
{ "input": [ "1 2\n3 3\n3", "1 2\n3 2\n3", "1 2\n3 1\n3" ], "output": [ "NO", "NO", "YES" ] }
{ "input": [ "1 0\n3 3\n3", "1 3\n3 2\n3", "1 2\n3 0\n3", "1 0\n3 6\n3", "0 3\n3 2\n3", "1 2\n5 0\n3", "1 0\n3 8\n3", "-1 3\n3 2\n3", "0 2\n5 0\n3", "1 0\n5 8\n3", "-1 3\n2 2\n3", "0 2\n5 -1\n3", "0 0\n5 8\n3", "-1 3\n2 4\n3", "0 4\n5 -1\n3", "0 0\n5 6\n...
p02775 AtCoder Beginner Contest 155 - Payment
In the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a takoyaki machine with a value of N. (Takoyaki is the name of a Japanese snack.) To make the paymen...
{ "input": [], "output": [] }
{ "input": [ "91", "314159265358979323846264338327950288419716939937551058209749445923078164062862089986280348253421170", "36" ], "output": [ "3", "243", "8" ] }
{ "input": [ "30", "476640020082194381531155118436783393866726953614433851622190777875571135215042541028243752681838573", "22", "41", "402419059500366785869358882282163159674165660152915334404536663378232442791064106232595577577780162", "85935701773254562628410719372396848335402648590418634844...
p02910 AtCoder Beginner Contest 141 - Tap Dance
Takahashi will do a tap dance. The dance is described by a string S where each character is `L`, `R`, `U`, or `D`. These characters indicate the positions on which Takahashi should step. He will follow these instructions one by one in order, starting with the first character. S is said to be easily playable if and onl...
{ "input": [], "output": [] }
{ "input": [ "RUDLUDR", "DULL", "RDULULDURURLRDULRLR", "UUUUUUUUUUUUUUU", "ULURU" ], "output": [ "Yes", "No", "Yes", "Yes", "No" ] }
{ "input": [ "RDULDUR", "LLUD", "RDULULDURURLLDULRRR", "ULURV", "EULL", "RCULULDURURLLDULRRR", "UKURU", "EULM", "RCVLULDURURLLDULRRR", "UJURU", "RCVLULDURURKLDULRRR", "URUJU", "RCVLUUDURLRKLDULRRR", "RCVLUUDURLRKLDVLRRR", "RRRLVDLKRLRUDUULVCR", "RRRLVDLK...
p03045 AtCoder Beginner Contest 126 - 1 or 2
There are N cards placed face down in a row. On each card, an integer 1 or 2 is written. Let A_i be the integer written on the i-th card. Your objective is to guess A_1, A_2, ..., A_N correctly. You know the following facts: * For each i = 1, 2, ..., M, the value A_{X_i} + A_{Y_i} + Z_i is an even number. You ar...
{ "input": [], "output": [] }
{ "input": [ "100000 1\n1 100000 100", "6 5\n1 2 1\n2 3 2\n1 3 3\n4 5 4\n5 6 5", "3 1\n1 2 1" ], "output": [ "99999", "2", "2" ] }
{ "input": [ "3 1\n2 2 1", "3 1\n3 2 1", "6 1\n3 2 1", "4 1\n2 2 1", "10 1\n3 2 1", "8 1\n1 2 1", "12 1\n3 2 -1", "6 1\n1 1 1", "13 1\n3 2 -1", "10 1\n2 2 1", "8 1\n2 2 2", "16 0\n2 2 -2", "16 1\n2 4 -2", "100000 1\n1 100000 101", "13 0\n3 0 -1", "6 5\n1...
p03187 AtCoder Grand Contest 030 - Tree Burning
Takahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-clockwise. There are N...
{ "input": [], "output": [] }
{ "input": [ "314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n298992265", "10 6\n1\n2\n3\n6\n7\n9", "10 3\n2\n7\n9" ], "output": [ "1204124749", "27", "15" ] }
{ "input": [ "314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n453863319", "6 6\n1\n2\n3\n6\n7\n9", "10 3\n2\n7\n17", "391985414 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n453863319", "10 3\n2\n7\n20", "10 3\n2\n7\n29", "3 6\n1\n2\n3\n6\n7\...
p03334 AtCoder Grand Contest 025 - Choosing Points
Takahashi is doing a research on sets of points in a plane. Takahashi thinks a set S of points in a coordinate plane is a good set when S satisfies both of the following conditions: * The distance between any two points in S is not \sqrt{D_1}. * The distance between any two points in S is not \sqrt{D_2}. Here, D_1 ...
{ "input": [], "output": [] }
{ "input": [ "3 1 5", "2 1 2" ], "output": [ "0 0\n0 2\n0 4\n1 1\n1 3\n1 5\n2 0\n2 2\n2 4", "0 0\n0 2\n2 0\n2 2" ] }
{ "input": [ "2 2 2", "2 2 4", "2 2 1", "2 1 5", "5 1 5", "3 2 4", "1 2 1", "3 1 6", "3 4 4", "4 4 6", "4 4 4", "4 4 1", "8 4 1", "2 4 1", "3 4 1", "5 1 6", "4 2 1", "4 6 6", "3 1 1", "2 4 4", "5 4 1", "7 4 1", "5 2 6", "7...
p03494 AtCoder Beginner Contest 081 - Shift only
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. Constraints * 1 \leq N...
{ "input": [], "output": [] }
{ "input": [ "6\n382253568 723152896 37802240 379425024 404894720 471526144", "4\n5 6 8 10", "3\n8 12 40" ], "output": [ "8", "0", "2" ] }
{ "input": [ "6\n382253568 723152896 37802240 379425024 590201381 471526144", "3\n10 12 40", "3\n16 36 16", "4\n5 6 13 10", "6\n382253568 723152896 32183854 379425024 590201381 471526144", "4\n5 6 22 10", "3\n10 12 27", "6\n348324507 723152896 32183854 379425024 590201381 471526144", ...
p03655 AtCoder Grand Contest 018 - Sightseeing Plan
Joisino is planning on touring Takahashi Town. The town is divided into square sections by north-south and east-west lines. We will refer to the section that is the x-th from the west and the y-th from the north as (x,y). Joisino thinks that a touring plan is good if it satisfies the following conditions: * Let (p,q)...
{ "input": [], "output": [] }
{ "input": [ "1 2 3 4 5 6\n1 2 3 4 5 6", "1 1 2 2 3 4\n1 1 2 2 3 3", "77523 89555 420588 604360 845669 973451\n2743 188053 544330 647651 709337 988194" ], "output": [ "2346", "10", "137477680" ] }
{ "input": [ "2 1 2 2 3 4\n1 1 2 2 3 3", "1 1 2 3 3 4\n1 1 2 2 3 3", "1 1 2 3 3 4\n0 1 2 2 3 3", "1 1 2 3 3 5\n0 1 2 2 3 3", "0 2 3 4 5 6\n1 2 3 4 5 6", "1 1 2 3 3 4\n0 2 2 2 3 3", "0 1 2 2 3 4\n1 1 2 3 3 3", "1 2 2 4 5 6\n1 2 3 4 5 6", "1 1 2 2 3 8\n1 1 2 2 3 3", "77523 89555 ...
p03811 AtCoder Grand Contest 010 - Rearranging
There are N integers written on a blackboard. The i-th integer is A_i. Takahashi and Aoki will arrange these integers in a row, as follows: * First, Takahashi will arrange the integers as he wishes. * Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as he wishes. We will assume...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5", "4\n2 3 4 6" ], "output": [ "5 3 2 4 1", "2 4 6 3" ] }
{ "input": [ "5\n1 2 3 1 5", "4\n2 0 4 6", "5\n1 2 3 0 5", "4\n1 0 4 6", "5\n1 2 4 0 5", "4\n1 0 2 6", "5\n1 2 6 0 5", "4\n1 0 2 2", "5\n1 4 6 0 5", "4\n2 0 2 2", "4\n2 0 3 2", "4\n2 0 6 2", "5\n1 4 3 4 5", "4\n2 3 4 1", "5\n2 2 3 1 5", "4\n2 0 3 6", ...
p03980 Kyoto University Programming Contest 2016 - Speed Solving
Gorillas in Kyoto University are good at math. They are currently trying to solve problems to find the value of an expression that contains two functions, `_` , `^`. Each of these functions takes two input values. `_` function returns the smaller of the two input values and `^` function returns the larger. Gorillas kno...
{ "input": [], "output": [] }
{ "input": [ "4\n_(4,51)?\n^(99,_(3,67))?\n_(0,87)?\n3?", "7\n_(23,^(_(22,40),4))?\n_(0,99)?\n^(99,_(^(19,2),5))?\n_(^(43,20),^(30,29))?\n^(_(20,3),_(50,41))?\n^(_(20,3),_(3,41))?\n^(_(20,3),_(4,41))?" ], "output": [ "4 5\n99 4\n0 3\n3 2", "22 18\n0 3\n99 4\n30 17\n41 17\n3 14\n4 15" ] }
{ "input": [ "7\n_(23,^(_(22,40),4))?\n_(0)99,?\n^(99,_(^(19,2),5))?\n_(^(43,20),^(30,29))?\n^(_(20,3),_(50,41))?\n^(_(20,3),_(3,41))?\n^(_(20,3),_(4,41))?", "7\n_(23,^(_(22,40),4))?\n_(0,99)?\n^(99,_(^(19,2),5))?\n_(^(43,20),^(30,29))?\n^(_(20,3),_(50,41))?\n^(_(20,3),_(3,41))?\n^(^(20,3),_(4,41))?", "7\...
p00068 Enclose Pins with a Rubber Band
Hit n nails one by one at the coordinates P1 (x1, y1), P2 (x2, y2), P3 (x3, y3), ..., Pn (xn, yn) on the flat plate, and put them on the rubber band ring. Surround it with a single rubber band so that all the nails fit inside. At this time, the rubber bands must not intersect. Create a program that reads the coordinat...
{ "input": [], "output": [] }
{ "input": [ "4\n1.0,0.0\n0.0,1.0\n2.0,1.0\n1.0,2.0\n9\n-509.94,892.63\n567.62,639.99\n-859.32,-64.84\n-445.99,383.69\n667.54,430.49\n551.12,828.21\n-940.2,-877.2\n-361.62,-970\n-125.42,-178.48\n0" ], "output": [ "0\n3" ] }
{ "input": [ "4\n1.0,0.0\n0.0,1.0\n2.0,1.0\n1.0,2.0\n9\n-509.94,892.63\n567.62,639.99\n-859.32,-64.84\n-445.99,383.96\n667.54,430.49\n551.12,828.21\n-940.2,-877.2\n-361.62,-970\n-125.42,-178.48\n0", "4\n0.0,0.1\n0.0,1.0\n0.1,0.2\n1.0,2.0\n9\n-509.94,892.63\n567.62,639.99\n-859.32,-64.84\n-445.99,383.96\n667.5...
p00200 Traveling Alone: One-way Ticket of Youth
Taro is planning a long trip by train during the summer vacation. However, in order for Taro, who is a high school student, to travel as far as possible during the summer vacation, which has only one month, he cannot make a good plan unless he finds the cheapest and the fastest way. Let's create a program to help Taro'...
{ "input": [], "output": [] }
{ "input": [ "6 5\n1 2 200 10\n1 4 400 15\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 5 300 20\n2\n1 5 0\n1 5 1\n0 0" ], "output": [ "450\n35" ] }
{ "input": [ "6 5\n1 2 200 10\n1 4 400 15\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 5 300 30\n2\n1 5 0\n1 5 1\n0 0", "6 5\n1 2 200 10\n1 4 400 22\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 3 300 30\n2\n1 5 0\n1 5 1\n0 0", "6 5\n1 2 200 10\n1 4 158 22\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 3 300 30\n2\n1 5 0\n1 5...
p00355 Reservation System
The supercomputer system L in the PCK Research Institute performs a variety of calculations upon request from external institutes, companies, universities and other entities. To use the L system, you have to reserve operation time by specifying the start and end time. No two reservation periods are allowed to overlap e...
{ "input": [], "output": [] }
{ "input": [ "3 7\n3\n7 10\n1 4\n4 5", "5 7\n3\n1 4\n4 5\n7 10" ], "output": [ "1", "0" ] }
{ "input": [ "3 7\n3\n7 10\n1 4\n7 5", "5 11\n3\n1 4\n4 5\n1 2", "5 7\n3\n1 4\n4 5\n1 10", "3 7\n3\n7 10\n1 4\n8 5", "5 11\n3\n1 4\n4 5\n1 10", "3 7\n3\n13 10\n1 4\n8 5", "3 7\n3\n13 16\n1 4\n8 5", "3 11\n3\n1 4\n4 5\n1 2", "3 7\n3\n13 16\n1 4\n8 2", "3 11\n3\n1 4\n4 5\n1 1", ...
p00561 Kingdom of JOIOI
The Kingdom of JOIOI is a rectangular grid of $H \times W$ cells. In the Kingdom of JOIOI, in order to improve efficiency of administrative institutions, the country will be divided into two regions called "JOI" and "IOI." Since we do not want to divide it in a complicated way, the division must satisfy the following ...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 12 6 11\n11 10 2 14\n10 1 9 20\n4 17 19 10" ], "output": [ "11" ] }
{ "input": [ "4 4\n1 12 6 11\n11 10 1 14\n10 1 9 20\n4 17 19 10", "1 4\n1 12 6 6\n11 10 1 14\n10 1 9 20\n4 17 19 10", "4 4\n1 12 7 11\n11 10 2 0\n10 1 9 20\n4 17 19 10", "2 4\n1 12 6 14\n5 10 1 14\n10 1 5 20\n4 17 19 10", "1 4\n1 12 6 2\n11 10 1 14\n10 1 9 20\n4 25 19 10", "1 4\n1 12 6 14\n5 1...
p00714 Water Tank
Mr. Denjiro is a science teacher. Today he has just received a specially ordered water tank that will certainly be useful for his innovative experiments on water flow. <image> --- Figure 1: The water tank The size of the tank is 100cm (Width) * 50cm (Height) * 30cm (Depth) (see Figure 1). For the experiments, he fits...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n15 40\n35 20\n50 45\n70 30\n80 10\n3\n20 3\n60 2\n65 2\n6\n40 4100\n25 7500\n10 18000\n90 7000\n25 15000\n25 22000\n5\n15 40\n35 20\n50 45\n70 30\n80 10\n2\n60 4\n75 1\n3\n60 6000\n75 6000\n85 6000" ], "output": [ "0.666667\n21.4286\n36.6667\n11.1111\n40.0\n50.0\n30.0\n13.3333\n13.3333...
{ "input": [ "2\n5\n15 40\n35 20\n50 45\n70 30\n80 8\n3\n20 3\n60 2\n65 2\n6\n40 4100\n25 7500\n10 18000\n90 7000\n25 15000\n25 22000\n5\n15 40\n35 20\n50 45\n70 30\n80 10\n2\n60 4\n75 1\n3\n60 6000\n75 6000\n85 6000", "2\n5\n15 40\n35 20\n50 45\n70 30\n80 8\n3\n20 3\n60 2\n65 2\n6\n40 4100\n25 7500\n10 18000...
p00854 And Then There Was One
Let’s play a stone removing game. Initially, n stones are arranged on a circle and numbered 1, ... , n clockwise (Figure 1). You are also given two numbers k and m. From this state, remove stones one by one following the rules explained below, until only one remains. In step 1, remove stone m. In step 2, locate the k-...
{ "input": [], "output": [] }
{ "input": [ "8 5 3\n100 9999 98\n10000 10000 10000\n0 0 0" ], "output": [ "1\n93\n2019" ] }
{ "input": [ "12 5 3\n100 9999 98\n10000 10000 10000\n0 0 0", "12 2 3\n100 9999 98\n10000 10000 10000\n0 0 0", "12 2 3\n100 15522 98\n10000 10000 10000\n0 0 0", "12 2 3\n100 15914 98\n10000 10000 10000\n0 0 0", "12 2 3\n100 15914 98\n10001 10000 10000\n0 0 0", "12 2 3\n100 15914 12\n10001 1000...
p00985 Ambiguous Encoding
Ambiguous Encoding A friend of yours is designing an encoding scheme of a set of characters into a set of variable length bit sequences. You are asked to check whether the encoding is ambiguous or not. In an encoding scheme, characters are given distinct bit sequences of possibly different lengths as their codes. A ch...
{ "input": [], "output": [] }
{ "input": [ "3\n0\n01\n10" ], "output": [ "3" ] }
{ "input": [ "3\n1\n01\n10", "3\n0\n1\n10", "3\n0\n-1\n10", "3\n-1\n0\n10", "3\n-1\n0\n14", "3\n0\n01\n11", "3\n-1\n0\n16", "3\n-1\n01\n10", "3\n1\n0\n10", "3\n-1\n01\n12", "3\n1\n01\n11", "3\n1\n0\n11", "3\n-1\n0\n12", "3\n-1\n2\n12", "3\n-1\n1\n11", "3...
p01117 Scores of Final Examination
Scores of Final Examination I am a junior high school teacher. The final examination has just finished, and I have all the students' scores of all the subjects. I want to know the highest total score among the students, but it is not an easy task as the student scores are listed separately for each subject. I would li...
{ "input": [], "output": [] }
{ "input": [ "5 2\n10 20 30 40 50\n15 25 35 45 55\n6 3\n10 20 30 15 25 35\n21 34 11 52 20 18\n31 15 42 10 21 19\n4 2\n0 0 0 0\n0 0 0 0\n0 0" ], "output": [ "105\n83\n0" ] }
{ "input": [ "5 2\n10 20 30 40 50\n15 25 35 45 55\n6 3\n10 20 30 15 25 35\n21 34 11 52 20 0\n31 15 42 10 21 19\n4 2\n0 0 0 0\n0 0 0 0\n0 0", "5 2\n10 20 30 40 50\n15 25 35 85 55\n6 3\n10 20 30 15 25 35\n21 34 11 52 20 0\n31 15 42 10 21 10\n4 2\n0 0 0 0\n0 0 0 0\n0 0", "5 2\n10 20 30 40 50\n15 25 35 85 55\...
p01255 Webby Subway
You are an officer of the Department of Land and Transport in Oykot City. The department has a plan to build a subway network in the city central of Oykot. In the plan, n subway lines are built, and each line has two or more stations. Because of technical problems, a rail track between two stations should be straight ...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n0 0\n10 0\n2\n0 10\n10 10\n2\n2\n0 0\n10 10\n2\n0 10\n10 0\n3\n2\n0 0\n10 10\n2\n0 10\n10 0\n2\n1 0\n1 10\n0" ], "output": [ "1\n2\n3" ] }
{ "input": [ "2\n2\n0 0\n10 0\n2\n0 2\n10 10\n2\n2\n0 0\n10 10\n2\n0 10\n10 0\n3\n2\n0 0\n10 10\n2\n0 10\n10 0\n2\n1 0\n1 10\n0", "2\n1\n0 1\n10 0\n2\n0 2\n10 10\n2\n2\n0 0\n10 11\n2\n0 10\n4 0\n3\n2\n0 0\n10 10\n2\n0 10\n10 0\n2\n1 0\n1 10\n0", "2\n2\n0 1\n10 0\n2\n0 0\n10 10\n2\n2\n1 0\n10 11\n2\n0 10\n...
p01416 Tiles are Colorful
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 quickly solve popular puzzles and train your instantaneous power. Today's challenge is a puzzle of colorful tiles lined up and erasing them well. In the initial st...
{ "input": [], "output": [] }
{ "input": [ "3 3\nABC\nD.D\nCBA", "5 10\n..A.......\n.......B..\n..........\n..B.......\n..A.CC....", "5 7\nNUTUBOR\nQT.SZRQ\nSANAGIP\nLMDGZBM\nKLKIODP" ], "output": [ "4", "4", "34" ] }
{ "input": [ "5 7\nNBTUUOR\nQT.SZRQ\nSANAGIP\nLMDGZBM\nKLKIODP", "5 0\nNBTUUOR\nQT.SZRQ\nPIGANAS\nLMDGZBM\nPDOIKKL", "5 7\nOUTUBOR\nQT.SZRQ\nSANAGIP\nLMDGZBM\nKLKIODP", "5 7\nNBTUUOR\nQT.SZSQ\nASNAGIP\nMBYGDML\nKKLIODP", "3 7\nNUTUBOR\nRT.SZQQ\nRANCGIP\nMLZGDMB\nLDOIKPK", "5 7\nNUTUBOR\nQT.SZR...
p01570 Usoperanto
Usoperanto is an artificial spoken language designed and regulated by Usoperanto Academy. The academy is now in study to establish Strict Usoperanto, a variation of the language intended for formal documents. In Usoperanto, each word can modify at most one other word, and modifiers are always put before modifiees. For...
{ "input": [], "output": [] }
{ "input": [ "3\n3 -1\n4 0\n5 0", "3\n10 -1\n10 0\n10 1", "4\n1 -1\n1 0\n1 1\n1 0" ], "output": [ "4", "0", "1" ] }
{ "input": [ "3\n3 -1\n4 0\n4 0", "3\n19 -1\n10 0\n10 1", "4\n1 -1\n2 0\n1 1\n1 0", "4\n1 -1\n1 0\n1 1\n2 0", "3\n3 -1\n5 0\n8 0", "3\n19 -1\n11 0\n11 0", "3\n10 -1\n10 0\n10 0", "3\n10 -1\n7 0\n10 0", "3\n3 -1\n8 0\n8 0", "4\n0 -1\n1 0\n1 0\n1 0", "3\n10 -1\n9 0\n9 0", ...
p01732 Trodden Cable
Nathan O. Davis is running a company. His company owns a web service which has a lot of users. So his office is full of servers, routers and messy LAN cables. He is now very puzzling over the messy cables, because they are causing many kinds of problems. For example, staff working at the company often trip over a cabl...
{ "input": [], "output": [] }
{ "input": [ "3 3 1\n1 1 3 3\n0 0\n1 RRDDLLUU" ], "output": [ "1" ] }
{ "input": [ "3 3 0\n1 1 3 3\n0 0\n1 RRDDLLUU", "3 3 1\n1 1 1 3\n0 0\n1 RRDDLLUU", "3 3 0\n1 1 3 3\n0 0\n0 RRDDLLUU", "3 3 0\n1 1 3 3\n0 1\n0 RRDDLLUU", "3 3 0\n0 1 3 3\n0 1\n0 RRDDLLUU", "3 3 0\n0 1 3 2\n0 1\n0 RRDDLLUU", "3 6 0\n0 1 3 2\n0 1\n0 RRDDLLUU", "3 3 0\n0 1 3 3\n0 0\n1 RRDD...
p01870 Relay
Problem statement There is a village called Biwako, which consists of $ N $ islets floating on the lake. Biwako Village has a simple bridge with $ N-1 $ books. The islands are numbered from $ 0 $ to $ N-1 $, and the bridges are numbered from $ 0 $ to $ N-2 $. The $ i $ bridge directly connects the $ i + 1 $ island and...
{ "input": [], "output": [] }
{ "input": [ "5\n0 1\n0 2\n0 3\n0 4" ], "output": [ "9" ] }
{ "input": [ "5\n0 1\n0 2\n0 3\n0 6", "5\n0 1\n0 2\n0 6\n0 4", "5\n0 1\n0 2\n0 6\n0 6", "5\n0 1\n0 2\n1 6\n0 4", "5\n0 1\n0 4\n1 6\n0 4", "5\n0 1\n0 4\n1 8\n0 4", "5\n0 1\n0 4\n1 8\n0 3", "5\n0 2\n1 4\n0 8\n2 5", "5\n0 1\n0 2\n0 4\n0 4", "5\n0 1\n0 4\n1 12\n0 4", "5\n0 1\n0...
p02007 Prefix Suffix Search
As an English learner, sometimes you cannot remember the entire spelling of English words perfectly, but you can only remember their prefixes and suffixes. For example, you may want to use a word which begins with 'appr' and ends with 'iate', but forget the middle part of the word. It may be 'appreciate', 'appropriate'...
{ "input": [], "output": [] }
{ "input": [ "7 4\nconnected\ndisconnected\ngraph\ndirected\ndiameter\ndistance\nminor\nc ed\ndi ed\ndis ed\ndis e", "6 7\nappreciate\nappropriate\nacceptance\nace\nacm\nacetylene\nappr iate\na e\na a\nac ce\nace e\nacceptance acceptance\nno match", "5 5\nd\ndd\nddd\ndddd\nddddd\nd d\ndd dd\nddd ddd\nd dd...
{ "input": [ "7 4\nbonnected\ndisconnected\ngraph\ndirected\ndiameter\ndistance\nminor\nc ed\ndi ed\ndis ed\ndis e", "6 7\nappreciate\nappropriate\nacceptance\nace\nacm\nacetylene\nappr iate\na e\na a\nac ce\nace e\nacceptance acceptance\non match", "5 5\nd\ndd\nddd\ndddd\nddddd\nd e\ndd dd\nddd ddd\nd dd...
p02151 Phone Number
Problem Den, the phone number of Ukunikia Co., Ltd., enters a very long phone number into the phone every day. One day, too tired, Den came up with a surprising idea. "Isn't it even a little easier if you rearrange the arrangement of the buttons on the phone ?!" The phone has squares evenly spaced at $ 3 \ times 3 $,...
{ "input": [], "output": [] }
{ "input": [ "10\n1236547896", "11\n31415926535" ], "output": [ "123\n456\n789", "137\n456\n892" ] }
{ "input": [ "10\n1598114589", "11\n18396312558", "10\n2555486547", "10\n2722382398", "10\n2713182985", "10\n4333783596", "11\n24764186449", "10\n1859787539", "10\n1888971773", "10\n6843843631", "10\n3639938767", "10\n3398916166", "11\n31342613688", "10\n1138256...
p02292 Counter-Clockwise
<image> For given three points p0, p1, p2, print COUNTER_CLOCKWISE if p0, p1, p2 make a counterclockwise turn (1), CLOCKWISE if p0, p1, p2 make a clockwise turn (2), ONLINE_BACK if p2 is on a line p2, p0, p1 in this order (3), ONLINE_FRONT if p2 is on a line p0, p1, p2 in this order (4), ON_SEGMENT ...
{ "input": [], "output": [] }
{ "input": [ "0 0 2 0\n3\n-1 0\n0 0\n3 0", "0 0 2 0\n2\n-1 1\n-1 -1" ], "output": [ "ONLINE_BACK\nON_SEGMENT\nONLINE_FRONT", "COUNTER_CLOCKWISE\nCLOCKWISE" ] }
{ "input": [ "0 0 2 -1\n3\n-1 0\n0 0\n3 0", "0 0 4 0\n2\n-1 1\n-1 -1", "0 1 2 0\n3\n-1 0\n0 0\n3 0", "0 0 2 -1\n3\n-1 0\n0 1\n3 0", "0 0 2 -1\n1\n-2 0\n0 1\n3 1", "1 2 0 -2\n2\n0 -1\n0 0\n1 2", "1 2 -1 -2\n2\n-1 0\n0 0\n0 2", "0 2 -1 -2\n2\n-1 1\n0 0\n1 0", "-1 0 -4 0\n2\n0 7\n0 0\...
p02439 Min-Max
For given three integers $a, b, c$, print the minimum value and the maximum value. Constraints * $-1,000,000,000 \leq a, b, c \leq 1,000,000,000$ Input The input is given in the following format. $a \; b \; c\;$ Three integers $a, b, c$ are given in a line. Output Print the minimum and maximum values separate...
{ "input": [], "output": [] }
{ "input": [ "4 5 3" ], "output": [ "3 5" ] }
{ "input": [ "6 5 3", "6 5 1", "6 5 0", "6 8 0", "6 3 -1", "3 4 -1", "3 2 -1", "6 2 -2", "5 2 -2", "9 2 -2", "9 2 0", "2 1 0", "0 1 0", "0 2 -1", "0 5 -1", "0 10 -1", "-2 10 -1", "-2 8 -1", "-4 8 -1", "0 15 -2", "0 15 0", "-1 15 0...
anuthm
Problem description As a holiday gift, Tojo received a probability problem. The problem read as follows Consider an N by M grid. Rows are numbered 1 to N, from top to bottom. Columns are numbered 1 to M, from left to right. You are initially at cell (1, 1) and want to go to cell (N, M). From any cell you can move to th...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2\n1 6" ], "output": [ "3.000000\n6.000000\n" ] }
{ "input": [ "2\n1 2\n1 6", "2\n0 2\n1 6", "2\n0 1\n1 6", "2\n0 1\n2 6", "2\n0 1\n4 6", "2\n0 1\n4 11", "2\n0 1\n8 11", "2\n0 1\n8 19", "2\n0 1\n8 33", "2\n0 1\n13 33", "2\n0 1\n16 33", "2\n0 1\n18 33", "2\n0 1\n18 40", "2\n2 2\n2 6", "2\n1 2\n1 11", "2\...
chrl2
Chef likes playing with strings. The most interesting game are named "CHEF in string". The move of the game consists of the following: Chef takes a subsequence of string's letters that form the word "CHEF" and then he removes that symbols. The goal of the game is to make the maximal number of moves. Please, help Chef a...
{ "input": [], "output": [] }
{ "input": [ "CHEFCHEFFFF", "CHHHEEEFFCC" ], "output": [ "2\n", "1\n" ] }
{ "input": [ "CIEFCHEFFFF", "BHHHEEFFFCC", "CHEFCHEFGFF", "CHHHEEFFFCC", "FIEFCHECFFF", "FJEFCHECFFF", "BHIHEEFFFCC", "FJEFCHFCFFF", "BHIHEEFFFCB", "FJEFCHFCGFF", "BHIHEEFEFCB", "FJEFCHFCGFE", "BHIHEFEEFCB", "FJEFCHFCGGE", "BHIHEGEEFCB", "EFGCFHCFEJF", ...
error
Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters '0' and '1'. Now since chef is not that great in deciphering binary strings, he has decided the following crit...
{ "input": [], "output": [] }
{ "input": [ "2\n11111110\n10101010101010" ], "output": [ "Bad\nGood\n" ] }
{ "input": [ "2\n11101110\n10101010101010", "2\n11111110\n10101010111010", "2\n01010010\n10000000111111", "2\n11111111\n11000001111100", "2\n11101110\n10101010111010", "2\n11111110\n10100010111010", "2\n01111110\n10100010111010", "2\n01111010\n10100010111010", "2\n01111010\n1010001...
ksum
Chef likes arrays a lot. Today, he found an array A consisting of N positive integers. Let L denote the sorted (in non-increasing order) list of size N*(N+1)/2 containing the sums of all possible contiguous subarrays of A. Chef is interested in finding the first K elements from the list L. Can you help him in accomplis...
{ "input": [], "output": [] }
{ "input": [ "3 3\n10 2 7", "3 4\n1 3 4" ], "output": [ "19 12 10", "8 7 4 4" ] }
{ "input": [ "3 3\n15 2 7", "3 4\n10 2 7", "3 4\n1 1 4", "3 3\n15 2 6", "3 3\n15 1 6", "3 5\n15 1 6", "3 4\n1 3 1", "3 3\n15 2 0", "3 5\n10 2 7", "3 1\n15 2 6", "3 3\n23 2 6", "3 5\n15 1 3", "3 4\n2 3 1", "3 3\n13 2 0", "3 1\n27 2 6", "3 3\n2 2 6", "...
passsys
Note: For Turbo C++, select "Text" as your language   Problem Description: In IIIT we use password system to unlock the lab doors and only Mtech students are given the password for these labs. Password system comprises of n*n keypad where n is odd. One day Ashish saw an Mtech student using the password. He figured out ...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 1 0\n0 0 0\n0 1 1\n3\n1 1 0\n0 0 0\n1 1 0\n3\n1 0 1\n1 0 0\n0 0 0" ], "output": [ "Yes\nNo\nNo" ] }
{ "input": [ "3\n3\n1 1 0\n0 0 0\n0 1 1\n3\n2 1 0\n0 0 0\n1 1 0\n3\n1 0 1\n1 0 0\n0 0 0", "3\n3\n1 1 1\n0 0 0\n0 1 1\n3\n2 0 0\n0 0 0\n1 1 0\n3\n1 -1 1\n1 0 0\n0 0 0", "3\n3\n1 1 1\n0 0 0\n0 1 1\n3\n2 0 0\n0 0 0\n1 1 0\n3\n0 0 0\n1 0 1\n0 0 0", "3\n3\n1 1 0\n0 0 0\n0 1 1\n3\n2 1 0\n0 0 0\n1 1 0\n3\n1 ...
stablemp
There are given n men and n women. Each woman ranks all men in order of her preference (her first choice, her second choice, and so on). Similarly, each man sorts all women according to his preference. The goal is to arrange n marriages in such a way that if a man m prefers some woman w more than his wife, and w prefer...
{ "input": [], "output": [] }
{ "input": [ "2\n4\n1 4 3 1 2\n2 2 1 3 4\n3 1 3 4 2\n4 4 3 1 2\n1 3 2 4 1\n2 2 3 1 4\n3 3 1 2 4\n4 3 2 4 1\n7\n1 3 4 2 1 6 7 5\n2 6 4 2 3 5 1 7\n3 6 3 5 7 2 4 1\n4 1 6 3 2 4 7 5\n5 1 6 5 3 4 7 2\n6 1 7 3 4 5 6 2\n7 5 6 2 4 3 7 1\n1 4 5 3 7 2 6 1\n2 5 6 4 7 3 2 1\n3 1 6 5 4 3 7 2\n4 3 5 6 7 2 4 1\n5 1 7 6 4 3 5 2\...
{ "input": [ "2\n4\n1 4 3 1 2\n2 2 1 3 4\n3 1 3 4 2\n4 4 3 1 2\n1 3 2 4 1\n2 2 3 1 4\n3 3 1 2 4\n4 3 2 4 1\n7\n1 3 4 2 1 6 7 5\n2 6 4 2 3 5 1 7\n3 6 3 5 2 2 4 1\n4 1 6 3 2 4 7 5\n5 1 6 5 3 4 7 2\n6 1 7 3 4 5 6 2\n7 5 6 2 4 3 7 1\n1 4 5 3 7 2 6 1\n2 5 6 4 7 3 2 1\n3 1 6 5 4 3 7 2\n4 3 5 6 7 2 4 1\n5 1 7 6 4 3 5 2\...
1075_B. Taxi drivers and Lyft
Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5. Lyft has become so popular so that it is now used by all m taxi drivers in the city, who every day transport the rest of the city residents — n riders. Each resident (including taxi drivers) of Palo...
{ "input": [], "output": [] }
{ "input": [ "1 4\n2 4 6 10 15\n1 1 1 1 0\n", "3 2\n2 3 4 5 6\n1 0 0 0 1\n", "3 1\n1 2 3 10\n0 0 1 0\n" ], "output": [ "0 0 0 1\n", "2 1\n", "3\n" ] }
{ "input": [ "3 1\n1 4 3 10\n0 0 1 0\n", "1 4\n2 4 6 10 14\n1 1 1 1 0\n", "3 2\n2 1 4 5 6\n1 0 0 0 1\n", "3 1\n1 4 3 14\n0 0 1 0\n", "3 1\n1 4 5 14\n0 0 1 0\n", "3 1\n1 4 5 22\n0 0 1 0\n", "3 1\n1 4 3 11\n0 0 1 0\n", "3 1\n1 4 2 14\n0 0 1 0\n", "3 1\n1 7 5 14\n0 0 1 0\n", "3 1\...
1304_C. Air Conditioner
Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it. Gildong tries so hard to satisfy the customers that he even memorized all customers' preferred temperature ranges! Looking through the reservation list, he wants to satisfy all custo...
{ "input": [], "output": [] }
{ "input": [ "4\n3 0\n5 1 2\n7 3 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0\n" ], "output": [ "YES\nNO\nYES\nNO\n" ] }
{ "input": [ "4\n3 0\n5 1 2\n7 2 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n99 -100 0\n", "4\n3 0\n5 1 2\n7 2 5\n10 -1 0\n2 12\n5 7 10\n10 16 20\n3 -100\n100 0 0\n100 -50 50\n200 100 100\n1 100\n122 -100 0\n", "4\n3 0\n5 1 2\n7 2 5\n10 -1 0\n2 12\n5 7 10\n10 7 20\...
1369_B. AccurateLee
Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way... The string s he found is a binary string of length n (i. e. string consists only of 0-s and 1-s). In one move he can choose two consecutive characters s_i and s_{i...
{ "input": [], "output": [] }
{ "input": [ "5\n10\n0001111111\n4\n0101\n8\n11001101\n10\n1110000000\n1\n1\n" ], "output": [ "0001111111\n001\n01\n0\n1\n" ] }
{ "input": [ "5\n10\n0001111111\n4\n0101\n8\n11001101\n10\n1010000000\n1\n1\n", "5\n10\n0011111111\n4\n0101\n8\n11001101\n10\n1010000000\n1\n1\n", "5\n10\n0001111110\n4\n0101\n8\n11001101\n10\n1110000000\n1\n1\n", "5\n10\n0001111110\n4\n0101\n8\n11001101\n10\n1110000001\n1\n1\n", "5\n10\n011111111...
1431_G. Number Deletion Game
Alice and Bob play a game. They have a set that initially consists of n integers. The game is played in k turns. During each turn, the following events happen: 1. firstly, Alice chooses an integer from the set. She can choose any integer except for the maximum one. Let the integer chosen by Alice be a; 2. secondl...
{ "input": [], "output": [] }
{ "input": [ "5 2\n3 4 1 5 2\n", "7 3\n101 108 200 1 201 109 100\n" ], "output": [ "\n4\n", "\n283\n" ] }
{ "input": [], "output": [] }
984_D. XOR-pyramid
For an array b of length m we define the function f as f(b) = \begin{cases} b[1] & if m = 1 \\\ f(b[1] ⊕ b[2],b[2] ⊕ b[3],...,b[m-1] ⊕ b[m]) & otherwise, \end{cases} where ⊕ is [bitwise exclusive OR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). For example, f(1,2,4,8)=f(1⊕2,2⊕4,4⊕8)=f(3,6,12)=f(3⊕6...
{ "input": [], "output": [] }
{ "input": [ "6\n1 2 4 8 16 32\n4\n1 6\n2 5\n3 4\n1 2\n", "3\n8 4 1\n2\n2 3\n1 2\n" ], "output": [ "60\n30\n12\n3\n", "5\n12\n" ] }
{ "input": [ "6\n1 2 4 8 16 32\n4\n1 6\n2 5\n3 6\n1 2\n", "3\n16 4 1\n2\n2 3\n1 2\n", "6\n1 2 4 8 16 32\n4\n1 6\n2 5\n3 6\n1 3\n", "3\n5 4 1\n2\n2 3\n1 2\n", "6\n1 2 4 8 16 32\n4\n1 6\n2 5\n3 6\n1 1\n", "6\n1 2 4 8 16 32\n4\n1 6\n3 5\n3 6\n1 3\n", "3\n5 4 0\n2\n2 3\n1 2\n", "6\n1 2 1 8...
aabbaac
You are given an array S of N strings numbered from 0 to N-1. You build string sequence Ti by the following rules: T0 = S0 Ti = Ti-1 + reverse(Ti-1) + Si Now please answer M queries: by non-negative integer x output x-th character of the TN-1 in 0-based indexation. It's guaranteed that x-th character of the TN-1 exi...
{ "input": [], "output": [] }
{ "input": [ "2\n3 7\na\nb\nc\n0\n1\n2\n3\n4\n5\n6\n2 6\nty\nqwe\n0\n2\n3\n4\n6\n1\n\nSAMPLE" ], "output": [ "aabbaac\ntytqey" ] }
{ "input": [ "2\n3 7\na\nb\nc\n0\n1\n2\n3\n4\n5\n6\n2 6\nty\nqwe\n0\n2\n3\n4\n0\n1\n\nSAMPLE", "2\n3 7\na\nb\nc\n0\n1\n2\n3\n4\n5\n6\n2 6\nty\nqwe\n0\n0\n3\n4\n0\n1\n\nSAMPLE", "2\n3 7\na\nb\nc\n0\n1\n2\n3\n4\n5\n6\n2 6\nty\nqwe\n0\n0\n4\n4\n0\n1\n\nSAMPME", "2\n3 7\na\nc\nc\n0\n1\n2\n3\n4\n5\n6\n2 6\...
crushing-violence
The students of college XYZ are getting jealous of the students of college ABC. ABC managed to beat XYZ in all the sports and games events. The main strength of the students of ABC is their unity. The students of XYZ decide to destroy this unity. The geeks of XYZ prepared a special kind of perfume. Anyone who inhales...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n2 2 1\n3 2 1\n4\n2 3 4 1\n2 3 4 1\n\nSAMPLE" ], "output": [ "1 0\n1 4" ] }
{ "input": [], "output": [] }
jp-and-rotations
Kabra is a very good friend of JP. So JP has assigned him a task. Given an array, two operations can be performed on it. They are 1) L X : Rotate the array towards left by X. 2) R X : Rotate the array towards right by X. Now you will be given 2 arrays containing N unique elements. The first one is the inital array(A) a...
{ "input": [], "output": [] }
{ "input": [ "4 4\n2 1 3 4\n3 4 2 1\nR 1\nL 2\nL 1\nL 5\n\nSAMPLE" ], "output": [ "3\n" ] }
{ "input": [ "4 3\n2 1 3 4\n3 4 2 1\nR 1\nL 2\nL 1\nL 5\n\nSAMPLE", "4 3\n2 1 3 4\n3 4 2 1\nR 1\nL 0\nL 1\nL 5\n\nSAMPLE", "4 4\n2 1 3 4\n3 4 2 1\nR 1\nL 2\nL 0\nL 5\n\nSAMELP", "4 3\n2 1 3 4\n3 4 2 1\nR 2\nL 0\nL 1\nL 7\n\nSAMPLE", "4 4\n2 1 3 4\n3 4 2 1\nR 1\nL 2\nL 1\nL 5\n\nSAMELP", "4 3\n...
milly-and-magical-array-3
Milly is playing with an Array A of size N. She wants to convert this array into a magical array. This magical array satisfies the condition Ai-1 < Ai where i ∈ [2, N] . She can add a value X to any element of this array any number of times. Your task is to tell her the minimum number of such addition of X are required...
{ "input": [], "output": [] }
{ "input": [ "2\n2 1\n1 1\n3 1\n1 1 2\n\nSAMPLE" ], "output": [ "1\n2\n" ] }
{ "input": [ "2\n2 1\n1 2\n3 1\n1 1 2\n\nSAMPLE", "2\n2 1\n2 2\n3 1\n1 1 2\n\nSAMELP", "2\n2 1\n1 2\n3 1\n1 1 3\n\nSAMPLE", "2\n2 2\n2 2\n3 1\n1 1 4\n\nSAMELP", "2\n2 1\n1 1\n3 2\n1 1 0\n\nSAMELP", "2\n2 1\n2 13\n3 2\n1 2 4\n\nSAMELP", "2\n2 1\n2 2\n3 2\n0 1 2\n\nSAMEKP", "2\n2 1\n0 1\...
pairs-5
King Klee's kingdom is under attack. He leaves the task of protecting his kingdom to you as you are Now you are given N teams of soldiers. There are 3 gates --> Large, Larger, Largest. You need to form three teams from these N teams to send them to those three gates. But the order should follow certain conditions ...L...
{ "input": [], "output": [] }
{ "input": [ "4\n3\n3\n1\n4\n\nSAMPLE" ], "output": [ "4" ] }
{ "input": [], "output": [] }
p02572 AtCoder Beginner Contest 177 - Sum of product of pairs
Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). Constraints * 2 \leq N \leq 2\times 10^5 * 0 \leq A_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N A_1 \ldot...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2 3", "4\n141421356 17320508 22360679 244949" ], "output": [ "11", "437235829" ] }
{ "input": [ "3\n0 2 3", "4\n141421356 17320508 22360679 176612", "3\n0 2 0", "4\n141421356 17320508 44188846 176612", "4\n141421356 15438004 44188846 176612", "4\n141421356 15438004 10545868 176612", "4\n141421356 22198551 10545868 176612", "4\n141421356 22198551 4405286 176612", ...
p02703 AtCoder Beginner Contest 164 - Two Currencies
There are N cities numbered 1 to N, connected by M railroads. You are now at City 1, with 10^{100} gold coins and S silver coins in your pocket. The i-th railroad connects City U_i and City V_i bidirectionally, and a one-way trip costs A_i silver coins and takes B_i minutes. You cannot use gold coins to pay the fare....
{ "input": [], "output": [] }
{ "input": [ "2 1 0\n1 2 1 1\n1 1000000000\n1 1", "3 2 1\n1 2 1 2\n1 3 2 4\n1 11\n1 2\n2 5", "4 6 1000000000\n1 2 50 1\n1 3 50 5\n1 4 50 7\n2 3 50 2\n2 4 50 4\n3 4 50 3\n10 2\n4 4\n5 5\n7 7", "6 5 1\n1 2 1 1\n1 3 2 1\n2 4 5 1\n3 5 11 1\n1 6 50 1\n1 10000\n1 3000\n1 700\n1 100\n1 1\n100 1", "4 4 1\...
{ "input": [ "2 1 1\n1 2 1 1\n1 1000000000\n1 1", "3 2 1\n1 2 1 2\n1 3 2 4\n1 11\n1 2\n2 1", "4 6 1000000000\n1 2 50 1\n1 3 50 5\n1 4 50 7\n2 3 50 2\n1 4 50 4\n3 4 50 3\n10 2\n4 4\n5 5\n7 7", "6 5 1\n1 2 1 1\n1 3 2 0\n2 4 5 1\n3 5 11 1\n1 6 50 1\n1 10000\n1 3000\n1 700\n1 100\n1 1\n100 1", "6 5 1\...
p02832 AtCoder Beginner Contest 148 - Brick Break
We have N bricks arranged in a row from left to right. The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it. Among them, you can break at most N-1 bricks of your choice. Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of t...
{ "input": [], "output": [] }
{ "input": [ "3\n2 2 2", "10\n3 1 4 1 5 9 2 6 5 3", "1\n1", "3\n2 1 2" ], "output": [ "-1", "7", "0", "1" ] }
{ "input": [ "3\n0 2 2", "10\n3 1 4 1 5 9 2 6 3 3", "3\n1 1 2", "3\n1 1 3", "10\n3 1 4 1 5 17 1 11 0 3", "10\n3 1 9 1 20 0 2 1 -1 6", "1\n001", "1\n2", "3\n-1 2 2", "10\n3 1 4 1 5 9 2 6 4 3", "1\n0", "3\n0 1 2", "3\n-1 2 0", "10\n3 1 4 1 5 17 2 6 4 3", "1\n-...
p02969 AtCoder Beginner Contest 134 - Dodecagon
It is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2. Given an integer r, find the area of a regular dodecagon inscribed in a circle of radius r. Constraints * 1 \leq r \leq 100 * r is an integer. Input Input is given from Standard Input in the following format: r Output ...
{ "input": [], "output": [] }
{ "input": [ "4", "15", "80" ], "output": [ "48", "675", "19200" ] }
{ "input": [ "6", "25", "133", "10", "3", "136", "18", "2", "155", "30", "0", "54", "60", "-1", "11", "40", "32", "20", "-4", "39", "9", "17", "8", "-7", "22", "33", "-13", "-5", "64", "66", "12...
p03105 AtCoder Beginner Contest 120 - Favorite Sound
Takahashi likes the sound when he buys a drink from a vending machine. That sound can be heard by spending A yen (the currency of Japan) each time. Takahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, as he would be satisfied at that time. How many times will he h...
{ "input": [], "output": [] }
{ "input": [ "3 9 5", "2 11 4", "100 1 10" ], "output": [ "3", "4", "0" ] }
{ "input": [ "3 1 5", "2 14 4", "1 13 2", "1 19 7", "1 19 13", "111 -1 33", "1 19 25", "2 2 2", "001 7 5", "001 0 -2", "1 19 12", "1 6 12", "001 9 13", "011 2 -4", "1 3 3", "001 11 13", "011 2 -5", "1 8 12", "001 2 -7", "1 -3 0", "6 3...
p03252 AtCoder Beginner Contest 110 - String Transformation
You are given strings S and T consisting of lowercase English letters. You can perform the following operation on S any number of times: Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1. Determine if S and T can ...
{ "input": [], "output": [] }
{ "input": [ "azzel\napple", "abcdefghijklmnopqrstuvwxyz\nibyhqfrekavclxjstdwgpzmonu", "chokudai\nredcoder" ], "output": [ "Yes", "Yes", "No" ] }
{ "input": [ "azzel\napqle", "abcdefghijklmnopqrstuvwxyz\nunomzpgwdtsjxlcvakerfqhybi", "ihokudac\nredcoder", "azzle\napqle", "zyxwvutsrqponmlkjihgfedcba\nunomzpgwdtsjxlcvakerfqhybi", "cadukohi\nredcoder", "azzle\napqld", "zyxwvutsrqponmlkjihgfedcba\nunonzpgwdtsjxlcvakerfqhybi", "ih...
p03405 AtCoder Regular Contest 093 - Bichrome Spanning Tree
We have an undirected weighted graph with N vertices and M edges. The i-th edge in the graph connects Vertex U_i and Vertex V_i, and has a weight of W_i. Additionally, you are given an integer X. Find the number of ways to paint each edge in this graph either white or black such that the following condition is met, mo...
{ "input": [], "output": [] }
{ "input": [ "5 4\n1\n1 2 3\n1 3 3\n2 4 6\n2 5 8", "8 10\n49\n4 6 10\n8 4 11\n5 8 9\n1 8 10\n3 8 128773450\n7 8 10\n4 2 4\n3 4 1\n3 1 13\n5 2 2", "3 3\n2\n1 2 1\n2 3 1\n3 1 1", "3 3\n3\n1 2 1\n2 3 1\n3 1 2" ], "output": [ "0", "4", "6", "2" ] }
{ "input": [ "5 4\n1\n1 2 3\n2 3 3\n2 4 6\n2 5 8", "8 10\n49\n4 6 10\n8 4 11\n5 8 9\n1 8 10\n3 8 128773450\n7 8 10\n4 2 4\n6 4 1\n3 1 13\n5 2 2", "3 3\n2\n1 2 1\n2 3 1\n3 1 2", "3 3\n2\n1 2 1\n1 3 1\n3 1 1", "3 3\n2\n1 2 0\n2 3 1\n3 1 2", "8 10\n49\n4 6 0\n5 4 11\n2 8 9\n1 8 10\n3 8 128773450\...
p03568 CODE FESTIVAL 2017 qual C - Similar Arrays
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many ...
{ "input": [], "output": [] }
{ "input": [ "10\n90 52 56 71 44 8 13 30 57 84", "2\n2 3", "1\n100", "3\n3 3 3" ], "output": [ "58921", "7", "1", "26" ] }
{ "input": [ "10\n90 101 56 71 44 8 13 30 57 84", "2\n2 4", "1\n000", "3\n3 3 2", "10\n41 101 56 71 44 8 13 30 57 84", "2\n3 6", "1\n011", "3\n3 2 0", "10\n60 101 56 71 44 8 13 30 114 84", "3\n1 1 -1", "3\n2 2 0", "2\n-1 1", "10\n105 100 11 98 11 7 6 43 114 135", ...
p03723 AtCoder Grand Contest 014 - Cookie Exchanges
Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below: * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons. This action will be repeated until there is a person ...
{ "input": [], "output": [] }
{ "input": [ "14 14 14", "454 414 444", "4 12 20" ], "output": [ "-1", "1", "3" ] }
{ "input": [ "15 14 14", "454 414 846", "454 414 1200", "1390 18 4202", "0 0 0", "4 12 13", "15 14 7", "4 0 13", "15 17 7", "781 414 1200", "3 0 13", "15 17 13", "781 94 1200", "6 0 13", "15 25 13", "1390 94 1200", "6 0 24", "17 25 13", "1390...
p03886 CODE FESTIVAL 2016 Grand Final(Parallel) - 90 and 270
Construct an N-gon that satisfies the following conditions: * The polygon is simple (see notes for the definition). * Each edge of the polygon is parallel to one of the coordinate axes. * Each coordinate is an integer between 0 and 10^9, inclusive. * The vertices are numbered 1 through N in counter-clockwise order. * ...
{ "input": [], "output": [] }
{ "input": [ "8\n90\n90\n270\n90\n90\n90\n270\n90", "3\n90\n90\n90" ], "output": [ "0 0\n2 0\n2 1\n3 1\n3 2\n1 2\n1 1\n0 1", "-1" ] }
{ "input": [ "3\n90\n9\n90", "3\n90\n9\n160", "3\n90\n3\n160", "3\n42\n3\n160", "3\n42\n5\n160", "3\n28\n5\n160", "3\n28\n4\n160", "3\n12\n4\n160", "3\n12\n0\n160", "3\n12\n1\n160", "3\n6\n1\n160", "3\n1\n1\n160", "3\n1\n1\n253", "3\n1\n0\n253", "3\n1\n1\n46...
p04044 AtCoder Beginner Contest 042 - Iroha Loves Strings (ABC Edition)
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is lexicographically sma...
{ "input": [], "output": [] }
{ "input": [ "3 3\ndxx\naxx\ncxx" ], "output": [ "axxcxxdxx" ] }
{ "input": [ "3 3\ndxx\naxx\ndxx", "3 3\ndxx\naxx\nxxd", "3 3\ndxx\nxxa\nxxd", "3 3\ncxx\nxxa\nxxd", "3 3\ndxx\n`xx\ncxx", "3 3\nxdx\naxx\ndxx", "3 3\nxxd\naxx\nxxd", "3 3\nxxd\nxxa\nxxd", "3 3\ncxx\naxx\nxxd", "3 3\nxxd\n`xx\ncxx", "3 3\nxdx\naxw\ndxx", "3 3\nwxd\naxx\...
p00125 Day Count
Create a program that takes two dates as input and outputs the number of days between the two dates. Date 1 (y1, m1, d1) is the same as or earlier than date 2 (y2, m2, d2). Date 1 is included in the number of days, not date 2. Also, take the leap year into account when calculating. The leap year conditions are as foll...
{ "input": [], "output": [] }
{ "input": [ "2006 9 2 2006 9 3\n2006 9 2 2006 11 11\n2004 1 1 2005 1 1\n2000 1 1 2006 1 1\n2000 1 1 2101 1 1\n-1 -1 -1 -1 -1 -1" ], "output": [ "1\n70\n366\n2192\n36890" ] }
{ "input": [ "2006 9 2 522 9 3\n2006 9 2 2006 11 11\n2004 1 1 2005 1 1\n2000 1 1 2006 1 1\n2000 1 1 2101 1 1\n-1 -1 -1 -1 -1 -1", "2006 9 2 2006 9 2\n2006 9 2 2006 11 11\n2004 1 1 2005 1 1\n2000 1 1 2006 1 1\n2000 1 1 2101 1 1\n-1 -1 -1 -1 -1 -1", "2006 9 2 522 9 3\n2006 9 1 2006 11 11\n2004 1 1 2005 1 1\...
p00258 Beat Panel
Yuta is addicted to the popular game "Beat Panel" at a nearby arcade. The game consists of a total of 16 panel-type buttons, 4x4, arranged in a grid as shown. <image> As shown in the figure, the buttons are arranged in the order of button 1, button 2,…, button 16 from the upper left to the lower right. In the game, ...
{ "input": [], "output": [] }
{ "input": [ "2 2\n0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1\n1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0\n0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1\n1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0\n2 2\n0 0 1 0 1 1 1 1 0 0 1 0 0 0 1 0\n0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0\n0 0 1 0 1 0 0 0 0 0 1 0 0 0 1 0\n0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0\n5 3\n0 0 0 0 0 1 1 0 0 1 1...
{ "input": [ "2 2\n0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1\n1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0\n0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1\n1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0\n2 2\n0 0 1 0 1 1 1 1 0 0 1 0 0 0 1 0\n0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0\n0 0 1 0 1 0 0 0 0 0 1 0 0 0 1 0\n0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0\n5 3\n0 0 0 0 0 1 1 0 0 1 1...
p00445 JOI and IOI
problem Create a program that counts the number of consecutive JOI or IOI characters in a given character string. The character string consists only of uppercase letters of the alphabet. For example, the character string "JOIOIOI" in the figure below contains JOI in one place and IOI in two places. <image> input ...
{ "input": [], "output": [] }
{ "input": [ "JOIJOI\nJOIOIOIOI\nJOIOIJOINXNXJIOIOIOJ", "None" ], "output": [ "2\n0\n1\n3\n2\n3", "None" ] }
{ "input": [ "JOIJOI\nJOIOIOIOI\nJOIOIOIJXNXNIOJIOIOJ", "eonN", "JOIJOI\nJOIOINIOI\nJOIOIOIJXNXNIOJIOIOJ", "JOIJOI\nJOIOINIOI\nJOIOIJOINXNXJIOIOIOJ", "JOIJOI\nJOIOINIOI\nJOIPIJOINXNXJIOIOIOJ", "JOIJOH\nJOIOINIOI\nJOIPIJOINXNXJIOIOIOJ", "JOIJOG\nJOIOINIOI\nJOIPIJOINXOXJINIOIOJ", "GOJIOJ...
p00636 The Last Dungeon
Brave Ponta has finally arrived at the final dungeon. This is a dark wilderness in front of the fort of the evil emperor Boromos, with fairly strong monsters guarding their territories. <image> Figure 1: Wilderness As shown in Fig. 1, the wilderness is represented by a 4 × 4 square region with the southwest as the ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1\n3 3\n4\n1.0 0.5\n1.0 2.5\n3.0 1.5\n3.0 3.5\n1\n2.0 2.0\n0" ], "output": [ "5.656854249492\n4.618033988750\nimpossible" ] }
{ "input": [ "2\n1 1\n3 3\n4\n1.0 0.5\n1.0 2.5\n3.0 1.5\n3.0 3.589169796022375\n1\n2.0 2.0\n0", "2\n1 1\n3 3\n4\n1.1278569475953018 0.5\n1.0 2.5\n3.0 1.5\n3.0 3.5\n1\n2.0 2.0\n0", "2\n1 1\n5 3\n4\n1.0 0.5\n1.0 2.5\n3.0 1.5\n3.0 3.589169796022375\n1\n2.0 2.0\n0", "2\n1 1\n3 3\n4\n1.1278569475953018 0.5...
p00779 Don't Cross the Circles!
Don't Cross the Circles! There are one or more circles on a plane. Any two circles have different center positions and/or different radiuses. A circle may intersect with another circle, but no three or more circles have areas nor points shared by all of them. A circle may completely contain another circle or two circl...
{ "input": [], "output": [] }
{ "input": [ "5 3\n0 0 1000\n1399 1331 931\n0 1331 500\n1398 0 400\n2000 360 340\n450 950 1600 380\n450 950 1399 1331\n450 950 450 2000\n1 2\n50 50 50\n0 10 100 90\n0 10 50 50\n2 2\n50 50 50\n100 50 50\n40 50 110 50\n40 50 0 0\n4 1\n25 100 26\n75 100 26\n50 40 40\n50 160 40\n50 81 50 119\n6 1\n100 50 40\n0 50 40\...
{ "input": [ "5 3\n0 0 1000\n1399 1331 931\n0 1331 500\n1398 0 400\n2000 360 340\n450 950 1600 380\n450 950 1399 1331\n450 950 450 2000\n1 2\n50 50 50\n0 10 100 90\n0 10 50 50\n2 2\n50 50 50\n100 50 50\n40 50 110 50\n40 50 0 0\n4 1\n25 100 26\n75 100 26\n50 40 40\n50 160 40\n50 81 50 119\n6 1\n100 50 40\n0 50 40\...
p00910 Let There Be Light
Suppose that there are some light sources and many spherical balloons. All light sources have sizes small enough to be modeled as point light sources, and they emit light in all directions. The surfaces of the balloons absorb light and do not reflect light. Surprisingly in this world, balloons may overlap. You want th...
{ "input": [], "output": [] }
{ "input": [ "12 5 4\n0 10 0 1\n1 5 0 2\n1 4 0 2\n0 0 0 2\n10 0 0 1\n3 -1 0 2\n5 -1 0 2\n10 10 0 15\n0 -10 0 1\n10 -10 0 1\n-10 -10 0 1\n10 10 0 1\n0 10 0 240\n10 0 0 200\n10 -2 0 52\n-10 0 0 100\n1 1 0 2\n0 0 0\n12 5 4\n0 10 0 1\n1 5 0 2\n1 4 0 2\n0 0 0 2\n10 0 0 1\n3 -1 0 2\n5 -1 0 2\n10 10 0 15\n0 -10 0 1\n10 ...
{ "input": [ "12 5 4\n0 10 0 1\n1 5 0 2\n1 4 0 2\n0 0 0 2\n10 0 0 1\n3 -1 0 2\n5 -1 0 2\n10 10 0 15\n0 -10 0 1\n10 -10 0 1\n-10 -10 0 1\n10 10 0 1\n0 10 0 240\n10 0 0 200\n10 -2 0 52\n-10 0 0 100\n1 1 0 2\n0 1 0\n12 5 4\n0 10 0 1\n1 5 0 2\n1 4 0 2\n0 0 0 2\n10 0 0 1\n3 -1 0 2\n5 -1 0 2\n10 10 0 15\n0 -10 0 1\n10 ...
p01044 Puzzle and Hexagons
Backgorund The super popular game "Puzzle & Hexagons" has finally been released. This game is so funny that many people are addicted to it. There were a number of people who were certified as addicted by doctors because of their excessive enthusiasm. Volunteers from around the world have created a "Puzzle & Hexagons" ...
{ "input": [], "output": [] }
{ "input": [ "4 5\nBYYGG\nRRRRR\nRRBRR\nYYGGB\n2\n3 1\n3 1", "3 3\nRGR\nRBP\nYEB\n1\n1 1", "4 4\nBEEP\nERYY\nBBRP\nRBYP\n1\n1 2" ], "output": [ ".....\n.....\n.....\nB.BGB", "…\nYBG\nEBP", "....\n....\n....\n.B.." ] }
{ "input": [ "4 4\nBEEP\nYYRE\nBBRP\nRBYP\n1\n1 2", "3 3\nRGR\nRBP\nYEB\n1\n1 2", "3 3\nGRR\nRBP\nYEB\n1\n1 1", "4 4\nBEEP\nERYY\nBBRP\nRBYP\n1\n1 3", "3 3\nGRR\nRBP\nYEB\n1\n1 0", "4 5\nBYYGG\nRRRRR\nRRBRR\nYYGGB\n2\n4 1\n3 1", "4 4\nBEEP\nYYRE\nBBRP\nRBYP\n1\n2 2", "3 3\nGRR\nRBP\nBE...
p01177 Entangled Tree
The electronics division in Ishimatsu Company consists of various development departments for electronic devices including disks and storages, network devices, mobile phones, and many others. Each department covers a wide range of products. For example, the department of disks and storages develops internal and externa...
{ "input": [], "output": [] }
{ "input": [ "3 2 3\n10 2 1 2\n20 2 3 2\n1\n2\n3\n5 2 5\n10 3 1 2 4\n20 3 2 3 5\n1\n2\n3\n4\n5\n4 1 4\n10 2 1 4\n1\n2\n3\n4\n4 3 4\n30 2 1 4\n20 2 2 4\n10 2 3 4\n1\n2\n3\n4\n4 3 4\n10 2 1 4\n20 2 2 4\n30 2 3 4\n1\n2\n3\n4\n4 3 4\n10 2 1 2\n15 2 1 4\n20 2 2 3\n1\n2\n3\n4\n3 2 3\n10 2 2 3\n20 2 1 2\n1\n2\n3\n1 0 1\...
{ "input": [ "3 2 3\n10 2 1 2\n20 2 3 2\n1\n2\n3\n5 2 5\n10 3 1 2 4\n20 3 2 3 5\n1\n2\n3\n4\n5\n4 1 4\n10 2 1 4\n1\n2\n2\n4\n4 3 4\n30 2 1 4\n20 2 2 4\n10 2 3 4\n1\n2\n3\n4\n4 3 4\n10 2 1 4\n20 2 2 4\n30 2 3 4\n1\n2\n3\n4\n4 3 4\n10 2 1 2\n15 2 1 4\n20 2 2 3\n1\n2\n3\n4\n3 2 3\n10 2 2 3\n20 2 1 2\n1\n2\n3\n1 0 1\...
p01314 Sum of Consecutive Integers
You survived several months of exam wars and were able to enter ICPC University on a sunny day. On the day of admission, there was an enthusiastic recruitment of circles on the campus of the university, and you received a large number of pamphlets and returned. When you return to your room, you find one of the pamphlet...
{ "input": [], "output": [] }
{ "input": [ "9\n500\n0" ], "output": [ "2\n3" ] }
{ "input": [ "9\n256\n0", "9\n160\n0", "9\n213\n0", "9\n200\n0", "9\n135\n0", "9\n350\n0", "9\n0\n-1", "9\n162\n0", "9\n315\n0", "9\n225\n0", "9\n166\n0", "9\n190\n0", "9\n235\n0", "9\n336\n0", "9\n73\n0", "9\n156\n0", "9\n319\n0", "9\n152\n0", ...
p01482 Memory Leak
Time Limit: 8 sec / Memory Limit: 64 MB Example Input 100 A=malloc(10) B=clone(A) free(A) Output 0
{ "input": [], "output": [] }
{ "input": [ "100\nA=malloc(10)\nB=clone(A)\nfree(A)" ], "output": [ "0" ] }
{ "input": [ "100\nA=malloc(10)\nB=clone(A)\nfrde(A)", "100\n1=malloc(A0)\nB=clone(A)\nfrde)A(", "100\nA=malloc(10)\nB=clone(A)\nfrde)A(", "100\nA=malloc(10)\nB=clone(A)\nfree'A)", "100\n1=malloc(A0)\nB=clone(A)\nf(de)Ar", "100\nA=malloc(10)\nB(clone=A)\nfrde(A)", "100\nA=malloc(10)\nB=clo...
p01643 Avant-garde Art
ICPC World Finals Day 6 Russian Constructivism is an art movement in the Soviet Union that began in the mid-1910s. Inspired by such things, Tee, who had been in Country R for a long time, decided to create a cool design despite the rehearsal of the ICPC World Finals. Mr. Tee says: "A circle and a line segment are enou...
{ "input": [], "output": [] }
{ "input": [ "n k\na" ], "output": [ "2" ] }
{ "input": [ "o k\na", "m k\na", "n k\n`", "o k\n`", "o j\n`", "p j\n`", "p i\n`", "p i\na", "o i\na", "p j\na", "q j\na", "q j\n`", "r j\n`", "r i\n`", "q i\n`", "q i\n_", "q j\nb", "q i\na", "p i\n_", "q i\n^", "q i\n]", "q h\n]...
p01795 ICPC Teams
Example Input 2 2 1 2 0 3 4 1 Output 2
{ "input": [], "output": [] }
{ "input": [ "2 2\n1 2 0\n3 4 1" ], "output": [ "2" ] }
{ "input": [ "2 0\n1 2 0\n3 4 1", "3 0\n1 2 1\n6 0 1", "0 0\n2 0 1\n5 0 2", "4 0\n1 0 1\n5 0 0", "2 1\n1 2 1\n3 3 1", "8 0\n-2 0 1\n12 2 12", "4 1\n1 2 0\n3 6 1", "2 1\n1 2 0\n6 1 2", "2 0\n1 2 1\n3 4 1", "2 0\n1 2 1\n3 0 1", "2 0\n1 2 1\n6 0 1", "3 0\n1 2 1\n5 0 1", ...
p01929 Room Assignment
Hey! There is a new building with N + 1 rooms lined up in a row. Each room is a residence for one person, and all rooms are currently vacant, but N new people are scheduled to live here from next month. Therefore, when they start living, one room becomes vacant. As a landlord, you want to propose many room allocation...
{ "input": [], "output": [] }
{ "input": [ "2\n2 1\n3\n3 1 2\n10\n2 1 1 1 1 1 1 1 1 1\n8\n2 1 4 3 3 7 6 6\n25\n2 3 2 5 4 5 8 7 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24\n10\n2 1 4 3 6 5 8 7 10 9\n0" ], "output": [ "2\n0\n0\n144\n633544712\n11520" ] }
{ "input": [ "2\n2 1\n3\n3 1 2\n10\n2 1 1 1 1 1 1 1 1 1\n8\n2 1 4 3 3 7 6 6\n25\n2 3 2 5 4 5 8 7 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 24\n10\n2 1 1 3 6 5 8 7 10 9\n0", "2\n2 1\n3\n3 1 2\n10\n2 1 1 1 1 1 1 1 1 1\n8\n2 1 4 3 3 7 6 6\n25\n2 3 2 5 4 5 8 9 8 11 10 13 12 15 14 17 16 19 18 21 20 23 22 25 2...
p02067 AIGo
Problem Statement Recently, AIs which play Go (a traditional board game) are well investigated. Your friend Hikaru is planning to develop a new awesome Go AI named Sai and promote it to company F or company G in the future. As a first step, Hikaru has decided to develop an AI for 1D-Go, a restricted version of the ori...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02209 Are Cards Snacks?
Does the card fit in a snack? (Are Cards Snacks?) square1001 You have $ N $ cards. Each of these cards has an integer written on it, and the integer on the $ i $ th card is $ A_i $. square1001 Your random number today is $ K $. square1001 You want to choose some of these $ N $ cards so that they add up to $ K $. E8...
{ "input": [], "output": [] }
{ "input": [ "5 9\n8 6 9 1 2" ], "output": [ "2" ] }
{ "input": [ "7 9\n8 6 9 1 2", "7 9\n8 6 12 1 2", "7 9\n8 6 12 2 0", "7 1\n2 8 -1 1 1", "7 9\n8 6 12 1 0", "7 9\n8 6 23 2 0", "7 9\n13 6 23 2 0", "7 9\n21 6 23 2 0", "7 9\n18 6 23 2 0", "7 9\n18 6 39 2 0", "7 9\n18 6 62 2 0", "7 9\n18 6 37 2 0", "10 9\n18 6 37 2 0",...
p02363 All Pairs Shortest Path
Constraints * 1 ≤ |V| ≤ 100 * 0 ≤ |E| ≤ 9900 * -2 × 107 ≤ di ≤ 2 × 107 * There are no parallel edges * There are no self-loops Input An edge-weighted graph G (V, E). |V| |E| s0 t0 d0 s1 t1 d1 : s|E|-1 t|E|-1 d|E|-1 |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named wi...
{ "input": [], "output": [] }
{ "input": [ "4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7", "4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7", "4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7" ], "output": [ "0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0", "NEGATIVE CYCLE", "0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0"...
{ "input": [ "4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 8\n2 3 1\n3 2 -7", "4 6\n0 1 1\n0 3 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7", "4 6\n0 1 1\n0 2 5\n1 2 3\n1 3 4\n2 3 1\n3 2 7", "4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 8\n0 3 1\n3 2 -7", "4 6\n0 1 2\n0 2 5\n1 2 2\n1 3 8\n0 3 1\n3 2 -7", "4 6\n0 1 2\n0 3 -5\n1 2 2\n1 3 ...
cd1it1
Given an array A[1..N] of N non-negative integers, you need to find the median of the array. The median of an array is the middle element in its sorted order. If N is even, choose the (N/2)^th element in the sorted order. Input The first line contains N, the number of integers in the array. The next line has N integer...
{ "input": [], "output": [] }
{ "input": [ "6\n17 13 10 1 3 1", "5\n9 34 1 290 32" ], "output": [ "3", "32" ] }
{ "input": [ "6\n17 13 18 1 3 1", "5\n15 34 1 290 32", "5\n15 34 1 290 61", "6\n17 13 18 -1 2 1", "5\n15 0 1 290 61", "5\n29 1 0 219 61", "5\n29 2 0 18 61", "5\n29 4 0 -1 61", "5\n29 1 0 -2 21", "6\n7 0 2 0 0 2", "5\n2 -1 -1 -1 1", "6\n-2 0 0 -2 -6 1", "6\n-3 1 0 -3...
ct03
Problem description. Chef decides to distribute fancy stationary among kids. Chef has collection of erasers and pencils . Each kid needs to be given a pencil and eraser. Your job is to help find Chef how many kids can get the stationary and how many min pencils or erasers the chef will need to clear the stock that is l...
{ "input": [], "output": [] }
{ "input": [ "2\nEPPEP\nEPPPPEE" ], "output": [ "2 1\n3 1" ] }
{ "input": [], "output": [] }
hotel
A holiday weekend is coming up, and Hotel Bytelandia needs to find out if it has enough rooms to accommodate all potential guests. A number of guests have made reservations. Each reservation consists of an arrival time, and a departure time. The hotel management has hired you to calculate the maximum number of guests t...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 2 3\n4 5 6\n5\n1 2 3 4 5\n2 3 4 5 6\n7\n13 6 5 8 2 10 12\n19 18 6 9 9 11 15" ], "output": [ "3\n1\n3\n" ] }
{ "input": [ "3\n3\n1 2 3\n4 5 6\n5\n1 2 3 4 5\n2 4 4 5 6\n7\n13 6 5 8 2 10 12\n19 18 6 9 9 11 15", "3\n3\n1 2 3\n4 5 6\n5\n1 2 3 4 1\n2 4 4 5 6\n7\n13 6 5 8 2 10 12\n19 18 6 9 9 11 15", "3\n3\n1 2 3\n4 5 7\n5\n1 2 3 4 1\n2 4 4 5 6\n7\n13 6 5 8 2 10 12\n19 18 6 16 9 11 15", "3\n3\n1 2 3\n4 5 6\n5\n1 2...
montrans
You are standing near a very strange machine. If you put C cents in the machine, the remaining money in your purse will transform in an unusual way. If you have A dollars and B cents remaining in your purse after depositing the C cents, then after the transformation you will have B dollars and A cents. You can repeat t...
{ "input": [], "output": [] }
{ "input": [ "2\n9 77 69\n98 99 69" ], "output": [ "4\n0\n" ] }
{ "input": [ "2\n9 77 69\n98 73 69", "2\n9 72 69\n98 3 69", "2\n11 72 69\n98 3 69", "2\n11 72 69\n98 2 69", "2\n11 72 69\n78 2 91", "2\n11 72 69\n78 2 28", "2\n9 77 69\n98 99 104", "2\n9 77 69\n98 116 69", "2\n9 72 53\n98 73 69", "2\n3 72 69\n98 3 69", "2\n11 72 79\n98 2 91...
resn04
Alice and Bob play the following game : There are N piles of stones with Si stones in the ith pile. Piles are numbered from 1 to N. Alice and Bob play alternately, with Alice starting. In a turn, the player chooses any pile i which has atleast i stones in it, and removes exactly i stones from it. The game ends when ...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n1\n2\n1 1" ], "output": [ "ALICE\nALICE\n" ] }
{ "input": [ "2\n1\n0\n2\n1 1", "2\n1\n0\n2\n2 1", "2\n1\n1\n2\n2 1", "2\n1\n1\n2\n1 0", "2\n1\n0\n2\n0 1", "2\n1\n0\n2\n1 2", "2\n1\n0\n2\n1 0", "2\n1\n0\n2\n0 0", "2\n1\n1\n2\n0 0", "2\n1\n1\n2\n2 0", "2\n1\n1\n2\n0 1", "2\n1\n0\n0\n2 1", "2\n0\n0\n2\n0 1", "2...
twofrnds
These days, Sid and Jake are learning about number theory. They have just visited the zoo and during the visit they have counted(yes, they are superb at counting :) ) the number of animals at the zoo. Now, after visiting the zoo, Sid is saying that f is a factor of the total number of animals at the zoo and Jake is say...
{ "input": [], "output": [] }
{ "input": [ "2\n1 4\n2 3" ], "output": [ "CORRECT\nWRONG" ] }
{ "input": [], "output": [] }
1194_B. Yet Another Crosses Problem
You are given a picture consisting of n rows and m columns. Rows are numbered from 1 to n from the top to the bottom, columns are numbered from 1 to m from the left to the right. Each cell is painted either black or white. You think that this picture is not interesting enough. You consider a picture to be interesting...
{ "input": [], "output": [] }
{ "input": [ "9\n5 5\n..*..\n..*..\n*****\n..*..\n..*..\n3 4\n****\n.*..\n.*..\n4 3\n***\n*..\n*..\n*..\n5 5\n*****\n*.*.*\n*****\n..*.*\n..***\n1 4\n****\n5 5\n.....\n..*..\n.***.\n..*..\n.....\n5 3\n...\n.*.\n.*.\n***\n.*.\n3 3\n.*.\n*.*\n.*.\n4 4\n*.**\n....\n*.**\n*.**\n" ], "output": [ "0\n0\n0\n0\n0...
{ "input": [ "9\n5 5\n..*..\n..*..\n*****\n..*..\n..*..\n3 4\n****\n.*..\n.*..\n4 3\n***\n*..\n*..\n*..\n5 5\n*****\n*.*.*\n*****\n..*.*\n..***\n1 4\n****\n5 5\n.....\n..*..\n.***.\n..*..\n.....\n5 3\n...\n.*.\n.*.\n***\n.*.\n3 3\n.*.\n*.*\n.*.\n4 4\n*.**\n....\n*.**\n***.\n", "9\n5 5\n..*..\n..*..\n*****\n.....
1252_H. Twin Buildings
As you might already know, space has always been a problem in ICPC Jakarta. To cope with this, ICPC Jakarta is planning to build two new buildings. These buildings should have a shape of a rectangle of the same size. Now, their problem is to find land to build the buildings. There are N lands available for sale. The i...
{ "input": [], "output": [] }
{ "input": [ "2\n5 5\n3 4\n", "2\n2 5\n4 3\n", "3\n10 1\n9 8\n7 6\n" ], "output": [ "\n12.5\n", "\n8.0\n", "\n42.0\n" ] }
{ "input": [], "output": [] }
1296_B. Food Buying
Mishka wants to buy some food in the nearby shop. Initially, he has s burles on his card. Mishka can perform the following operation any number of times (possibly, zero): choose some positive integer number 1 ≤ x ≤ s, buy food that costs exactly x burles and obtain ⌊x/10⌋ burles as a cashback (in other words, Mishka ...
{ "input": [], "output": [] }
{ "input": [ "6\n1\n10\n19\n9876\n12345\n1000000000\n" ], "output": [ "1\n11\n21\n10973\n13716\n1111111111\n" ] }
{ "input": [ "6\n1\n10\n33\n9876\n12345\n1000000000\n", "6\n1\n5\n33\n9876\n12345\n1000000000\n", "6\n1\n5\n33\n4820\n12345\n1000000000\n", "6\n1\n5\n50\n4820\n12345\n1000000000\n", "6\n1\n5\n44\n4820\n12345\n1000000000\n", "6\n1\n1\n44\n4820\n12345\n1000000000\n", "6\n1\n1\n44\n4820\n1234...
1400_D. Zigzags
You are given an array a_1, a_2 ... a_n. Calculate the number of tuples (i, j, k, l) such that: * 1 ≤ i < j < k < l ≤ n; * a_i = a_k and a_j = a_l; Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains a single integer n (4 ≤ n ≤ ...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n2 2 2 2 2\n6\n1 3 3 1 2 3\n" ], "output": [ "5\n2\n" ] }
{ "input": [ "2\n5\n2 2 2 4 2\n6\n1 3 3 1 2 3\n", "2\n5\n2 2 3 4 2\n6\n2 3 3 1 2 3\n", "2\n5\n2 2 3 4 2\n6\n2 4 3 1 2 3\n", "2\n5\n2 2 2 2 2\n6\n1 5 3 1 2 3\n", "2\n5\n4 2 2 4 2\n6\n1 3 3 1 2 3\n", "2\n5\n2 2 2 4 2\n6\n1 4 3 1 2 3\n", "2\n5\n2 2 3 5 3\n6\n2 3 3 1 2 5\n", "2\n5\n2 4 2 4...
bad-odd-times
Once upon a times , there lived King Nihal who hated odd counting . He has received various gifts from different kings of other kingdoms on his birthday. There is one enemy king , and to make our king angry he will send odd number of gifts . As a sincere minister , its your task to find the enemy kingdom. Input T- n...
{ "input": [], "output": [] }
{ "input": [ "2\n\n7\n\n1 1 2 2 2 2 3\n\n5\n\n4 4 4 7 7\n\nSAMPLE" ], "output": [ "3\n4" ] }
{ "input": [], "output": [] }
haunted
The king of ghosts is really disappointed when he sees that all the human beings on Planet Earth have stopped fearing the ghost race. He knows the reason for this. The existing ghost race has become really lazy and has stopped visiting Planet Earth to scare the human race. Hence, he decides to encourage the entire ghos...
{ "input": [], "output": [] }
{ "input": [ "7 5\n1 3 1 3 2 2 2\n\nSAMPLE" ], "output": [ "1 1\n3 1\n1 2\n3 2\n3 2\n3 2\n2 3\n" ] }
{ "input": [ "7 5\n1 3 2 3 2 2 2\n\nSAMPLE", "7 3\n1 3 2 3 2 1 2\n\nSAMPLE", "7 3\n1 3 2 3 2 1 1\n\nSAMPLE", "7 3\n1 3 2 3 3 1 1\n\nSAMPLE", "7 3\n2 3 2 3 3 1 1\n\nSAMPLE", "7 5\n1 3 1 3 2 2 2\n\nS@MPLE", "7 3\n1 3 2 1 2 1 2\n\nSAMPLE", "7 3\n1 0 2 3 2 1 1\n\nSAMPLE", "7 3\n2 3 2 4...
service-lane-1
Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any risks. Luckily, a service lane runs parallel to the highway. The length of the highway and the service lane is N units. The service lane consists of...
{ "input": [], "output": [] }
{ "input": [ "8 5\n2 3 1 2 3 2 3 3\n0 3\n4 6\n6 7\n3 5\n0 7\n\nSAMPLE" ], "output": [ "1\n2\n3\n2\n1" ] }
{ "input": [], "output": [] }
xenny-and
Xenny has 2 positive integers A and B. He wants to find the prime factorization of the integer A^B. Input format: Each line contains 2 space-separated integers A and B. Output format: Consider A^B to have N prime factors. Print N lines. For every prime factor, print the base and the exponent separated by a single s...
{ "input": [], "output": [] }
{ "input": [ "10 1\n\nSAMPLE" ], "output": [ "2 1\n5 1" ] }
{ "input": [ "16 1\n\nSAMPLE", "10 0\n\nSAMPLE", "22 1\n\nSAMPLE", "16 2\n\nELPMAS", "22 2\n\nSAMPLE", "16 3\n\nELPMAS", "22 4\n\nSAMPLE", "16 0\n\nSAOMLE", "22 0\n\nSAMPLE", "6 3\n\nELPMAT", "3 0\n\nELPNAR", "37 0\n\nSBMPLE", "6 4\n\nEPLMAT", "17 1\n\nELMO@S", ...
p02641 AtCoder Beginner Contest 170 - Forbidden List
Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N. Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, repo...
{ "input": [], "output": [] }
{ "input": [ "6 5\n4 7 10 6 5", "10 5\n4 7 10 6 5", "100 0" ], "output": [ "8", "9", "100" ] }
{ "input": [ "6 2\n4 7 10 6 5", "10 3\n4 7 10 6 5", "6 2\n4 7 10 8 5", "10 3\n4 7 9 6 5", "15 3\n7 5 3 6 5", "12 1\n2 5 3 16 11", "2 1\n4 5 0 16 4", "6 5\n3 7 10 6 5", "19 5\n4 7 10 6 5", "101 0", "0 2\n4 7 10 8 2", "1 0\n4 3 14 16 4", "30 1\n1 8 3 16 11", "3 1\...
p02771 AtCoder Beginner Contest 155 - Poor
A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers. You will be given three integers A, B, and C. If this triple is poor, print `Yes`; otherwise, print `No`. Constraints * A, B, and C are all integers between 1 and 9 (inclusive). Input...
{ "input": [], "output": [] }
{ "input": [ "3 3 4", "4 4 4", "5 7 5", "4 9 6" ], "output": [ "Yes", "No", "Yes", "No" ] }
{ "input": [ "2 3 4", "1 4 4", "10 7 5", "7 9 6", "4 3 4", "1 4 8", "10 2 5", "7 4 6", "4 5 4", "0 4 8", "18 2 5", "7 4 8", "6 5 4", "0 4 14", "18 2 3", "7 1 8", "6 5 6", "1 4 14", "18 3 3", "7 1 1", "3 5 6", "1 4 26", "18 4 3...
p02906 AtCoder Grand Contest 038 - Unique Path
Snuke's mother gave Snuke an undirected graph consisting of N vertices numbered 0 to N-1 and M edges. This graph was connected and contained no parallel edges or self-loops. One day, Snuke broke this graph. Fortunately, he remembered Q clues about the graph. The i-th clue (0 \leq i \leq Q-1) is represented as integers...
{ "input": [], "output": [] }
{ "input": [ "4 4 3\n0 1 0\n1 2 1\n2 3 0", "10 9 9\n7 6 0\n4 5 1\n9 7 0\n2 9 0\n2 3 0\n4 1 0\n8 0 0\n9 1 0\n3 0 0", "5 5 3\n0 1 0\n1 2 1\n2 3 0" ], "output": [ "No", "No", "Yes" ] }
{ "input": [ "4 4 3\n0 1 0\n1 2 1\n1 3 0", "5 5 3\n0 1 0\n1 4 1\n2 3 0", "10 9 9\n7 6 0\n4 5 1\n9 7 0\n2 9 0\n2 3 0\n4 1 0\n10 0 0\n9 1 0\n3 0 0", "4 4 3\n0 1 0\n2 2 1\n1 3 0", "10 9 16\n7 6 0\n4 5 1\n9 7 0\n2 9 0\n2 3 0\n4 1 0\n10 0 0\n9 1 0\n3 0 0", "4 4 3\n0 1 0\n2 2 1\n1 0 0", "10 9 16...