name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p00900 Captain Q's Treasure
You got an old map, which turned out to be drawn by the infamous pirate "Captain Q". It shows the locations of a lot of treasure chests buried in an island. The map is divided into square sections, each of which has a digit on it or has no digit. The digit represents the number of chests in its 9 neighboring sections ...
{ "input": [], "output": [] }
{ "input": [ "5 6\n*2.2**\n..*...\n..2...\n..*...\n*2.2**\n6 5\n.*2*.\n..*..\n..*..\n..2..\n..*..\n.*2*.\n5 6\n.1111.\n**...*\n33....\n**...0\n.*2**.\n6 9\n....1....\n...1.1...\n....1....\n.1..*..1.\n1.1***1.1\n.1..*..1.\n9 9\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4***\...
{ "input": [ "5 6\n*3.2**\n..*...\n..2...\n..*...\n*2.2**\n6 5\n.*2*.\n..*..\n..*..\n..2..\n..*..\n.*2*.\n5 6\n.1111.\n**...*\n33....\n**...0\n.*2**.\n6 9\n....1....\n...1.1...\n....1....\n.1..*..1.\n1.1***1.1\n.1..*..1.\n9 9\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4***\...
p01033 Coupling
Problem A large-scale joint party is held every year at Aizu University. This year, N men and M women will participate. Males are assigned IDs from 0 to N-1, and females are assigned IDs from 0 to M-1. At this joint party, you will be presented with the IDs of your "loved person" and "moderately favorite person". Eac...
{ "input": [], "output": [] }
{ "input": [ "3 3\n3\n0 0\n1 1\n2 2\n2\n1 0\n2 1\n3\n1 1\n2 2\n0 1\n2\n1 0\n2 0", "5 5\n5\n4 1\n2 2\n1 4\n1 3\n4 2\n5\n1 1\n1 2\n3 3\n3 0\n3 4\n5\n2 3\n2 2\n0 3\n0 2\n4 1\n5\n2 0\n4 0\n1 0\n4 3\n2 1" ], "output": [ "2 0 0", "2 1 0" ] }
{ "input": [ "3 3\n3\n0 0\n1 1\n2 2\n2\n1 0\n2 1\n3\n1 1\n2 2\n0 1\n2\n0 0\n2 0", "3 3\n3\n0 0\n2 1\n2 2\n2\n1 0\n2 1\n3\n1 1\n2 2\n0 1\n2\n1 0\n2 0", "5 5\n5\n4 1\n0 2\n1 4\n1 3\n4 2\n5\n1 1\n1 2\n3 3\n3 0\n3 4\n5\n2 3\n2 2\n0 3\n1 2\n4 1\n5\n2 0\n4 0\n1 0\n4 0\n2 1", "5 5\n5\n4 1\n3 2\n1 4\n1 3\n4 2...
p01166 So Sleepy
You have an appointment to meet a friend of yours today, but you are so sleepy because you didn’t sleep well last night. As you will go by trains to the station for the rendezvous, you can have a sleep on a train. You can start to sleep as soon as you get on a train and keep asleep just until you get off. However, bec...
{ "input": [], "output": [] }
{ "input": [ "3 1\n1 09:00 3 10:00\n3\n1 09:10\n2 09:30\n3 09:40\n3 2\n1 09:00 1 10:00\n3\n1 09:10\n2 09:30\n3 09:40\n3\n3 09:20\n2 09:30\n1 10:00\n1 0\n1 09:00 1 10:00\n1 0\n1 10:00 1 09:00\n3 1\n1 09:00 3 09:35\n3\n1 09:10\n2 09:30\n3 09:40\n4 3\n1 09:00 4 11:00\n3\n1 09:10\n2 09:20\n4 09:40\n3\n1 10:30\n3 10:4...
{ "input": [ "3 1\n1 09:00 3 10:00\n3\n1 09:10\n2 09:30\n3 09:40\n3 2\n1 09:00 1 10:00\n3\n1 09:10\n2 09:30\n3 09:40\n3\n3 09:20\n2 09:30\n1 10:00\n1 0\n1 09:00 1 10:00\n1 0\n1 10:00 1 09:00\n3 1\n1 09:00 3 09:35\n3\n1 09:10\n2 09:30\n3 09:40\n4 3\n1 09:00 4 11:00\n3\n2 09:10\n2 09:20\n4 09:40\n3\n1 10:30\n3 10:4...
p01303 Petting Cats
Many cats live on the campus of a school. Natsume's daily routine is to pet those cats. However, the cats may be capricious and go for a walk off campus. The campus site is a rectangle with each side parallel to the x-axis or y-axis and is surrounded by a fence except for the gate, but cats can freely enter and exit t...
{ "input": [], "output": [] }
{ "input": [ "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10" ], "output": [ "2\n2" ] }
{ "input": [ "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n41 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10", "2\n1 3 6 10\n4\n21 13\n1 15\n10 10\n25 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10", "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n55 10\n1 3 20 10\n4\n21 13\n1 15\n10 2\n25 10", "2\n1 3 6 10\n4\n21 13\n1 15\n...
p01472 Game
Problem statement Two players are playing the game. The rules of the game will be described below. There is a board of $ N × N $ squares, and each square has the number $ X_ {i, j} $ ($ 1 \ leq i, j \ leq N $) written on it. The first move and the second move alternately select hands and accumulate points. The first ...
{ "input": [], "output": [] }
{ "input": [ "2 5\n3 4\n7 6", "2 0\n1 3\n1 1", "2 100\n0 0\n0 0" ], "output": [ "Draw\n4", "Second\n3", "First\n2" ] }
{ "input": [ "2 5\n3 7\n7 6", "2 100\n0 0\n0 -1", "3 5\n3 7\n7 6", "2 000\n0 0\n0 -2", "3 5\n3 7\n0 0", "3 5\n3 7\n0 1", "4 0\n1 3\n2 0", "6 5\n3 7\n0 0", "5 5\n3 7\n0 0", "6 7\n3 7\n1 1", "7 0\n1 1\n4 0", "7 0\n1 1\n1 0", "7 -1\n1 1\n1 0", "4 0\n0 3\n3 -1", ...
p01632 Bicycle
Problem Statement Kikuchi loves big bicycles. Today he is still riding his favorite bike on the cycling road. There are N towns in the area where he lives. Each town will be called town 1, town 2 ..., town N. The town where he lives is Town 1. Many people in this area have a hobby of cycling, and recently, cycling ro...
{ "input": [], "output": [] }
{ "input": [ "3 3\n1 2\n2 3\n3 1", "4 4\n1 2\n2 3\n2 4\n3 4" ], "output": [ "No\nNo\nYes", "No\nNo\nNo\nNo" ] }
{ "input": [ "3 3\n1 2\n2 3\n3 2", "4 4\n1 1\n2 3\n2 4\n3 4", "4 4\n1 2\n2 3\n2 4\n1 4", "4 2\n1 2\n2 3\n2 4\n1 4", "4 2\n1 2\n2 1\n2 1\n1 1", "4 4\n1 3\n2 2\n2 4\n1 4", "4 2\n1 1\n2 2\n2 4\n1 4", "4 4\n1 4\n1 2\n2 4\n1 4", "3 3\n1 2\n2 1\n3 1", "4 3\n1 2\n2 3\n2 1\n1 1", "...
p01784 Parentheses
Example Input 3 ()(()(( ))()()(() )())(()) Output Yes
{ "input": [], "output": [] }
{ "input": [ "3\n()(()((\n))()()(()\n)())(())" ], "output": [ "Yes" ] }
{ "input": [ "3\n()(()((\n))()(((()\n)())(())", "3\n()(()((\n))()(((()\n))(())()", "3\n()(()((\n))()(((()\n)())((*)", "3\n()(()((\n))()(((()\n)())((*(", "3\n()(()((\n))()(((()\n)()(((*(", "3\n()(()((\n)(((()())\n)()(((*(", "3\n()(()((\n)(((')())\n)()(((*(", "3\n()(())(\n)(((')())\n)()(...
p01919 Country in Distortion
D: Country In Distortion- story Alice was completely bored. This is because the White Rabbit, who is always playing with him, is out to Trump Castle. (Ah, I wish I had gone out with him in this case.) Alice thought. However, this is a country of distortion. If you go out so easily, you will get very tired. What does ...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 2 3\n2 3 1\n2 4 5\n3 4 2\n5\n4 5 6" ], "output": [ "34" ] }
{ "input": [ "4 4\n1 3 3\n2 3 1\n2 4 5\n3 4 2\n5\n4 5 6", "4 4\n1 2 3\n2 3 1\n2 4 5\n3 4 2\n5\n4 5 7", "4 4\n1 3 4\n2 3 1\n2 4 5\n3 4 2\n5\n4 5 6", "4 4\n1 3 4\n2 3 0\n2 4 5\n3 4 2\n5\n4 5 6", "4 4\n1 3 4\n2 3 1\n2 2 10\n3 4 1\n5\n4 5 6", "4 4\n1 2 3\n2 3 1\n3 4 5\n3 4 2\n5\n4 5 6", "4 4\n...
p02057 MOD Rush
F: MOD Rush problem Given a positive integer sequence A of length N and a positive integer sequence B of length M. For all (i, j) (1 \ leq i \ leq N, 1 \ leq j \ leq M), find the remainder of A_i divided by B_j and output the sum of them. Input format N M A_1 A_2 ... A_N B_1 B_2 ... B_M Constraint * 1 \ leq N,...
{ "input": [], "output": [] }
{ "input": [ "3 3\n5 1 6\n2 3 4" ], "output": [ "9" ] }
{ "input": [ "3 3\n5 2 6\n2 3 4", "3 3\n4 2 6\n2 3 4", "2 3\n4 2 6\n2 3 4", "2 3\n4 2 6\n2 2 4", "2 4\n4 2 6\n2 2 4", "3 3\n5 1 7\n2 3 4", "3 0\n5 4 6\n2 3 4", "2 4\n8 3 6\n2 3 4", "2 4\n4 2 6\n2 3 5", "2 2\n2 2 6\n2 0 6", "2 2\n5 2 5\n2 0 6", "2 2\n7 6 9\n2 2 4", "...
p02199 Run
Run, Twins E869120 You started running from home to school at a speed of $ P $ meters per minute. square1001 noticed E869120's forgotten thing $ A $ minutes after E869120 left home and chased at $ Q $ meters per minute. Then E869120 noticed something left behind $ B $ minutes after E869120 left home and turned back ...
{ "input": [], "output": [] }
{ "input": [ "14 86\n9 1 20" ], "output": [ "119.428571428571" ] }
{ "input": [ "14 86\n15 1 20", "14 86\n4 1 20", "11 86\n4 1 20", "20 86\n4 1 20", "20 86\n4 1 37", "20 86\n4 0 37", "20 86\n4 0 39", "20 73\n4 0 39", "20 73\n5 0 39", "20 73\n5 0 47", "20 73\n5 0 27", "20 73\n10 0 27", "20 124\n10 0 27", "20 122\n10 0 27", "...
p02353 RSQ and RUQ
Write a program which manipulates a sequence $A$ = {$a_0, a_1, ..., a_{n-1}$} with the following operations: * $update(s, t, x)$: change $a_s, a_{s+1}, ..., a_t$ to $x$. * $getSum(s, t)$: print the sum of $a_s, a_{s+1}, ..., a_t$. Note that the initial values of $a_i ( i = 0, 1, ..., n-1 )$ are 0. Constraints * $...
{ "input": [], "output": [] }
{ "input": [ "6 7\n0 1 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5" ], "output": [ "-5\n1\n6\n8" ] }
{ "input": [ "6 7\n0 1 3 1\n0 2 4 -2\n1 0 4\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5", "6 7\n0 1 3 1\n0 2 2 -2\n1 0 4\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5", "6 7\n0 1 3 1\n0 2 4 -2\n1 0 5\n1 0 1\n0 3 5 0\n1 3 4\n1 0 5", "6 7\n0 2 3 1\n0 2 4 -2\n1 0 4\n1 0 1\n0 3 5 3\n1 3 4\n1 0 5", "6 7\n0 1 3 2\n0 2 2 -2\n1 0 4\n1...
and
You are given a sequence of N integer numbers A. Calculate the sum of Ai AND Aj for all the pairs (i, j) where i < j. The AND operation is the Bitwise AND operation, defined as in here. Input The first line of input consists of the integer N. The second line contains N integer numbers - the sequence A. Output Out...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5" ], "output": [ "9\n" ] }
{ "input": [ "5\n2 2 3 4 5", "5\n2 2 6 4 5", "5\n0 2 6 4 5", "5\n1 2 5 4 6", "5\n0 2 3 4 5", "5\n2 2 6 6 5", "5\n1 2 8 4 6", "5\n0 2 5 4 4", "5\n0 2 3 0 5", "5\n0 2 3 1 5", "5\n2 2 3 6 5", "5\n2 2 6 4 3", "5\n1 2 3 1 5", "5\n2 2 3 2 5", "5\n1 2 8 4 16", ...
chocolat
Balajiganapathi and Bipin are brothers. They have saved their money to buy Dairy Milk for their respective girlfriend on this Valentine's day. Balaji managed to buy M chocolates and Bipin managed to buy N chocolates. They have made a bet as if who will give more Dairy Milk to their girlfriend.If Bipin manages to give...
{ "input": [], "output": [] }
{ "input": [ "2\n4 6\n8 1" ], "output": [ "Balaji 2\nBipin 7" ] }
{ "input": [], "output": [] }
epi02
Once upon a time, a king and a few of his soldiers were caught by an enemy king in a war. He puts them in a circle. The first man in the circle has to kill the second man, the third man has to kill the fourth, fifth man to kill the sixth and so on. When the circle is completed, the remaining people have to form a ci...
{ "input": [], "output": [] }
{ "input": [ "9" ], "output": [ "3" ] }
{ "input": [], "output": [] }
kjcc07
Chef is known to have friends as well as enemies. Chef has a habit of communicating with friends through encrypted messages. But recently some of his enemies found the way to decrypt and get the original message. You need to write a program that simulates how the enemies decrypted the messages. Chef’s enemies observe...
{ "input": [], "output": [] }
{ "input": [ "4\nazfjybgbxnpyatfgcaxqylbxd\ngzbbbgaxnfatxqdjfaypgcyafl\nyjbfpcygxlgznyfbgxtqgxydaaa\nxxyyxxyyxdlbqffctpbngggjz\ncbkumuwlwkmtt_zwksa!!" ], "output": [ "kjscecodecell_rocks!!" ] }
{ "input": [], "output": [] }
packband
Did you know that the yummy golden triangle was introduced in India as early as 13th century ? By the way, I'm referring to the popular South Asian snack, Samosa. I guess its hard to code while thinking of Samosa, especially if you are very hungry now ; so lets not get in to any recipe or eating game. You have N box...
{ "input": [], "output": [] }
{ "input": [ "1\n4\n10 20 34 55\n4\n7 14\n7 21\n14 21\n7 35" ], "output": [ "2\n" ] }
{ "input": [ "1\n4\n10 20 34 55\n4\n7 14\n7 21\n14 6\n7 35", "1\n4\n10 20 34 55\n4\n7 14\n7 21\n14 6\n7 2", "1\n2\n10 20 34 55\n4\n7 5\n2 4\n21 6\n7 2", "1\n4\n10 8 45 28\n4\n7 26\n4 21\n21 6\n13 35", "1\n4\n20 8 45 40\n4\n13 38\n4 38\n3 7\n10 55", "1\n4\n10 20 34 89\n4\n7 14\n7 21\n14 21\n7 3...
sprnmbrs
Euler's phi function for a positive integer N is usually denoted as φ(N) and defined as the number of positive integers less than or equal to N that are coprime with N. Let's call a positive integer N a super number if N can be divided by φ(N) without a remainder. e.g. 2 is a super number (since 2 mod φ(2) = 0), whi...
{ "input": [], "output": [] }
{ "input": [ "3\n2 3\n90 95\n12 21" ], "output": [ "1\n0\n3\n" ] }
{ "input": [ "3\n2 3\n90 95\n12 10", "3\n2 3\n90 95\n12 16", "3\n4 3\n90 95\n12 16", "3\n4 3\n90 95\n12 21", "3\n2 3\n90 151\n12 10", "3\n4 3\n90 95\n12 28", "3\n4 3\n90 95\n18 16", "3\n3 3\n90 151\n12 10", "3\n4 3\n90 190\n18 16", "3\n3 3\n13 151\n12 10", "3\n4 3\n90 190\n...
1183_G. Candy Box (hard version)
This problem is a version of problem D from the same contest with some additional constraints and tasks. There are n candies in a candy box. The type of the i-th candy is a_i (1 ≤ a_i ≤ n). You have to prepare a gift using some of these candies with the following restriction: the numbers of candies of each type pres...
{ "input": [], "output": [] }
{ "input": [ "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 0\n7 1\n7 0\n7 1\n" ], "output": [ "3 3\n3 3\n9 5\n" ] }
{ "input": [ "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 0\n9 1\n7 0\n7 1\n", "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n5 0\n9 0\n7 0\n7 1\n", "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1...
1346_H. Game with Segments
Alice and Bob are playing a game (yet again). They have two sequences of segments of the coordinate axis: a sequence of n initial segments: [l_1, r_1], [l_2, r_2], ..., [l_n, r_n], and a sequence of m terminal segments: [L_1, R_1], [L_2, R_2], ..., [L_m, R_m]. At the beginning of the game, they choose one of the initi...
{ "input": [], "output": [] }
{ "input": [ "1 1\n4 7\n4 7\n", "1 2\n2 5\n2 4\n3 5\n", "2 1\n1 5\n1 4\n2 3\n" ], "output": [ "\n0\n", "\n-1\n", "\n-1 1\n" ] }
{ "input": [], "output": [] }
1431_B. Polycarp and the Language of Gods
Polycarp has just finished writing down the lecture on elvish languages. The language this week was "VwV" (pronounced as "uwu"). The writing system of this language consists of only two lowercase Latin letters: 'v' and 'w'. Unfortunately, Polycarp has written all the lecture in cursive and without any spaces, so the n...
{ "input": [], "output": [] }
{ "input": [ "5\nvv\nv\nw\nvwv\nvwvvwv\n" ], "output": [ "\n1\n0\n1\n1\n3\n" ] }
{ "input": [], "output": [] }
1454_E. Number of Simple Paths
You are given an undirected graph consisting of n vertices and n edges. It is guaranteed that the given graph is connected (i. e. it is possible to reach any vertex from any other vertex) and there are no self-loops and multiple edges in the graph. Your task is to calculate the number of simple paths of length at leas...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n" ], "output": [ "\n6\n11\n18\n" ] }
{ "input": [ "3\n3\n1 2\n2 3\n1 3\n4\n1 4\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n", "3\n3\n1 2\n2 3\n1 3\n4\n1 2\n1 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3\n2 5\n4 3\n", "3\n3\n1 2\n2 3\n1 3\n4\n1 2\n2 3\n3 4\n4 2\n5\n1 2\n2 3\n1 5\n2 5\n4 3\n", "3\n3\n1 2\n2 3\n1 3\n4\n1 2\n1 3\n3 4\n4 2\n5\n1 2\n2 3\n1 3...
1505_F. Math
<image> <image> *The two images are equivalent, feel free to use either one. Input The input contains a single integer a (-100 ≤ a ≤ 100). Output Output the result – an integer number. Example Input 1 Output 1
{ "input": [], "output": [] }
{ "input": [ "1\n" ], "output": [ "\n1\n" ] }
{ "input": [ "0\n", "-1\n", "-2\n", "4\n", "-3\n", "5\n", "-8\n", "-11\n", "-7\n", "-13\n", "-17\n", "-29\n", "-52\n", "-9\n", "-6\n", "-10\n", "-19\n", "-35\n", "-57\n", "-113\n", "-53\n", "-33\n", "-12\n", "-14\n", "...
creativity
Ed, Edd and Eddy are given an art homework. They have to prepare a banner and print a single line of text on it. They can print any text they want. Ed has decided the text that he wants to put on his banner. Lets call it string s1. But he is too lazy to make a new banner all by himself. He borrows an old banner from ...
{ "input": [], "output": [] }
{ "input": [ "5\nhello\nhi hello hi\ndef\nabc def\njava\npython\nc\ncplusplus\nhellohi\nhellotherehi\n\nSAMPLE" ], "output": [ "possible\npossible\nnot possible\npossible\nnot possible\n" ] }
{ "input": [ "5\nlehlo\nhi hello hi\ndef\nabc def\njava\npython\nc\ncplusplus\nhellohi\nhellotherehi\n\nSAMPLE", "5\nlehlo\nhi olleh hi\ndef\nabc fed\naavj\npython\nc\ncplusplus\nhellohi\nhellotherdhi\n\nSAMPLE", "5\nkelio\nhi olldg ii\nged\ncba eed\njwaa\npxthon\nd\ncplusplus\nhellohi\nhellotherdhi\n\nS@...
paint-the-house-5
You want to repaint your house entirely for an upcoming occasion. The total area of your house is D units. There are a total of N workers. The i^th worker has his available time Ti, hiring cost Xi and speed Yi. This means that he is available for hiring from time Ti and remains available ever since. Once available, yo...
{ "input": [], "output": [] }
{ "input": [ "3 3\n1 1 1\n2 2 2\n3 1 5\n\nSAMPLE" ], "output": [ "3" ] }
{ "input": [ "3 3\n1 1 1\n2 2 3\n3 1 5\n\nSAMPLE", "3 3\n1 1 1\n2 2 1\n6 1 5\n\nSAMPLE", "2 3\n1 2 1\n1 2 1\n6 1 5\n\nSAMPLE", "3 2\n1 1 1\n2 4 2\n3 1 5\n\nSAMQEL", "3 3\n1 0 1\n2 2 -1\n6 2 5\n\nSAMPLE", "3 2\n1 1 0\n2 4 2\n3 1 5\n\nSAMQEL", "3 3\n1 -1 1\n4 2 -1\n6 2 5\n\nSAMPLE", "3 4...
sonu-and-monu
Sonu and Monu are good friends. One day, Sonu gave a binary string of length L to Monu, and asks Monu to pick two positions a and b in the string. Now he given a number P to Monu and he have to tell what are the chances that there will be 1 on both positions and |a-b| ≤ P Note: Binary String means which contains only...
{ "input": [], "output": [] }
{ "input": [ "2\n4 3\n1011\n4 1\n1011\n\nSAMPLE" ], "output": [ "9/16\n5/16" ] }
{ "input": [], "output": [] }
p02567 AtCoder Library Practice Contest - Segment Tree
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types. The type of i-th query is represented by T_i. * T_i=1: You are given two integers X_i,V_i. Replace the value of A_{X_i} with V_i. * T_i=2: You are given two integers L_i,R_i. Calculate the maximum value among A_{L_i},...
{ "input": [], "output": [] }
{ "input": [ "5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 3" ], "output": [ "3\n3\n2\n6" ] }
{ "input": [ "5 5\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0", "5 3\n1 2 3 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0", "5 1\n1 2 3 2 1\n2 0 5\n3 2 3\n1 1 2\n2 2 4\n3 1 0", "5 5\n1 2 1 2 1\n2 1 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0", "8 3\n1 2 3 2 1\n2 0 5\n3 2 3\n1 3 1\n2 2 4\n3 1 0", "5 3\n1 2 0 2 1\...
p02698 AtCoder Beginner Contest 165 - LIS on Tree
We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: * We will make a sequence by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k...
{ "input": [], "output": [] }
{ "input": [ "10\n1 2 5 3 4 6 7 3 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10" ], "output": [ "1\n2\n3\n3\n4\n4\n5\n2\n2\n3" ] }
{ "input": [ "10\n1 2 5 3 4 6 7 6 2 4\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n1 8\n8 9\n9 10", "10\n1 2 5 2 7 6 7 3 0 4\n1 2\n2 3\n3 4\n4 5\n2 6\n6 7\n1 8\n8 9\n9 10", "10\n0 2 5 2 7 6 7 3 0 4\n1 3\n2 3\n3 4\n4 5\n2 6\n6 7\n1 8\n8 9\n9 10", "10\n0 2 5 2 7 1 7 3 0 4\n1 3\n2 3\n3 4\n4 5\n2 6\n6 7\n1 8\n8 9\n9 10...
p02827 AtCoder Grand Contest 041 - Balancing Network
A balancing network is an abstract device built up of N wires, thought of as running from left to right, and M balancers that connect pairs of wires. The wires are numbered from 1 to N from top to bottom, and the balancers are numbered from 1 to M from left to right. Balancer i connects wires x_i and y_i (x_i < y_i). ...
{ "input": [], "output": [] }
{ "input": [ "4 5 2\n1 3\n2 4\n1 2\n3 4\n2 3", "3 1 1\n1 2", "2 1 2\n1 2", "4 5 1\n1 3\n2 4\n1 2\n3 4\n2 3" ], "output": [ "v^^^^", "-1", "-1", "^^^^^" ] }
{ "input": [ "4 5 2\n1 3\n0 4\n1 2\n3 4\n2 3", "3 1 1\n1 3", "4 5 1\n2 3\n2 4\n1 2\n3 4\n2 3", "4 5 2\n1 3\n0 4\n1 2\n6 4\n2 3", "4 5 2\n2 3\n2 4\n1 2\n3 4\n2 3", "4 5 2\n1 3\n0 4\n2 2\n6 4\n2 3", "4 5 2\n1 3\n0 4\n2 2\n6 4\n0 3", "3 1 2\n0 1", "4 5 2\n1 3\n0 6\n2 2\n7 7\n0 3", ...
p02964 AtCoder Grand Contest 036 - Do Not Duplicate
We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \times N + j}=A_j holds. Snuke has an integer sequence s, which is initially empty...
{ "input": [], "output": [] }
{ "input": [ "11 97\n3 1 4 1 5 9 2 6 5 3 5", "5 10\n1 2 3 2 3", "6 1000000000000\n1 1 2 2 3 3", "3 2\n1 2 3" ], "output": [ "9 2 6", "3", "", "2 3" ] }
{ "input": [ "5 10\n1 3 3 2 3", "6 1000000000000\n1 2 2 2 3 3", "6 1000000000000\n1 2 2 4 3 3", "11 97\n3 2 4 1 5 9 2 6 5 3 5", "6 1000000000000\n1 1 2 4 3 3", "11 97\n0 2 4 1 5 9 2 6 2 3 5", "11 97\n0 2 4 2 5 4 2 6 2 3 5", "11 97\n0 2 0 2 5 4 2 6 2 3 5", "11 97\n0 0 0 2 5 4 2 6 2 ...
p03099 AtCoder Grand Contest 031 - Snuke the Phantom Thief
A museum exhibits N jewels, Jewel 1, 2, ..., N. The coordinates of Jewel i are (x_i, y_i) (the museum can be regarded as a two-dimensional plane), and the value of that jewel is v_i. Snuke the thief will steal some of these jewels. There are M conditions, Condition 1, 2, ..., M, that must be met when stealing jewels,...
{ "input": [], "output": [] }
{ "input": [ "10\n66 47 71040136000\n65 77 74799603000\n80 53 91192869000\n24 34 24931901000\n91 78 49867703000\n68 71 46108236000\n46 73 74799603000\n56 63 93122668000\n32 51 71030136000\n51 26 70912345000\n21\nL 51 1\nL 7 0\nU 47 4\nR 92 0\nR 91 1\nD 53 2\nR 65 3\nD 13 0\nU 63 3\nL 68 3\nD 47 1\nL 91 5\nR 32 4\...
{ "input": [ "10\n66 47 71040136000\n65 55 74799603000\n80 53 91192869000\n24 34 24931901000\n91 78 49867703000\n68 71 46108236000\n46 73 74799603000\n56 63 93122668000\n32 51 71030136000\n51 26 70912345000\n21\nL 51 1\nL 7 0\nU 47 4\nR 92 0\nR 91 1\nD 53 2\nR 65 3\nD 13 0\nU 63 3\nL 68 3\nD 47 1\nL 91 5\nR 32 4\...
p03245 AtCoder Beginner Contest 111 - Robot Arms
Snuke is introducing a robot arm with the following properties to his factory: * The robot arm consists of m sections and m+1 joints. The sections are numbered 1, 2, ..., m, and the joints are numbered 0, 1, ..., m. Section i connects Joint i-1 and Joint i. The length of Section i is d_i. * For each section, its mode ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1\n1 1", "5\n0 0\n1 0\n2 0\n3 0\n4 0", "3\n-7 -3\n7 3\n-3 -7", "3\n-1 0\n0 3\n2 -1" ], "output": [ "2\n1 1\nRU\nUR", "-1", "5\n3 1 4 1 5\nLRDUL\nRDULR\nDULRD", "2\n1 2\nRL\nUU\nDR" ] }
{ "input": [ "2\n2 1\n1 1", "2\n2 1\n1 0", "3\n-8 -4\n7 3\n-3 -7", "3\n-8 -4\n13 3\n-3 -7", "3\n0 0\n0 0\n2 0", "2\n2 2\n1 -1", "3\n0 0\n0 0\n4 0", "2\n2 1\n2 -1", "3\n1 -1\n0 0\n4 0", "2\n0 1\n2 -1", "2\n-1 1\n2 0", "3\n2 -2\n0 0\n8 0", "2\n-1 1\n0 0", "2\n0 2\...
p03398 AtCoder Grand Contest 022 - Checkers
Let X = 10^{100}. Inaba has N checker pieces on the number line, where the i-th checker piece is at coordinate X^{i} for all 1 \leq i \leq N. Every second, Inaba chooses two checker pieces, A and B, and move A to the symmetric point of its current position with respect to B. After that, B is removed. (It is possible t...
{ "input": [], "output": [] }
{ "input": [ "3", "4", "22" ], "output": [ "12", "84", "487772376" ] }
{ "input": [ "6", "43", "11", "2", "1", "7", "10", "5", "12", "13", "8", "9", "19", "15", "26", "16", "17", "14", "18", "48", "20", "21", "32", "25", "34", "40", "27", "24", "35", "50", "30", ...
p03563 AtCoder Beginner Contest 076 - Rating Goal
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. ...
{ "input": [], "output": [] }
{ "input": [ "4500\n0", "2002\n2017" ], "output": [ "-4500", "2032" ] }
{ "input": [ "4500\n-1", "2002\n1006", "4500\n-2", "2002\n416", "4500\n1", "2002\n468", "4500\n2", "2002\n87", "4500\n-4", "2002\n33", "4500\n-8", "2002\n2", "4500\n-15", "2002\n3", "4500\n-14", "2002\n0", "4500\n-27", "2002\n-1", "4500\n-12"...
p03718 AtCoder Regular Contest 074 - Lotus Leaves
There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j). Some of the squares in the pond contains a lotus leaf floating on the water. On one of those leaves, S, there ...
{ "input": [], "output": [] }
{ "input": [ "4 3\n.S.\n.o.\n.o.\n.T.", "3 4\nS...\n.oo.\n...T", "3 3\nS.o\n.o.\no.T", "10 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n....o.....\n........oo" ], "output": [ "-1", "0", "2", "5" ] }
{ "input": [ "2 3\nS.o\n.o.\no.T", "4 3\n.S.\no..\n.o.\n.T.", "9 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\no..o....So\no....T....\n....o.....\n........oo", "3 3\nS.o\n.o.\noT.", "9 10\n.o...o..o.\n....o.....\n....oo.oo.\n..oooo..o.\n....oo....\n..o..o....\noS....o...
p03878 CODE FESTIVAL 2016 Grand Final(Parallel) - 1D Matching
There are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct. Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to onl...
{ "input": [], "output": [] }
{ "input": [ "2\n0\n10\n20\n30", "3\n3\n10\n8\n7\n12\n5" ], "output": [ "2", "1" ] }
{ "input": [ "2\n0\n10\n20\n34", "3\n3\n10\n8\n7\n0\n10", "3\n3\n10\n8\n7\n0\n0", "3\n3\n10\n8\n7\n2\n5", "2\n0\n10\n20\n68", "3\n3\n10\n8\n7\n1\n5", "2\n1\n10\n20\n68", "3\n3\n10\n8\n7\n0\n5", "2\n0\n10\n20\n135", "2\n0\n10\n20\n231", "3\n3\n10\n9\n7\n0\n10", "2\n0\n10...
p04039 AtCoder Regular Contest 058 - Iroha's Obsession
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ...
{ "input": [], "output": [] }
{ "input": [ "1000 8\n1 3 4 5 6 7 8 9", "9999 1\n0" ], "output": [ "2000", "9999" ] }
{ "input": [ "67 1\n0", "34 1\n0", "3 1\n0", "6 1\n0", "10 1\n0", "5 1\n0", "39 1\n0", "10 1\n1", "4 1\n1", "56 1\n0", "12 1\n0", "8 1\n0", "2 1\n0", "0 1\n-1", "1001 8\n1 3 4 5 6 7 8 9", "9999 1\n-1", "115 1\n0", "10 1\n-1", "7 1\n1", "1...
p00120 Patisserie
The cake shop made a lot of roll cakes of various sizes. You have been tasked with arranging this cake in a box. The roll cake is so soft that it will collapse if another roll cake is on top. Therefore, as shown in Fig. (A), all roll cakes must be arranged so that they touch the bottom of the box. Sorting also changes...
{ "input": [], "output": [] }
{ "input": [ "30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10" ], "output": [ "OK\nOK\nOK\nNA" ] }
{ "input": [ "30 4 5 6\n8 5 5 5\n50 3 3 3 10 10\n49 3 3 3 10 10", "30 3 5 6\n6 5 5 5\n50 3 3 3 13 10\n49 3 3 3 10 10", "3 3 5 6\n5 5 5 5\n37 3 3 3 4 10\n4 1 3 3 10 10", "3 3 5 2\n5 10 5 5\n37 3 3 3 4 3\n4 1 3 3 10 10", "30 4 5 6\n30 5 5 5\n50 3 3 3 10 10\n49 3 3 3 4 10", "30 4 5 6\n30 5 5 5\n4...
p00253 Kitchen Garden
I decided to plant vegetables in the vegetable garden. There were n seeds, so I sown n seeds one by one a day over n days. All seeds sprout and grow quickly. I can't wait for the harvest time. One day, when I was watering the seedlings as usual, I noticed something strange. There should be n vegetable seedlings, but o...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 6 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 12\n0" ], "output": [ "6\n1\n12" ] }
{ "input": [ "5\n1 2 3 6 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 6\n0", "5\n1 2 3 2 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 6\n0", "5\n1 2 3 2 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 7\n0", "5\n1 2 3 6 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 8\n0", "5\n1 2 3 6 4 5\n6\n1 3 6 9 12 15 18\n4\n5 7 9 11 5\n0", ...
p00439 Maximum Sum
problem Given a sequence of n integers a1, a2, ..., an and a positive integer k (1 ≤ k ≤ n), then the sum of k consecutive integers Si = ai + ai + Create a program that outputs the maximum value of 1 + ... + ai + k-1 (1 ≤ i ≤ n --k + 1). input The input consists of multiple datasets. Each dataset is given in the f...
{ "input": [], "output": [] }
{ "input": [ "5 3\n2\n5\n-4\n10\n3\n0 0" ], "output": [ "11" ] }
{ "input": [ "5 3\n2\n5\n-4\n8\n3\n0 0", "5 3\n2\n5\n-4\n12\n3\n0 0", "5 3\n2\n5\n-4\n14\n3\n0 0", "5 3\n2\n9\n-4\n14\n1\n0 0", "5 3\n1\n9\n-4\n2\n1\n0 0", "5 3\n2\n8\n-4\n12\n3\n0 0", "5 1\n2\n9\n-4\n14\n1\n0 0", "5 3\n1\n9\n-4\n13\n1\n0 0", "5 3\n1\n2\n-4\n13\n1\n0 0", "5 3\n...
p00630 CamelCase
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions: * Set to Upp...
{ "input": [], "output": [] }
{ "input": [ "get_user_name L\ngetUserName U\nGetUserName D\nEndOfInput X" ], "output": [ "getUserName\nGetUserName\nget_user_name" ] }
{ "input": [ "get_user_name L\ngetUserOame U\nGetUserName D\nEndOfInput X", "get_user_name L\ngetUserName U\nGrtUseeName D\nEndOfInput X", "get_user_nbme L\ngetUserOame U\nGetUserName D\nEndOfInput X", "embn_resu_teg L\ngetUserOame U\nGetUserName D\nEndOfInput X", "get_user_name L\ngetUserNamd U\n...
p00774 Chain Disappearance Puzzle
Chain Disappearance Puzzle We are playing a puzzle. An upright board with H rows by 5 columns of cells, as shown in the figure below, is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cells are engraved with the...
{ "input": [], "output": [] }
{ "input": [ "1\n6 9 9 9 9\n5\n5 9 5 5 9\n5 5 6 9 9\n4 6 3 6 9\n3 3 2 9 9\n2 2 1 1 1\n10\n3 5 6 5 6\n2 2 2 8 3\n6 2 5 9 2\n7 7 7 6 1\n4 6 6 4 9\n8 9 1 1 8\n5 6 1 8 1\n6 8 2 1 2\n9 6 3 3 5\n5 3 8 8 8\n5\n1 2 3 4 5\n6 7 8 9 1\n2 3 4 5 6\n7 8 9 1 2\n3 4 5 6 7\n3\n2 2 8 7 4\n6 5 7 7 7\n8 8 9 9 9\n0" ], "output": ...
{ "input": [ "1\n6 9 9 9 9\n5\n5 9 5 2 9\n5 5 6 9 9\n4 6 3 6 9\n3 3 2 9 9\n2 2 1 1 1\n10\n3 5 6 5 6\n2 2 2 8 3\n6 2 5 9 2\n7 7 7 6 1\n4 6 6 4 9\n8 9 1 1 8\n5 6 1 8 1\n6 8 2 1 2\n9 6 3 3 5\n5 3 8 8 8\n5\n1 2 3 4 5\n6 7 8 9 1\n2 3 4 5 6\n7 8 9 1 2\n3 4 5 6 7\n3\n2 2 8 7 4\n6 5 7 7 7\n8 8 9 9 9\n0", "1\n6 9 9 9 ...
p00905 Stylish
Stylish is a programming language whose syntax comprises names, that are sequences of Latin alphabet letters, three types of grouping symbols, periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ')'), curly brackets ('{' and '}'), and square brackets ('[' and ']'), must match and be nested pro...
{ "input": [], "output": [] }
{ "input": [ "5 4\n(Follow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.to.use.round.brackets)\n.........[but.not.about.square.brackets]\n.......
{ "input": [ "5 4\n(Follow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.to.use.round.brackets)\n.........[but.not.about.square.brackets]\n.......
p01039 Manhattan Warp Machine 1
Problem In a certain universe, stars exist on one-dimensional integer coordinate points, and aliens use the Manhattan warp device to move between stars. This warp device has N buttons, and when you press button i, you can warp any star whose Manhattan distance from the current star is di at cost ci. Now, an alien at p...
{ "input": [], "output": [] }
{ "input": [ "1 3\n4 1", "2 12\n9 1\n3 2", "2 5\n1 1\n2 1" ], "output": [ "-1", "3", "3" ] }
{ "input": [ "1 4\n4 1", "2 12\n9 1\n3 4", "2 5\n2 1\n2 1", "2 4\n1 1", "3 12\n11 0\n3 4", "3 12\n1 0\n3 4", "3 3\n2 1\n1 1", "2 12\n9 1\n6 4", "3 3\n2 1\n1 2", "3 12\n17 0\n4 4", "2 17\n9 1\n4 4", "4 4\n1 2", "3 9\n21 1\n4 4", "2 19\n1 1\n1 4", "3 17\n9 1\n...
p01172 Headstrong Student
You are a teacher at a cram school for elementary school pupils. One day, you showed your students how to calculate division of fraction in a class of mathematics. Your lesson was kind and fluent, and it seemed everything was going so well - except for one thing. After some experiences, a student Max got so curious ab...
{ "input": [], "output": [] }
{ "input": [ "1 3\n1 6\n3 5\n2 200\n25 99\n0 0" ], "output": [ "0 1\n1 1\n1 0\n2 0\n0 2" ] }
{ "input": [ "2 3\n1 6\n3 5\n2 200\n25 99\n0 0", "2 6\n1 5\n3 5\n2 200\n25 99\n0 0", "1 6\n1 5\n3 5\n2 200\n34 99\n0 0", "1 6\n1 5\n3 9\n2 200\n34 99\n0 0", "1 6\n1 8\n3 9\n2 200\n34 99\n0 0", "1 6\n1 8\n3 9\n2 200\n34 62\n0 0", "2 6\n1 8\n3 9\n2 200\n34 62\n0 0", "2 6\n1 16\n3 9\n2 20...
p01308 Angel Stairs
An angel lives in the clouds above the city where Natsume lives. The angel, like Natsume, loves cats and often comes down to the ground to play with cats. To get down to the ground, the angel made a long, long staircase leading from the clouds to the ground. However, the angel thought that it would be boring to just go...
{ "input": [], "output": [] }
{ "input": [ "4\n6 4\nC E D# F G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\n8 8\nC B B B B B F F\nC B B B B B B B" ], "output": [ "Yes\nNo\nYes\nNo" ] }
{ "input": [ "4\n6 4\nC E D# E G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\n8 8\nC B B B B B F F\nC B B B B B B B", "4\n6 4\nC E D# G G A\nC E F G\n6 4\nC E D# F G A\nC D# F G\n3 6\nC D D\nD# B D B D# C#\n8 8\nC B B B B B F F\nC B B B B B B B", "4\n6 4\nC E D# G G A\nC E F G\n6 4...
p01477 Sharp 2SAT
Problem statement $ (X_ {1,1} ∨X_ {1,2}) ∧ (X_ {2,1} ∨X_ {2,2}) ∧ ... ∧ (X_ {M, 1} ∨X_ {M,2 }) Given a logical expression represented by $. However, it is $ X_ {i, j} \ in \\ {x_1, x_2, ..., x_N, ~ x_1, ~ x_2, ..., ~ x_N \\} $. I want to assign a boolean value to each variable $ x_i $ ($ 1 \ leq i \ leq N $) so that t...
{ "input": [], "output": [] }
{ "input": [ "3 2\n-1 -2\n1 -3", "2 1\n1 -2" ], "output": [ "4", "3" ] }
{ "input": [ "3 2\n-2 -2\n1 -3", "1 2\n-1 -3\n1 -3", "1 2\n-2 -3\n1 -3", "2 2\n-1 -2\n1 -3", "3 2\n-1 -4\n2 -3", "1 1\n1 1", "3 3\n-2 -4\n1 -1", "2 2\n-3 -2\n1 -1", "1 2\n-1 -3\n1 -6", "1 2\n-2 -1\n1 -3", "2 2\n-1 -2\n1 -5", "2 2\n-1 -2\n2 -5", "1 1\n1 -2", "2 2...
p01637 Change
ICPC World Finals Day 2 Mr. Tee and his colleagues arrived at the airport terminal. From now on, I will transfer the plane and board the enemy land R country. Since we go through Country D, we have to exchange our money into two currencies. Mr. Kay "How does Mr. Tee exchange money?" Mr. Tee "Huff Huff Huff Huff Huff...
{ "input": [], "output": [] }
{ "input": [ "M r" ], "output": [ "9333" ] }
{ "input": [ "L r", "L q", "M q", "L p", "M p", "M o", "N o", "N n", "O n", "O m", "P m", "P l", "O l", "O k", "P k", "Q k", "Q l", "R l", "S l", "S k", "R k", "R j", "R i", "S i", "S h", "S g", "T g", "T h...
p01789 Unfair Game
Example Input 3 5 4 3 6 12 Output Hanako
{ "input": [], "output": [] }
{ "input": [ "3 5 4\n3\n6\n12" ], "output": [ "Hanako" ] }
{ "input": [ "3 5 4\n3\n6\n3", "3 5 4\n1\n2\n3", "3 5 5\n3\n6\n12", "3 5 4\n3\n4\n3", "3 5 5\n3\n6\n4", "3 5 4\n3\n2\n3", "3 8 5\n3\n6\n4", "3 5 4\n6\n2\n3", "3 8 5\n3\n6\n8", "3 1 5\n3\n6\n8", "3 5 4\n1\n1\n3", "3 1 5\n3\n6\n9", "3 4 4\n1\n1\n3", "3 1 5\n3\n8\n...
p01924 Coastline
coastline Waves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≤ i ≤ T), a wave from point P to the point exactly xi m rushes in i second...
{ "input": [], "output": [] }
{ "input": [ "5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n8\n4\n2\n2\n8\n1\n8\n8\n2\n5\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0" ], "output": [ "3\n0\n11\n5" ] }
{ "input": [ "5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n8\n4\n2\n2\n8\n1\n8\n8\n2\n6\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0", "5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n0\n4\n2\n2\n8\n1\n8\n8\n2\n6\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0", ...
p02062 Short Circuit Evaluation
C: Short-circuit evaluation problem Naodai-kun and Hokkaido University-kun are playing games. Hokkaido University first generates the following logical formula represented by BNF. <formula> :: = <or-expr> <or-expr> :: = <and-expr> | <or-expr> "|" <and-expr> <and-expr> :: = <term> | <and-expr> "&" <term> <term> :: =...
{ "input": [], "output": [] }
{ "input": [ "?&?|?&?|?&?" ], "output": [ "3 2" ] }
{ "input": [ "?&?&?|?|?&?", "?|?&?|?&?&?", "?&?&?|?&?|?", "?&?|?|?&?&?", "?|?|?&?&?&?", "?&?&?&?|?|?", "?|?&?&?|?&?", "?&?|?&?&?|?", "?|?|?&?&??&", "?|?&?&?&?|?", "?|?&?|?&??&", "?&?|?|?&??&", "?|?|?&??&?&", "?|?|?&?&?&?", "?&?&?&?|?|?", "?|?&?&?|?&?", ...
p02204 Contest T-shirts
Contest T-shirts Segtree has $ M $ contest T-shirts. He decided to spend $ N $ days on the contest T-shirt alone, and told $ i = 1, 2, 3, \ dots, N $ "$ A_i $ T-shirt on the $ i $ day." I made a plan for $ N $ to wear. However, if you keep the current plan, you may not be able to do the laundry in time, so I would l...
{ "input": [], "output": [] }
{ "input": [ "2 3\n2 2 1" ], "output": [ "1" ] }
{ "input": [ "2 0\n2 2 1", "-2 2\n2 2 1", "2 0\n2 0 1", "2 0\n2 0 0", "2 0\n1 0 0", "4 0\n1 0 0", "0 0\n2 2 1", "2 1\n2 0 1", "3 0\n2 0 0", "2 1\n1 0 0", "0 0\n2 2 0", "1 1\n2 0 1", "6 0\n2 0 0", "1 1\n1 0 0", "0 0\n2 3 0", "1 1\n2 1 1", "6 0\n2 0 -1...
p02358 Union of Rectangles
Given a set of $N$ axis-aligned rectangles in the plane, find the area of regions which are covered by at least one rectangle. Constraints * $ 1 \leq N \leq 2000 $ * $ −10^9 \leq x1_i < x2_i\leq 10^9 $ * $ −10^9 \leq y1_i < y2_i\leq 10^9 $ Input The input is given in the following format. $N$ $x1_1$ $y1_1$ $x2_1$ ...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0 3 1\n0 0 1 3\n0 2 3 3\n2 0 3 3", "3\n1 1 2 5\n2 1 5 2\n1 2 2 5", "2\n0 0 3 4\n1 2 4 3" ], "output": [ "8", "7", "13" ] }
{ "input": [ "4\n0 0 3 1\n0 0 1 3\n0 2 4 3\n2 0 3 3", "3\n1 1 2 5\n2 1 5 3\n1 2 2 5", "3\n1 1 3 5\n2 1 5 3\n1 2 2 5", "2\n1 0 3 6\n1 2 4 3", "3\n1 1 3 10\n2 1 5 3\n1 2 2 5", "2\n1 0 3 6\n1 2 4 6", "3\n1 1 3 20\n2 1 5 3\n1 2 2 5", "2\n1 0 3 6\n1 4 4 6", "2\n1 0 3 6\n1 4 7 6", "3...
buy1get1
One day Alice visited Byteland to purchase jewels for her upcoming wedding anniversary. In Byteland, every Jewelry shop has their own discount methods to attract the customers. One discount method called Buy1-Get1 caught Alice's attention. That is, Alice buys one jewel, then she can get one additional jewel with the sa...
{ "input": [], "output": [] }
{ "input": [ "4\nssss\nssas\nsa\ns" ], "output": [ "2\n3\n2\n1\n" ] }
{ "input": [ "4\nssss\nrsas\nsa\ns", "4\ntsss\nsasr\nas\nt", "4\nssss\natrs\nat\nt", "4\nrsss\natsr\nbt\nt", "4\nrstq\narsr\nra\nt", "4\nrstu\nrqta\nar\nt", "4\nssss\nsasr\nsa\ns", "4\nssss\nsasr\nas\ns", "4\nssss\nssas\nas\ns", "4\nssss\nrsas\nsa\nt", "4\nssss\nsasr\nsa\nt...
comr03
On the eve of Diwali, Hari is decorating his house with a serial light bulb set. The serial light bulb set has N bulbs placed sequentially on a string which is programmed to change patterns every second. If atleast one bulb in the set is on at any given instant of time, how many different patterns of light can the seri...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n2" ], "output": [ "1\n3" ] }
{ "input": [], "output": [] }
gerald03
Problem Statement Chef has a sequence of N segments: [L1, R1], [L2, R2], ..., [LN, RN]. He wants to transform the first segment to the last one (with index N). His plan is to do this big deal with a number of transformations: firstly he will transform the first segment to the second one, then to the third one, then to ...
{ "input": [], "output": [] }
{ "input": [ "4\n3\n-1 0\n0 1\n3 5\n1\n0 1\n3\n-2 -1\n-2 -1\n-2 0\n4\n4 6\n3 5\n-1 1\n1 2" ], "output": [ "9\nR+L+R+L+R+L+R+L+R+\n0\n\n1\nR+\n13\nL-R-L-L-L-L-R-R-R-R-L+R+L+" ] }
{ "input": [], "output": [] }
maandi
Problem Statement Maxim likes dividers of the numbers. Also Maxim is fond of lucky numbers of small elephant from Lviv city.   If you remember, lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky, 5, 17, 467 — aren't.   Now ...
{ "input": [], "output": [] }
{ "input": [ "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10" ], "output": [ "0\n0\n0\n1\n0\n0\n1\n1\n0\n0\n" ] }
{ "input": [ "10\n1\n2\n2\n4\n5\n6\n7\n8\n9\n10", "10\n2\n4\n2\n7\n5\n6\n7\n8\n9\n2", "10\n2\n2\n2\n4\n5\n6\n1\n8\n9\n10", "10\n1\n2\n3\n4\n5\n7\n7\n12\n1\n10", "10\n1\n2\n2\n4\n5\n6\n7\n12\n1\n20", "10\n2\n4\n2\n7\n5\n6\n7\n11\n9\n2", "10\n2\n2\n4\n4\n5\n6\n7\n8\n9\n15", "10\n2\n2\n2\...
psudo1
Chef is all ready to show his new dish at the restaurant but he is very scared if the people dislike it. He wants to show them his dish at a perfect time, so that all may like the dish. If the time displayed as HH:MM, where HH is the hour and MM is the minute then, for the Chef's time to be lucky it should be of the fo...
{ "input": [], "output": [] }
{ "input": [ "2\n12:21 11:10\n06:00" ], "output": [ "1\n0" ] }
{ "input": [], "output": [] }
time
Exciting offer….!!! It’s World Cup time…. :) Here is an offer awaiting for you i.e… you will get a ticket to watch world cup finals @ Australia. Your task is so simple. You will be given a function . In order to win the prize, you need to reduce the time complexity of that function. fun( n) { if (n==0) ...
{ "input": [], "output": [] }
{ "input": [ "2" ], "output": [ "4" ] }
{ "input": [], "output": [] }
1170_H. Longest Saw
You are given the sequence a_1, a_2, ..., a_n. You can choose any subset of elements and then reorder them to create a "saw". The sequence b_1, b_2, ..., b_m is called a "saw" if the elements satisfy one of the following series of inequalities: b_1>b_2<b_3>b_4<... or b_1<b_2>b_3<b_4>.... Find the longest saw which ca...
{ "input": [], "output": [] }
{ "input": [ "3\n10\n10 9 8 7 6 5 4 3 2 1\n7\n1 2 2 2 3 2 2\n3\n100 100 100\n" ], "output": [ "\n10\n1 6 2 7 3 8 4 9 5 10 \n4\n2 1 3 2 \n1\n100 \n" ] }
{ "input": [], "output": [] }
1250_E. The Coronation
The coronation of King Berl XXII is soon! The whole royal family, including n daughters of Berl XXII, will be present. The King has ordered his jeweler to assemble n beautiful necklaces, so each of the princesses could wear exactly one necklace during the ceremony — and now these necklaces are finished. Each necklace ...
{ "input": [], "output": [] }
{ "input": [ "5\n5 7 2\n1010100\n0010101\n1111010\n1000010\n0000101\n6 9 3\n011111110\n100111000\n111100000\n000111111\n110100111\n111110111\n3 4 2\n0001\n1000\n0000\n3 4 4\n0001\n1000\n0000\n2 4 3\n0001\n1000\n" ], "output": [ "\n2\n1 3 \n1\n3 \n0\n\n-1\n1\n1 \n" ] }
{ "input": [], "output": [] }
1355_B. Young Explorers
Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting locations as possible. Russell was trying to form groups, but ran into some difficulties... Most of the young explorer...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n1 1 1\n5\n2 3 1 2 2\n" ], "output": [ "3\n2\n\n" ] }
{ "input": [ "2\n3\n1 1 1\n5\n2 3 1 2 4\n", "2\n3\n1 1 1\n5\n2 3 1 1 2\n", "2\n3\n1 2 2\n5\n2 3 1 2 2\n", "2\n3\n1 2 2\n5\n2 1 1 2 2\n", "2\n3\n1 1 1\n5\n2 4 2 2 4\n", "2\n3\n1 1 1\n5\n1 1 1 1 2\n", "2\n3\n1 1 1\n5\n2 3 1 2 1\n", "2\n3\n1 1 1\n5\n2 3 1 1 4\n", "2\n3\n1 1 1\n5\n1 3 ...
1375_A. Sign Flipping
You are given n integers a_1, a_2, ..., a_n, where n is odd. You are allowed to flip the sign of some (possibly all or none) of them. You wish to perform these flips in such a way that the following conditions hold: 1. At least (n - 1)/(2) of the adjacent differences a_{i + 1} - a_i for i = 1, 2, ..., n - 1 are grea...
{ "input": [], "output": [] }
{ "input": [ "5\n3\n-2 4 3\n5\n1 1 1 1 1\n5\n-2 4 7 -6 4\n9\n9 7 -4 -2 1 -3 9 -4 -5\n9\n-4 1 9 4 8 9 5 1 -9\n" ], "output": [ "2 -4 3\n1 -1 1 -1 1\n2 -4 7 -6 4\n9 -7 4 -2 1 -3 9 -4 5\n4 -1 9 -4 8 -9 5 -1 9\n" ] }
{ "input": [ "5\n3\n-2 4 3\n5\n1 1 1 1 1\n5\n-2 4 7 -6 4\n9\n9 7 -4 -2 2 -3 9 -4 -5\n9\n-4 1 9 4 8 9 5 1 -9\n", "5\n3\n-2 4 3\n5\n1 1 1 1 1\n5\n-2 4 7 -6 4\n9\n9 7 -4 -2 2 -3 9 -4 -5\n9\n-4 1 9 4 8 9 5 1 -15\n", "5\n3\n-2 4 3\n5\n1 1 1 1 1\n5\n-2 4 7 -6 4\n9\n9 7 -4 -2 1 -3 9 -4 -5\n9\n-4 1 9 3 8 9 5 1 -9...
1540_E. Tasty Dishes
Note that the memory limit is unusual. There are n chefs numbered 1, 2, …, n that must prepare dishes for a king. Chef i has skill i and initially has a dish of tastiness a_i where |a_i| ≤ i. Each chef has a list of other chefs that he is allowed to copy from. To stop chefs from learning bad habits, the king makes sur...
{ "input": [], "output": [] }
{ "input": [ "5\n1 0 -2 -2 4\n4 2 3 4 5\n1 3\n1 4\n1 5\n0\n7\n1 1 1 5\n2 4 3\n1 1 1 5\n2 3 2\n1 2 2 4\n2 5 1\n1 981 4 5\n" ], "output": [ "57\n71\n316\n278497818\n" ] }
{ "input": [ "5\n1 0 -2 -2 4\n4 2 3 4 5\n1 3\n1 4\n1 5\n0\n7\n1 1 1 5\n2 4 3\n1 1 1 5\n2 3 2\n1 2 2 4\n2 5 1\n1 981 4 4\n", "5\n1 0 -2 -2 4\n4 2 3 4 5\n1 3\n1 4\n1 5\n0\n7\n1 1 1 5\n2 4 3\n1 1 1 5\n1 3 2\n1 2 2 4\n2 5 1\n1 981 4 4\n", "5\n1 0 -2 -2 4\n4 2 3 4 5\n1 3\n1 4\n1 5\n0\n7\n1 1 1 5\n2 4 3\n1 1 1 ...
chandu-and-his-toy-stack
After setting up the area. Chandu wanted all his toys to be stacked there in that area. So that all of them are accessible easily. Currently, He is having N stacks of toys each with height H_1,H_2...H_n (assuming all toys are of same height).Chandu did not like the configuration much and want to change the height of ea...
{ "input": [], "output": [] }
{ "input": [ "1\n3 6 4\n3 1\n1 2\n1 2\n\nSAMPLE" ], "output": [ "10" ] }
{ "input": [], "output": [] }
good-times-vs-bad-times-3
Chandan, our problem moderator, recently got a digital clock as a birthday present. A digital clock shows time in the format HH:MM:SS, where HH, MM, SS represents hours , minutes, and seconds respectively. It is a 24 hour clock and so the day starts at 00:00:00 hours while it ends at 23:59:59. We all know how punctual...
{ "input": [], "output": [] }
{ "input": [ "2\n23 59 58\n23 46 22\n\nSAMPLE" ], "output": [ "0:2\n1:408\n" ] }
{ "input": [ "2\n23 59 58\n23 46 22\n\nSAMPLD", "2\n23 59 58\n23 46 32\n\nSAMPLD", "2\n23 59 58\n23 46 27\n\nSAMPLE", "2\n23 59 58\n9 46 27\n\nSAMPLE", "2\n23 4 58\n9 46 27\n\nSAMPLE", "2\n23 2 58\n9 46 27\n\nSAMPLE", "2\n23 2 58\n9 46 45\n\nSAMPLE", "2\n23 2 58\n9 46 58\n\nSAMPLE", ...
monks-school-4
Today is the 25th anniversary of Berland International School in Berland. On this auspicious Occasion, our friend Monk has been given the responsibility of preparing the Inventory for his school. There are exactly N teachers and M students in the school. Each of these teachers teaches arbitary number of students. Ho...
{ "input": [], "output": [] }
{ "input": [ "3 4\nvasya\npetya\nkolya\nvasya errichto 21\nkolya petr 22\npetya egor 19\nvasya tourist 19\n\nSAMPLE" ], "output": [ "kolya\npetr 22\npetya\negor 19\nvasya\ntourist 19\nerrichto 21" ] }
{ "input": [ "3 4\nvasya\npetya\nkolya\nvasya errichto 17\nkolya petr 22\npetya egor 19\nvasya tourist 19\n\nSAMPLE", "3 4\nvasya\npetya\nkolya\nvasya errichto 17\nkolya petr 22\npetya egor 25\nvasya tourist 19\n\nSAMPLE", "3 4\nvasya\npetya\nkolya\nvasya errichto 17\nkolya petr 23\npetya egor 25\nvasya t...
sum-of-powers-6
You need to find if a number can be expressed as sum of two perfect powers. That is, given x find if there exists non negative integers a, b, m, n such that a^m + b^n = x. Input First line of the input contains number of test cases T. It is followed by T lines, each line contains a sinle number x. Output For each te...
{ "input": [], "output": [] }
{ "input": [ "5\n5\n15\n9\n77\n100\n\nSAMPLE" ], "output": [ "Yes\nNo\nYes\nNo\nYes\n" ] }
{ "input": [ "5\n5\n15\n9\n77\n100\n\nELPMAS", "5\n5\n28\n9\n77\n100\n\nSAMPLE", "5\n5\n15\n23\n77\n100\n\nQAMPLE", "5\n4\n15\n12\n77\n100\n\nELPMAQ", "5\n4\n26\n12\n77\n100\n\nELPMAQ", "5\n7\n30\n12\n77\n110\n\nELPMAQ", "5\n10\n49\n9\n77\n001\n\nSAMPLE", "5\n9\n15\n9\n136\n101\n\nSAMP...
we-are-on-fire
An intergallactic war is on. Aliens are throwing fire-balls at our planet and this fire is so deadly that whichever nation it hits, it will wipe out not only that nation, but also spreads to any other nation which lies adjacent to it. Given an NxM map which has N x M cells. Each cell may have a country or else it may...
{ "input": [], "output": [] }
{ "input": [ "3 3 3\n0 0 0\n1 0 1\n0 1 1\n1 2\n2 2\n3 3\n\nSAMPLE" ], "output": [ "4\n4\n1\n" ] }
{ "input": [ "3 3 3\n0 0 0\n1 0 1\n0 1 1\n1 1\n2 2\n3 3\n\nSAMPLE", "3 3 3\n0 0 0\n1 0 1\n1 1 1\n1 2\n2 2\n3 3\n\nSAMPLE", "3 3 3\n0 0 1\n1 0 1\n1 1 1\n1 2\n2 2\n3 3\n\nSAMPLE", "3 3 3\n0 0 0\n1 0 1\n0 1 1\n1 0\n2 2\n3 1\n\nSAMPLE", "3 3 3\n0 0 0\n1 0 1\n0 1 1\n1 0\n2 2\n2 1\n\nSAMPLE", "3 3 3...
p02616 AtCoder Beginner Contest 173 - Multiplication 4
Given are N integers A_1,\ldots,A_N. We will choose exactly K of these elements. Find the maximum possible product of the chosen elements. Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive). Constraints * 1 \leq K \leq N \leq 2\times 10^5 * |A_i| \leq 10^9 Input Inp...
{ "input": [], "output": [] }
{ "input": [ "4 2\n1 2 -3 -4", "10 10\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1", "4 3\n-1 -2 -3 -4", "2 1\n-1 1000000000" ], "output": [ "12", "999983200", "1000000001", "1000000000" ] }
{ "input": [ "4 2\n1 2 -3 0", "10 2\n1000000000 100000000 10000000 1000000 100000 10000 1000 100 10 1", "4 3\n-1 -3 -3 -4", "3 1\n-1 1000000000", "4 2\n1 2 -3 -1", "3 0\n-1 1000000000", "10 2\n1000000000 100000010 10000000 1000000 100000 10000 0000 101 10 1", "4 4\n1 2 -3 -4", "10 ...
p02747 Social Infrastructure Information Systems Division Hitachi Programming Contest 2020 - Hitachi String
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string. Constraints * The length of S is between 1 and 10 (inclusive). * S is a string consisting of lowerc...
{ "input": [], "output": [] }
{ "input": [ "ha", "hi", "hihi" ], "output": [ "No", "Yes", "Yes" ] }
{ "input": [ "ah", "ih", "hhhi", "hb", "hh", "hhhj", "bh", "gi", "jhhh", "gb", "hg", "hjhh", "fb", "gh", "gjhh", "bf", "gg", "hjgh", "af", "fg", "gjgh", "bg", "eg", "gkgh", "ga", "ge", "hgjg", "ag", "he...
p02882 AtCoder Beginner Contest 144 - Water Bottle
Takahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\mathrm{cm} and whose height is b~\mathrm{cm}. (The thickness of the bottle can be ignored.) We will pour x~\mathrm{cm}^3 of water into the bottle, and gradually tilt the bottle around one of the sides of the base. Whe...
{ "input": [], "output": [] }
{ "input": [ "2 2 4", "12 21 10", "3 1 8" ], "output": [ "45.0000000000", "89.7834636934", "4.2363947991" ] }
{ "input": [ "2 4 4", "12 30 10", "3 2 8", "5 30 10", "3 4 8", "2 30 10", "3 4 3", "2 18 10", "2 18 18", "2 18 26", "2 18 6", "2 18 2", "2 4 5", "15 21 10", "3 1 14", "12 30 9", "1 2 8", "5 30 14", "3 7 8", "2 9 10", "2 16 18", "2...
p03017 AtCoder Grand Contest 034 - Kenken Race
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty. In the beginning, Snuke stands on Square A, and Fnuke stand...
{ "input": [], "output": [] }
{ "input": [ "7 1 3 7 6\n.#..#..", "7 1 3 6 7\n.#..#..", "15 1 3 15 13\n...#.#...#.#..." ], "output": [ "No", "Yes", "Yes" ] }
{ "input": [ "9 1 3 7 6\n.#..#..", "15 1 3 15 11\n...#.#...#.#...", "4 1 3 7 6\n.#..#..", "8 1 3 7 6\n.#..#..", "15 0 3 15 13\n...#.#...#.#...", "15 0 3 15 11\n...#.#...#.#...", "1 1 3 7 6\n.#..#..", "15 1 3 15 7\n...#.#...#.#...", "8 1 4 7 6\n.#..#..", "15 0 6 15 13\n...#.#......
p03157 AISing Programming Contest 2019 - Alternating Path
There is a grid with H rows and W columns, where each square is painted black or white. You are given H strings S_1, S_2, ..., S_H, each of length W. If the square at the i-th row from the top and the j-th column from the left is painted black, the j-th character in the string S_i is `#`; if that square is painted whi...
{ "input": [], "output": [] }
{ "input": [ "3 3\n.#.\n..#\n#..", "4 3\n\n\n...", "3 3\n.#.\n..#\n..", "2 4\n....\n...." ], "output": [ "10", "6", "10", "0" ] }
{ "input": [ "3 4\n.#.\n..#\n#..", "4 4\n\n\n...", "3 3\n.#.\n-.#\n..", "3 4\n.#.\n..#\n#./", "3 2\n.#.\n-.#\n..", "3 1\n.#.\n..#\n#./", "3 2\n.#.\n#.-\n..", "4 2\n.#.\n#.-\n..", "4 2\n.#.\n#.-\n-.", "4 1\n.#.\n#--\n..", "3 3\n/#.\n..#\n#..", "1 3\n.#.\n..#\n..", "3...
p03300 AtCoder Grand Contest 026 - Synchronized Subsequence
You are given a string S of length 2N, containing N occurrences of `a` and N occurrences of `b`. You will choose some of the characters in S. Here, for each i = 1,2,...,N, it is not allowed to choose exactly one of the following two: the i-th occurrence of `a` and the i-th occurrence of `b`. (That is, you can only cho...
{ "input": [], "output": [] }
{ "input": [ "3\nbbabaa", "3\naababb", "9\nabbbaababaababbaba", "6\nbbbaabbabaaa" ], "output": [ "bbabaa", "abab", "bbaababababa", "bbbabaaa" ] }
{ "input": [ "9\nabbaaababaababbabb", "9\nabbbaababbaaabbaba", "9\naabaaabbbaababbabb", "9\nababbaaabbabaabbba", "6\naaababbaabbb", "6\naaabbbbaaabb", "6\naaabbbabaabb", "3\nbabbaa", "6\nbbaababbbaaa", "9\nbbabbabaababaaabba", "3\naabbba", "6\nbbbabaabbaaa", "3\nbab...
p03458 AtCoder Beginner Contest 086 - Checker
AtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K. Here, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square. Below is an example of a checked pattern of side 3: cba927b2484f...
{ "input": [], "output": [] }
{ "input": [ "6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W", "4 3\n0 1 W\n1 2 W\n5 3 B\n5 4 B", "2 1000\n0 0 B\n0 1 W" ], "output": [ "4", "4", "2" ] }
{ "input": [ "6 2\n1 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n4 5 W", "4 3\n0 1 W\n1 0 W\n5 3 B\n5 4 B", "2 1000\n1 0 B\n0 1 W", "2 0001\n1 -1 B\n0 1 X", "0 0001\n1 -1 B\n-1 1 W", "6 2\n1 0 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W", "6 2\n0 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n4 5 W", "4 3\n0 1 W\n2 0...
p03619 AtCoder Grand Contest 019 - Fountain Walk
In the city of Nevermore, there are 10^8 streets and 10^8 avenues, both numbered from 0 to 10^8-1. All streets run straight from west to east, and all avenues run straight from south to north. The distance between neighboring streets and between neighboring avenues is exactly 100 meters. Every street intersects every ...
{ "input": [], "output": [] }
{ "input": [ "4 2 2 2\n3\n3 2\n5 3\n2 4", "1 1 6 5\n3\n3 2\n5 3\n2 4", "3 5 6 4\n3\n3 2\n5 3\n2 4" ], "output": [ "211.415926535897938", "891.415926535897938", "400.000000000000000" ] }
{ "input": [ "4 2 2 2\n3\n3 0\n5 3\n2 4", "0 1 6 5\n3\n3 2\n5 3\n2 4", "3 5 6 5\n3\n3 2\n5 3\n2 4", "0 1 6 8\n3\n3 2\n5 3\n2 4", "3 1 6 5\n3\n3 4\n5 3\n2 4", "4 2 2 2\n3\n3 2\n5 3\n0 4", "1 1 6 5\n3\n3 2\n5 3\n2 5", "4 0 2 2\n3\n3 0\n5 3\n2 4", "0 1 6 6\n3\n3 2\n5 3\n2 4", "0 1...
p03777 AtCoder Beginner Contest 056 - HonestOrDishonest
Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDe...
{ "input": [], "output": [] }
{ "input": [ "D D", "H H", "D H" ], "output": [ "H", "H", "D" ] }
{ "input": [ "H I", "E H", "I H", "F H", "G H", "J H", "H J", "H G", "H K", "H F", "H L", "H E", "K H", "H D", "C H", "H M", "L H", "H C", "B H", "M H", "H B", "A H", "N H", "O H", "H A", "H N", "H O", "H P...
p03948 AtCoder Regular Contest 063 - An Invisible Hand
There are N towns located in a line, conveniently numbered 1 through N. Takahashi the merchant is going on a travel from town 1 to town N, buying and selling apples. Takahashi will begin the travel at town 1, with no apple in his possession. The actions that can be performed during the travel are as follows: * Move: ...
{ "input": [], "output": [] }
{ "input": [ "5 8\n50 30 40 10 20", "10 100\n7 10 4 5 9 3 6 8 2 1", "3 2\n100 50 200" ], "output": [ "2", "2", "1" ] }
{ "input": [ "5 8\n21 30 40 10 20", "10 100\n7 10 4 5 9 3 6 8 1 1", "3 2\n100 78 200", "5 8\n21 30 40 0 20", "3 3\n100 78 200", "5 8\n21 30 24 0 20", "3 3\n100 38 200", "3 5\n100 38 200", "3 8\n100 38 200", "3 0\n100 50 200", "3 2\n100 78 356", "5 8\n21 56 40 0 20", ...
p00038 Poker Hand
Create a program that reads poker hand data and outputs the role for each. However, this issue follows the rules below. * Poker is a competition with 5 playing cards. * No more than 5 cards with the same number. * There is no joker. * Suppose you only consider the following poker roles: (The higher the number, the hig...
{ "input": [], "output": [] }
{ "input": [ "1,2,3,4,1\n2,3,2,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,12,10,1,13\n11,12,13,1,2" ], "output": [ "one pair\ntwo pair\nthree card\nfull house\nfour card\nstraight\nstraight\nnull" ] }
{ "input": [ "1,2,3,4,1\n2,3,1,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,12,10,1,13\n11,12,13,1,2", "1,2,3,4,1\n2,3,1,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,13,10,1,13\n11,12,13,1,2", "1,2,3,4,1\n2,3,1,3,12\n13,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,13,10,1,...
p00170 Lunch
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won't fall over, but some foods are soft and will collapse if I put a heav...
{ "input": [], "output": [] }
{ "input": [ "4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 100 500\nchocolate 50 350\ncookie 30 80\npurin 40 400\ncracker 40 160\n0" ], "output": [ "apple\ncake\nsandwich\ncheese\nkanzume\npurin\nchocolate\nonigiri\noni...
{ "input": [ "4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 100 500\nchocolaue 50 350\ncookie 30 80\npurin 40 400\ncracker 40 160\n0", "4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri...
p00326 Scheduler
You are working on the development of the unique operating system "Unsgune 15" and are struggling to design a scheduler that determines performance. A scheduler is a program that expresses the processes to be executed in units called tasks and determines the order in which they are executed. The scheduler manages tasks...
{ "input": [], "output": [] }
{ "input": [ "5 3\n1 5 2\n3 8 5\n1 2 3\n5 5 5\n4 8 2\n0\n1 2 3\n2\n2 2 3 1\n4 3 1 2", "5 2\n1 1\n2 1\n3 1\n4 4\n5 2\n3\n1 4\n2 4\n2 5\n1 2\n1\n3 2 1" ], "output": [ "4\n5\n2\n1\n3", "3\n2\n5\n1\n4" ] }
{ "input": [ "5 3\n1 5 2\n3 8 5\n1 2 3\n5 5 5\n4 8 2\n0\n1 2 3\n1\n2 2 3 1\n4 3 1 2", "5 2\n1 1\n2 1\n6 1\n4 4\n5 2\n3\n1 4\n2 4\n2 5\n1 2\n1\n3 2 1", "5 3\n1 5 2\n3 8 5\n1 2 0\n5 5 5\n0 8 2\n0\n1 2 3\n1\n2 2 3 1\n4 3 1 2", "5 3\n1 9 2\n3 8 5\n2 2 3\n5 5 5\n4 8 3\n0\n1 2 3\n2\n2 2 3 1\n4 3 1 2", "...
p00499 Homework
problem JOI, who has been suffering from his winter vacation homework every time, decided to do his homework systematically this time. Homework is a national language and math drill, with a national language drill on page A and a math drill on page B. JOI can advance the Japanese drill up to C pages and the math dril...
{ "input": [], "output": [] }
{ "input": [ "20\n25\n30\n6\n8" ], "output": [ "15" ] }
{ "input": [ "20\n4\n30\n6\n8", "20\n4\n30\n7\n1", "20\n4\n30\n6\n6", "20\n4\n30\n7\n15", "20\n4\n30\n7\n13", "20\n2\n6\n3\n1", "20\n1\n30\n1\n2", "20\n1\n46\n6\n6", "20\n1\n52\n1\n2", "20\n4\n0\n6\n1", "20\n25\n47\n6\n1", "20\n1\n60\n1\n1", "20\n1\n44\n1\n2", "...
p00683 A Simple Offline Text Editor
A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and finally reports the text obtained by perfor...
{ "input": [], "output": [] }
{ "input": [ "3\nA sample input\n9\nforward word\ndelete char\nforward word\ndelete char\nforward word\ndelete char\nbackward word\nbackward word\nforward word\nHallow, Word.\n7\nforward char\ndelete word\ninsert \"ello, \"\nforward word\nbackward char\nbackward char\ninsert \"l\"\n\n3\nforward word\nbackward wor...
{ "input": [ "3\nA sample input\n9\nforward word\ndelete char\nforward word\ndelete char\nforward word\ndelete char\nbackward word\nbackward word\nforward word\nHallow, Word.\n7\nforward char\ndelete word\ninsert \"ello, \"\nforward word\nbackward char\nbackward char\ninsert \"l\"\n\n3\nforward vord\nbackward wor...
p00825 Concert Hall Scheduling
You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money for many years. The two rooms are of the same size and arrangement...
{ "input": [], "output": [] }
{ "input": [ "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n3 25 10000\n5 15 5000\n22 300 5500\n10 295 9000\n7 7 6000\n8\n32 251 2261\n123 281 1339\n211 235 5641\n162 217 7273\n22 139 7851\n194 198 9190\n119 274 878\n122 173 8640\n0" ], "output": [ "30\n25500\n38595" ] }
{ "input": [ "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n3 25 10000\n5 15 5000\n22 300 5500\n10 295 9000\n7 7 6000\n8\n32 251 2261\n123 281 1339\n211 235 5641\n162 217 7273\n22 158 7851\n194 198 9190\n119 274 878\n122 173 8640\n0", "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n3 25 10000\n5 15 5000\...
p00956 Black and White Boxes
Example Input 4 B W WB WB Output 5
{ "input": [], "output": [] }
{ "input": [ "4\nB\nW\nWB\nWB" ], "output": [ "5" ] }
{ "input": [ "4\nB\nW\nWB\nBW", "4\nB\nW\nBW\nBW", "4\nC\nW\nWB\nBV", "4\nB\nW\nBW\nWB", "4\nC\nW\nXB\nBV", "4\nC\nW\nVB\nBV", "4\nC\nW\nVB\nBU", "4\nC\nW\nXB\nBW", "4\nD\nW\nVB\nBV", "4\nC\nW\nUB\nBU", "4\nC\nW\nTB\nBU", "4\nD\nW\nTB\nBU", "4\nC\nW\nBW\nXB", "4...
p01089 Deadlock Detection
Deadlock Detection In concurrent processing environments, a deadlock is an undesirable situation where two or more threads are mutually waiting for others to finish using some resources and cannot proceed further. Your task is to detect whether there is any possibility of deadlocks when multiple threads try to execute...
{ "input": [], "output": [] }
{ "input": [ "11\n01u12u0123u\n6\n01u10u\n8\n201u210u\n9\n01u12u20u\n3\n77u\n12\n9u8u845u954u\n0" ], "output": [ "SAFE\nUNSAFE\nSAFE\nUNSAFE\nUNSAFE\nUNSAFE" ] }
{ "input": [ "11\n01u12u0123u\n6\n01u10u\n8\n201u210u\n9\n01u12u20u\n3\nu77\n12\n9u8u845u954u\n0", "11\n01u12u0123u\n6\n01u10u\n0\n201u210u\n9\n01u12u20u\n3\n77u\n12\n9u8u845u954u\n0", "11\n01u12u3120u\n6\n01u10u\n0\n20u1210u\n5\n01u12u20u\n3\n77u\n12\n9u8u845u954u\n0", "11\n01u12u0123u\n6\n01u10u\n1\...
p01225 Rummy
Your friend recently came up with a card game called UT-Rummy. The cards used in this game are numbered red, green, or blue and any number from 1 to 9. Each player in this game has 9 cards in his or her hand, chooses one from his or her hand, discards it, and draws one from the deck instead. In this way, the turn is a...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 6\nR R B G G G R R R\n2 2 2 3 3 3 1 1 1\nR G B R G B R G B" ], "output": [ "1\n0\n0\n0\n1" ] }
{ "input": [ "5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 6\nR R B G G G R R R\n2 2 2 3 3 3 1 1 2\nR G B R G B R G B", "5\n1 2 3 3 4 5 7 7 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R R R R R\n1 2 3 4 4 4 5 5 5\nR R...
p01359 Era Name
As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as “Western calendar” in Japan. The other calendar system is era-based calendar, or so-called “Japanese calendar.” This system comes from ancient Chines...
{ "input": [], "output": [] }
{ "input": [ "4 3\nmeiji 10 1877\ntaisho 6 1917\nshowa 62 1987\nheisei 22 2010\n1868\n1917\n1988\n1 1\nuniversalcentury 123 2168\n2010\n0 0" ], "output": [ "meiji 1\ntaisho 6\nUnknown\nUnknown" ] }
{ "input": [ "4 3\nmeiji 10 1877\ntaisho 6 1917\nshowa 62 1987\nheisei 22 2010\n2046\n1917\n1988\n1 1\nuniversalcentury 123 2168\n2010\n0 0", "4 3\nmeiji 10 1877\ntaisho 6 1917\nshowa 62 1987\ngeisei 22 2010\n1868\n1917\n1988\n1 1\nuniversalcentury 123 2168\n2010\n0 0", "4 3\nmeiji 10 1877\ntaisho 6 1917\...
p01541 hosonagaitokoro
Takahashi decided to go sightseeing in New York with Apple. Takahashi didn't have any particular hope for sightseeing, but due to Sachika-chan's enthusiastic invitation, he decided to go sightseeing in the "hosonogai place" as shown in the map below. <image> Google Maps-(C) 2012 Google This "horizontal place" is very...
{ "input": [], "output": [] }
{ "input": [ "100\n4\n3\n1\n1\n3\n2\n40\n60", "100\n2\n2\n1\n0", "100\n3\n2\n1\n1\n1\n50", "100\n2\n1\n2\n0" ], "output": [ "421", "200", "200", "201" ] }
{ "input": [ "100\n4\n6\n1\n1\n3\n2\n40\n60", "100\n3\n2\n1\n1\n1\n59", "100\n2\n0\n2\n0", "100\n2\n0\n4\n0", "100\n4\n6\n2\n1\n3\n2\n63\n60", "100\n4\n7\n2\n1\n3\n2\n63\n60", "100\n4\n7\n2\n1\n5\n2\n63\n68", "100\n4\n7\n0\n1\n5\n4\n63\n93", "100\n4\n6\n1\n1\n2\n2\n40\n60", "10...
p01697 1 Day Passport
One-day pass Mr. D, a university student living in a certain country, is a big fan of Mr. A, a national guitarist, and is thinking of going to a live concert in the city center this summer. However, since Mr. D lives in a remote area, he was very worried about the cost of transportation. At that time, he learned of th...
{ "input": [], "output": [] }
{ "input": [ "3 3 3 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n0\n3 3 2 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n0\n6 4 3 2\n1 2 3 1 1\n1 3 8 1 1\n4 6 3 2 2\n5 6 7 2 2\n1 6\n0\n3 3 3 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n2\n2 6 1 2\n1 2 2\n3 3 2 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n2\n2 6 1 2\n1 2 2\n3 2 2 2...
{ "input": [ "3 3 3 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n0\n3 3 2 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n0\n6 4 3 2\n1 2 3 1 1\n1 3 8 1 1\n4 6 3 2 2\n5 6 7 2 2\n1 6\n0\n3 3 3 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n2\n2 6 1 2\n1 2 2\n3 3 2 2\n1 2 3 1 1\n1 3 8 1 1\n2 3 3 2 2\n1 3\n2\n2 6 1 2\n1 2 2\n3 2 2 2...
p01841 Rooted Tree for Misawa-san
C --Misawa's rooted tree Problem Statement You noticed that your best friend Misawa's birthday was near, and decided to give him a rooted binary tree as a gift. Here, the rooted binary tree has the following graph structure. (Figure 1) * Each vertex has exactly one vertex called the parent of that vertex, which is c...
{ "input": [], "output": [] }
{ "input": [ "((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\n(()[4]())[3](((()[2]())[1]())[8](()[3]()))" ], "output": [ "(()[6]())[8](((()[4]())[7]())[9]())" ] }
{ "input": [ "((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\n(()[4]())[3](((()[2]())[1]())[8](()[3]()*)", "((()[8]())[2]())[5](((()[3]())[6](()[3]()))[1]())\n(()[4]())[3](((()[2]())[1]())[8](()[3]()))", "((()[8]())[2]())[5](((()[2]())[6](()[3]()))[1]())\n(()[4]())[3](((()[2]())[0]())[8](()[3]')))", ...
p01977 Aquarium
problem AOR Ika got a water tank with a size of $ 1 $ in length and $ N $ in width. The aquarium is tall enough to hold water. The aquarium has $ N-1 $ partitions and is evenly spaced into $ N $ compartments. When water was poured here, the height of the water in each section became $ a_i $. AOR Ika decided to remove...
{ "input": [], "output": [] }
{ "input": [ "5 3\n9 1 2 3 9" ], "output": [ "20.000000" ] }
{ "input": [ "5 3\n9 1 4 3 9", "5 3\n9 1 4 3 8", "5 3\n9 1 3 3 8", "4 3\n9 1 3 3 8", "4 3\n5 1 3 3 8", "4 3\n5 1 5 3 8", "4 3\n5 1 3 0 12", "7 3\n5 1 3 0 12", "5 3\n9 1 2 3 5", "5 3\n4 1 4 3 9", "4 3\n5 1 3 6 8", "4 1\n5 1 5 3 8", "4 3\n5 1 1 0 12", "7 5\n5 1 3 ...
p02123 Fissure Puzzle Hard
Problem There is a grid of $ N \ times N $ cells. Initially all cells are white. Follow the steps below to increase the number of black squares. Select one white cell from the cells that are even-numbered from the top and even-numbered from the left. The selected square turns black. Further, the adjacent white square...
{ "input": [], "output": [] }
{ "input": [ "3\noxx\noxx\nooo", "5\noxooo\noxooo\noxooo\nxxxxx\noxooo", "9\noxoooooxo\noxxxxxxxx\noxoooooxo\nxxxxxxxxx\noxoxooooo\noxxxxxxxx\noxoxoxooo\noxoxxxxxx\noxoxoxooo" ], "output": [ "-1", "1\n4\n2", "4\n4\n2\n2\n8\n6\n4\n8\n6" ] }
{ "input": [ "3\noxx\nowx\nooo", "9\noxoooooxo\noxxxxxxxx\noxoooooxo\nxxxxxxxxx\noxoxooooo\noxxxxxxxx\noxoxoxooo\noxoxxxxxx\noxoxoxpoo", "3\nyyn\nwup\npnp", "5\noxooo\noxooo\noxooo\nxxxxx\noxoop", "3\noxy\nowx\nooo", "3\nyxo\nowx\nooo", "3\nyxo\novx\nooo", "3\nyxo\novx\noop", "3\ny...
p02263 Stack
Notes Template in C Constraints 2 ≤ the number of operands in the expression ≤ 100 1 ≤ the number of operators in the expression ≤ 99 -1 × 109 ≤ values in the stack ≤ 109 Input An expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character. You can assume that +...
{ "input": [], "output": [] }
{ "input": [ "1 2 + 3 4 - *", "1 2 +" ], "output": [ "-3", "3" ] }
{ "input": [ "1 4 + 3 4 - *", "1 3 +", "1 4 + 2 4 - *", "0 3 +", "1 1 + 2 4 - *", "0 3 *", "1 4 + 3 8 - *", "0 5 +", "1 1 + 3 4 - *", "1 4 * 3 1 - *", "1 4 * 3 8 - *", "1 1 + 5 4 - *", "1 4 * 3 1 - +", "1 4 * 3 0 - *", "2 4 * 3 1 - +", "2 4 * 3 0 - *", ...
p02411 Grading
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, t...
{ "input": [], "output": [] }
{ "input": [ "40 42 -1\n20 30 -1\n0 2 -1\n-1 -1 -1" ], "output": [ "A\nC\nF" ] }
{ "input": [ "40 42 -1\n34 30 -1\n0 2 -1\n-1 -1 -1", "40 42 -1\n16 30 -1\n0 2 -1\n-1 -1 -1", "92 64 -1\n16 50 -1\n1 1 0\n-1 -1 -1", "40 10 -1\n16 30 -1\n0 2 -1\n-1 -1 -1", "40 12 -1\n34 30 0\n0 2 -1\n-1 -1 -1", "40 53 -1\n0 7 -1\n0 1 -1\n-1 -1 -1", "20 11 -2\n16 30 0\n1 0 -1\n-1 -1 -1", ...
cc
Given a undirected graph find the number of connected components. Input First line of the input is 't'- number of test case. Followed by N, the number of vertices (Numbered 0 to N-1). Followed by 'e' number of edges. Followed by description of 'e' edges in the form 'a b' I.e. an edge exist between vertex a and b. ...
{ "input": [], "output": [] }
{ "input": [ "2\n4\n2\n0 1\n0 2\n8\n0" ], "output": [ "2\n8" ] }
{ "input": [ "2\n4\n2\n0 1\n0 1\n8\n0", "2\n4\n2\n0 0\n0 2\n9\n0", "2\n4\n2\n0 1\n0 2\n3\n0", "2\n4\n2\n0 2\n0 1\n8\n0", "2\n4\n2\n0 0\n0 3\n3\n0", "2\n4\n2\n0 0\n0 0\n8\n-1", "2\n4\n2\n1 0\n0 2\n9\n-1", "2\n4\n2\n1 0\n0 2\n6\n-1", "2\n4\n2\n0 2\n1 2\n1\n0", "2\n3\n2\n0 2\n1 2\...
csixiepa
Given a list of sentences, for each sentence, determine if it is a pangram or not. pangrams are sentences constructed by using every letter of the alphabet at least once. For example: How quickly daft jumping zebras vex   Input The first line contains T, the number of test cases. The following lines will contain...
{ "input": [], "output": [] }
{ "input": [ "2\nHow quickly daft jumping zebras vex\nwhat are you doing" ], "output": [ "TRUE\nFALSE" ] }
{ "input": [ "2\nHow quickly daft jumping zebras vex\nwhat are uoy doing", "2\nHow qlickvy daft ginpmuj zebras vew\nwhas afr you doing", "2\nHow quickly daft jumping zebras vex\nwhat aer uoy doing", "2\nHow quickly daft jumping zebras vex\nwhat afr uoy doing", "2\nHow quickly daft jumping zebras v...
helplira
Problem Statement Lira is a little girl form Bytenicut, a small and cozy village located in the country of Byteland.  As the village is located on a somewhat hidden and isolated area, little Lira is a bit lonely and she needs to invent new games that she can play for herself. However, Lira is also very clever, so, she...
{ "input": [], "output": [] }
{ "input": [ "2\n0 0 0 100 100 0\n1 1 1 5 5 1" ], "output": [ "2 1\n" ] }
{ "input": [ "2\n0 0 0 100 100 0\n1 2 1 5 5 1", "2\n-1 0 0 010 000 0\n1 3 0 7 14 1", "2\n0 0 0 111 000 1\n1 2 0 3 2 1", "2\n0 0 0 100 100 0\n1 2 1 5 5 2", "2\n0 0 0 100 100 0\n1 2 1 5 9 2", "2\n0 0 0 100 100 0\n1 2 1 5 9 1", "2\n0 0 0 100 100 0\n1 2 1 7 9 1", "2\n-1 0 0 100 100 0\n1 2 ...
missp
Chef is fan of pairs and he likes all things that come in pairs. He even has a doll collection in which all dolls have paired.One day while going through his collection he found that there are odd number of dolls. Someone had stolen a doll!!! Help chef find which type of doll is missing.. Input The first line conta...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n1 \n2\n1", "1\n5\n1\n1\n2\n2\n3" ], "output": [ "2\n", "3\n" ] }
{ "input": [ "1\n3\n2 \n2\n1", "1\n3\n0 \n2\n0", "1\n5\n1\n1\n3\n3\n3", "1\n3\n1 \n4\n1", "1\n5\n1\n1\n3\n6\n3", "1\n3\n1 \n8\n1", "1\n5\n1\n1\n2\n2\n5", "1\n5\n1\n1\n3\n3\n9", "1\n3\n1 \n10\n1", "1\n1\n11 \n4\n0", "1\n1\n15 \n4\n0", "1\n1\n27 \n4\n0", "1\n1\n7 \n6\...
ren2013a
NOTE :This problem is just a test problem. The submissions to this problem will not be counted in the final ranklist for prize distribution. We apologize for the inconvenience caused.   Problem description Given two integers A and B that are not necessarily in base-10, find the smallest possible A + B in base-10. Fo...
{ "input": [], "output": [] }
{ "input": [ "3\n213 4721\n1001 90\n638 241" ], "output": [ "2552\n99\n592" ] }
{ "input": [], "output": [] }