name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p02076 Rooks Game
Problem Statement "Rooks Game" is a single-player game and uses a chessboard which has $N \times N$ grid and $M$ rook pieces. A rook moves through any number of unoccupied squares horizontally or vertically. When a rook can attack another rook, it can capture the rook and move to the square which was occupied. Note t...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02217 Tree of Peony
Problem statement There is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices. Each vertex has a button, and the button at the $ i $ th vertex is called the button $ i $. First, the beauty of the button $ i $ is $ a_i $. Each time you press the button ...
{ "input": [], "output": [] }
{ "input": [ "4\n1 2\n1 3\n3 4\n0 3 2 0\n-3 4 5 -1" ], "output": [ "4" ] }
{ "input": [ "4\n1 2\n1 3\n1 4\n0 3 2 0\n-3 4 5 -1", "4\n1 2\n2 3\n1 4\n0 3 2 0\n-3 4 5 -1", "4\n1 2\n1 4\n3 4\n0 3 2 0\n-3 4 5 -1", "4\n1 2\n1 3\n1 4\n0 4 2 0\n-3 4 5 -1", "4\n1 2\n2 3\n1 4\n0 3 2 0\n-3 2 5 -1", "4\n1 2\n1 3\n3 4\n0 3 2 0\n-4 4 5 -1", "4\n1 2\n1 4\n3 4\n0 3 3 0\n-3 4 5 -1...
p02370 Topological Sort
<image> A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can undertake task B after both task A and task B are finished. You can obt...
{ "input": [], "output": [] }
{ "input": [ "6 6\n0 1\n1 2\n3 1\n3 4\n4 5\n5 2" ], "output": [ "0\n3\n1\n4\n5\n2" ] }
{ "input": [ "6 6\n0 1\n1 2\n4 1\n3 4\n4 5\n5 2", "6 6\n0 1\n1 2\n4 1\n3 4\n4 5\n5 0", "6 6\n0 2\n1 2\n3 1\n3 4\n4 5\n5 2", "6 6\n0 1\n1 2\n3 1\n3 4\n4 5\n5 1", "6 6\n0 2\n1 2\n4 1\n3 4\n1 5\n5 0", "6 0\n0 1\n1 2\n4 1\n3 4\n4 5\n5 2", "4 0\n1 2\n2 3\n2 2\n5 4\n6 4\n5 2", "7 0\n1 1\n1 2...
aln
There is a country which recently got invaded by a fleet of aliens. They started living with the people there. Relations between the aliens and humans were generally bitter. The government at the center decided that they will divide the country into 2 states (initially there were none). There are N citizens in the coun...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n1 -1\n4\n-1 1 -1 -1\n5\n1 1 1 -1 -1" ], "output": [ "-1 1\n-1 -1 -1 1\n-1 -1 1 1 1" ] }
{ "input": [], "output": [] }
cheftic
Tic-Tac-Toe used to be Chef's favourite game during his childhood. Reminiscing in his childhood memories, he decided to create his own "Tic-Tac-Toe", with rules being similar to the original Tic-Tac-Toe, other than the fact that it is played on an NxN board. The game is played between two players taking turns. First ...
{ "input": [], "output": [] }
{ "input": [ "1\n4 4\nXOXO\nOX..\nXO..\nOXOX", "3\n3 3\nXOX\nO.O\nXOX\n3 1\n...\n...\n...\n3 2\n...\n...\n..." ], "output": [ "YES", "YES\nYES\nNO" ] }
{ "input": [], "output": [] }
ds24
Problem You are living in 2050, People do not work any more. Only surrogates (clone having same features & DNA characteristics) work for every individual. Government is substituting man labor by surrogates. Every person can control his own surrogate from his home and paid for his services one of the criminal master mi...
{ "input": [], "output": [] }
{ "input": [ "9 6\nAAAAAA\nACACAC\nGTTTTG\nACACAC\nGTTTTG\nACACAC\nACACAC\nTCCCCC\nTCCCCC\n0 0" ], "output": [ "1\n2\n0\n1\n0\n0\n0\n0\n0" ] }
{ "input": [], "output": [] }
kc03
Points:15 The Environmental Protection Agency is a billion dollar organisation that works to protect the environment from hazardous changes worldwide. It is funded by the national governments, charitable organisations, business donations as well as its own earnings. To evaluate the ground realities of the theory of glo...
{ "input": [], "output": [] }
{ "input": [ "3\n4\n1 0 1 0\n0 0 0 0\n1 0 1 0\n0 0 0 0\n4\n1 0 1 0\n0 0 1 0\n1 1 1 1\n0 1 0 1\n4\n1 0 1 0\n0 1 1 0\n1 1 1 1\n0 1 0 1" ], "output": [ "1\n(2,3)\n0\n" ] }
{ "input": [ "3\n4\n1 0 1 0\n0 0 0 0\n1 0 1 0\n0 0 0 0\n4\n1 0 1 0\n0 0 1 0\n1 1 1 1\n0 2 0 1\n4\n1 0 1 0\n0 1 1 0\n1 1 1 1\n0 1 0 1", "3\n4\n1 0 1 0\n0 0 0 0\n1 -1 1 0\n0 0 0 0\n4\n2 0 1 0\n0 0 1 0\n1 1 1 1\n0 2 0 1\n4\n1 0 1 0\n0 1 1 0\n1 1 1 1\n0 1 0 1", "3\n4\n1 0 1 0\n0 0 0 0\n1 -1 1 0\n0 0 0 0\n4\n2...
numsum
According to folklore, the great mathematician Gauss was able to calculate the sum of the first 50 natural numbers in mere seconds. You are given a similar problem, where you have to calculate the sum of the first 'n' natural numbers. The only catch being that the the number 'n' can be really very large. You have to ca...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n5" ], "output": [ "6\n15" ] }
{ "input": [], "output": [] }
smpair
You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N. Input The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.  The first line of each description consists of a single integer N. The second ...
{ "input": [], "output": [] }
{ "input": [ "1\n4\n5 1 3 4" ], "output": [ "4\n" ] }
{ "input": [ "1\n4\n5 1 3 8", "1\n4\n4 0 3 8", "1\n4\n7 1 3 0", "1\n4\n7 0 3 0", "1\n4\n5 1 6 8", "1\n4\n1 1 3 8", "1\n4\n5 2 9 8", "1\n4\n5 3 12 8", "1\n4\n2 1 2 -2", "1\n4\n2 0 2 -2", "1\n4\n2 -1 0 -2", "1\n4\n9 1 11 8", "1\n4\n-1 1 0 -3", "1\n4\n-2 1 0 -3", ...
11_C. How Many Squares?
You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2 × 2. We are only interested in two types of squares: 1. squares with each side parallel to a side of the matrix; 2. squares with each sid...
{ "input": [], "output": [] }
{ "input": [ "2\n8 8\n00010001\n00101000\n01000100\n10000010\n01000100\n00101000\n11010011\n11000011\n10 10\n1111111000\n1000001000\n1011001000\n1011001010\n1000001101\n1001001010\n1010101000\n1001001000\n1000001000\n1111111000\n", "1\n12 11\n11111111111\n10000000001\n10111111101\n10100000101\n10101100101\n10...
{ "input": [ "2\n8 8\n00010001\n00101000\n01000100\n10000010\n01000100\n00101000\n11010011\n11000011\n10 10\n1111111000\n1000001000\n1011001000\n1011001010\n1000001111\n1001001010\n1010101000\n1001001000\n1000001000\n1111111000\n", "1\n12 11\n11111111111\n10000000001\n10111111101\n10100000101\n10101100101\n11...
1302_E. Amazing bitset
This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543) Andrey has just started to study competitive programming and he is fascinated by bitsets and operations on them. For example, assume he has a bitset with n elements. ...
{ "input": [], "output": [] }
{ "input": [ "5 1 2\n", "1 228 239\n" ], "output": [ "\n848765426\n", "\n0\n" ] }
{ "input": [], "output": [] }
1388_C. Uncle Bogdan and Country Happiness
Uncle Bogdan is in captain Flint's crew for a long time and sometimes gets nostalgic for his homeland. Today he told you how his country introduced a happiness index. There are n cities and n−1 undirected roads connecting pairs of cities. Citizens of any city can reach any other city traveling by these roads. Cities a...
{ "input": [], "output": [] }
{ "input": [ "2\n4 4\n1 1 1 1\n4 1 -3 -1\n1 2\n1 3\n1 4\n3 13\n3 3 7\n13 1 4\n1 2\n1 3\n", "2\n7 4\n1 0 1 1 0 1 0\n4 0 0 -1 0 -1 0\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n5 11\n1 2 5 2 1\n-11 -2 -6 -2 -1\n1 2\n1 3\n1 4\n3 5\n" ], "output": [ "NO \nNO \n", "YES\nYES\n" ] }
{ "input": [ "2\n7 4\n1 0 1 1 0 1 0\n4 0 0 -1 0 -1 0\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n5 11\n1 2 5 2 1\n-11 0 -6 -2 -1\n1 2\n1 3\n1 4\n3 5\n", "2\n7 4\n1 0 1 1 0 1 0\n4 0 -1 -1 0 -1 0\n1 2\n1 3\n1 4\n3 5\n3 6\n3 7\n5 11\n1 2 5 2 1\n-11 -2 -6 -2 -1\n1 2\n1 3\n1 4\n3 5\n", "2\n7 4\n1 0 1 1 0 1 0\n4 0 0 -1 0 -2...
1453_A. Cancel the Trains
Gildong's town has a train system that has 100 trains that travel from the bottom end to the top end and 100 trains that travel from the left end to the right end. The trains starting from each side are numbered from 1 to 100, respectively, and all trains have the same speed. Let's take a look at the picture below. <i...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n1\n3 4\n3 2\n1 3 4\n2 4\n9 14\n2 7 16 28 33 57 59 86 99\n3 9 14 19 25 26 28 35 41 59 85 87 99 100\n" ], "output": [ "\n0\n1\n3\n" ] }
{ "input": [ "3\n1 2\n1\n3 4\n3 2\n1 3 4\n2 4\n9 14\n2 7 16 28 33 57 59 92 99\n3 9 14 19 25 26 28 35 41 59 85 87 99 100\n", "3\n1 2\n1\n1 4\n3 2\n1 3 4\n2 4\n9 14\n2 7 16 28 33 57 59 92 99\n3 9 14 19 25 26 28 35 41 59 85 87 99 100\n", "3\n1 2\n1\n1 4\n3 2\n1 3 4\n3 4\n9 14\n2 7 16 28 33 12 59 92 99\n3 9 1...
345_A. Expecting Trouble
It is Friday the 13th today, and even though you're a modern well-educated person, you can't help feeling a bit nervous about it. You decide to look for evidence against this superstition (or for it). As a first step, you recall all Fridays the 13th in your life and calculate how many of them were unusually bad — like ...
{ "input": [], "output": [] }
{ "input": [ "?111?1??1\n1.0\n", "01?10??10000\n0.5\n" ], "output": [ "1.00000\n", "0.37500\n" ] }
{ "input": [], "output": [] }
counter-strike-12
Navi is a counter strike pro. He always say how good he is at counter strike. After being tired of Navi, his friends decided to test his skills at shooting. They put M targets on a X-Y plane, each target is denoted by (X, Y) where X is x-coordinate and Y is y-coordinate. His friends also gave him N locations on X-Y pl...
{ "input": [], "output": [] }
{ "input": [ "1\n3 3 5\n1 1\n2 2\n3 3\n1 0\n0 0\n2 0\n\nSAMPLE" ], "output": [ "YES\n" ] }
{ "input": [ "1\n3 3 5\n1 1\n2 2\n3 3\n1 0\n0 0\n2 0\n\nSAMPLF", "1\n3 2 0\n1 0\n2 -1\n5 3\n1 1\n2 1\n2 1\n\nSPMALE", "1\n3 3 5\n1 1\n2 2\n3 3\n1 0\n0 0\n4 0\n\nSAMPLF", "1\n3 3 5\n1 1\n2 4\n3 3\n1 0\n0 0\n4 0\n\nSAMPLF", "1\n3 3 5\n1 1\n2 4\n3 3\n1 0\n0 0\n4 0\n\nFLPMAS", "1\n3 3 5\n2 1\n2 4\...
finding-present-1
Today is Tom's Birthday. His Mom gifted him two sets of integers to play with, set Q and set R. R is the transformation of set Q. Both Q and R contains same frequency of numbers. While playing, he accidently drops few of integers of set Q. You have to help him find the numbers that he has dropped in ascending order a...
{ "input": [], "output": [] }
{ "input": [ "10\n23 24 25 26 27 28 23 24 25 26\n13\n23 24 24 25 26 27 25 28 23 26 25 26 24\n\nSAMPLE" ], "output": [ "24 25 26" ] }
{ "input": [ "10\n23 24 25 26 27 28 23 24 25 26\n22\n23 24 24 25 26 27 25 28 23 26 25 26 24\n\nSAMPLE", "10\n23 24 25 26 27 28 23 24 25 26\n22\n23 24 24 25 26 27 24 28 23 26 25 26 24\n\nSAMPLE", "10\n23 24 25 26 27 28 23 24 25 26\n13\n23 26 24 25 26 27 25 28 23 26 25 26 24\n\nSAMPLE", "10\n23 24 25 26...
smoothing-pixels-1
You have a one-dimensional array of N pixels. Each pixel has a value, represented by a number between 0 and 255, inclusive. The distance between two pixels is the absolute difference of their numbers. You can perform each of the following operations zero or more times: With cost D, delete any pixel, so its original n...
{ "input": [], "output": [] }
{ "input": [ "1\n6 6 2 3\n1 7 5\n\nSAMPLE" ], "output": [ "Case #1: 4" ] }
{ "input": [ "1\n6 2 2 3\n1 7 5\n\nSAMPLE", "1\n6 2 3 3\n1 7 5\n\nSAMPLE", "1\n6 2 3 3\n1 11 5\n\nSAMPLE", "1\n6 2 3 3\n1 11 10\n\nSAMOLE", "1\n6 2 0 3\n1 11 10\n\nSAMOLE", "1\n10 2 0 3\n1 11 10\n\nSAMOLE", "1\n10 2 0 3\n1 2 1\n\nSAMOLE", "1\n6 2 3 3\n0 7 5\n\nSAMPLE", "1\n10 2 1 3...
tic-tac-toe
King Tle4Ever of Time Limit Exceeded is really fascinated about Tic Tac Toe. He organizes a national level contest for Tic Tac Toe every year in Time Limit Exceeded. (Though I agree you need to be really stupid to loose a game of Tic Tac Toe but for the sake of question assume playing Tic Tac Toe for them is same as pl...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n5\n\nSAMPLE" ], "output": [ "3 5\n20 30\n" ] }
{ "input": [ "2\n1\n5\n\nSAMPLE", "2\n1\n9\n\nSBMQLE", "2\n3\n1\n\nSAMPLE", "2\n1\n3\n\nRAMQLE", "2\n3\n5\n\nSAMPME", "2\n1\n1\n\nSAMPLD", "2\n1\n7\n\nELQMBR", "2\n1\n11\n\nELQMBR", "2\n1\n13\n\nELQMAS", "2\n3\n3\n\nSAMPLE", "2\n3\n7\n\nSAMPME", "2\n1\n17\n\nELQMAR", ...
p02557 AtCoder Beginner Contest 178 - Contrast
Given are two sequences A and B, both of length N. A and B are each sorted in the ascending order. Check if it is possible to reorder the terms of B so that for each i (1 \leq i \leq N) A_i \neq B_i holds, and if it is possible, output any of the reorderings that achieve it. Constraints * 1\leq N \leq 2 \times 10^5 *...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1 2\n1 1 3", "4\n1 1 2 3\n1 2 3 3", "6\n1 1 1 2 2 3\n1 1 1 2 2 3" ], "output": [ "No", "Yes\n3 3 1 2", "Yes\n2 2 3 1 1 1" ] }
{ "input": [ "3\n1 1 0\n1 1 3", "4\n1 1 2 3\n2 2 3 3", "6\n1 1 1 2 3 3\n1 1 1 2 2 3", "3\n2 1 0\n1 1 3", "4\n1 1 2 3\n2 2 3 5", "6\n1 1 1 2 3 3\n1 1 0 2 2 3", "3\n2 1 0\n1 2 3", "4\n1 1 2 3\n1 2 3 5", "3\n2 1 0\n1 3 3", "4\n1 1 4 3\n1 2 3 5", "6\n2 1 1 2 1 3\n1 1 0 2 2 3", ...
p02688 AtCoder Beginner Contest 166 - Trick or Treat
N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town. There are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}. Takahashi will walk around this town and make mischief on the Snukes who have no s...
{ "input": [], "output": [] }
{ "input": [ "3 2\n2\n1 3\n1\n3", "3 3\n1\n3\n1\n3\n1\n3" ], "output": [ "1", "2" ] }
{ "input": [ "3 1\n2\n1 3\n1\n3", "5 1\n2\n1 3\n1\n3", "3 3\n0\n3\n1\n3\n1\n3", "0 -1\n2\n1 2\n5\n-1", "6 -2\n1\n0 0\n0\n-1", "12 -2\n1\n0 0\n0\n-1", "4 -8\n-2\n1 0\n0\n0", "7 -14\n-2\n1 0\n0\n0", "21 -2\n0\n0 0\n0\n-2", "5 -2\n1\n0 1\n0\n-1", "32 -3\n0\n-1 0\n1\n0", "2...
p02817 AtCoder Beginner Contest 149 - Strings
Given are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string. Constraints * S and T are strings consisting of lowercase English letters. * The lengths of S and T are between 1 and 100 (inclusive). Input Input is gi...
{ "input": [], "output": [] }
{ "input": [ "humu humu", "oder atc" ], "output": [ "humuhumu", "atcoder" ] }
{ "input": [ "gumu humu", "oder atb", "gumt humu", "redo atb", "gums humu", "redp atb", "gums muhu", "redp bta", "gums luhu", "redo bta", "gums lugu", "redo bat", "smug lugu", "redo b`t", "smuf lugu", "rdeo b`t", "smtf lugu", "redo b`s", "smt...
p02953 AtCoder Beginner Contest 136 - Build Stairs
There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i. For each square, you will perform either of the following operations once: * Decrease the height of the square by 1. * Do nothing. Determine if it is possible to perform the operations so that the heights ...
{ "input": [], "output": [] }
{ "input": [ "1\n1000000000", "4\n1 3 2 1", "5\n1 2 3 4 5", "5\n1 2 1 1 3" ], "output": [ "Yes", "No", "Yes", "Yes" ] }
{ "input": [ "1\n1000010000", "4\n1 5 2 1", "5\n1 2 3 6 5", "5\n1 2 0 1 3", "1\n1000011000", "4\n1 5 2 2", "5\n1 2 0 6 5", "5\n0 2 0 1 3", "1\n1000011100", "4\n0 5 2 2", "5\n1 2 0 1 5", "5\n0 3 0 1 3", "1\n1000001100", "4\n0 8 2 2", "5\n1 4 0 1 5", "5\n0...
p03089 AtCoder Grand Contest 032 - Limited Insertion
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N oper...
{ "input": [], "output": [] }
{ "input": [ "9\n1 1 1 2 2 1 2 3 2", "2\n2 2", "3\n1 2 1" ], "output": [ "1\n2\n2\n3\n1\n2\n2\n1\n1", "-1", "1\n1\n2" ] }
{ "input": [ "3\n1 3 1", "9\n1 1 1 1 2 1 2 3 2", "3\n1 1 1", "2\n1 1", "2\n1 2", "9\n1 1 1 2 1 1 2 3 2", "3\n1 2 2", "9\n1 1 1 1 2 1 4 3 2", "9\n1 1 1 2 2 1 4 3 2", "9\n1 1 1 2 2 1 4 1 2", "9\n1 1 1 2 2 1 1 1 2", "3\n1 2 3", "3\n1 1 2", "9\n1 1 1 1 2 1 4 1 2", ...
p03234 AtCoder Grand Contest 028 - Chords
There are 2N points evenly spaced on the circumference of a circle. These points are numbered 1 to 2N in clockwise order, starting from some of them. Snuke will divide these points into N pairs, then for each pair, he will draw a line segment connecting the two points. After the line segments are drawn, two points are...
{ "input": [], "output": [] }
{ "input": [ "2 0", "20 10\n10 18\n11 17\n14 7\n4 6\n30 28\n19 24\n29 22\n25 32\n38 34\n36 39", "4 2\n5 2\n6 1" ], "output": [ "5", "27087418", "6" ] }
{ "input": [ "20 10\n10 18\n11 17\n14 7\n4 5\n30 28\n19 24\n29 22\n25 32\n38 34\n36 39", "4 0\n5 2\n6 1", "20 10\n10 18\n21 17\n14 7\n4 5\n30 28\n19 24\n29 22\n25 32\n38 34\n36 39", "4 1\n5 1\n12 0", "20 10\n10 18\n11 17\n14 7\n1 5\n30 28\n19 24\n29 22\n25 32\n38 34\n36 39", "20 10\n10 18\n11 ...
p03385 AtCoder Beginner Contest 093 - abc of ABC
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. Constraints * |S|=3 * S consists of `a`, `b` and `c`. Input Input is given from Standard Input in the following format: S Output If S can be obtained by permuting `abc`, print `Yes`; otherwis...
{ "input": [], "output": [] }
{ "input": [ "bab", "abc", "aaa", "bac" ], "output": [ "No", "Yes", "No", "Yes" ] }
{ "input": [ "bba", "cab", "abb", "aab", "aac", "bbb", "baa", "caa", "bb`", "`bb", "aba", "acb", "_bb", "bcb", "aca", "b`b", "cba", "aa`", "b_b", "bbc", "cbb", "`aa", "cca", "cbc", "``b", "acc", "bca", "a`a...
p03549 AtCoder Beginner Contest 078 - HSI
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of th...
{ "input": [], "output": [] }
{ "input": [ "100 5", "10 2", "1 1" ], "output": [ "608000", "18400", "3800" ] }
{ "input": [ "100 1", "10 4", "1 0", "110 1", "10 7", "0 0", "111 1", "10 3", "-1 0", "101 1", "10 5", "111 2", "8 5", "011 2", "7 5", "011 3", "7 2", "111 0", "12 2", "110 0", "2 2", "2 4", "2 0", "4 0", "4 1", "4...
p03705 AtCoder Grand Contest 015 - A+...+B Problem
Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? Constraints * 1 ≤ N,A,B ≤ 10^9 * A and B are integers. Input Input is given from Standard Input in the following format: N A B Output Print th...
{ "input": [], "output": [] }
{ "input": [ "5 4 3", "1 7 10", "1 3 3", "4 4 6" ], "output": [ "0", "0", "1", "5" ] }
{ "input": [ "5 5 3", "1 7 7", "4 4 8", "12 -1 0", "12 -2 0", "12 -3 0", "16 -3 0", "16 -2 0", "11 -2 0", "11 -3 0", "19 -3 0", "19 -4 0", "19 0 1", "16 0 1", "13 -1 1", "18 -1 1", "18 -1 2", "32 0 2", "109 0 1", "11 0 1", "5 4 6", ...
p03860 AtCoder Beginner Contest 048 - AtCoder *** Contest
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe...
{ "input": [], "output": [] }
{ "input": [ "AtCoder Beginner Contest", "AtCoder Snuke Contest", "AtCoder X Contest" ], "output": [ "ABC", "ASC", "AXC" ] }
{ "input": [ "AtCoder Befinner Contest", "AtCoder nSuke Contest", "AtCoder sennifeB Cpntest", "AtCoder Sunke Contest", "AtCoder X Contert", "AtCoder Runke Contest", "AtCoder W Contert", "AsDored ekuSn Cnntest", "AtCoder rennigeB Contest", "AtCoder V Contert", "AtCoder Aeifn...
p04026 AtCoder Regular Contest 059 - Unbalanced
Given a string t, we will call it unbalanced if and only if the length of t is at least 2, and more than half of the letters in t are the same. For example, both `voodoo` and `melee` are unbalanced, while neither `noon` nor `a` is. You are given a string s consisting of lowercase letters. Determine if there exists a (...
{ "input": [], "output": [] }
{ "input": [ "needed", "atcoder" ], "output": [ "2 5", "-1 -1" ] }
{ "input": [ "deened", "aoctder", "aocteer", "aectepp", "defnfd", "ndeedd", "defned", "fedned", "aocueer", "efdned", "aocueeq", "efnded", "aocueep", "dendfe", "peeucoa", "peetcoa", "aocteep", "aecteop", "aecsepp", "neeedd", "actoder",...
p00109 Smart Calculator
Your task is to write a program which reads an expression and evaluates it. * The expression consists of numerical values, operators and parentheses, and the ends with '='. * The operators includes +, - , *, / where respectively represents, addition, subtraction, multiplication and division. * Precedence of the operat...
{ "input": [], "output": [] }
{ "input": [ "2\n4-2*3=\n4*(8+4+3)=" ], "output": [ "-2\n60" ] }
{ "input": [ "2\n4-2*3=\n8*(4+4+3)=", "2\n4-2*3=\n8*(4+4+2)=", "2\n4-3*3=\n4*(8+4+3)=", "2\n4-1*3=\n4*(8+4+3)=", "2\n4-1+3=\n4*(8+4+3)=", "2\n4-2+3=\n4*(8+4+3)=", "2\n5-1+3=\n4*(8+4+3)=", "2\n3-1*3=\n4*(8+4+3)=", "2\n4-2+3=\n4+(8+4*3)=", "2\n4-2*3=\n4+(8+4*3)=", "2\n5-1*3=\...
p00243 Filling Game
The tablet interface technology, which can be operated by touching the screen with a finger, has also been applied in the field of games, and various types of games with new operability have been created. The game currently being developed by AZ is one of them. The requirements for this software (game) are as follows....
{ "input": [], "output": [] }
{ "input": [ "3 3\nR G B\nG G G\nG B B\n2 4\nR G\nG G\nR B\nB R\n4 3\nG G B R\nG R R G\nB G G R\n0 0" ], "output": [ "2\n4\n4" ] }
{ "input": [ "3 3\nR G B\nG G G\nG B B\n2 4\nR G\nG G\nR B\nB R\n4 3\nF G B R\nG R R G\nB G G R\n0 0", "3 3\nR G B\nG G G\nG B B\n2 4\nS G\nG G\nR B\nB R\n4 3\nG G B R\nG R R G\nB G G R\n0 0", "3 3\nR G B\nG G G\nG B B\n2 4\nS G\nG G\nR B\nB R\n4 3\nF G B R\nG R R G\nB G G R\n0 0", "3 3\nR G B\nG G G\...
p00424 Data Conversion
Create a program that converts data based on the given conversion table. The characters used in the data are letters or numbers, and the letters are case sensitive. There is no regularity in the order of the characters that appear in the conversion table. The conversion table has two characters (not a string), one be...
{ "input": [], "output": [] }
{ "input": [ "3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0" ], "output": [ "aBC5144aba\naBC5144aba" ] }
{ "input": [ "3\nA a\n0 5\n5 4\n10\nB\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0", "3\nA a\n0 0\n5 4\n10\nB\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\nA a\n0 5\n5 4\n10\nA\nB\nC\n0\n1\n4\n5\na\nb\nA\n0", "3\nA a\n0 0\n5 4\n10\nB\nB\nC\n0\n1\n4\n5\na\nb\nA\n3\n@ a\n0 5\n5 4\n10\n...
p00619 Kuru-Kuru Robot
Dr. Asimov, a robotics researcher, has succeeded in developing a new robot. The robot can move freely along a special wire stretched around the floor. The robot always moves forward in a direction parallel to the current wire. The good news is that this robot doesn't consume energy to move on the wire, regardless of i...
{ "input": [], "output": [] }
{ "input": [ "8\n1 3 11 3\n5 3 13 11\n10 10 17 10\n11 2 11 6\n10 5 14 5\n13 6 13 2\n17 10 17 3\n13 3 19 3\n1 3 19 3\n6\n1 3 11 3\n5 3 13 11\n10 10 17 10\n11 2 11 6\n10 5 14 5\n13 3 19 3\n1 3 19 3\n2\n0 0 7 0\n3 0 7 3\n0 0 7 3\n0" ], "output": [ "270.0000\n-1\n36.86989765" ] }
{ "input": [ "8\n1 3 11 3\n5 3 13 11\n10 10 17 10\n11 2 11 6\n10 5 14 5\n13 6 13 2\n17 10 17 3\n13 3 19 3\n1 3 19 3\n6\n1 3 11 3\n5 3 13 11\n10 10 17 10\n11 2 11 6\n10 8 14 5\n13 3 19 3\n1 3 19 3\n2\n0 0 7 0\n3 0 7 3\n0 0 7 3\n0", "8\n1 3 11 3\n5 3 13 11\n10 10 17 10\n11 2 11 6\n10 5 14 5\n13 6 13 2\n17 10 17...
p00763 Railway Connection
Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1. <image> Figure D-1: A sample railway network Suppose you are going to station D from station A. Obviously, the path with the shortest distance is A->B->D. However, the path with the shortes...
{ "input": [], "output": [] }
{ "input": [ "4 4 2 1 4\n1 2 2 1\n2 3 2 1\n3 4 5 1\n2 4 4 2\n3 1\n3 6\n10 5 3\n\n10\n2 0 1 1 2\n1\n\n1\n4 5 2 4 1\n4 3 10 1\n3 2 2 1\n3 2 1 2\n3 2 5 2\n2 1 10 1\n3 3\n20 30\n3 2 1\n5 10\n3 2 1\n5 5 2 1 5\n1 2 10 2\n1 3 20 2\n2 4 20 1\n3 4 10 1\n4 5 20 1\n2 2\n20\n4 1\n20\n3 1\n0 0 0 0 0" ], "output": [ "5...
{ "input": [ "4 4 2 1 4\n1 2 2 1\n2 3 2 1\n3 4 5 1\n2 4 4 2\n3 1\n3 6\n10 5 3\n\n10\n2 0 1 1 2\n1\n\n1\n4 5 2 4 1\n4 3 10 1\n3 2 2 1\n3 4 1 2\n3 2 5 2\n2 1 10 1\n3 3\n20 30\n3 2 1\n5 10\n3 2 1\n5 5 2 1 5\n1 2 10 2\n1 3 20 2\n2 4 20 1\n3 4 10 1\n4 5 20 1\n2 2\n20\n4 1\n20\n3 1\n0 0 0 0 0", "4 4 2 1 4\n1 2 2 1\...
p00895 The Sorcerer's Donut
Your master went to the town for a day. You could have a relaxed day without hearing his scolding. But he ordered you to make donuts dough by the evening. Loving donuts so much, he can't live without eating tens of donuts everyday. What a chore for such a beautiful day. But last week, you overheard a magic spell that ...
{ "input": [], "output": [] }
{ "input": [ "5 7\nRRCABXT\nAABMFAB\nRROMJAC\nAPTADAB\nYABADAO\n3 13\nABCDEFGHIJKLM\nXMADAMIMADAMY\nACEGIKMOQSUWY\n3 4\nDEFG\nACAB\nHIJK\n3 6\nABCDEF\nGHIAKL\nMNOPQR\n10 19\nJFZODYDXMZZPEYTRNCW\nXVGHPOKEYNZTQFZJKOD\nEYEHHQKHFZOVNRGOOLP\nQFZOIHRQMGHPNISHXOC\nDRGILJHSQEHHQLYTILL\nNCSHQMKHTZZIHRPAUJA\nNCCTINCLAUTFJH...
{ "input": [ "5 7\nRRCABXT\nAABMFAB\nRROMJAC\nAPTADAB\nYABADAO\n3 13\nABCDEFGHIJKLM\nXMADAMIMADAMY\nACEGIKMOQSUWY\n3 4\nDEFG\nACAB\nHIJK\n3 6\nABCDEF\nGHIAKL\nMNOPQR\n10 19\nJFZODYDXMZZPEYTRNCW\nXVGHPOKEYNZTQFZJKOD\nEYEHHQKHFZOVNRGOOLP\nQFZOIHRQMGHPNISHXOC\nDRGILJHSQEHHQLYTILL\nNCSHQMKHTZZIHRPAUJA\nNCCTIMCLAUTFJH...
p01028 Yu-kun Likes an Integer
Hint In solving this problem, the following may be referred to. Shows how to convert an integer value to a string. Assign value as a string to str. For C include <stdio.h> int main () { int value = 123; // Convert this value to a string char str [6]; // This variable contains a string of value sprintf (str, "% d",...
{ "input": [], "output": [] }
{ "input": [ "5 30\n25 51 32 9 2 1 10 2 5 10", "1 10\n1 2 3 4 5 6 7 8 9 10", "5 100\n101 101 101 101 101 101 101 101 101 101", "3 10\n8 4 5 3 5 6 9 10 11 2" ], "output": [ "04555", "0", "NA", "119" ] }
{ "input": [ "5 30\n13 51 32 9 2 1 10 2 5 10", "1 10\n1 2 3 4 7 6 7 8 9 10", "5 100\n101 101 101 101 101 101 101 101 100 101", "5 10\n8 4 5 3 5 6 9 10 11 2", "5 35\n13 51 32 14 2 1 10 2 5 10", "7 35\n13 51 32 14 2 1 10 2 5 10", "7 35\n13 51 1 14 2 1 10 2 5 10", "5 30\n25 51 32 9 2 1 10...
p01159 Autocorrelation Function
Nathan O. Davis is taking a class of signal processing as a student in engineering. Today’s topic of the class was autocorrelation. It is a mathematical tool for analysis of signals represented by functions or series of values. Autocorrelation gives correlation of a signal with itself. For a continuous real function f(...
{ "input": [], "output": [] }
{ "input": [ "3 1\n0 0\n1 1\n2 0\n11 1.5\n0 0\n2 7\n5 3\n7 8\n10 -5\n13 4\n15 -1\n17 3\n20 -7\n23 9\n24 0\n0 0" ], "output": [ "0.166666666666667\n165.213541666667" ] }
{ "input": [ "3 1\n0 0\n1 1\n2 0\n11 1.5\n0 0\n4 7\n5 3\n7 8\n10 -5\n13 4\n15 -1\n17 3\n20 -7\n23 9\n24 0\n0 0", "3 1\n0 0\n1 2\n2 0\n11 1.5\n0 0\n4 7\n5 3\n7 8\n10 -5\n13 4\n15 -1\n17 3\n20 -7\n23 9\n24 0\n0 0", "3 1\n0 0\n1 1\n2 0\n11 1.5\n0 0\n4 7\n5 3\n7 8\n10 -5\n13 4\n15 -1\n17 3\n20 -7\n23 3\n24 0\...
p01298 Water Tank
You built an apartment. The apartment has a water tank with a capacity of L in order to store water for the residents. The tank works as a buffer between the water company and the residents. It is required to keep the tank "not empty" at least during use of water. A pump is used to provide water into the tank. From th...
{ "input": [], "output": [] }
{ "input": [ "1 100\n0 86400 1\n1 100\n43200 86400 1\n0 0" ], "output": [ "1.000000\n0.997685" ] }
{ "input": [ "1 100\n0 86400 1\n1 110\n43200 86400 1\n0 0", "1 101\n0 86400 1\n1 100\n43200 86400 1\n0 0", "1 101\n0 86400 1\n1 000\n43200 86400 1\n0 0", "1 101\n0 73100 1\n1 000\n43200 86400 1\n0 0", "1 101\n0 73100 1\n1 000\n43200 86400 0\n0 0", "1 100\n0 86400 1\n1 100\n68033 86400 1\n0 0",...
p01467 A-B Problem
Problem statement There are two integers $ A $ and $ B $. The process of finding $ A --B $ by writing in decimal is shown below. 1. Express $ A $ and $ B $ in decimal. Subscripts are $ 0,1,2, ..., n-1 $ in order from the bottom, $ A = A_ {n-1} A_ {n-2} ... A_ {0} $, $ B = B_ { n-1} B_ {n-2} ... B_ {0} $. $ n $ is the...
{ "input": [], "output": [] }
{ "input": [ "538 84 1", "2012 1987 1", "99 98 1", "100 2 3" ], "output": [ "554", "1025", "1", "198" ] }
{ "input": [ "538 139 1", "2012 1987 2", "142 98 1", "100 0 3", "538 258 1", "142 98 2", "100 1 3", "110 1 3", "142 73 1", "010 1 3", "142 80 1", "011 1 3", "142 7 1", "111 1 4", "231 7 3", "231 8 3", "333 8 6", "333 6 1", "333 4 2", "333...
p01627 Seishun 18 Kippu 2013
Problem Statement Mr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and does not have much money. Therefore, he is trying to save money by using the Seishun 18 Ticket. With only one 18 ticket, you can ride a local train all day long, and you can enter and exit the ticket gates f...
{ "input": [], "output": [] }
{ "input": [ "8 24\n05:30 Kyoto 06:37 Maibara\n06:50 Maibara 07:36 Tsuruga\n07:42 Tsuruga 10:03 Kanazawa\n10:58 Kanazawa 12:07 Toyama\n12:15 Toyama 14:12 Naoetsu\n14:29 Naoetsu 15:57 Nagaoka\n16:11 Nagaoka 17:14 Niitsu\n17:38 Niitsu 20:06 AizuWakamatsu", "N T\nst_time1 st_name1 ar_time1 ar_name1\nst_time2 st_...
{ "input": [ "8 24\n05:30 Kyoto 06:37 Maibara\n06:50 Maibara 07:36 Tsuruga\n07:42 Tsuruga 10:03 Kanazawa\n10:58 Kanazawa 12:07 Toyama\n12:15 Toyama 14:12 Naoetsu\n14:29 Noaetsu 15:57 Nagaoka\n16:11 Nagaoka 17:14 Niitsu\n17:38 Niitsu 20:06 AizuWakamatsu", "1 180\n10:44 Kosiyama 11:52 AizuWakamatsu", "8 24\...
p01779 Typing Game
H: Typing Game / Typing Game story From here, it's time to train your typing skills. Can you type quickly and accurately? Let ’s enjoy Typing Game! problem As a typing game game system, create a program that operates interactively with respect to the AI ​​output prepared by the judge. AI plays a game of typing N s...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p01913 Islands Survival
problem There is a simple concatenated undirected graph with $ N $ vertices and $ M $ edges. The vertices are numbered $ 1, 2, \ dots, N $. The edges are numbered $ 1, 2, \ dots, M $, and the edge $ i $ connects the vertices $ a_i $ and $ b_i $. Also, the edge $ i $ disappears at time $ t_i $. It takes a unit time to ...
{ "input": [], "output": [] }
{ "input": [ "5 4 2\n1 2 2\n2 3 1\n1 4 2\n4 5 1" ], "output": [ "8" ] }
{ "input": [ "5 4 2\n1 2 2\n4 3 1\n1 4 2\n4 5 1", "5 4 4\n1 2 2\n2 3 1\n1 4 2\n4 5 1", "5 4 2\n1 2 2\n2 3 2\n1 4 2\n4 5 1", "5 4 2\n1 2 1\n1 3 1\n1 4 2\n4 5 1", "5 4 2\n1 2 1\n1 3 1\n1 4 1\n4 5 1", "5 4 4\n1 2 2\n4 3 1\n1 4 2\n4 5 2", "5 4 4\n1 2 4\n2 3 1\n1 4 2\n4 5 1", "5 4 8\n1 2 2\...
p02052 Hokkaido University Easy
A: Hokkaido University Easy Note Please note that the problem settings are the same as problem B, except for the constraints. story Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, a huge campus awaits ... "Eh ... I'm not in time for the next class ...
{ "input": [], "output": [] }
{ "input": [ "3 3\nB.B\n..B\n.BB" ], "output": [ "4" ] }
{ "input": [ "3 3\nA.B\n..B\n.BB", "3 3\nB.B\n..B\n-BB", "1 3\nAB.\n.B.\n.BB", "3 3\nA.B\nA..\n.CB", "3 3\nA.B\n..B\n.AA", "3 3\nA.B\nB..\n.BB", "3 3\nB.B\nB..\n.BB", "3 3\nA.B\n.B.\n.BB", "3 3\nA.B\nA..\n.BB", "3 3\nB.B\nA..\n.BB", "3 3\nAB.\n.B.\n.BB", "3 3\n@.B\nA..\...
p02194 Zero AND Subsets
Zero AND Subsets Given a multiset of nonnegative integers a_1, a_2, .., a_N. How many non-empty subsets of this set have a value bitwiseAND of 0? Find the remainder of the answer divided by 10 ^ 9 + 7. input N a_1 a_2 ... a_N output Divide the answer by 10 ^ 9 + 7 and output the remainder. Constraint * 1 \ l...
{ "input": [], "output": [] }
{ "input": [ "6\n8 6 9 1 2 1" ], "output": [ "51" ] }
{ "input": [ "6\n13 6 9 1 2 1", "6\n13 10 9 1 2 1", "6\n13 9 9 1 2 1", "6\n13 8 9 1 2 1", "6\n4 12 5 1 2 1", "6\n4 12 6 1 2 1", "6\n5 12 6 2 2 1", "6\n5 12 6 0 1 2", "6\n5 12 6 0 1 0", "6\n13 10 9 0 2 1", "6\n13 12 9 1 4 1", "6\n4 12 5 0 2 1", "6\n7 12 6 1 2 1", ...
p02348 Range Update Query (RUQ)
Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations: * update(s, t, x): change as, as+1, ..., at to x. * find(i): output the value of ai. Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1. Constraints * 1 ≤ n ≤ 100000 * 1 ≤ q ≤ 100000 * 0 ≤ s ≤ ...
{ "input": [], "output": [] }
{ "input": [ "3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0\n1 1", "1 3\n1 0\n0 0 0 5\n1 0" ], "output": [ "1\n3", "2147483647\n5" ] }
{ "input": [ "3 5\n0 0 1 1\n0 1 2 3\n0 0 2 2\n1 0\n1 1", "2 3\n1 0\n0 0 0 5\n1 0", "3 5\n0 0 1 1\n0 1 2 3\n0 0 2 2\n1 0\n0 1", "2 3\n1 0\n0 0 0 5\n1 1", "3 5\n1 0 1 1\n0 1 2 3\n0 0 2 2\n1 0\n1 1", "2 1\n1 0\n0 0 0 5\n1 1", "3 5\n1 1 1 2\n0 1 2 3\n-1 0 2 2\n0 0\n0 1", "9 5\n1 0 1 1\n1 1...
chearmy
The Head Chef is receiving a lot of orders for cooking the best of the problems lately. For this, he organized an hiring event to hire some talented Chefs. He gave the following problem to test the skills of the participating Chefs. Can you solve this problem and be eligible for getting hired by Head Chef. A non-nega...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n5" ], "output": [ "2\n8\n" ] }
{ "input": [ "2\n2\n3", "2\n2\n10", "2\n1\n3", "2\n1\n10", "2\n1\n15", "2\n2\n15", "2\n1\n13", "2\n2\n13", "2\n2\n26", "2\n2\n44", "2\n2\n77", "2\n2\n79", "2\n2\n14", "2\n4\n14", "2\n3\n14", "2\n3\n7", "2\n3\n11", "2\n2\n11", "2\n2\n21", ...
devhand
As you have probably realized up to now that Devu is not a normal guy, he is a very weird and abnormal guy. Normally people have two hands, but Devu has three of them. So he wears three wrist watches on his hands. Devu loves to write name of his friends on his wrist watches. So he want to attach a string correspondin...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n1 3\n2 2" ], "output": [ "0\n6\n36" ] }
{ "input": [], "output": [] }
iitk2p10
Chef was feeling bored so he decided to create a pattern to play with. His pattern always has 1 as its first element. Then he chooses a number K as the second element. After selecting K as his second number he creates next element in the pattern by multiplying all previously existing elements of the pattern. Now he a...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2\n3 4" ], "output": [ "2\n9" ] }
{ "input": [ "2\n1 2\n3 4", "2\n2 2\n3 2", "2\n2 2\n3 5", "2\n2 1\n3 5", "2\n2 2\n3 6", "2\n2 4\n3 6", "2\n2 4\n6 6", "2\n2 2\n6 6", "2\n1 2\n6 6", "2\n1 2\n6 1", "2\n0 2\n3 4", "2\n1 2\n4 4", "2\n2 2\n4 2", "2\n3 2\n3 3", "2\n2 4\n3 5", "2\n2 1\n3 6", ...
neuronb4
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 22344. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 774410 we shall call a positive integer that is neither increasing nor decreasing ...
{ "input": [], "output": [] }
{ "input": [ "7\n1\n2\n3\n4\n5\n6\n150" ], "output": [ "valid\nvalid\nvalid\nvalid\nvalid\nvalid\ninvalid" ] }
{ "input": [ "7\n1\n2\n6\n4\n5\n6\n150", "7\n0\n3\n1\n4\n18\n8\n147", "7\n1\n2\n6\n4\n5\n4\n150", "7\n1\n2\n6\n4\n5\n4\n262", "7\n1\n2\n6\n4\n10\n4\n262", "7\n1\n3\n6\n4\n10\n4\n262", "7\n1\n3\n6\n4\n10\n7\n262", "7\n0\n3\n6\n4\n10\n7\n262", "7\n0\n3\n6\n4\n10\n7\n162", "7\n0\n...
saarc07
Problem description. Tic-tac-toe is the third most popular activity to kill a lazy afternoon in Ardenia.Arthum and Breece are not fans of this game, but their mother told them to play, so they sit at a 5 x 5 board. Both have a large pile of marbles: marbles of Arthum have an A written on them and that of Breece have a ...
{ "input": [], "output": [] }
{ "input": [ "2\nAABBA\nBAAAB\nAAABA\nABAAB\nBAAAB\nAAAAA\nAAAAA\nBAAAA\nABAAA\nAABAA" ], "output": [ "A wins\ndraw" ] }
{ "input": [], "output": [] }
xorsub
You have an array of integers A1, A2, ..., AN. The function F(P), where P is a subset of A, is defined as the XOR (represented by the symbol ⊕) of all the integers present in the subset. If P is empty, then F(P) Given an integer K, what is the maximum value of K ⊕ F(P), over all possible subsets P of A? Input The firs...
{ "input": [], "output": [] }
{ "input": [ "1\n3 4\n1 2 3" ], "output": [ "7" ] }
{ "input": [ "1\n3 4\n0 2 3", "1\n0 4\n0 2 2", "1\n0 8\n0 2 0", "1\n0 13\n0 2 0", "1\n0 13\n0 4 -2", "1\n3 1\n1 2 3", "1\n0 4\n0 0 0", "1\n0 8\n0 3 0", "1\n0 14\n0 3 0", "1\n0 2\n0 2 -2", "1\n0 5\n1 4 -2", "1\n0 26\n0 7 -2", "1\n0 26\n0 14 -2", "1\n-1 0\n-1 1 1"...
1405_C. Balanced Bitstring
A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k/2 of each). You are given an integer k and a string s which is composed only of characters 0, 1, and ?. You need to determine w...
{ "input": [], "output": [] }
{ "input": [ "9\n6 4\n100110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 4\n1?0??1?\n10 10\n11??11??11\n4 2\n1??1\n4 4\n?0?0\n6 2\n????00\n" ], "output": [ "YES\nYES\nNO\nYES\nYES\nNO\nNO\nYES\nNO\n" ] }
{ "input": [ "9\n6 4\n110110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 4\n1?0??1?\n10 10\n11??11??11\n4 2\n1??1\n4 4\n?0?0\n6 2\n????00\n", "9\n6 4\n110110\n3 2\n1?1\n3 2\n1?0\n4 4\n????\n7 3\n1?0??1?\n10 10\n11??11??11\n4 2\n1??1\n4 4\n?0?0\n6 2\n????00\n", "9\n6 4\n100110\n3 2\n1?1\n3 2\n0?1\n4 4\n????\n7 4\n1?...
1473_D. Program
You are given a program that consists of n instructions. Initially a single variable x is assigned to 0. Afterwards, the instructions are of two types: * increase x by 1; * decrease x by 1. You are given m queries of the following format: * query l r — how many distinct values is x assigned to if all the...
{ "input": [], "output": [] }
{ "input": [ "2\n8 4\n-+--+--+\n1 8\n2 8\n2 5\n1 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n" ], "output": [ "\n1\n2\n4\n4\n3\n3\n4\n2\n3\n2\n1\n2\n2\n2\n" ] }
{ "input": [ "2\n8 4\n-+--+--+\n2 8\n2 8\n2 5\n1 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n", "2\n8 4\n-+--+--+\n1 8\n2 8\n2 5\n2 1\n4 10\n+-++\n1 1\n1 2\n2 2\n1 3\n2 3\n3 3\n1 4\n2 4\n3 4\n4 4\n", "2\n8 4\n-+--+--+\n2 8\n2 8\n2 5\n1 1\n4 10\n+-++\n1 2\n1 2\n2 2\n1 3\n2 3\n3 3\n2 4\...
benny-and-her-school-reports
Benny is a little pig. She usually goes to school, but the summer is coming which is also the time of getting the grade card report of all the N + 1 subjects. Benny has a M grade point system. Hence, all the scores for any subject are not less than 1 and not greater than M. During this year of education, Benny got N ...
{ "input": [], "output": [] }
{ "input": [ "4\n1 2 2\n1\n6 10 4\n5 4 7 8 4 1 \n1 4 3\n2 \n1 6 2\n5 \n\nSAMPLE" ], "output": [ "Impossible\n1\n4\n1\n" ] }
{ "input": [ "4\n1 2 2\n1\n6 10 4\n5 4 0 8 4 1 \n1 4 3\n2 \n1 6 2\n5 \n\nSAMPLE", "4\n1 2 2\n1\n6 10 4\n5 4 0 8 4 1 \n1 4 3\n2 \n1 6 2\n1 \n\nSAMPLE", "4\n1 2 2\n1\n6 10 7\n5 4 0 8 4 1 \n1 4 3\n2 \n1 6 2\n1 \n\nSAMPLE", "4\n1 2 2\n2\n6 10 7\n5 4 0 8 4 1 \n1 4 3\n2 \n1 6 2\n1 \n\nSAMPLE", "4\n1 2 2...
fibo-stones
Suresh is a fan of Mario. But being a programmer he decided to modify the game. In one module he needs your help. He modified the game as follows: There are N stones on the way indexed from 1 to N. Every stone having index i is associated with points equal to i^th fibonacci number. That is if there are 5 stones then th...
{ "input": [], "output": [] }
{ "input": [ "5 3\n1 1 5\n\nSAMPLE" ], "output": [ "5\n" ] }
{ "input": [ "5 3\n1 1 5\n\nSAPMLE", "5 3\n1 2 5\n\nSAMPLE", "5 3\n1 1 3\n\nELMPAS", "10 3\n1 1 5\n\nELMPBS", "9 3\n1 1 5\n\nSAFMLP", "7 3\n1 2 5\n\nSLPMAE", "10 3\n1 2 5\n\nELMPBS", "5 3\n1 2 3\n\nELMPAS", "5 3\n1 1 2\n\nELMPBS", "8 3\n1 1 5\n\nSLPMAE", "6 3\n1 2 5\n\nELMP...
the-magical-shop
There is a magical shop owned by The Monk, which consists of magical potions. On the first day there are A number of potions. Let, potions[I] denote the number of potions present in the shop on the I^th day. potions[I] = potions[I-1] * potions[I-1] You, Monk's favorite student love to play around with various type...
{ "input": [], "output": [] }
{ "input": [ "5 100\n101\n\nSAMPLE" ], "output": [ "30\n" ] }
{ "input": [ "5 100\n101\n\nASMPLE", "5 100\n001\n\nASMPLE", "5 110\n001\n\nASMPLE", "8 110\n001\n\nASMLPE", "8 100\n001\n\nASMLPE", "11 100\n001\n\nASMLQE", "11 110\n001\n\nMSALQE", "11 110\n101\n\nMSALQE", "0 110\n100\n\nEQL@SM", "1 111\n010\n\nDQL@TL", "2 101\n010\n\nDQ@...
p02665 NOMURA Programming Competition 2020 - Folia
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1. Constraints * 0 \leq N \...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0 1 0 2", "3\n0 1 1 2", "10\n0 0 1 1 2 3 5 8 13 21 34", "2\n0 3 1", "1\n1 1" ], "output": [ "10", "7", "264", "-1", "-1" ] }
{ "input": [ "4\n0 0 0 0 2", "3\n0 1 1 1", "10\n0 0 1 0 2 3 5 8 13 21 34", "2\n0 3 2", "10\n0 0 1 0 2 3 5 8 13 23 34", "10\n0 0 1 0 3 3 5 8 13 23 34", "2\n-1 3 2", "10\n0 0 1 1 3 3 5 8 13 23 34", "2\n-2 3 2", "4\n0 1 0 1 2", "10\n0 0 1 1 3 3 4 8 13 23 34", "4\n0 1 0 1 3...
p02794 AtCoder Beginner Contest 152 - Tree and Constraints
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i. Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satisfy all of the following M restrictions? * The i-th (1 \leq i \leq M) restriction...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2\n1\n1 2", "5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n2 4\n2 5", "3\n1 2\n2 3\n1\n1 3", "8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n2 8\n7 8" ], "output": [ "1", "9", "3", "62" ] }
{ "input": [ "5\n1 2\n3 2\n3 4\n5 3\n3\n1 3\n3 4\n2 5", "5\n1 2\n3 2\n3 4\n5 3\n3\n2 3\n3 4\n2 5", "2\n1 2\n1\n1 1", "5\n1 2\n3 2\n5 4\n5 3\n3\n1 3\n2 4\n2 5", "8\n1 2\n2 3\n4 3\n2 5\n6 3\n6 7\n8 6\n5\n2 7\n3 5\n1 6\n4 8\n7 8", "5\n1 2\n3 2\n3 4\n5 3\n3\n2 3\n3 4\n3 5", "5\n1 2\n3 2\n5 4\n...
p02930 Japanese Student Championship 2019 Qualification - Classified
AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms. For security reasons, Takahashi the president asked you to set a level for every passage, which is a positive integer and must satisfy the following condition: * For each room i\ (1 \leq i \...
{ "input": [], "output": [] }
{ "input": [ "3" ], "output": [ "1 2\n1" ] }
{ "input": [ "5", "10", "11", "17", "2", "28", "4", "56", "7", "18", "6", "9", "15", "20", "8", "12", "14", "103", "21", "13", "24", "34", "16", "124", "39", "19", "25", "44", "31", "233", "59",...
p03066 Tenka1 Programmer Contest 2019 - Banned X
Find the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X. Constraints * 1 \leq N \leq 3000 * 1 \leq X \leq 2N * N and X are integers. Input Input is given from Standard Input in the following format: N X Output Print the nu...
{ "input": [], "output": [] }
{ "input": [ "3 3", "8 6", "9 13", "10 1", "314 159" ], "output": [ "14", "1179", "18402", "1024", "459765451" ] }
{ "input": [ "5 3", "1 6", "13 13", "15 1", "56 159", "5 1", "19 13", "15 2", "43 159", "1 1", "27 2", "61 159", "0 2", "2 13", "16 2", "39 159", "11 2", "89 205", "102 205", "169 205", "3 6", "16 6", "5 13", "613 159", ...
p03209 AtCoder Beginner Contest 115 - Christmas
In some other world, today is Christmas. Mr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing: * A level-0 burger is a patty. * A level-L burger (L \geq 1) is a bun, a level-(L-1) burger, a patty, another level-(L-1) b...
{ "input": [], "output": [] }
{ "input": [ "50 4321098765432109", "1 1", "2 7" ], "output": [ "2160549382716056", "0", "4" ] }
{ "input": [ "50 3396494817772502", "2 1", "4 7", "0 1", "8 19", "6 19", "6 11", "6 14", "61 4321098765432109", "6 32", "9 11", "6 28", "6 33", "5 23", "6 41", "10 30", "4 20", "50 1069850374224873", "61 2749304303033015", "4 19", "10...
p03358 AtCoder Regular Contest 097 - Monochrome Cat
There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = `W` represents the vertex is white; c_i = `B` represents the vertex is black. A cat will walk along this tree. More...
{ "input": [], "output": [] }
{ "input": [ "20\n2 19\n5 13\n6 4\n15 6\n12 19\n13 19\n3 11\n8 3\n3 20\n16 13\n7 14\n3 17\n7 8\n10 20\n11 9\n8 18\n8 2\n10 1\n6 13\nWBWBWBBWWWBBWWBBBBBW", "6\n3 1\n4 5\n2 6\n6 1\n3 4\nWWBWBB", "5\n1 2\n2 3\n2 4\n4 5\nWBBWW", "1\nB" ], "output": [ "21", "7", "5", "0" ] }
{ "input": [ "6\n3 1\n4 5\n2 6\n2 1\n3 4\nWWBWBB", "20\n2 19\n5 13\n6 4\n15 6\n12 19\n13 19\n3 11\n12 3\n3 20\n16 13\n7 14\n3 17\n7 8\n10 20\n11 9\n8 18\n8 2\n10 1\n6 13\nWBWBWBBWWWBBWWBBBBBW", "20\n2 19\n5 13\n6 4\n15 6\n12 19\n13 19\n3 11\n12 3\n3 20\n16 13\n7 14\n3 17\n7 8\n10 20\n2 9\n8 18\n8 2\n10 1\...
p03516 CODE FESTIVAL 2017 Elimination Tournament Round 3 (Parallel) - Unicyclic Graph Counting
Snuke has come up with the following problem. > You are given a sequence d of length N. Find the number of the undirected graphs with N vertices labeled 1,2,...,N satisfying the following conditions, modulo 10^{9} + 7: > > * The graph is simple and connected. > * The degree of Vertex i is d_i. > When 2 \leq N, 1...
{ "input": [], "output": [] }
{ "input": [ "16\n2 1 3 1 2 1 4 1 1 2 1 1 3 2 4 3", "5\n1 2 2 3 2" ], "output": [ "555275958", "6" ] }
{ "input": [ "16\n2 1 4 1 2 1 4 1 1 2 1 1 3 2 4 3", "5\n1 2 2 6 2", "16\n2 1 3 1 2 1 3 1 1 2 1 1 3 2 4 3", "5\n1 2 3 3 2", "5\n1 2 1 6 2", "16\n2 1 3 1 2 1 3 1 1 2 2 1 3 2 4 3", "5\n1 2 2 3 4", "5\n1 2 2 4 4", "5\n1 2 2 6 4", "5\n1 2 3 6 1", "5\n1 2 4 6 1", "16\n2 1 4 1...
p03679 AtCoder Beginner Contest 065 - Expired?
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Ot...
{ "input": [], "output": [] }
{ "input": [ "4 3 6", "6 5 1", "3 7 12" ], "output": [ "safe", "delicious", "dangerous" ] }
{ "input": [ "0 3 6", "6 5 0", "4 2 6", "0 7 12", "1 3 6", "11 5 0", "-1 7 12", "1 0 6", "11 2 0", "-1 7 14", "2 0 6", "13 2 0", "-1 7 5", "4 0 6", "13 2 -1", "-2 7 5", "4 1 6", "13 4 -1", "-2 1 5", "0 1 6", "0 4 -1", "-2 2 5", ...
p03834 AtCoder Beginner Contest 051 - Haiku
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform th...
{ "input": [], "output": [] }
{ "input": [ "haiku,atcoder,tasks", "abcde,fghihgf,edcba", "happy,newyear,enjoy" ], "output": [ "haiku atcoder tasks", "abcde fghihgf edcba", "happy newyear enjoy" ] }
{ "input": [ "gaiku,atcoder,tasks", "abgde,fchihgf,edcba", "ha,pypnewyear,enjoy", "gaiku,atcoeer,tasks", "abcde,fghihcf,edgba", "ha,pypnewzear,enjoy", "gaiku,atcoeer-tasks", "abgde,fchihgf+edcba", "hap,ypnewzear,enjoy", "gbiku,atcoeer-tasks", "aagde,fchihgf+edcba", "hap...
p03999 AtCoder Beginner Contest 045 - Many Formulas
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. ...
{ "input": [], "output": [] }
{ "input": [ "9999999999", "125" ], "output": [ "12656242944", "176" ] }
{ "input": [ "88", "131", "189", "292", "348", "260", "11", "16", "0", "1", "2", "188", "67", "29", "182", "135", "672", "497", "20", "25", "4", "3", "5", "42", "130", "58", "139", "144", "1333", "9...
p00087 Strange Mathematical Expression
Dr .: Peter, I've finally done it. Peter: See you again? What kind of silly invention is this time? Dr .: I finally came up with a revolutionary way to process mathematical formulas on a computer. Look at this table. Ordinary notation | Dr.'s "breakthrough" notation --- | --- 1 + 2 | 1 2 + 3 * 4 + 7 | 3 4 * 7 + 10 /...
{ "input": [], "output": [] }
{ "input": [ "10 2 12 - /\n3 4 - 7 2 3 * + *\n-1 -2 3 + +" ], "output": [ "-1.000000\n-13.000000\n0.000000" ] }
{ "input": [ "10 2 12 - /\n6 4 - 7 2 3 * + *\n-1 -2 3 + +", "10 2 12 - /\n9 4 - 7 2 3 * + *\n-1 -2 3 + +", "10 2 12 - /\n9 4 - 7 2 6 * + *\n-1 -2 3 + +", "10 2 12 - /\n9 4 - 7 2 6 * + *\n-1 -2 4 + +", "10 2 23 - /\n9 4 - 7 2 6 * + *\n-1 -2 4 + +", "10 2 23 - /\n9 4 - 7 2 6 * + *\n-1 -2 0 + +",...
p00219 A Popular Ice-cream Shop
There is an ice cream shop named Ten Ice Cream. At this store, we always have 10 types of ice cream on the shelves. The store manager creates a daily graph showing how well ice cream is selling for reference in product development. For such a store manager, you decided to create a program that displays the number of e...
{ "input": [], "output": [] }
{ "input": [ "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0" ], "output": [ "*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*" ] }
{ "input": [ "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n4\n2\n3\n9\n1\n5\n0", "15\n2\n6\n7\n0\n0\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0", "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n4\n2\n3\n9\n1\n2\n0", "15\n2\n6\n7\n0\n0\n9\n8\n7\n3\n8\n9\n8\n8\n2\n2\n3\n9\n1\n5\n0", "15\n2\n6\n7\n0\n1\n9...
p00381 Transporter
In the year 30XX, an expedition team reached a planet and found a warp machine suggesting the existence of a mysterious supercivilization. When you go through one of its entrance gates, you can instantaneously move to the exit irrespective of how far away it is. You can move even to the end of the universe at will with...
{ "input": [], "output": [] }
{ "input": [ "25\nneihsokcpuziafoytisrevinu\nuniversityofaizupckoshien", "6\nabbaba\nbaabab" ], "output": [ "4", "5" ] }
{ "input": [ "25\nneihsokcpuziafoytisrevinu\nuniversityofaizupckoshhen", "6\nbaabba\nbaabab", "25\nuniversityofaiztpckoshien\nuniversityofaizupbkoshhen", "25\nuniversityofaiztpckoshien\nnehhsokbpuziafoytisrevinu", "25\nneihsokcptziafoytisrevinu\nsniveruityofaizupbkoshhen", "6\nababba\nbaabab",...
p00597 Finding the Largest Carbon Compound Given Its Long
An bydrocarbon is an organic compound which contains only carbons and hydrogens. An isomer is a compound that has the same number of carbons but different structures. Heptane, for example, is a hydrocarbon with 7 carbons. It has nine isomers. The structural formula of three are shown in Figure 1. Carbons are represente...
{ "input": [], "output": [] }
{ "input": [ "1\n4" ], "output": [ "1\n8" ] }
{ "input": [ "1\n6", "1\n8", "1\n12", "1\n16", "1\n1", "1\n13", "1\n25", "1\n5", "1\n2", "1\n3", "1\n10", "1\n19", "1\n23", "1\n9", "1\n17", "1\n7", "1\n18", "1\n20", "1\n21", "1\n11", "1\n29", "1\n15", "1\n14", "1\n26", ...
p00733 Dr. Podboq or: How We Became Asymmetric
After long studying how embryos of organisms become asymmetric during their development, Dr. Podboq, a famous biologist, has reached his new hypothesis. Dr. Podboq is now preparing a poster for the coming academic conference, which shows a tree representing the development process of an embryo through repeated cell div...
{ "input": [], "output": [] }
{ "input": [ "(((x x) x) ((x x) (x (x x))))\n(((x x) (x x)) ((x x) ((x x) (x x))))\n(((x x) ((x x) x)) (((x (x x)) x) (x x)))\n(((x x) x) ((x x) (((((x x) x) x) x) x)))\n(((x x) x) ((x (x x)) (x (x x))))\n((((x (x x)) x) (x ((x x) x))) ((x (x x)) (x x)))\n((((x x) x) ((x x) (x (x x)))) (((x x) (x x)) ((x x) ((x x...
{ "input": [], "output": [] }
p00873 Zigzag
Given several points on a plane, let’s try to solve a puzzle connecting them with a zigzag line. The puzzle is to find the zigzag line that passes through all the given points with the minimum number of turns. Moreover, when there are several zigzag lines with the minimum number of turns, the shortest one among them sh...
{ "input": [], "output": [] }
{ "input": [ "2\n0 0\n10 9\n4\n0 0\n3 1\n0 3\n3 3\n10\n2 2\n4 2\n6 2\n2 4\n4 4\n6 4\n2 6\n4 6\n6 6\n3 3\n10\n0 0\n2 0\n4 0\n0 2\n2 2\n4 2\n0 4\n2 4\n4 4\n6 8\n9\n0 0\n1 0\n3 0\n0 1\n1 1\n3 1\n0 2\n1 2\n2 2\n10\n0 0\n1 0\n0 1\n1 1\n9 9\n9 10\n10 9\n10 10\n0 2\n10 8\n10\n0 0\n0 10\n2 0\n2 1\n2 7\n2 10\n5 1\n6 7\n9 ...
{ "input": [ "2\n0 0\n10 9\n4\n0 0\n3 1\n0 3\n3 3\n10\n2 2\n4 2\n6 2\n2 4\n4 4\n6 4\n2 6\n4 6\n6 6\n3 3\n10\n0 0\n2 0\n4 0\n0 2\n2 2\n4 2\n0 4\n2 4\n1 4\n6 8\n9\n0 0\n1 0\n3 0\n0 1\n1 1\n3 1\n0 2\n1 2\n2 2\n10\n0 0\n1 0\n0 1\n1 1\n9 9\n9 10\n10 9\n10 10\n0 2\n10 8\n10\n0 0\n0 10\n2 0\n2 1\n2 7\n2 10\n5 1\n6 7\n9 ...
p01004 Balloon Contest
Problem The appearance of the sky is different from usual. A variety of colorful hot-air balloons covered the sky. Today is a hot-air balloon tournament. It seems that all the participants will compete for the scored ball dropped from the hot-air balloon. I decided to predict the winner because it was a big deal. * N...
{ "input": [], "output": [] }
{ "input": [ "3 4\n10 75\n50 5\n90 75\n50 50 10 10 2\n40 90 1 1 3\n10 20 10 15 1\n50 70 50 50 4\n4 2\n25 25\n25 75\n75 75\n75 25\n50 50 10 10 1\n50 50 15 15 2\n1 1\n5 5\n1 1 1 1 1\n0 0" ], "output": [ "5.442857\n0.750000\n1.000000" ] }
{ "input": [ "3 4\n10 75\n50 5\n79 75\n50 50 10 10 2\n40 90 1 1 3\n10 20 10 15 1\n50 70 50 50 4\n4 2\n25 25\n25 75\n75 75\n75 25\n50 50 10 10 1\n50 50 15 15 2\n1 1\n5 5\n1 1 1 1 1\n0 0", "3 4\n10 75\n50 5\n79 75\n50 50 10 10 2\n40 90 1 1 3\n10 20 10 15 1\n66 70 50 50 4\n4 2\n25 25\n25 75\n75 75\n75 25\n50 50 ...
p01136 Gather the Maps!
It is said that a legendary treasure left by Mr. Yao is sleeping somewhere in Hachioji long ago. The treasure map, which is said to show its whereabouts, has been handed down by Yao's n descendants, divided into several pieces. Now, the descendants of Mr. Yao were trying to cooperate to obtain the treasure. However, t...
{ "input": [], "output": [] }
{ "input": [ "4\n1 1\n2 2 3\n2 1 2\n3 3 4 5\n0" ], "output": [ "3" ] }
{ "input": [ "4\n1 1\n2 2 3\n2 1 2\n3 4 4 5\n0", "4\n1 1\n2 2 3\n2 1 2\n3 3 4 10\n0", "4\n1 1\n2 2 5\n2 0 2\n3 1 4 5\n0", "4\n1 1\n2 2 3\n2 1 2\n3 1 4 5\n0", "4\n1 1\n2 1 3\n2 0 1\n3 1 4 5\n0", "4\n1 1\n2 2 3\n2 0 4\n3 1 4 2\n0", "4\n1 1\n2 2 3\n2 1 2\n3 4 4 0\n0", "4\n1 1\n2 2 3\n2 2 ...
p01275 Dial Lock
A dial lock is a kind of lock which has some dials with printed numbers. It has a special sequence of numbers, namely an unlocking sequence, to be opened. You are working at a manufacturer of dial locks. Your job is to verify that every manufactured lock is unlocked by its unlocking sequence. In other words, you have ...
{ "input": [], "output": [] }
{ "input": [ "4\n1357 4680\n6\n777777 003330\n0" ], "output": [ "1\n2" ] }
{ "input": [ "4\n1433 4680\n6\n777777 003330\n0", "4\n1357 4680\n6\n509138 003330\n0", "4\n1357 4680\n6\n297443 003330\n0", "4\n1357 5363\n6\n777777 003330\n0", "4\n1357 1908\n6\n509138 003330\n0", "4\n2443 5385\n6\n568742 003330\n0", "4\n1433 4680\n6\n211871 003330\n0", "4\n3052 5385\...
p01445 Mobile Network
The trafic on the Internet is increasing these days due to smartphones. The wireless carriers have to enhance their network infrastructure. The network of a wireless carrier consists of a number of base stations and lines. Each line connects two base stations bi-directionally. The bandwidth of a line increases every y...
{ "input": [], "output": [] }
{ "input": [ "3 3\n1 2 x+2\n2 3 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 2\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 x^2+2x+3\n3 4 x+2\n0 0" ], "output": [ "2x+3\n0\n2\nx+2" ] }
{ "input": [ "3 3\n1 2 x+2\n2 2 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 2\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 x^2+2x+3\n3 4 x+2\n0 0", "3 3\n1 2 x+2\n2 2 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 1\n4 3\n1 2 x^3+2x^2+3x+4\n2 3 x^2+2x+3\n3 4 x+2\n0 0", "3 3\n1 2 x+2\n2 2 2x+1\n3 1 x+1\n2 0\n3 2\n1 2 x\n2 3 4\n4 3\n1 2 x^3+...
p01594 Exportation in Space
Problem D: Exportation in Space In an era of space travelling, Mr. Jonathan A. Goldmine exports a special material named "Interstellar Condensed Powered Copper". A piece of it consists of several spheres floating in the air. There is strange force affecting between the spheres so that their relative positions of them ...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0 0\n0 0 1\n0 1 0\n1 0 0", "8\n0 0 0\n0 0 1\n0 1 0\n0 1 1\n1 0 0\n1 0 1\n1 1 0\n1 1 1" ], "output": [ "2.366", "6.000" ] }
{ "input": [ "4\n0 0 0\n0 -1 1\n0 1 0\n1 0 0", "8\n0 0 0\n0 0 1\n0 1 0\n0 1 1\n1 0 0\n2 0 1\n1 1 0\n1 1 1", "8\n0 0 0\n0 0 1\n0 1 0\n0 1 1\n1 0 1\n2 0 1\n1 1 0\n1 1 1", "8\n0 0 0\n0 0 1\n0 1 0\n0 1 1\n1 0 1\n2 0 1\n2 1 0\n1 1 1", "8\n0 0 0\n0 0 1\n0 1 0\n0 1 1\n1 0 1\n4 0 1\n2 1 0\n1 1 1", "8\...
p01751 Yamanote Line
Mr. A wants to get to the destination on the Yamanote line. After getting on the train, Mr. A gets up for a minute and sleeps for b minutes repeatedly. It is c minutes after boarding to the destination, and you can get off if you are awake at this time, but on the contrary, if you are sleeping, you will miss it. Also,...
{ "input": [], "output": [] }
{ "input": [ "20 20 20", "50 40 51", "10 10 5", "30 30 40" ], "output": [ "20", "111", "5", "-1" ] }
{ "input": [ "20 25 20", "89 40 51", "10 14 5", "36 18 15", "3 18 15", "16 5 4", "0 18 15", "128 12 16", "0 18 12", "2 5 4", "2 5 5", "2 5 9", "134 22 13", "2 5 14", "134 22 21", "1 0 8", "1 0 1", "1 2 3", "0 2 2", "18 20 20", "50 40 ...
p01891 Cabbage
Problem statement AOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \ ldots, N $ in order from the outside, and the dirtiness of the $ i $ th leaf is $ D_i $. The larger this value is, the worse the degree of dirt is. AOR Ika-chan decided to use the cabbage leaves for cooking, so sh...
{ "input": [], "output": [] }
{ "input": [ "5 3 6 9\n9 7 5 3 1" ], "output": [ "2" ] }
{ "input": [ "5 3 6 9\n9 1 5 3 1", "21 10 0 4\n5 2 13 -1 0", "21 7 1 4\n0 2 23 -1 2", "9 3 1 9\n22 2 6 2 0", "21 14 1 4\n2 2 0 -1 2", "5 3 6 9\n9 1 6 3 1", "8 3 6 9\n9 1 6 3 1", "8 3 6 9\n15 1 6 3 1", "8 3 6 9\n15 0 6 3 1", "8 3 6 9\n22 0 6 3 1", "11 3 6 9\n22 0 6 3 1", ...
p02028 Mail Order
N: Mail order Mr. Komozawa bought building blocks toys from Makai mail order. The building blocks are in the shape of a cube with a side length of 1, and are stacked on squares divided into $ H $ pieces vertically and $ W $ pieces horizontally. Seen from the side, $ A_1, A_2, A_3, \ dots, A_H $ blocks were stacked i...
{ "input": [], "output": [] }
{ "input": [ "2 2\n1 5\n1 5" ], "output": [ "8" ] }
{ "input": [ "2 2\n0 5\n1 5", "2 2\n0 2\n1 5", "2 2\n0 4\n1 5", "2 2\n-1 2\n1 5", "2 2\n0 3\n1 5", "2 2\n0 5\n2 5", "2 2\n0 5\n3 5", "2 2\n0 1\n1 5", "2 2\n-1 0\n1 5", "2 2\n2 5\n1 5", "2 2\n0 0\n3 8", "2 2\n2 5\n2 5", "2 2\n1 5\n3 5", "2 2\n-2 0\n0 0", "2 2...
p02170 Coin and Die
Problem There are coins with front and back sides and dice with rolls from $ 1 $ to $ N $. Gacho decided to play the following games using these. The game starts with a score of $ 0 $ and proceeds as follows. 1. Roll the dice $ 1 $ and add the number of rolls to the score. 2. If the current score is $ K $ or more, ...
{ "input": [], "output": [] }
{ "input": [ "1 1 50", "6 10 99", "2 2 10" ], "output": [ "1", "650893870", "648858830" ] }
{ "input": [ "6 13 99", "2 2 15", "6 13 187", "2 1 15", "6 18 187", "6 23 187", "6 23 338", "9 23 338", "9 43 338", "9 43 467", "9 43 58", "2 43 58", "3 43 58", "6 43 58", "6 26 58", "6 42 58", "0 42 58", "1 4 56", "1 4 85", "1 4 147", ...
p02311 Common Tangent
Find common tangent lines of two circles $c1$ and $c2$. Constraints * $-1,000 \leq c1x, c1y, c2x, c2y \leq 1,000$ * $1 \leq c1r, c2r \leq 1,000$ * $c1$ and $c2$ are different Input Center coordinates ($cix$, $ciy$) and radii $cir$ of two circles $c1$ are $c2$ are given in the following format. $c1x \; c1y \; c1r$ ...
{ "input": [], "output": [] }
{ "input": [ "1 2 1\n4 2 2", "1 2 1\n3 2 2", "0 0 1\n1 0 2", "1 1 1\n6 2 2" ], "output": [ "0.6666666667 1.0571909584\n0.6666666667 2.9428090416\n2.0000000000 2.0000000000", "0.5000000000 1.1339745962\n0.5000000000 2.8660254038", "-1.0000000000 0.0000000000", "0.6153846154 1.923076...
{ "input": [ "0 2 1\n4 2 2", "1 2 2\n3 2 2", "0 0 2\n1 0 2", "1 1 2\n6 2 2", "0 2 1\n1 2 2", "0 -1 2\n1 0 2", "1 1 2\n6 4 2", "0 -2 2\n1 0 2", "1 1 2\n6 6 2", "0 -4 2\n1 0 2", "0 1 2\n6 6 2", "0 -4 2\n1 0 1", "0 1 2\n11 6 2", "0 -4 3\n1 0 2", "1 1 2\n11 6 2"...
p02459 Map: Search
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique. * insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$. If there is an element with $key$, replace the cor...
{ "input": [], "output": [] }
{ "input": [ "7\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 8\n1 black" ], "output": [ "1\n4\n8" ] }
{ "input": [ "7\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 16\n1 black", "7\n0 blue 4\n0 red 1\n0 white 3\n1 red\n1 blue\n0 black 8\n1 black", "7\n0 blue 5\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 16\n1 black", "7\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 11\n1 black", "7...
amr15c
The Kalakeyas were a powerful, ferocious and cruel clan of Danavas. They were known to be really strong and they did not have any war strategy. They would just attack the enemy randomly and overpower them with sheer number of soldiers. However, we all know that Baahubali and Bhallaladeva defeated the Kalakeyas by follo...
{ "input": [], "output": [] }
{ "input": [ "3\n2 2\n3 0\n3 1" ], "output": [ "-1\n1 2 3\n2 3 1" ] }
{ "input": [], "output": [] }
chfmax
You are given a string of lower case characters. You have to find the character with the most frequency. In case there are 2 such characters, consider the one with lower ASCII value. After this replace the character with the maximum frequency with '?' (without quotes). Then, print the resulting string. You have to do t...
{ "input": [], "output": [] }
{ "input": [ "1\naba" ], "output": [ "?b?" ] }
{ "input": [ "1\nabb", "1\nbbb", "1\nbbc", "1\nbbd", "1\ncbd", "1\nbcd", "1\ndcb", "1\ncdb", "1\nceb", "1\nbec", "1\ncbe", "1\ndbc", "1\ncbc", "1\ndcc", "1\nadc", "1\ndda", "1\ndc`", "1\n`cd", "1\n`cc", "1\ncba", "1\nabc", "1\nbcc...
egrcake
Chef has bought N robots to transport cakes for a large community wedding. He has assigned unique indices, from 1 to N, to each of them. How it will happen? Chef arranges the N robots in a row, in the (increasing) order of their indices. Then, he chooses the first M robots and moves them to the end of the queue. Now, C...
{ "input": [], "output": [] }
{ "input": [ "3\n2 0\n2 1\n4 2" ], "output": [ "No 1\nYes\nNo 2\n" ] }
{ "input": [ "3\n1 0\n2 1\n4 2", "3\n1 0\n2 1\n5 2", "3\n2 0\n2 1\n5 2", "3\n2 0\n2 1\n2 2", "3\n1 -1\n2 1\n5 2", "3\n2 -1\n2 1\n5 2", "3\n2 0\n2 0\n5 3", "3\n4 -1\n2 1\n5 2", "3\n3 -1\n2 1\n5 2", "3\n3 -1\n2 2\n5 2", "3\n3 0\n2 3\n6 2", "3\n3 1\n4 3\n6 2", "3\n2 -1...
kingship
Chef is the new king of the country Chefland. As first and most important responsibility he wants to reconstruct the road system of Chefland. There are N (1 to N) cities in the country and each city i has a population Pi. Chef wants to build some bi-directional roads connecting different cities such that each city is c...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n5 10\n4\n15 10 7 13" ], "output": [ "50\n266\n" ] }
{ "input": [ "2\n2\n5 5\n4\n15 10 7 13", "2\n2\n5 10\n4\n29 10 7 13", "2\n2\n5 5\n4\n15 10 12 13", "2\n2\n5 10\n4\n29 0 7 13", "2\n2\n5 5\n4\n27 10 12 13", "2\n2\n2 5\n4\n27 10 12 13", "2\n2\n2 5\n4\n27 10 11 13", "2\n2\n9 10\n4\n29 0 4 17", "2\n2\n2 5\n4\n27 8 11 13", "2\n2\n5...
onoz
3:33 It's possible for all the digits displayed on a digital clock in the hours:minutes format to be identical. The time shown above (3:33) is an example of such a situation. Other examples are 2:2 and 1:11. Note that the digits of 33:33 are identical, but it is not a valid time on a usual digital clock. The above exam...
{ "input": [], "output": [] }
{ "input": [ "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 1" ], "output": [ "19\n20\n10\n11\n10\n1\n" ] }
{ "input": [ "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 2", "6\n24 60\n34 50\n1 11\n10 12\n11 10\n1 2", "6\n24 60\n34 5\n1 11\n10 12\n11 10\n1 2", "6\n24 60\n7 50\n10 11\n10 12\n11 11\n1 1", "6\n24 60\n34 50\n10 11\n10 12\n13 11\n1 2", "6\n24 60\n34 50\n10 11\n9 12\n11 10\n1 2", "6\n24 60\n3...
spit3
On Internet sites usually the registration form automatically checks and validate the passowrd's crypt resistance. If the user's password isn't complex enough a message is displayed. You have already implemented password validation in Web Programming class. Today your task is to implement password validation program. ...
{ "input": [], "output": [] }
{ "input": [ "SPIT_Coders_Club_2.0", "abcdefgh" ], "output": [ "YES", "NO" ] }
{ "input": [ "0.2_bulC_sredoC_TIPS", "abcdeegh", "0.2_bumC_sredoC_TIPS", "ebcdaegh", "0.2_bumC_sredoC_SIPS", "ebceaegh", "C.2_bumC_sredo0_SIPS", "ebceaefh", "SPIS_0oders_Cmub_2.C", "hfeaecbe", "SPIS_1oders_Cmub_2.C", "hfdaecbe", "SQIS_1oders_Cmub_2.C", "ebceadfh...
1029_E. Tree with Small Distances
You are given an undirected tree consisting of n vertices. An undirected tree is a connected undirected graph with n - 1 edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex 1 to any other vertex is at most 2. Note that you are not allowed to add loo...
{ "input": [], "output": [] }
{ "input": [ "7\n1 2\n2 3\n3 4\n3 5\n3 6\n3 7\n", "7\n1 2\n2 3\n2 4\n4 5\n4 6\n5 7\n", "7\n1 2\n1 3\n2 4\n2 5\n3 6\n1 7\n" ], "output": [ "1\n", "2\n", "0\n" ] }
{ "input": [ "7\n1 2\n2 3\n2 4\n2 5\n3 6\n1 7\n", "7\n1 2\n2 3\n2 4\n2 5\n2 6\n1 7\n", "7\n1 2\n4 6\n2 4\n3 5\n3 2\n3 7\n", "7\n1 2\n2 3\n2 4\n2 5\n1 6\n1 7\n", "7\n1 2\n2 3\n2 4\n3 5\n3 6\n3 7\n", "7\n1 2\n2 3\n2 4\n3 5\n1 6\n1 7\n", "7\n1 2\n4 3\n2 4\n2 5\n3 6\n1 7\n", "7\n1 2\n2 6\n...
1346_D. Constructing the Dungeon
Polycarp is developing an RPG game where the main character fights monsters and searches for treasure in dungeons. Now Polycarp is making one of the dungeons the character can explore. The dungeon consists of n rooms connected by m two-way tunnels, and it is possible to reach every room from every other room using tun...
{ "input": [], "output": [] }
{ "input": [ "3\n3 2\n1 2 1\n2 3 1\n5 7\n3 2 7\n3 4 9\n1 5 5\n1 2 5\n4 1 5\n4 2 7\n3 1 5\n4 4\n1 2 5\n3 2 2\n4 1 3\n3 4 4\n" ], "output": [ "\nYES\n1 1 1\nYES\n5 7 9 9 5\nNO\n" ] }
{ "input": [], "output": [] }
345_G. Suffix Subgroup
You are given a group of n strings: s1, s2, ..., sn. You should find a subgroup si1, si2, ..., sik (1 ≤ i1 < i2 < ... < ik ≤ n) of the group. The following two conditions must hold: * there exists a string t such, that each string from found subgroup is its suffix; * the number of strings in the found subgroup i...
{ "input": [], "output": [] }
{ "input": [ "6\nbb\nbb\nb\naaa\naa\nz\n" ], "output": [ "3\n" ] }
{ "input": [], "output": [] }
a-needle-in-the-haystack-1
Our hacker, Little Stuart lately has been fascinated by ancient puzzles. One day going through some really old books he finds something scribbled on the corner of a page. Now Little Stuart believes that the scribbled text is more mysterious than it originally looks, so he decides to find every occurrence of all the per...
{ "input": [], "output": [] }
{ "input": [ "3\nhack\nindiahacks\ncode\neddy\ncoder\niamredoc\n\nSAMPLE" ], "output": [ "YES\nNO\nYES\n" ] }
{ "input": [ "3\nhacj\nindiahacks\ncode\neddy\ncoder\niamredoc\n\nSAMPLE", "3\nhack\nindiahacks\ndoce\neddy\ncoder\niamredoc\n\nSAMPLE", "3\nhack\nindiahacks\ndoce\neddy\ncoder\nicmredoa\n\nSAMPLE", "3\nhcaj\nskcaiaidni\ncddo\nyddd\ncoder\nirmaedoc\n\nESPMAL", "3\nhacj\nindiahacks\ndode\neddy\ncod...
jal-mahal-lake
Jal Mahal Lake is famous tourist place in Jaipur. The lake has floating planks in a straight line. The planks are currently not attached to each other, and there may be gaps between some of them. You have to push them all together and connect them into a single long plank. You are given the positions and lengths. For ...
{ "input": [], "output": [] }
{ "input": [ "2\n4\n1 3 10 20\n2 2 5 3\n3\n100 50 1\n10 2 1\n\nSAMPLE" ], "output": [ "15\n96" ] }
{ "input": [ "2\n4\n1 3 10 20\n2 2 5 3\n3\n100 50 1\n15 2 1\n\nSAMPLE", "2\n4\n1 3 10 20\n2 3 5 3\n3\n100 50 1\n18 2 1\n\nSAMPLE", "2\n4\n1 3 10 20\n2 3 5 3\n3\n100 90 1\n18 3 1\n\nSAMPLE", "2\n4\n1 3 10 20\n2 3 5 4\n3\n100 129 1\n18 3 1\n\nSAMPLE", "2\n4\n1 3 10 20\n2 3 5 3\n3\n100 129 1\n23 3 1\...
micro-and-minmax
Micro is a big fan of the famous competitive programmer Gennady Korotkevich, known by his handle tourist. He wants to be like him. He has been practising hard but is not reaching anywhere. So he has left his fate to one game he has, called MinMax. The game consists of an array A of N integers. If the difference between...
{ "input": [], "output": [] }
{ "input": [ "1\n5\n1 2 3 4 5\n\nSAMPLE" ], "output": [ "No" ] }
{ "input": [], "output": [] }
p02563 AtCoder Library Practice Contest - Convolution
You are given two integer arrays a_0, a_1, ..., a_{N - 1} and b_0, b_1, ..., b_{M - 1}. Calculate the array c_0, c_1, ..., c_{(N - 1) + (M - 1)}, defined by c_i = \sum_{j = 0}^i a_j b_{i - j} \bmod 998244353. Constraints * 1 \leq N, M \leq 524288 * 0 \leq a_i, b_i < 998244353 * All values in Input are integer. Input...
{ "input": [], "output": [] }
{ "input": [ "4 5\n1 2 3 4\n5 6 7 8 9", "1 1\n10000000\n10000000" ], "output": [ "5 16 34 60 70 70 59 36", "871938225" ] }
{ "input": [ "4 5\n1 2 3 4\n5 6 12 8 9", "1 1\n10000000\n10100000", "1 1\n10001000\n10100000", "4 5\n1 2 3 4\n5 6 7 4 9", "4 5\n1 2 3 4\n5 6 12 8 18", "1 1\n10001000\n10110000", "4 5\n1 1 3 4\n5 6 7 4 9", "4 5\n1 2 3 4\n5 0 12 8 18", "1 1\n10001000\n00110000", "4 5\n1 2 3 4\n5 ...
p02694 AtCoder Beginner Contest 165 - 1%
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo...
{ "input": [], "output": [] }
{ "input": [ "1333333333", "103", "1000000000000000000" ], "output": [ "1706", "3", "3760" ] }
{ "input": [ "1925339908", "121", "1000010000000000000", "2918372355", "1100010000000000000", "1759180116", "314793131", "385473767", "693073999", "463707925", "620557412", "55916268", "29927702", "12264538", "23000309", "1110000100001111000", "19790...
p02823 AtCoder Grand Contest 041 - Table Tennis Training
2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses. The winner of the...
{ "input": [], "output": [] }
{ "input": [ "5 2 3", "5 2 4" ], "output": [ "2", "1" ] }
{ "input": [ "4 2 3", "5 2 8", "6 3 3", "6 3 5", "1 2 5", "0 3 4", "2 -1 0", "5 2 16", "5 2 27", "10 4 5", "5 1 27", "10 4 7", "6 0 28", "2 4 11", "0 2 27", "1 3 8", "0 3 27", "7 1 28", "7 0 12", "6 -1 36", "1 4 38", "0 -1 15", ...
p02959 AtCoder Beginner Contest 135 - City Savers
There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes can cooperate to defeat? Constraints * All values in input are i...
{ "input": [], "output": [] }
{ "input": [ "3\n5 6 3 8\n5 100 8", "2\n100 1 1\n1 100", "2\n3 5 2\n4 5" ], "output": [ "22", "3", "9" ] }
{ "input": [ "3\n5 6 3 8\n2 100 8", "2\n100 0 1\n1 100", "2\n3 5 2\n7 5", "3\n0 6 3 8\n2 100 8", "2\n100 -1 1\n1 100", "2\n3 5 1\n7 5", "3\n0 4 3 8\n2 100 8", "2\n000 -1 1\n1 100", "2\n3 5 1\n0 5", "3\n0 4 2 8\n2 100 8", "2\n000 -1 0\n1 100", "2\n000 -1 -1\n1 100", ...
p03095 AtCoder Grand Contest 031 - Colorful Subsequence
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a conca...
{ "input": [], "output": [] }
{ "input": [ "3\nbaa", "4\nabcd", "5\nabcab" ], "output": [ "5", "15", "17" ] }
{ "input": [ "3\naab", "4\ndcba", "4\nbbcd", "3\nbac", "5\nbbbba", "5\naabbc", "3\naaa", "4\nadda", "5\nabcda", "4\nbbbb", "5\nbdacf", "5\nabcaa", "3\nabb", "5\nabbaa", "3\nbab", "4\ndcbb", "5\naabba", "4\necbb", "5\nabbba", "3\ncac", ...