name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p00916 Count the Regions
There are a number of rectangles on the x-y plane. The four sides of the rectangles are parallel to either the x-axis or the y-axis, and all of the rectangles reside within a range specified later. There are no other constraints on the coordinates of the rectangles. The plane is partitioned into regions surrounded by ...
{ "input": [], "output": [] }
{ "input": [ "3\n4 28 27 11\n15 20 42 5\n11 24 33 14\n5\n4 28 27 11\n12 11 34 2\n7 26 14 16\n14 16 19 12\n17 28 27 21\n2\n300000 1000000 600000 0\n0 600000 1000000 300000\n0" ], "output": [ "8\n6\n6" ] }
{ "input": [ "3\n4 28 27 11\n15 20 42 5\n11 24 33 14\n5\n4 28 27 11\n12 11 34 2\n7 26 14 16\n14 16 19 12\n17 28 27 21\n2\n322297 1000000 600000 0\n0 600000 1000000 300000\n0", "3\n4 28 27 17\n15 20 42 5\n19 24 33 14\n5\n4 28 27 11\n12 11 34 2\n7 26 14 16\n14 16 19 12\n17 28 50 21\n2\n322297 1000000 828907 0\n...
p01049 Array Update
Problem There is an arithmetic progression A with the number of terms N, the first term a, and the tolerance d. Since M statements that update the sequence are given in the following format, find the value of the K item when the sequence A is updated M times in the given order. * The i-th statement is represented by ...
{ "input": [], "output": [] }
{ "input": [ "6\n5 5\n4\n0 1 2\n1 1 2\n0 4 1\n1 1 6\n3", "5\n2 3\n3\n0 2 5\n0 3 5\n1 2 4\n2" ], "output": [ "15", "11" ] }
{ "input": [ "6\n5 5\n4\n-1 1 2\n1 1 2\n0 4 1\n1 1 6\n3", "6\n5 4\n4\n-1 1 2\n0 1 2\n0 4 1\n1 1 6\n3", "5\n2 2\n3\n0 2 5\n0 3 5\n1 2 4\n2", "6\n10 5\n4\n-1 1 2\n0 1 2\n0 4 1\n1 1 6\n3", "6\n7 5\n4\n0 1 2\n1 1 2\n0 4 1\n0 1 6\n3", "6\n7 5\n4\n0 1 2\n1 1 2\n0 4 1\n0 1 6\n2", "6\n5 3\n4\n-1 1...
p01181 Moduic Squares
Have you ever heard of Moduic Squares? They are like 3 × 3 Magic Squares, but each of them has one extra cell called a moduic cell. Hence a Moduic Square has the following form. <image> Figure 1: A Moduic Square Each of cells labeled from A to J contains one number from 1 to 10, where no two cells contain the same n...
{ "input": [], "output": [] }
{ "input": [ "3 1 6 8 10 7 0 0 2 5\n0 0 0 0 0 0 0 0 0 1\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1" ], "output": [ "2\n362880" ] }
{ "input": [ "3 1 6 8 10 7 0 0 2 5\n0 0 0 0 0 0 0 0 0 1\n-1 -1 -1 -1 -1 -1 -1 -1 -2 -1", "3 1 6 8 10 7 0 0 2 5\n0 0 0 0 0 0 0 0 0 0\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1", "3 1 6 4 10 7 0 0 2 5\n0 0 0 0 0 0 0 0 0 1\n-1 -1 -1 -1 -1 -1 -1 -2 -2 -1", "3 0 1 8 10 7 0 0 2 5\n0 0 0 0 0 0 0 0 1 0\n-1 -2 -1 -1 -1 -1...
p01318 Immortal Jewels
English text is not available in this practice contest. At one point, a nobleman fell in love with a brave princess in a poor country and applied for marriage. The princess has given certain conditions to the aristocrats. The condition was to bring in a large number of jewels called "immortal jewels". Immortal gems ar...
{ "input": [], "output": [] }
{ "input": [ "6\n-2 -2 1 1\n2 2 2 0\n5 7 1 1\n8 0 3 1\n13 4 1 1\n16 1 1 2\n3\n0 0 2 1\n10 0 2 1\n0 10 2 1\n3\n0 0 2 1\n10 0 2 1\n0 6 2 1\n3\n0 0 2 1\n10 0 2 1\n0 4 2 1\n1\n0 0 1 1\n0" ], "output": [ "4\n2\n3\n3\n1" ] }
{ "input": [ "6\n-2 -2 1 1\n2 2 2 0\n5 7 1 1\n8 0 3 1\n13 4 1 1\n16 1 1 2\n3\n-1 0 2 1\n10 0 2 1\n0 10 4 1\n3\n0 0 2 1\n10 0 2 1\n0 6 2 1\n3\n0 0 2 1\n10 0 2 1\n0 4 2 1\n1\n0 0 1 1\n0", "6\n-2 -2 1 1\n2 2 4 0\n5 7 1 1\n8 0 3 1\n13 4 1 1\n16 1 0 2\n3\n-1 0 2 1\n10 0 2 1\n0 10 4 1\n3\n0 0 2 1\n10 0 2 1\n0 6 2 1...
p01486 CatChecker
Example Input mmemewwemeww Output Cat
{ "input": [], "output": [] }
{ "input": [ "mmemewwemeww" ], "output": [ "Cat" ] }
{ "input": [ "mmemwweemeww", "wwemeewwmemm", "mmemwweeneww", "mnemwweeneww", "wweneewwmenm", "wwmneewwmene", "xwmneewwmene", "xweneewwmmne", "xweneewvmmne", "xmeneewvmwne", "enwmvweenemx", "enwmvwfenemx", "enwmwwfenemx", "enwmwweenemx", "enwmwweememx", "...
p01648 Median Tree
Problem Statement You are given a connected undirected graph which has even numbers of nodes. A connected graph is a graph in which all nodes are connected directly or indirectly by edges. Your task is to find a spanning tree whose median value of edges' costs is minimum. A spanning tree of a graph means that a tree ...
{ "input": [], "output": [] }
{ "input": [ "2 1\n1 2 5\n4 6\n1 2 1\n1 3 2\n1 4 3\n2 3 4\n2 4 5\n3 4 6\n8 17\n1 4 767\n3 1 609\n8 3 426\n6 5 972\n8 1 607\n6 4 51\n5 1 683\n3 6 451\n3 4 630\n8 7 912\n3 7 43\n4 7 421\n3 5 582\n8 4 538\n5 7 832\n1 6 345\n8 2 608\n0 0" ], "output": [ "5\n2\n421" ] }
{ "input": [ "2 1\n1 2 5\n4 6\n2 2 1\n1 3 2\n1 4 3\n2 3 4\n2 4 5\n3 4 6\n8 17\n1 4 767\n3 1 609\n8 3 426\n6 5 972\n8 1 607\n6 4 51\n5 1 683\n3 6 451\n3 4 630\n8 7 912\n3 7 43\n4 7 421\n3 5 582\n8 4 538\n5 7 832\n1 6 345\n8 2 608\n0 0", "2 1\n1 2 5\n4 6\n1 2 1\n1 3 2\n1 4 3\n2 3 7\n2 4 5\n3 4 6\n8 17\n1 4 767\...
p01799 New Game AI
Example Input 5 3 1 5 3 4 5 3 7 2 9 1 Output 5
{ "input": [], "output": [] }
{ "input": [ "5 3\n1 5\n3 4\n5 3\n7 2\n9 1" ], "output": [ "5" ] }
{ "input": [ "5 3\n1 5\n3 4\n5 0\n7 2\n9 1", "5 3\n0 5\n6 3\n5 1\n7 2\n16 1", "5 3\n1 5\n3 4\n5 3\n7 2\n9 2", "5 3\n1 3\n2 4\n3 3\n1 2\n2 2", "5 3\n0 8\n0 4\n5 1\n2 2\n5 0", "5 3\n1 5\n3 3\n5 0\n7 2\n9 1", "5 3\n1 5\n3 3\n5 0\n7 2\n16 1", "5 3\n1 5\n3 3\n5 1\n7 2\n16 1", "5 3\n0 5\...
p01933 Displayed tweets
problem In Ikatta, the SNS used by AOR Ika-chan, posts are called tweets. And in squid, there is a concern that visibility will deteriorate if there are many replies to tweets, so when a tweet meets any of the following rules, the tweet will be displayed on the screen. ing. * Rule 1. No reply to any tweet * Rule 2. ...
{ "input": [], "output": [] }
{ "input": [ "6 3\n0\n0\n2\n3\n4\n5" ], "output": [ "5" ] }
{ "input": [ "6 6\n0\n0\n2\n3\n4\n5", "2 9\n0\n0\n2\n3\n4\n5", "4 3\n0\n0\n2\n3\n4\n5", "4 1\n0\n0\n2\n3\n4\n5", "5 25\n0\n1\n0\n3\n1\n17", "0 22\n0\n1\n1\n1\n1\n6", "1 16\n0\n0\n2\n5\n4\n2", "12 3\n0\n0\n0\n3\n4\n5", "7 10\n0\n0\n2\n3\n1\n0", "11 4\n0\n1\n2\n2\n4\n4", "6 9...
p02071 Consistent Trading
Problem Statement Your company is developing a video game. In this game, players can exchange items. This trading follows the rule set by the developers. The rule is defined as the following format: "Players can exchange one item $A_i$ and $x_i$ item $B_i$". Note that the trading can be done in both directions. Items ...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02213 Don't Rotate the Dice!
Problem statement I have a grid of $ H $ rows and $ W $ columns. Hereafter, the cells in the $ i $ row and $ j $ column on the grid are written as $ (i, j) $ cells. Each cell in the grid has a number between $ 1 $ and $ 6 $, or the letter `#` in $ 1 $ each. However, `#` is always written in the cell of $ (i, j) $ whe...
{ "input": [], "output": [] }
{ "input": [ "3 3\n631\n4#2\n516" ], "output": [ "YES" ] }
{ "input": [ "3 3\n631\n4#2\n486", "3 2\n631\n4#2\n246", "3 3\n631\n4#2\n246", "3 2\n631\n4$2\n246", "3 3\n421\n4#2\n516", "3 3\n631\n4#2\n646", "3 3\n631\n4#2\n266", "1 2\n631\n4#2\n246", "3 2\n631\n4$2\n153", "3 3\n631\n4#3\n646", "3 3\n734\n4#2\n266", "1 2\n631\n4$2\...
p02367 Bridges
Find bridges of an undirected graph G(V, E). A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components. Constraints * 1 ≤ |V| ≤ 100,000 * 0 ≤ |E| ≤ 100,000 * The graph is connected * There are no parallel edges * There are no self-loops Input |V| |E| s0 t0 s1 t1 : s...
{ "input": [], "output": [] }
{ "input": [ "5 4\n0 1\n1 2\n2 3\n3 4", "4 4\n0 1\n0 2\n1 2\n2 3" ], "output": [ "0 1\n1 2\n2 3\n3 4", "2 3" ] }
{ "input": [ "5 4\n0 1\n1 2\n1 3\n3 4", "4 4\n0 1\n0 2\n1 2\n2 4", "4 4\n0 1\n1 2\n1 2\n2 4", "4 3\n0 1\n1 2\n1 2\n2 4", "4 3\n0 1\n1 4\n1 2\n2 4", "5 4\n0 1\n1 3\n2 3\n3 4", "4 2\n0 1\n0 2\n1 2\n2 3", "2 4\n0 1\n0 2\n1 2\n2 3", "2 4\n0 1\n1 2\n1 2\n2 3", "3 1\n0 1\n1 2\n1 2\n2...
atom
Mr. Yagami is a scientist in the Bhabha Atomic Research Centre. They are conducting a lab experiment on nuclear fission. In nuclear fission, one atom breaks into more than one atom of the same type. Initially, there are N atoms in the lab. Starting from now (t=0), after each second, every atom will break into ...
{ "input": [], "output": [] }
{ "input": [ "2\n2 2 7\n2 2 8" ], "output": [ "1\n2" ] }
{ "input": [ "2\n2 2 7\n2 3 8", "2\n2 2 10\n2 2 8", "2\n2 2 10\n2 2 7", "2\n2 4 7\n1 5 12", "2\n2 2 1\n2 2 8", "2\n1 2 10\n2 2 8", "2\n2 2 7\n3 5 12", "2\n2 2 1\n2 2 1", "2\n1 2 10\n2 3 6", "2\n1 2 10\n3 3 6", "2\n2 2 11\n3 5 12", "2\n1 4 7\n1 5 28", "2\n1 2 17\n3 3...
clperm
Today is Chef's birthday. His mom gifted him a truly lovable gift, a permutation of first N positive integers. She placed the permutation on a very long table in front of Chef and left it for him to play with it. But as there was a lot of people coming and wishing him. It was interfering with his game which made him ve...
{ "input": [], "output": [] }
{ "input": [ "2\n5 2\n3 5\n5 1\n1" ], "output": [ "Mom\nChef" ] }
{ "input": [ "2\n5 2\n3 5\n7 1\n1", "2\n5 2\n3 3\n7 1\n1", "2\n6 2\n1 3\n7 1\n2", "2\n6 0\n1 3\n7 0\n1", "2\n5 2\n3 3\n7 0\n1", "2\n5 2\n1 3\n7 0\n1", "2\n6 2\n1 3\n7 0\n1", "2\n6 2\n1 3\n7 1\n1", "2\n6 2\n1 0\n7 1\n2", "2\n6 2\n1 0\n8 1\n2", "2\n4 2\n1 0\n8 1\n2", "2\n...
flow008
Write a program, which takes an integer N and if the number is less than 10 then display "What an obedient servant you are!" otherwise print "-1". Input The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N. Output Output the given string or -1 depend...
{ "input": [], "output": [] }
{ "input": [ "3 \n1\n12\n-5" ], "output": [ "What an obedient servant you are!\n-1\nWhat an obedient servant you are!\n" ] }
{ "input": [ "3 \n0\n12\n-5", "3 \n1\n1\n-12", "3 \n17\n0\n1", "3 \n0\n0\n12", "3 \n1\n12\n-9", "3 \n1\n12\n-12", "3 \n1\n1\n-5", "3 \n1\n2\n-5", "3 \n1\n0\n-5", "3 \n0\n0\n-5", "3 \n-1\n0\n-5", "3 \n-1\n0\n-4", "3 \n-1\n0\n0", "3 \n-1\n0\n-1", "3 \n-1\n1\n-...
lelemon
Little Elephant likes lemonade. When Little Elephant visits any room, he finds the bottle of the lemonade in that room that contains the greatest number of litres of lemonade and drinks it all. There are n rooms (numbered from 0 to n-1), each contains Ci bottles. Each bottle has a volume (in litres). The first room v...
{ "input": [], "output": [] }
{ "input": [ "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 3 0 1 0 0\n1 7\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 1" ], "output": [ "17\n22\n" ] }
{ "input": [ "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 2 0 1 0 0\n1 7\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 2 0 2 0 0\n1 7\n3 9 4 5\n7 2 2 3 4 5 6 7\n1 1", "2\n3 3\n0 2 1\n3 1 2 3\n1 7\n2 4 7\n4 7\n0 1 3 0 1 0 0\n1 7\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 0", "2\n3 3...
power2
Problem Description: Mr. Y’s favourite number is the number 2. Such is his passion that he begins to hate all other digits. Whenever faced with a number he tries to convert it to sum of powers of 2 where the power is non-zero positive integer. If he is successful he calls the number magical. You have to help Mr. Y in c...
{ "input": [], "output": [] }
{ "input": [ "1\n6" ], "output": [ "Yes\n" ] }
{ "input": [ "1\n4", "1\n7", "1\n12", "1\n9", "1\n17", "1\n18", "1\n29", "1\n27", "1\n32", "1\n26", "1\n2", "1\n0", "1\n10", "1\n24", "1\n3", "1\n-1", "1\n21", "1\n14", "1\n39", "1\n51", "1\n15", "1\n-2", "1\n-4", "1\n-3",...
submin
Little Elephant is playing a game with arrays. He is given an array A0, A1, ..., AN−1 of N integers. And then Q queries are given, each containing an integer K. He has to tell how many subarrays satisfy the condition: the function foo returns K when it is applied to the subarray. In this problem, a subarray is defined ...
{ "input": [], "output": [] }
{ "input": [ "5\n4 1 2 3 4\n4\n3\n4\n6\n1" ], "output": [ "2\n2\n0\n8\n" ] }
{ "input": [ "5\n4 0 2 3 4\n4\n3\n4\n6\n1", "5\n4 0 2 3 4\n4\n5\n4\n6\n1", "5\n4 1 2 3 4\n4\n5\n4\n6\n1", "5\n4 1 2 6 4\n4\n5\n4\n6\n1", "5\n4 1 2 3 4\n4\n3\n7\n6\n1", "5\n4 0 2 3 4\n1\n3\n4\n6\n1", "5\n4 0 2 3 0\n4\n5\n4\n6\n1", "5\n4 1 2 3 4\n3\n5\n4\n6\n1", "5\n4 1 2 6 4\n4\n5\n...
100_G. Name the album
The famous singer, Aryo, is going to publish a new album of his great work! Unfortunately these days, there are many albums, Aryo wants to choose a new name for his album, a name that has not been used or at least has not been used recently. He has a list of all used album names together with the year the albums were...
{ "input": [], "output": [] }
{ "input": [ "3\neyesonme 2008\nanewdayhascome 2002\noneheart 2003\n2\noneheart\nbienbien\n", "2\nnasimevasl 2003\nbasetareha 2006\n2\nnasimevasl\nbasetareha\n" ], "output": [ "bienbien\n", "nasimevasl\n" ] }
{ "input": [], "output": [] }
130_B. Gnikool Ssalg
You are given a string. Reverse its characters. Input The only line of input contains a string between 1 and 100 characters long. Each character of the string has ASCII-code between 33 (exclamation mark) and 126 (tilde), inclusive. Output Output the characters of this string in reverse order. Examples Input secr...
{ "input": [], "output": [] }
{ "input": [ "secrofedoc\n", "!ssalg-gnikool5\n" ], "output": [ "codeforces\n", "5looking-glass!\n" ] }
{ "input": [], "output": [] }
1331_E. Jordan Smiley
<image> Input The input contains two integers row, col (0 ≤ row, col ≤ 63), separated by a single space. Output Output "IN" or "OUT". Examples Input 0 0 Output OUT Input 27 0 Output IN Input 0 27 Output OUT Input 27 27 Output IN
{ "input": [], "output": [] }
{ "input": [ "0 0\n", "0 27\n", "27 27\n", "27 0\n" ], "output": [ "OUT", "OUT", "IN", "IN" ] }
{ "input": [ "0 45\n", "53 27\n", "27 1\n", "0 18\n", "51 1\n", "0 13\n", "51 0\n", "1 13\n", "0 6\n", "0 10\n", "0 8\n", "0 3\n", "1 0\n", "1 1\n", "27 36\n", "9 0\n", "32 1\n", "0 22\n", "2 13\n", "0 5\n", "1 10\n", "1 8\n", ...
1461_D. Divide and Summarize
Mike received an array a of length n as a birthday present and decided to test how pretty it is. An array would pass the i-th prettiness test if there is a way to get an array with a sum of elements totaling s_i, using some number (possibly zero) of slicing operations. <image> An array slicing operation is conducted...
{ "input": [], "output": [] }
{ "input": [ "2\n5 5\n1 2 3 4 5\n1\n8\n9\n12\n6\n5 5\n3 1 3 1 3\n1\n2\n3\n9\n11\n" ], "output": [ "\nYes\nNo\nYes\nNo\nYes\nNo\nYes\nNo\nYes\nYes\n" ] }
{ "input": [ "2\n5 5\n1 2 3 4 5\n1\n8\n9\n12\n6\n5 5\n0 1 3 1 3\n1\n2\n3\n9\n11\n", "2\n5 5\n1 2 3 4 5\n1\n8\n9\n12\n6\n5 5\n0 1 3 1 3\n1\n2\n3\n2\n11\n", "2\n5 5\n1 2 3 4 5\n1\n5\n9\n12\n6\n5 5\n3 1 3 1 3\n1\n2\n3\n9\n11\n", "2\n5 5\n1 2 3 4 5\n1\n8\n9\n12\n6\n5 0\n0 1 3 1 3\n1\n2\n3\n9\n11\n", "...
683_D. Chocolate Bar
A chocolate bar has a rectangular shape and consists of n × m slices. In other words, a bar consists of n rows with m slices of chocolate in each row. Each slice of chocolate is known to weigh 1 gram. Your task is to determine for each of the q chocolate bars whether it is possible to obtain a piece weighing p grams b...
{ "input": [], "output": [] }
{ "input": [ "2\n3 3 4\n4 4 7\n" ], "output": [ "Yes\nNo\n" ] }
{ "input": [], "output": [] }
alphanumeric-string
A student is assigned a problem, to get a alphanumeric string from the user and to calculate the sum of digits in the given string.after this he has to delete the digits(0-9) from the string and to display the each word of the string in dictionary order followed by the sum of digits continuously decreasing by the size...
{ "input": [], "output": [] }
{ "input": [ "2\nthi6s is a85 t6es6t\nh8e is7 a b9oy5\n\nSAMPLE" ], "output": [ "a 30 is 28 test 24 this 20 \na 28 boy 25 he 23 is 21 \n" ] }
{ "input": [ "2\nthi6s is a85 t6es6t\nh8e is7 a b9oy5\n\nSAMQLE", "2\nthi6s is a85 t6es6t\nh8e is7 a 5yo9b\n\nSAMQLE", "2\nthi6s is a85 t6es6t\nh8e is7 a 5yo9a\n\nSAMQLE", "2\nthi6s is a58 t6es6t\nh8e hs7 a y5o9a\n\nSAMQLE", "2\nthi6s is a57 t6es6t\nh8e hs7 a y5o9a\n\nSEMQLA", "2\nthi6s is a57...
decreasing-paths
See Russian Translation The end semester exams are now approaching. Ritu is the Computer Science Teacher of Coder Public School. He has been assigned the task of preparing good algorithmic problems for the students by the Dean of the school. Ritu like every other teacher has his own favorite topics. Ritu likes matri...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2\n1 3\n\nSAMPLE" ], "output": [ "8" ] }
{ "input": [], "output": [] }
kings-race-8
Shizuka, the daughter of Code King, is the most beautiful girl of Candyland. Every other Prince wants to marry her.The Code King invites all the other Prince in the town for a RACE and the winner of the race gets a chance to marry her. Obviously , the RACE will be full of hurdles. Given the number of Princes N, each w...
{ "input": [], "output": [] }
{ "input": [ "2\n5 5\n10 20 30 40 50\n7 7 7 7 7\n7 5 \n1 2 3 4 5 6 7\n2 1 5 1 8\n\nSAMPLE" ], "output": [ "0\n4" ] }
{ "input": [ "2\n2 5\n10 20 30 40 50\n7 7 7 7 7\n7 5 \n1 2 3 4 5 6 7\n2 1 5 1 8\n\nSAMPLE", "2\n2 5\n10 20 30 40 50\n7 7 7 7 7\n7 5 \n1 2 3 5 5 2 7\n2 1 5 1 8\n\nSAMPLE", "2\n2 5\n10 20 30 40 50\n11 9 7 7 7\n7 5 \n1 2 3 4 5 2 7\n2 1 5 1 8\n\nSAMPLE", "2\n2 5\n10 20 30 40 50\n7 9 7 7 7\n7 5 \n1 2 3 4 3...
monk-and-champions-league
Monk's favourite game is Football and his favourite club is "Manchester United". Manchester United has qualified for the Champions League Final which is to be held at the Wembley Stadium in London. So, he decided to go there and watch his favourite team play. After reaching the stadium, he saw that many people have lin...
{ "input": [], "output": [] }
{ "input": [ "3 4\n1 2 4\n\nSAMPLE" ], "output": [ "11\n" ] }
{ "input": [ "3 4\n1 4 4\n\nSAMPLE", "3 4\n4 4 4\n\nSAMPLE", "3 4\n4 4 6\n\nSAMPLE", "3 8\n4 4 6\n\nSAMPLE", "3 6\n4 4 6\n\nSAMPLE", "3 5\n4 4 6\n\nSAMPLE", "3 7\n4 4 6\n\nSAMPLE", "3 2\n4 4 6\n\nSAMPLE", "3 2\n4 4 11\n\nSAMPLE", "3 2\n4 4 13\n\nSAMPLE", "3 0\n6 4 13\n\nSAM...
roy-and-code-streak
Roy is working on HackerEarth Profile. Right now he is working on User Statistics. One of the statistics data (Code Streak) is as follows: Given the User Activity Data, find the maximum number of continuous correct solutions submitted by any user. Seems easy eh? Here's the catch! In order to maximize this number a use...
{ "input": [], "output": [] }
{ "input": [ "3\n6\n1 0\n2 1\n3 1\n4 1\n5 1\n6 0\n5\n1 1\n2 0\n3 1\n1 1\n2 1\n4\n1 1\n2 1\n2 1\n3 1\n\nSAMPLE" ], "output": [ "4\n2\n3\n" ] }
{ "input": [ "3\n6\n1 0\n3 1\n3 1\n4 1\n5 1\n6 0\n5\n1 1\n2 0\n3 1\n1 1\n2 1\n4\n1 1\n2 1\n2 1\n3 1\n\nSAMPLE", "3\n6\n2 0\n2 1\n3 1\n4 1\n5 1\n6 0\n5\n1 1\n2 0\n3 1\n1 1\n2 1\n4\n1 1\n2 1\n2 1\n3 1\n\nSAMPLE", "3\n6\n2 1\n2 1\n3 1\n4 1\n5 1\n6 0\n5\n1 1\n2 0\n3 0\n1 1\n2 1\n4\n1 1\n2 1\n2 1\n3 1\n\nSAMPL...
p02593 AtCoder Grand Contest 047 - Rooks
You are given positions (X_i, Y_i) of N enemy rooks on an infinite chessboard. No two rooks attack each other (at most one rook per row or column). You're going to replace one rook with a king and then move the king repeatedly to beat as many rooks as possible. You can't enter a cell that is being attacked by a rook....
{ "input": [], "output": [] }
{ "input": [ "6\n1 8\n6 10\n2 7\n4 4\n9 3\n5 1", "5\n5 5\n100 100\n70 20\n81 70\n800 1", "10\n2 5\n4 4\n13 12\n12 13\n14 17\n17 19\n22 22\n16 18\n19 27\n25 26" ], "output": [ "5\n0\n7\n5\n0\n0", "985\n985\n1065\n1034\n0", "2\n2\n9\n9\n3\n3\n24\n5\n0\n25" ] }
{ "input": [ "6\n1 0\n6 10\n2 7\n4 4\n9 3\n5 1", "5\n5 5\n100 100\n70 21\n81 70\n800 1", "6\n1 0\n6 10\n2 7\n4 6\n9 3\n5 1", "5\n5 5\n100 100\n70 20\n81 36\n800 1", "6\n1 0\n6 10\n0 7\n4 4\n9 3\n5 1", "5\n5 5\n100 100\n70 21\n31 70\n800 1", "5\n5 5\n100 100\n70 20\n81 36\n21 1", "5\n5 ...
p02724 AtCoder Beginner Contest 160 - Golden Coins
Takahashi loves gold coins. He gains 1000 happiness points for each 500-yen coin he has and gains 5 happiness points for each 5-yen coin he has. (Yen is the currency of Japan.) Takahashi has X yen. If he exchanges his money so that he will gain the most happiness points, how many happiness points will he earn? (We as...
{ "input": [], "output": [] }
{ "input": [ "0", "1000000000", "1024" ], "output": [ "0", "2000000000", "2020" ] }
{ "input": [ "1", "1000000001", "656", "-1", "506", "685", "925", "-8", "989", "-11", "1802", "2972", "2636", "1385", "1233", "865", "-20", "1608", "2611", "743", "1352", "1311", "42", "8", "15", "14", "-37", ...
p02855 DISCO Presents Discovery Channel Code Contest 2020 Qual - Strawberry Cakes
Chokudai made a rectangular cake for contestants in DDCC 2020 Finals. The cake has H - 1 horizontal notches and W - 1 vertical notches, which divide the cake into H \times W equal sections. K of these sections has a strawberry on top of each of them. The positions of the strawberries are given to you as H \times W ch...
{ "input": [], "output": [] }
{ "input": [ "3 3 5\n#.#\n.#.\n#.#", "13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.##...
{ "input": [ "13 21 106\n.....................\n.####.####.####.####.\n..#.#..#.$.#....#....\n..#.#..#.#.#....#....\n..#.#..#.#.#....#....\n.####.####.####.####.\n.....................\n.####.####.####.####.\n....#.#..#....#.#..#.\n.####.#..#.####.#..#.\n.#....#..#.#....#..#.\n.####.####.####.####.\n................
p02991 AtCoder Beginner Contest 132 - Hopscotch Addict
Ken loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G. G consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i. First, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one ken-ken-pa, he does th...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 2\n2 3\n3 4\n4 1\n1 3", "6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6", "3 3\n1 2\n2 3\n3 1\n1 2", "2 0\n1 2" ], "output": [ "2", "2", "-1", "-1" ] }
{ "input": [ "4 4\n1 3\n2 3\n3 4\n4 1\n1 3", "6 8\n1 4\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6", "3 3\n1 2\n2 3\n2 1\n1 2", "3 1\n1 1\n3 3\n3 1\n1 2", "4 1\n1 3\n2 3\n3 4\n4 1\n1 3", "6 8\n1 4\n2 3\n3 4\n4 6\n5 1\n1 4\n1 5\n4 6\n1 6", "6 8\n1 2\n2 3\n3 4\n4 6\n5 1\n1 4\n1 5\n4 6\n1 6", ...
p03132 Yahoo Programming Contest 2019 - Ears
Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point with integer coordinate, and also finishes walking at a point with ...
{ "input": [], "output": [] }
{ "input": [ "4\n1\n0\n2\n3", "8\n2\n0\n0\n2\n1\n3\n4\n1", "7\n314159265\n358979323\n846264338\n327950288\n419716939\n937510582\n0" ], "output": [ "1", "3", "1" ] }
{ "input": [ "4\n1\n0\n4\n3", "8\n2\n0\n0\n2\n0\n3\n4\n1", "4\n0\n0\n4\n3", "8\n2\n0\n1\n2\n0\n1\n0\n1", "8\n2\n0\n1\n2\n0\n1\n0\n0", "8\n4\n0\n0\n2\n0\n1\n2\n1", "7\n314159265\n429733551\n846264338\n327950288\n419716939\n937510582\n0", "8\n2\n0\n0\n2\n0\n0\n4\n1", "7\n314159265\n4...
p03275 AtCoder Beginner Contest 107 - Median of Medians
We will define the median of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of ...
{ "input": [], "output": [] }
{ "input": [ "3\n10 30 20", "10\n5 9 5 9 8 9 3 5 4 3", "1\n10" ], "output": [ "30", "8", "10" ] }
{ "input": [ "3\n10 9 20", "10\n5 9 5 9 8 4 3 5 4 3", "1\n4", "10\n5 9 5 9 16 8 3 5 4 3", "1\n2", "1\n16", "1\n7", "1\n3", "1\n6", "1\n1", "3\n-1 9 3", "3\n10 31 20", "1\n19", "1\n21", "3\n12 8 32", "1\n14", "3\n15 2 32", "1\n26", "1\n11", ...
p03432 AtCoder Grand Contest 021 - Trinity
We have an N \times M grid. The square at the i-th row and j-th column will be denoted as (i,j). Particularly, the top-left square will be denoted as (1,1), and the bottom-right square will be denoted as (N,M). Takahashi painted some of the squares (possibly zero) black, and painted the other squares white. We will de...
{ "input": [], "output": [] }
{ "input": [ "5000 100", "17 13", "4 3", "2 3" ], "output": [ "57613837", "229876268", "2588", "64" ] }
{ "input": [ "5000 101", "17 5", "4 0", "1 3", "3993 101", "28 5", "2 5", "3993 111", "28 6", "8 1", "1 5", "7184 111", "19 6", "16 1", "7184 101", "15 6", "21 1", "1487 101", "15 4", "1487 100", "3 4", "2354 100", "2354 010",...
p03591 CODE FESTIVAL 2017 qual A - Snuke's favorite YAKINIKU
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of ...
{ "input": [], "output": [] }
{ "input": [ "YAKINIKU", "TAKOYAKI", "YAK" ], "output": [ "Yes", "No", "No" ] }
{ "input": [ "UKINIKAY", "UAKOYAKI", "KAY", "NKIUIKAY", "IKAYOKAU", "JAY", "NKIUAKIY", "AAKOYUKI", "JAZ", "OKIUAKIY", "AAKPYUKI", "ZAJ", "OKIVAKIY", "IKUYPKAA", "[AJ", "OKIVALIY", "IKVYPKAA", "[AK", "OKIVBLIY", "IKTYPKAA", "KA[", ...
p03748 AtCoder Grand Contest 013 - Piling Up
Joisino has a lot of red and blue bricks and a large box. She will build a tower of these bricks in the following manner. First, she will pick a total of N bricks and put them into the box. Here, there may be any number of bricks of each color in the box, as long as there are N bricks in total. Particularly, there may...
{ "input": [], "output": [] }
{ "input": [ "1000 3000", "1000 10", "2 3" ], "output": [ "693347555", "1048576", "56" ] }
{ "input": [ "1100 3000", "1001 10", "2 4", "1001 7", "2 8", "2 12", "3 12", "0 12", "2 2", "1001 1", "2 5", "4 8", "1 8", "6 12", "1 6", "1 5", "3 8", "1 14", "5 12", "2 6", "1 4", "1 32", "1 60", "4 4", "1011 15", ...
p03910 CODE FESTIVAL 2016 Final - Exactly N points
The problem set at CODE FESTIVAL 20XX Finals consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest...
{ "input": [], "output": [] }
{ "input": [ "4", "7", "1" ], "output": [ "1\n3", "1\n2\n4", "1" ] }
{ "input": [ "14", "2", "3", "8", "12", "21", "5", "9", "17", "31", "32", "10", "41", "13", "80", "101", "111", "6", "11", "25", "16", "30", "40", "22", "57", "44", "19", "33", "15", "001", "38"...
p00014 Integral
Write a program which computes the area of a shape represented by the following three lines: $y = x^2$ $y = 0$ $x = 600$ It is clear that the area is $72000000$, if you use an integral you learn in high school. On the other hand, we can obtain an approximative area of the shape by adding up areas of many rectangles...
{ "input": [], "output": [] }
{ "input": [ "20\n10" ], "output": [ "68440000\n70210000" ] }
{ "input": [ "20\n15", "20\n4", "20\n8", "20\n2", "20\n6", "20\n1", "20\n-1", "20\n3", "20\n5", "20\n24", "20\n12", "20\n20", "20\n25", "20\n30", "20\n50", "20\n60", "20\n75", "20\n40", "20\n100", "20\n120", "20\n150", "20\n200", ...
p00146 Lupin The 4th
The phantom thief "Lupin IV" is told by the beautiful "Fujiko Mine", a descendant of the Aizu clan, that the military funds left by the Aizu clan are sleeping in Aizuwakamatsu city. According to a report by Lupine's longtime companion, "Ishikawa Koshiemon," military funds are stored in several warehouses in a Senryobak...
{ "input": [], "output": [] }
{ "input": [ "5\n13 199 1\n51 1000 1\n37 350 10\n27 300 2\n99 200 1000", "3\n11 100 1\n13 200 20\n12 300 3", "2\n1 100 1\n2 200 2" ], "output": [ "51 37 27 13 99", "11 12 13", "1 2" ] }
{ "input": [ "5\n13 199 1\n93 1000 1\n37 350 10\n27 300 2\n99 200 1000", "3\n9 100 1\n13 200 20\n12 300 3", "2\n2 100 1\n2 200 2", "5\n13 199 1\n93 1000 1\n37 350 10\n27 300 2\n82 200 1000", "3\n9 100 1\n13 200 20\n19 300 3", "5\n13 199 1\n93 1000 1\n37 350 10\n27 300 2\n123 200 1100", "3\...
p00279 Happy End Problem
Let's write a program related to an unsolved math problem called "Happy End Problem". Create a program to find the smallest convex polygon formed by connecting exactly k points from the N points given on the plane. However, after being given the coordinates of N points, the question is given the number k of the angles ...
{ "input": [], "output": [] }
{ "input": [ "5\n0 0\n3 0\n5 2\n1 4\n0 3\n3\n3\n4\n5" ], "output": [ "1 4 5\n1 2 4 5\n1 2 3 4 5" ] }
{ "input": [ "5\n0 0\n3 -1\n5 2\n1 4\n0 3\n3\n3\n4\n5", "5\n1 0\n3 -1\n5 2\n1 1\n0 3\n3\n3\n4\n5", "5\n0 0\n2 0\n5 2\n1 4\n0 3\n3\n3\n4\n5", "5\n1 0\n3 -1\n5 2\n1 1\n0 3\n3\n3\n4\n4", "5\n0 0\n2 0\n5 1\n1 4\n0 3\n3\n3\n4\n5", "5\n1 0\n3 0\n5 2\n1 1\n0 3\n3\n3\n4\n4", "5\n1 0\n3 0\n5 2\n1 1...
p00467 Sugoroku
Sugoroku problem JOI is playing sugoroku alone. There are N squares in a straight line in this sugoroku, and each has a movement instruction written on it. The starting point is the 1st square and the goal is the Nth square. JOI repeats the following until he reaches the goal. Roll the dice and proceed from the curr...
{ "input": [], "output": [] }
{ "input": [ "10 5\n0\n0\n5\n6\n-3\n8\n1\n8\n-4\n0\n1\n3\n5\n1\n5\n10 10\n0\n-1\n-1\n4\n4\n-5\n0\n1\n-6\n0\n1\n5\n2\n4\n6\n5\n5\n4\n1\n6\n0 0" ], "output": [ "5\n6" ] }
{ "input": [ "10 5\n0\n0\n5\n6\n-3\n8\n1\n8\n-4\n0\n1\n3\n5\n1\n5\n10 10\n0\n-1\n-1\n4\n4\n-5\n0\n1\n-6\n0\n1\n5\n2\n5\n6\n5\n5\n4\n1\n6\n0 0", "10 5\n0\n0\n5\n6\n-2\n8\n1\n8\n-4\n0\n1\n3\n5\n1\n5\n10 10\n0\n-1\n-1\n4\n4\n-5\n0\n1\n-6\n0\n2\n5\n2\n4\n6\n5\n5\n4\n1\n6\n0 0", "10 5\n0\n1\n5\n6\n-2\n8\n1\n8\...
p00659 Popularity Estimation
You are the planning manager of an animation production company. What animation production companies produce these days is not limited to animation itself. Related products, such as figures of characters and character song CDs, are also important sources of revenue. How much this profit can be increased depends solely ...
{ "input": [], "output": [] }
{ "input": [ "4\nakzakr 2 1 8\nfnmyi 5 2 3 4 6 9\ntsnukk 5 2 3 4 7 9\nyskwcnt 6 3 4 7 8 9 10\n4\nakzakr 1 2\nfnmyi 3 10 11 12\ntsnukk 2 1 8\nyskwcnt 2 1 8\n5\nknmmdk 2 13 19\nakmhmr 4 13 15 19 22\nmksyk 6 3 7 12 13 15 19\nskrkyk 3 1 4 8\ntmemm 3 1 17 24\n5\nknmmdk 5 5 6 16 18 26\nakmhmr 9 3 4 7 11 14 15 17 18 20\...
{ "input": [ "4\nakzakr 2 1 8\nfnmyi 5 2 3 4 6 9\ntsnukk 5 2 3 4 7 9\nyskwcnt 6 3 4 7 8 9 10\n4\nakzakr 1 2\nfnmyi 3 10 11 12\ntsnukk 2 1 8\nyskwcnt 2 1 8\n5\nknmmdk 2 13 19\nakmhmr 4 13 15 19 22\nmksyk 6 3 7 12 13 15 19\nskrkyk 3 1 4 8\ntmemm 3 1 17 24\n5\nknmmdk 5 5 6 16 18 26\nakmhmr 9 3 4 7 11 14 15 17 18 20\...
p00802 Telescope
Dr. Extreme experimentally made an extremely precise telescope to investigate extremely curi- ous phenomena at an extremely distant place. In order to make the telescope so precise as to investigate phenomena at such an extremely distant place, even quite a small distortion is not allowed. However, he forgot the influe...
{ "input": [], "output": [] }
{ "input": [ "4 3\n0.0 0.25 0.5 0.666666666666666666667\n4 4\n0.0 0.25 0.5 0.75\n30 15\n0.00 0.03 0.06 0.09 0.12 0.15 0.18 0.21 0.24 0.27\n0.30 0.33 0.36 0.39 0.42 0.45 0.48 0.51 0.54 0.57\n0.61 0.64 0.66 0.69 0.72 0.75 0.78 0.81 0.84 0.87\n40 20\n0.351 0.353 0.355 0.357 0.359 0.361 0.363 0.365 0.367 0.369\n0.371...
{ "input": [ "4 3\n0.0 0.25 0.5 0.666666666666666666667\n4 4\n0.9209996761802979 0.25 0.5 0.75\n30 15\n0.00 0.03 0.06 0.09 0.12 0.15 0.18 0.21 0.24 0.27\n0.30 0.33 0.36 0.39 0.42 0.45 0.48 0.51 0.54 0.57\n0.61 0.64 0.66 0.69 0.72 0.75 0.78 0.81 0.84 0.87\n40 20\n0.351 0.353 0.355 0.357 0.359 0.361 0.363 0.365 0.3...
p00933 Exhibition
Example Input 6 5 1 2 3 5 5 5 1 5 5 2 5 4 3 5 3 4 5 2 5 5 1 Output 0.631579
{ "input": [], "output": [] }
{ "input": [ "6 5 1 2 3\n5 5 5\n1 5 5\n2 5 4\n3 5 3\n4 5 2\n5 5 1" ], "output": [ "0.631579" ] }
{ "input": [ "6 5 1 2 3\n5 5 5\n1 5 5\n2 5 3\n3 5 3\n4 5 2\n5 5 1", "6 5 1 4 3\n5 5 5\n1 5 5\n2 3 3\n3 1 3\n4 3 2\n5 5 0", "6 5 1 4 3\n5 5 5\n1 5 5\n2 3 5\n3 1 3\n4 3 2\n5 5 0", "6 5 1 4 3\n5 5 9\n1 5 5\n2 3 5\n3 1 3\n4 3 2\n5 5 0", "12 5 1 4 3\n5 5 9\n1 5 5\n2 3 5\n3 1 3\n4 3 2\n5 5 0", "12 5...
p01066 Reflection Warp Machine
Problem In a certain universe, there are n stars on a two-dimensional lattice point, and aliens use the Reflection Warp Machine to move between the stars. This device can draw a straight line at any position and angle. With this straight line as the axis of symmetry, it is possible to move from the current coordinates...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0\n0 1\n0 2\n0 3", "3\n0 0\n0 1\n1 0" ], "output": [ "2", "2" ] }
{ "input": [ "4\n0 0\n0 1\n-1 2\n0 3", "3\n-1 0\n0 1\n1 0", "3\n-2 0\n0 1\n1 0", "3\n-2 0\n0 2\n1 0", "3\n0 0\n0 2\n1 0", "3\n0 0\n0 2\n1 -1", "3\n0 0\n0 3\n1 -1", "3\n0 -1\n0 3\n1 -1", "3\n0 -1\n0 2\n1 -1", "4\n0 0\n0 1\n-1 2\n-1 3", "3\n-1 -1\n0 1\n1 0", "3\n-3 0\n0 2...
p01199 Flame of Nucleus
Year 20XX — a nuclear explosion has burned the world. Half the people on the planet have died. Fearful. One city, fortunately, was not directly damaged by the explosion. This city consists of N domes (numbered 1 through N inclusive) and M bidirectional transportation pipelines connecting the domes. In dome i, Pi citiz...
{ "input": [], "output": [] }
{ "input": [ "1 0 1\n51\n50\n2 1 1\n1 2 1\n1000 0\n0 1000\n4 3 5\n1 2 4\n1 3 1\n3 4 2\n0 1000 1000 1000\n3000 0 0 0" ], "output": [ "50\n0\n3000" ] }
{ "input": [ "1 0 1\n51\n50\n2 1 1\n1 2 1\n1000 0\n0 1000\n4 3 5\n1 2 1\n1 3 1\n3 4 2\n0 1000 1000 1000\n3000 0 0 0", "1 0 1\n51\n58\n2 1 1\n1 2 1\n1000 0\n0 1000\n4 3 5\n1 2 1\n1 3 1\n3 4 2\n0 1000 1000 1000\n3000 0 0 0", "1 0 1\n51\n58\n2 1 1\n1 2 2\n1000 0\n0 1000\n4 3 5\n1 1 1\n1 3 1\n3 4 2\n0 1000 10...
p01336 THE BYDOLM@STER
Description THE BY DOLM @ STER is a training simulation game scheduled to be released on EXIDNA by 1rem on April 1, 2010. For the time being, it probably has nothing to do with an arcade game where the network connection service stopped earlier this month. This game is a game in which members of the unit (formation) t...
{ "input": [], "output": [] }
{ "input": [ "3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n5 3 11 14\n2 300\nBydo System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300" ], "output": [ "29\n462" ] }
{ "input": [ "3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n5 3 11 14\n2 300\nBydp System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300", "3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n5 7 21 14\n2 300\nBydp System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300", "3 10\nDobkeradops\n7 5...
p01503 Tampopo Machine
Example Input 1 1 1 1 1 Output 0.000000000000
{ "input": [], "output": [] }
{ "input": [ "1 1 1 1 1" ], "output": [ "0.000000000000" ] }
{ "input": [ "1 1 0 1 1", "0 2 1 0 3", "1 1 1 1 3", "1 0 1 1 5", "2 0 1 1 5", "4 1 1 1 12", "0 1 1 0 2", "2 0 1 1 7", "4 1 1 1 6", "0 1 1 0 12", "0 2 1 0 5", "1 0 1 1 9", "1 1 1 0 12", "1 2 1 0 8", "2 0 1 1 21", "2 -1 1 0 4", "0 1 1 1 10", "1 2 4...
p01674 Rings
H - Rings Problem Statement There are two circles with radius 1 in 3D space. Please check two circles are connected as chained rings. Input The input is formatted as follows. {c_x}_1 {c_y}_1 {c_z}_1 {v_x}_{1,1} {v_y}_{1,1} {v_z}_{1,1} {v_x}_{1,2} {v_y}_{1,2} {v_z}_{1,2} {c_x}_2 {c_y}_2 {c_z}_2 {v_x}_{2,1} {v_y}_{...
{ "input": [], "output": [] }
{ "input": [ "0.0 0.0 0.0\n1.0 0.0 0.0 0.0 1.0 0.0\n1.0 0.0 0.5\n1.0 0.0 0.0 0.0 0.0 1.0" ], "output": [ "YES" ] }
{ "input": [ "0.0 0.0 0.0\n1.3851474630540055 0.0 0.0 0.0 1.0 0.0\n1.0 0.0 0.5\n1.0 0.0 0.0 0.0 0.0 1.0", "0.9153144643366036 0.0 0.0\n1.3851474630540055 0.0 0.0 0.0 1.0 0.0\n1.0 0.0 0.5\n1.0 0.0 0.0 0.0 0.0 1.0", "0.0 0.0 0.0\n1.0 0.0 0.0 0.0 1.0 0.0\n1.0 0.0 0.5\n1.2038717327869979 0.0 0.0 0.0 0.0 1.0",...
p01816 Bit Operation Game
H --Bit Operation Game Given a rooted tree with N vertices. The vertices are numbered from 0 to N − 1, and the 0th vertex represents the root. `T = 0` for the root, but for the other vertices * `T = T & X;` * `T = T & Y;` * `T = T | X` * `T = T | Y` * `T = T ^ X` * `T = T ^ Y` One of the operations is written. Her...
{ "input": [], "output": [] }
{ "input": [ "6 3\nT=T|X\nT=T|Y\nT=T|Y\nT=T^Y\nT=T&X\n0 1\n0 2\n1 3\n1 4\n2 5\n5 6\n3 5\n0 0" ], "output": [ "4\n6\n0" ] }
{ "input": [ "6 6\nT=T|X\nT=T|Y\nT=T|Y\nT=T^Y\nT=T&X\n0 1\n0 2\n1 3\n1 4\n2 5\n5 6\n3 5\n0 0", "6 6\nT=T|X\nT=T|Y\nT=T|Y\nT=T^Y\nT=T&X\n0 1\n0 2\n1 3\n1 4\n2 5\n9 6\n3 5\n0 0", "6 6\nT=T|X\nT=T|Y\nT=T|Y\nT=T^Y\nT=T&X\n0 1\n0 2\n1 3\n1 4\n2 5\n5 6\n3 5\n1 0", "6 6\nT=T|X\nT=T|Y\nT=T|Y\nT=T^Y\nT=T&X\n0 ...
p01951 Low Range-Sum Matrix
You received a card at a banquet. On the card, a matrix of $N$ rows and $M$ columns and two integers $K$ and $S$ are written. All the elements in the matrix are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is denoted by $A_{i,j}$. You can select up to $K$ elements from th...
{ "input": [], "output": [] }
{ "input": [ "2 2 3 100\n0 0\n0 0", "3 3 2 10\n5 3 7\n2 6 1\n3 4 1", "2 3 1 5\n4 8 -2\n-2 -5 -3", "2 3 1 5\n9 8 -2\n-2 -5 -3" ], "output": [ "Yes", "Yes", "Yes", "No" ] }
{ "input": [ "2 2 6 100\n0 0\n0 0", "2 3 1 7\n9 8 -2\n-2 -5 -3", "0 3 2 10\n5 3 7\n2 6 1\n3 4 1", "2 3 1 5\n4 8 0\n-2 -5 -3", "2 2 6 100\n0 1\n0 0", "0 3 2 10\n5 3 7\n0 6 1\n3 4 1", "2 1 6 100\n0 1\n0 0", "0 3 2 10\n5 3 6\n0 6 1\n3 4 1", "2 2 6 100\n0 1\n0 -1", "0 3 2 6\n5 3 6\...
p02100 Factorization
Problem Mr. ukuku1333 is a little sloppy, so when I expanded the product of the linear expressions of x, I couldn't figure out the original linear expression. Given the nth degree polynomial of x, factor it into the product of the original linear expressions of x. The nth degree polynomial of x is given by the follow...
{ "input": [], "output": [] }
{ "input": [ "x^5+15x^4+85x^3+225x^2+274x+120", "x^2+3x+2", "x^3-81x^2-1882x-1800", "x^2-1" ], "output": [ "(x+1)(x+2)(x+3)(x+4)(x+5)", "(x+1)(x+2)", "(x-100)(x+1)(x+18)", "(x-1)(x+1)" ] }
{ "input": [ "x^1-2", "x^1-1", "x^1-3", "x^1-4", "x^2-4", "x^1-5", "x^1-6", "x^1+6", "x^1+5", "x^1+7", "x^2+4x+3", "x^1+8", "x^1+9", "x^1+2", "x^1+4", "x^1-7", "x^1+3", "x^1-8", "x^1+1", "x^1-1", "x^1-2", "x^1-3", "x^1-4", ...
p02238 Depth First Search
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving ...
{ "input": [], "output": [] }
{ "input": [ "4\n1 1 2\n2 1 4\n3 0\n4 1 3", "6\n1 2 2 3\n2 2 3 4\n3 1 5\n4 1 6\n5 1 6\n6 0" ], "output": [ "1 1 8\n2 2 7\n3 4 5\n4 3 6", "1 1 12\n2 2 11\n3 3 8\n4 9 10\n5 4 7\n6 5 6" ] }
{ "input": [ "6\n1 2 2 3\n2 2 3 4\n3 1 6\n4 1 6\n5 1 6\n6 0", "4\n1 1 1\n2 1 4\n3 0\n4 1 3", "4\n1 1 1\n2 1 4\n3 0\n4 1 2", "6\n1 2 2 3\n2 2 3 4\n3 1 5\n4 1 6\n5 1 6\n6 -1", "4\n1 1 3\n2 1 4\n3 0\n4 1 3", "4\n1 1 3\n2 1 1\n3 0\n4 1 3", "6\n1 2 2 3\n2 2 4 4\n3 1 5\n4 1 6\n5 1 6\n6 -1", ...
p02384 Dice II
Construct a dice from a given sequence of integers in the same way as Dice I. You are given integers on the top face and the front face after the dice was rolled in the same way as Dice I. Write a program to print an integer on the right side face. <image> Constraints * $0 \leq $ the integer assigned to a face $ ...
{ "input": [], "output": [] }
{ "input": [ "1 2 3 4 5 6\n3\n6 5\n1 3\n3 2" ], "output": [ "3\n5\n6" ] }
{ "input": [ "1 2 3 4 5 6\n3\n4 5\n1 3\n3 2", "1 2 3 4 5 6\n3\n4 5\n1 3\n6 2", "1 2 3 4 5 6\n3\n4 5\n2 3\n6 2", "1 2 3 4 5 6\n3\n6 5\n2 3\n6 2", "1 2 3 4 5 6\n3\n6 3\n1 3\n3 2", "1 2 3 4 5 6\n3\n4 2\n1 3\n3 2", "1 2 3 4 5 6\n3\n4 5\n2 3\n4 2", "1 2 3 4 5 6\n3\n6 5\n2 6\n6 2", "1 2 ...
brokphon
Chef is judging a game called "Broken telephone". There are total N players taking part in the game. They are all sitting in a line. In the start of the game, first player is given a secret message written on a sheet of paper. Then they keep sending the message by whispering it to the player sitting immediate right to ...
{ "input": [], "output": [] }
{ "input": [ "3\n7\n1 1 1 3 3 3 2\n5\n1 3 1 1 1\n4\n5 5 5 5" ], "output": [ "4\n3\n0\n" ] }
{ "input": [ "3\n7\n1 1 1 3 3 3 2\n5\n1 3 1 1 2\n4\n5 5 5 5", "3\n7\n1 1 1 3 3 3 3\n5\n1 3 1 1 2\n4\n5 5 5 5", "3\n7\n1 1 1 3 3 3 2\n5\n1 0 1 1 1\n4\n5 5 5 5", "3\n7\n1 1 1 3 3 3 2\n5\n1 3 1 1 2\n4\n9 5 5 5", "3\n7\n1 1 1 3 3 3 3\n5\n1 3 1 1 2\n4\n5 5 9 5", "3\n7\n1 2 1 3 3 3 2\n5\n1 0 1 1 1\n...
commute
The Chef commutes to work every day using the city's underground metro. The schedule for the trains has recently been changed and he wants to know how long it will take to travel from the station nearest to his house and the station nearest to his restaurant. The Chef doesn't want to change the route he took before, ...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n0 4 7\n0 6 5\n2\n0 1 2\n6 2 10\n2\n1 2 3\n0 2 3" ], "output": [ "11\n8\n5\n" ] }
{ "input": [ "3\n2\n0 4 7\n0 6 5\n2\n0 1 2\n6 2 10\n2\n1 2 5\n0 2 3", "3\n2\n0 4 7\n0 6 5\n2\n0 1 2\n6 4 10\n2\n1 2 5\n0 2 3", "3\n2\n0 3 7\n0 6 5\n2\n0 1 2\n8 4 10\n2\n1 1 5\n0 2 3", "3\n2\n0 3 7\n0 6 5\n2\n0 1 3\n8 4 10\n2\n1 1 5\n0 4 3", "3\n2\n0 3 7\n0 6 5\n2\n0 1 3\n8 4 10\n2\n1 1 5\n0 4 2", ...
gcdq
You are given an array A of integers of size N. You will be given Q queries where each query is represented by two integers L, R. You have to find the gcd(Greatest Common Divisor) of the array after excluding the part from range L to R inclusive (1 Based indexing). You are guaranteed that after excluding the part of th...
{ "input": [], "output": [] }
{ "input": [ "1\n3 3\n2 6 9\n1 1\n2 2\n2 3" ], "output": [ "3\n1\n2\n" ] }
{ "input": [ "1\n3 3\n2 6 9\n1 1\n3 2\n2 3", "1\n3 3\n2 6 9\n1 1\n2 2\n2 1", "1\n3 3\n3 6 9\n1 1\n2 2\n4 1", "1\n3 3\n3 2 9\n1 1\n3 2\n4 1", "1\n3 3\n2 6 9\n2 1\n3 2\n2 3", "1\n3 3\n2 6 16\n1 1\n2 2\n2 1", "1\n3 3\n2 4 16\n1 1\n2 2\n2 1", "1\n3 3\n4 4 16\n1 1\n2 2\n2 1", "1\n3 3\n2...
luckystr
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant has K favorite lucky strings A1, A2, ..., AK. He thinks that the lucky string S is good if either |S| ≥ 47 or for some j from 1 to K we have that Aj is a substring of S. The ...
{ "input": [], "output": [] }
{ "input": [ "2 4\n47\n744\n7444\n447\n7774\n77777777777777777777777777777777777777777777774" ], "output": [ "Good\nGood\nBad\nGood\n" ] }
{ "input": [ "2 4\n51\n744\n7444\n447\n7774\n77777777777777777777777777777777777777777777774", "2 2\n51\n744\n7444\n447\n7831\n95142413585696281004906476796906063037090967865", "2 2\n51\n744\n2650\n447\n7831\n95142413585696281004906476796906063037090967865", "2 4\n47\n744\n1534\n447\n7774\n77777777777...
prpotion
Naturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid, B potions of blue liquid, and G potions of green liquid. The red liquid potions have liquid amounts given by r[1], ..., r[R] liters. The green liquid potions have liquid am...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1 1 1\n1\n2\n3\n1 1 1 1\n2\n4\n6\n3 2 2 2\n1 2 3\n2 4\n6 8" ], "output": [ "2\n4\n4\n" ] }
{ "input": [ "3\n1 1 1 1\n1\n2\n3\n1 1 1 1\n3\n4\n6\n3 2 2 2\n1 2 3\n2 4\n6 8", "3\n1 1 1 1\n1\n4\n5\n1 1 1 1\n3\n4\n6\n3 2 2 2\n2 2 3\n2 7\n6 8", "3\n1 1 1 1\n1\n4\n5\n1 1 1 2\n3\n4\n6\n3 2 2 2\n2 2 3\n2 7\n6 8", "3\n2 1 1 1\n1\n4\n5\n1 1 1 2\n3\n4\n6\n3 2 2 2\n2 2 5\n2 7\n6 8", "3\n2 1 1 1\n1\n4...
tic02
Guru S has turned miserly after the rise in petrol prices and wants to save as much petrol. For this he decides to calculate the total distance he has to travel to go to a place from a given distance T between each city. He also wants to see what distances he will travel in the reverse journey. For N distances given b...
{ "input": [], "output": [] }
{ "input": [ "9\n1 2 3 4 5 6 7 8 9" ], "output": [ "9 8 7 6 5 4 3 2 1\n45" ] }
{ "input": [ "9\n1 2 3 4 5 6 7 8 17", "9\n1 2 3 5 5 6 7 8 17", "9\n1 0 3 5 5 6 7 8 17", "9\n1 0 3 5 1 6 7 8 17", "9\n1 0 3 5 1 5 7 8 17", "9\n1 -1 3 5 1 5 7 8 17", "9\n1 -1 3 10 1 5 7 8 17", "9\n2 -1 3 10 1 5 7 8 17", "9\n2 -1 3 10 1 5 11 8 17", "9\n2 -1 3 10 1 5 11 8 21", ...
1170_F. Wheels
Polycarp has n wheels and a car with m slots for wheels. The initial pressure in the i-th wheel is a_i. Polycarp's goal is to take exactly m wheels among the given n wheels and equalize the pressure in them (then he can put these wheels in a car and use it for driving). In one minute he can decrease or increase the pr...
{ "input": [], "output": [] }
{ "input": [ "6 6 7\n6 15 16 20 1 5\n", "6 3 1\n4 8 15 16 23 42\n", "5 4 0\n5 5 5 4 5\n" ], "output": [ "\n39\n", "\n8\n", "\n0\n" ] }
{ "input": [], "output": [] }
1208_E. Let Them Slide
You are given n arrays that can have different sizes. You also have a table with w columns and n rows. The i-th array is placed horizontally in the i-th row. You can slide each array within its row as long as it occupies several consecutive cells and lies completely inside the table. You need to find the maximum sum o...
{ "input": [], "output": [] }
{ "input": [ "3 3\n3 2 4 8\n2 2 5\n2 6 3\n", "2 2\n2 7 8\n1 -8\n" ], "output": [ "10\n15\n16\n", "7\n8\n" ] }
{ "input": [ "3 3\n3 2 4 8\n2 2 5\n2 10 3\n", "3 3\n3 2 4 8\n2 2 5\n2 10 2\n", "2 2\n2 7 2\n1 -8\n", "3 5\n3 2 4 8\n2 2 5\n2 10 3\n", "3 4\n3 2 4 8\n2 2 5\n2 6 3\n", "3 3\n3 2 4 8\n2 2 5\n2 20 3\n", "3 3\n3 4 4 8\n2 2 5\n2 10 2\n", "3 5\n3 0 4 8\n2 2 5\n2 10 3\n", "3 5\n3 0 4 11\n2...
1250_C. Trip to Saint Petersburg
You are planning your trip to Saint Petersburg. After doing some calculations, you estimated that you will have to spend k rubles each day you stay in Saint Petersburg — you have to rent a flat, to eat at some local cafe, et cetera. So, if the day of your arrival is L, and the day of your departure is R, you will have ...
{ "input": [], "output": [] }
{ "input": [ "4 5\n1 1 3\n3 3 11\n5 5 17\n7 7 4\n", "1 3\n1 2 5\n", "4 8\n1 5 16\n2 4 9\n3 3 24\n1 5 13\n" ], "output": [ "\n13 3 5 2\n3 2 \n", "\n0\n", "\n22 1 5 4\n3 2 1 4 \n" ] }
{ "input": [], "output": [] }
1398_B. Substring Removal Game
Alice and Bob play a game. They have a binary string s (a string such that each character in it is either 0 or 1). Alice moves first, then Bob, then Alice again, and so on. During their move, the player can choose any number (not less than one) of consecutive equal characters in s and delete them. For example, if the...
{ "input": [], "output": [] }
{ "input": [ "5\n01111001\n0000\n111111\n101010101\n011011110111\n" ], "output": [ "4\n0\n6\n3\n6\n" ] }
{ "input": [ "5\n01111101\n0000\n111111\n101010101\n011011110111\n", "5\n01111101\n0000\n111111\n101010101\n011001110111\n", "5\n01111101\n0000\n111111\n101010101\n011001111111\n", "5\n11111101\n0000\n111111\n101010101\n011001111111\n", "5\n11111101\n0000\n111111\n101010101\n011001111011\n", "...
1540_C2. Converging Array (Hard Version)
This is the hard version of the problem. The only difference is that in this version 1 ≤ q ≤ 10^5. You can make hacks only if both versions of the problem are solved. There is a process that takes place on arrays a and b of length n and length n-1 respectively. The process is an infinite sequence of operations. Each...
{ "input": [], "output": [] }
{ "input": [ "3\n2 3 4\n2 1\n5\n-1 0 1 -100000 100000\n" ], "output": [ "56\n28\n4\n60\n0\n" ] }
{ "input": [ "3\n2 3 4\n2 1\n5\n-1 1 1 -100000 100000\n", "3\n2 3 4\n2 1\n5\n-1 2 1 -100000 100100\n", "3\n2 3 4\n2 1\n5\n-2 2 1 -100000 100100\n", "3\n1 3 4\n2 1\n5\n-2 2 1 -100000 100100\n", "3\n1 3 4\n2 0\n5\n-2 2 1 -100000 100100\n", "3\n2 3 4\n2 1\n5\n-1 0 1 -9627 100000\n", "3\n4 3 4...
188_H. Stack
In this problem we'll use a stack which supports two types of operations: * Push a given number on the stack. * Pop two numbers from the stack, perform a given operation (addition or multiplication) on them and push the result on the stack. You are given a string which describes the sequence of operations to ...
{ "input": [], "output": [] }
{ "input": [ "12+3*66*+\n", "149\n" ], "output": [ "45\n", "9\n" ] }
{ "input": [], "output": [] }
470_G. Hamming Distance
Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. You are given two strings; calculate the distance between them. Input The input consists of two lines. Each line contains a string of characters 'A'-'Z' between 1 and 100 characters, inclu...
{ "input": [], "output": [] }
{ "input": [ "CODECHEF\nTOPCODER\n", "HAMMING\nDISTANC\n" ], "output": [ "6\n", "6\n" ] }
{ "input": [], "output": [] }
963_C. Cutting Rectangle
A rectangle with sides A and B is cut into rectangles with cuts parallel to its sides. For example, if p horizontal and q vertical cuts were made, (p + 1) ⋅ (q + 1) rectangles were left after the cutting. After the cutting, rectangles were of n different types. Two rectangles are different if at least one side of one r...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2 5\n2 3 5\n", "1\n1 1 9\n", "2\n2 3 20\n2 4 40\n" ], "output": [ "0\n", "3\n", "6\n" ] }
{ "input": [ "2\n1 2 5\n2 3 10\n", "2\n2 2 20\n2 4 40\n", "2\n2 2 20\n2 7 16\n", "1\n1 1 8\n", "2\n2 2 5\n2 -1 10\n", "2\n1 2 5\n2 0 10\n", "2\n2 2 20\n2 7 40\n", "2\n1 2 5\n2 1 10\n", "2\n1 2 5\n2 -1 10\n", "2\n1 1 5\n2 3 10\n", "2\n4 2 20\n2 4 40\n", "2\n2 2 20\n2 10 ...
aprileasy-easy-non-linear-recurrences
You are given the following recurrences, F(n) = a * F(n - 1) * G(n - 2) + b * G(n - 1) * F(n - 2) for n ≥ 2 G(n) = c * G(n - 1) * F(n - 2) + d * (3 ^ F(n - 1) ) for n ≥2 H(n) = e * F(n) + f * G(n) for n ≥ 0 F[0] = F[1] = G[0] = 0 G[1] = 1 Input First line contains the following 6 numbers in order : a, b, c, d, ...
{ "input": [], "output": [] }
{ "input": [ "1 2 3 4 5 6\n2\n2 \n3\n\nSAMPLE" ], "output": [ "30\n54" ] }
{ "input": [], "output": [] }
monks-encounter-with-polynomial
Our monk, while taking a stroll in the park, stumped upon a polynomial ( A X^2 + B X +C ) lying on the ground. The polynomial was dying! Being considerate, our monk tried to talk and revive the polynomial. The polynomial said: I have served my purpose, and shall not live anymore. Please fulfill my dying wish. Find m...
{ "input": [], "output": [] }
{ "input": [ "3\n3 4 5 6\n3 4 5 5\n3 4 5 150\n\nSAMPLE" ], "output": [ "1\n0\n7\n" ] }
{ "input": [ "3\n3 4 5 8\n3 4 5 5\n3 4 5 150\n\nSAMPLE", "3\n3 3 5 8\n1 4 5 5\n4 4 10 150\n\nSAMPLD", "3\n3 3 5 0\n1 4 5 5\n4 4 10 150\n\nSAMPLD", "3\n3 3 5 0\n1 4 5 5\n4 3 10 119\n\nSAMPLD", "3\n3 3 5 0\n1 4 5 5\n4 4 10 44\n\nSAMPLD", "3\n3 3 5 0\n1 8 5 5\n1 4 10 40\n\nSAMPLD", "3\n3 3 5 ...
sum-of-medians-1
Median of K numbers is defined as the (K/2)th smallest number, if K is even; and the ((K+1)/2)th smallest number if K is odd. For example, median of the 4 numbers: 2 1 8 7 is the 2nd smallest number i.e. 2, and the median of the 5 numbers: 2 1 8 7 6 is the 3rd smallest number i.e. 6. In this problem, you'll be g...
{ "input": [], "output": [] }
{ "input": [ "5\n10\n5\n1\n2\n15\n\nSAMPLE" ], "output": [ "27" ] }
{ "input": [ "5\n11\n5\n1\n2\n15\n\nSAMPLE", "5\n11\n5\n1\n4\n15\n\nSAMPLE", "5\n11\n10\n1\n4\n15\n\nSALPLE", "5\n11\n19\n1\n4\n15\n\nSALOLE", "5\n11\n19\n1\n4\n1\n\nSALOLE", "5\n11\n8\n1\n4\n1\n\nSALOLE", "5\n11\n8\n1\n0\n1\n\nSALOLE", "5\n11\n13\n0\n0\n1\n\nSAMOLE", "5\n11\n13\n0...
p02614 AtCoder Beginner Contest 173 - H and V
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation...
{ "input": [], "output": [] }
{ "input": [ "2 3 4\n..#", "6 6 8\n..##..\n.#..#.\n....#\n\n....#\n....#", "2 3 2\n..#", "2 2 3", "2 3 2\n..#\n###" ], "output": [ "1", "208", "5", "0", "5" ] }
{ "input": [ "2 2 4\n..#", "4 3 2\n..#\n###", "4 3 2\n..#\n$##", "2 3 0\n.-#", "3 3 0\n/,#", "6 3 0\n/,#", "6 3 1\n/,#", "6 3 0\n/,$", "6 2 0\n/,$", "1 4 0", "6 0 0\n/,%", "18 0 0\n%,/", "13 0 0\n%-/", "2 3 2\n..#\n$##", "2 3 1\n.-#", "2 5 0\n/,#", "...
p02745 Panasonic Programming Contest 2020 - Three Substrings
Snuke has a string s. From this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows: * Choose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it with `?`s. For example, if s is `mississippi`, we can choose the su...
{ "input": [], "output": [] }
{ "input": [ "a?c\nder\ncod", "atcoder\natcoder\n???????" ], "output": [ "7", "7" ] }
{ "input": [ "`?c\nder\ncod", "atcoder\natcoder\n?????>?", "`?d\nder\ncod", "redocta\natcoder\n?????>?", "eacodtr\naoetdcr\n?????>>", "ebdobur\nppedact\n>>????@", "qcbdpvg\nbfpepbs\n?>A>>@<", "tocojcb\nbs_fpph\n=?>@@@?", "`?d\nddr\ncod", "redocta\nateodcr\n?????>?", "`?d\nd...
p02880 AtCoder Beginner Contest 144 - 81
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. Given an integer N, determine whether N can be represented as the product of two integers between 1 and 9. If it can, print `Yes`; if it cannot, print `No`. Constraints * 1 \leq N \leq 100 * N is an int...
{ "input": [], "output": [] }
{ "input": [ "10", "81", "50" ], "output": [ "Yes", "Yes", "No" ] }
{ "input": [ "2", "84", "83", "1", "107", "92", "0", "100", "64", "-1", "110", "91", "-2", "111", "167", "-3", "101", "235", "-4", "001", "145", "3", "199", "6", "375", "4", "348", "7", "597", "8", ...
p03014 AtCoder Beginner Contest 129 - Lamp
There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares. Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it. The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and...
{ "input": [], "output": [] }
{ "input": [ "4 6\n#..#..\n.....#\n....#.\n#.#...", "4 6\n..#..\n.....#\n....#.\n.#...", "8 8\n..#...#.\n....#...\n......\n..###..#\n...#..#.\n....#.\n...#...\n.#..#" ], "output": [ "8", "8", "13" ] }
{ "input": [ "3 6\n#..#..\n.....#\n....#.\n#.#...", "8 8\n..#...#.\n....#...\n......\n..###..#\n...#..#-\n....#.\n...#...\n.#..#", "4 8\n#..#..\n.....#\n....#.\n#.#...", "2 6\n..#..\n.....#\n....#.\n.#...", "1 8\n..#...#.\n....#...\n......\n..###..#\n...#..#.\n....#.\n...#...\n#..#.", "4 1\n.....
p03155 AISing Programming Contest 2019 - Bulletin Board
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where ...
{ "input": [], "output": [] }
{ "input": [ "5\n4\n2", "3\n2\n3", "100\n1\n1" ], "output": [ "8", "2", "10000" ] }
{ "input": [ "3\n4\n3", "100\n2\n1", "3\n3\n3", "100\n0\n1", "3\n3\n1", "100\n-1\n1", "3\n2\n1", "100\n-2\n1", "3\n0\n1", "100\n-1\n0", "3\n-1\n1", "100\n-1\n-1", "3\n-2\n1", "100\n-2\n-1", "3\n-2\n0", "100\n-2\n0", "100\n-4\n0", "3\n-1\n2", ...
p03298 AtCoder Grand Contest 026 - String Coloring
You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red from left to right is equal to the string obtained by r...
{ "input": [], "output": [] }
{ "input": [ "4\ncabaacba", "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "11\nmippiisssisssiipsspiim", "4\nabcdefgh" ], "output": [ "4", "9075135300", "504", "0" ] }
{ "input": [ "4\ncacaabba", "4\nacbaacab", "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`aaaa", "11\nmippiisstisssiipsspiim", "4\nhgfedcba", "4\nabbaacac", "18\naaaaaaaaaaaaaaaaaaaaaaabaaaaaaa`aaaa", "11\nmippiissuisssiipsspiim", "4\nhgfbdcea", "4\nacbaacac", "18\naaaaaaaaaaaaaaaaaa...
p03456 AtCoder Beginner Contest 086 - 1 21
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. Constraints * 1 ≤ a,b ≤ 100 * a and b are integers. Input Input is given from Standard Input in the following format: a b Output If the concatenation of a and b in this o...
{ "input": [], "output": [] }
{ "input": [ "1 21", "12 10", "100 100" ], "output": [ "Yes", "No", "No" ] }
{ "input": [ "2 21", "000 001", "5 10", "110 100", "2 22", "7 10", "101 100", "4 22", "7 16", "101 101", "8 22", "7 20", "101 111", "14 22", "7 6", "001 101", "9 22", "12 6", "100 101", "9 11", "9 6", "100 111", "11 11", "...
p03617 AtCoder Grand Contest 019 - Ice Tea Store
You've come to your favorite store Infinitesco to buy some ice tea. The store sells ice tea in bottles of different volumes at different costs. Specifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen, a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen. The store has an infinite supply...
{ "input": [], "output": [] }
{ "input": [ "10 100 1000 10000\n1", "20 30 70 90\n3", "10000 1000 100 10\n1", "12345678 87654321 12345678 87654321\n123456789" ], "output": [ "40", "150", "100", "1524157763907942" ] }
{ "input": [ "10 100 1010 10000\n1", "20 30 70 129\n3", "10000 1001 100 10\n1", "12345678 87654321 12345678 87654321\n226515686", "20 30 70 83\n3", "10000 1001 100 10\n0", "12345678 87654321 12873114 87654321\n226515686", "20 30 70 63\n3", "10000 1001 100 10\n-1", "1103255 8765...
p03775 AtCoder Beginner Contest 057 - Digits in Multiplication
You are given an integer N. For two positive integers A and B, we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A, and the number of digits in the decimal notation of B. For example, F(3,11) = 2 since 3 has one digit and 11 has two digits. Find the minimum value of F...
{ "input": [], "output": [] }
{ "input": [ "1000003", "10000", "9876543210" ], "output": [ "7", "3", "6" ] }
{ "input": [ "101914", "17346", "2771679283", "7026", "5110764300", "472", "10211397040", "16034112351", "010", "53937807463", "2375578529", "102392", "3360905534", "1567311305", "6220", "748", "18677078008", "395", "593", "1108", "10...
p03944 AtCoder Beginner Contest 047 - Snuke's Coloring 2 (ABC Edit)
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) po...
{ "input": [], "output": [] }
{ "input": [ "5 4 3\n2 1 1\n3 3 4\n1 4 2", "5 4 2\n2 1 1\n3 3 4", "10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3" ], "output": [ "0", "9", "64" ] }
{ "input": [ "5 4 3\n2 1 1\n3 6 4\n1 4 2", "5 4 2\n2 1 1\n6 3 4", "5 4 2\n2 1 2\n6 3 4", "10 10 5\n1 6 1\n4 1 1\n6 9 4\n9 4 2\n3 1 4", "5 4 1\n2 1 2\n6 3 4", "5 4 3\n2 0 2\n2 6 2\n1 4 2", "10 10 5\n1 14 1\n4 1 1\n6 4 4\n9 0 2\n3 2 4", "10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 0 3", "...
p00036 A Figure on Surface
There is a plane like Figure 1 with 8 vertical and 8 horizontal squares. □ | □ | □ | □ | □ | □ | □ | □ --- | --- | --- | --- | --- | --- | --- | --- □ | □ | □ | □ | □ | □ | □ | □ □ | □ | □ | □ | □ | □ | □ | □ □ | □ | □ | □ | □ | □ | □ | □ □ | □ | □ | □ | □ | □ | □ | □ □ | □ | □ | □ | □ | □ | □ | □ □ | □ | □ | □ | □ | □...
{ "input": [], "output": [] }
{ "input": [ "00000000\n00000000\n01100000\n00110000\n00000000\n00000000\n00000000\n00000000\n\n00011110\n00000000\n00000000\n00000000\n00000000\n00000000\n00000000\n00000000\n\n00000000\n00000000\n00110000\n00110000\n00000000\n00000000\n00000000\n00000000" ], "output": [ "E\nC\nA" ] }
{ "input": [], "output": [] }
p00168 Kannondou
There is Kannon-do in the mountain behind Ichiro's house. There are 30 steps from the foot to this Kannon-do, and Ichiro goes to Kannon-do almost every day. Ichiro can go up the stairs up to 3 steps with one foot. While playing, I noticed that there are so many types of stair climbing (the number of steps to skip). So...
{ "input": [], "output": [] }
{ "input": [ "1\n10\n20\n25\n0" ], "output": [ "1\n1\n34\n701" ] }
{ "input": [ "1\n10\n14\n25\n0", "1\n10\n14\n23\n0", "1\n10\n14\n6\n0", "1\n1\n20\n25\n0", "1\n10\n14\n24\n0", "1\n10\n0\n25\n0", "1\n19\n14\n5\n0", "1\n18\n0\n25\n0", "1\n18\n1\n25\n0", "1\n0\n14\n6\n0", "1\n23\n14\n10\n0", "1\n18\n20\n25\n0", "1\n23\n14\n0\n0", ...
p00324 Bilateral Trade
Aiz, which is located in cyberspace, trades information with Wakamatsu. The two countries are developing their economies by exchanging useful data with each other. The two countries, whose national policy is philanthropy and equality, and above all, the old word of the Aizu region, "what must be done", conducts regular...
{ "input": [], "output": [] }
{ "input": [ "4\n1\n1\n-1\n-1", "5\n18\n102\n-155\n53\n32" ], "output": [ "4", "3" ] }
{ "input": [ "4\n0\n1\n-1\n-1", "4\n0\n2\n-1\n-1", "5\n18\n102\n-181\n53\n9", "4\n0\n0\n-1\n-1", "4\n0\n1\n-2\n-1", "5\n1\n19\n-30\n8\n2", "5\n18\n102\n-155\n53\n9", "5\n18\n146\n-181\n53\n9", "5\n33\n146\n-181\n53\n9", "4\n1\n1\n-2\n-1", "5\n55\n146\n-181\n53\n9", "4\n...
p00496 Night Market
Taro decided to go to the summer festival held at JOI Shrine. N night shops are open along the way to JOI Shrine. Each night shop is numbered from 1 to N in order, and the fun of playing and the time it takes to play are determined by integers. The fun of playing at night shop i is Ai, and the time it takes to play at...
{ "input": [], "output": [] }
{ "input": [ "5 20 14\n8 9\n2 4\n7 13\n6 3\n5 8", "None" ], "output": [ "16", "None" ] }
{ "input": [ "5 20 14\n8 9\n2 4\n7 13\n1 3\n5 8", "eonN", "5 20 14\n7 9\n2 4\n7 13\n1 3\n0 8", "5 20 14\n7 18\n2 4\n7 13\n1 3\n0 8", "5 5 14\n7 18\n2 4\n7 13\n1 3\n0 12", "5 5 26\n7 13\n2 6\n7 17\n1 3\n0 12", "5 2 38\n7 13\n3 0\n7 27\n1 3\n0 15", "8 4 38\n7 13\n3 0\n7 27\n1 3\n0 15", ...
p00681 Wall Breaker KND
Problem KND is a student programmer at the University of Aizu. He is both a programmer and a fighter. He is known to be a sweet tooth, but he especially likes fresh cream. Eating fresh cream will allow you to break the concrete wall several times. Interested in its power, his neighbor decided to experiment with a new ...
{ "input": [], "output": [] }
{ "input": [ "3 3\n0 0\n0 0 0\n0 0\n0 0 1\n0 1\n0 0\n0 1\n1 1\n2 2\n1\n5 5\n0 1 0 0\n1 0 0 1 0\n1 0 1 0\n0 1 0 0 1\n0 1 1 0\n0 1 0 1 0\n1 1 1 0\n0 0 0 0 0\n0 0 1 1\n0 0\n1 0\n4 4\n0 1\n2\n0 0", "3 3\n 0 0\n0 0 0\n 0 0\n0 0 1\n 0 1\n0 0\n0 1\n1 1\n2 2\n1\n5 5\n 0 1 0 0\n1 0 0 1 0\n 1 0 1 0\n0 1 0 0 1\n 0 1 1 0...
{ "input": [], "output": [] }
p00823 Molecular Formula
Your mission in this problem is to write a computer program that manipulates molecular for- mulae in virtual chemistry. As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not have chemical reality. The following are the definitions of atomic symbols and ...
{ "input": [], "output": [] }
{ "input": [ "H 1\nHe 4\nC 12\nO 16\nF 19\nNe 20\nCu 64\nCc 333\nEND_OF_FIRST_PART\nH2C\n(MgF)2As\nCu(OH)2\nH((CO)2F)99\n0" ], "output": [ "14\nUNKNOWN\n98\n7426" ] }
{ "input": [ "H 1\nHe 4\nC 12\nO 16\nF 19\nNe 24\nCu 64\nCc 333\nEND_OF_FIRST_PART\nH2C\n(MgF)2As\nCu(OH)2\nH((CO)2F)99\n0", "H 1\nHe 4\nC 12\nO 16\nF 22\nNe 24\nCu 64\nCc 333\nEND_OF_FIRST_PART\nH2C\n(MgF)2As\nCu(OH)2\nH((CO)2F)99\n0", "H 1\nHe 4\nC 12\nO 16\nF 19\nNe 20\nCu 64\nCc 333\nEND_OF_FIRST_PART...
p00954 Skinny Polygon
Example Input 2 5 6 1000000000 2 Output 4 5 6 0 6 0 0 5 0 3 1000000000 0 0 2 999999999 0
{ "input": [], "output": [] }
{ "input": [ "2\n5 6\n1000000000 2" ], "output": [ "4\n5 6\n0 6\n0 0\n5 0\n3\n1000000000 0\n0 2\n999999999 0" ] }
{ "input": [ "2\n5 6\n1001000000 2", "2\n5 6\n1001100000 2", "2\n5 6\n1001000000 3", "2\n5 1\n1001100000 2", "2\n5 6\n1011000000 3", "2\n5 1\n1001100000 4", "2\n5 1\n0001100000 4", "2\n5 1\n0001100000 1", "2\n5 1\n0001100001 1", "2\n10 6\n1001100000 2", "2\n5 6\n1001001000 ...
p01087 ICPC Calculator
ICPC Calculator In mathematics, we usually specify the order of operations by using parentheses. For example, 7 × (3 + 2) always means multiplying 7 by the result of 3 + 2 and never means adding 2 to the result of 7 × 3. However, there are people who do not like parentheses. International Counter of Parentheses Counci...
{ "input": [], "output": [] }
{ "input": [ "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0\n.+\n..*\n...1\n...*\n....1\n....2\n..0\n10\n+\n.+\n..6\n..2\n.+\n..1\n..*\n...7\n...6\n.3\n0" ], "output": [ "9\n6\n2\n54" ] }
{ "input": [ "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0\n.+\n..*\n...1\n...+\n....1\n....2\n..0\n10\n+\n.+\n..6\n..2\n.+\n..1\n..*\n...7\n...6\n.3\n0", "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0\n.*\n..*\n...1\n...+\n....1\n....2\n..0\n10\n+\n.+\n..6\n..2\n.+\n..1\n..*\n...7\n...6\n.3\n0", "1\n9\n4\n+\n.1\n.2\n.3\n9\n+\n.0...
p01223 Saizo
A TV program called "Saizo" is popular in a certain country. In this program, participants challenge field athletics and get a prize if they successfully capture it. Field athletics are made by arranging blocks of different heights in a row, and how to climb up and down the steps is important for capture (Fig. 1). You...
{ "input": [], "output": [] }
{ "input": [ "5\n5\n10 70 30 50 90\n2\n20 100\n2\n100 30\n3\n50 50 50\n7\n123 45 678 901 234 567 890" ], "output": [ "60 40\n80 0\n0 70\n0 0\n633 667" ] }
{ "input": [ "5\n5\n10 70 30 50 177\n2\n20 100\n2\n100 30\n3\n50 50 50\n7\n123 45 678 901 234 567 890", "5\n5\n10 70 5 50 177\n2\n20 100\n2\n100 30\n3\n50 50 50\n7\n123 45 678 901 234 567 890", "5\n5\n10 70 5 50 206\n2\n20 100\n2\n100 30\n3\n50 50 50\n7\n123 45 678 901 234 567 890", "5\n5\n10 70 30 50...
p01357 Lapin Noir
This is a city where the ground is a square of regular hexagons. Each square is represented by two integers as shown in the figure below. <image> The cat is about to go to the square (0, 0). The mischievous black rabbit knew this and decided to get in the way of the cat. The black rabbit can jump to the square with ...
{ "input": [], "output": [] }
{ "input": [ "2\n1 -1 3 -1 3 1 1 3 -1 3 -1 1\n3 0 4 0 4 1 3 2 2 2 2 1\n3\n1 1\n-1 -1\n2 4" ], "output": [ "YES\nNO\nYES" ] }
{ "input": [ "2\n1 -1 3 -1 3 1 1 3 -1 3 -1 1\n3 0 4 0 4 1 3 2 2 2 2 1\n3\n1 1\n-1 -2\n2 4", "2\n1 -1 3 -1 3 1 1 3 -2 2 -1 1\n3 0 4 0 4 1 3 2 2 2 2 1\n3\n0 1\n-1 -2\n2 5", "2\n2 -1 3 -1 3 1 1 3 -2 3 -1 1\n3 0 4 0 4 1 3 2 2 2 2 1\n3\n1 1\n-1 0\n2 4", "2\n1 -1 3 -1 3 1 1 3 -2 2 -1 1\n3 0 1 0 4 1 3 0 2 2 ...
p01539 A Holiday of Miss Brute Force
The full exploration sister is a very talented woman. Your sister can easily count the number of routes in a grid pattern if it is in the thousands. You and your exploration sister are now in a room lined with hexagonal tiles. The older sister seems to be very excited about the hexagon she sees for the first time. The ...
{ "input": [], "output": [] }
{ "input": [ "0 0 0 2\n1\n0 1\n2 2", "0 0 0 2\n6\n0 1\n1 0\n1 -1\n0 -1\n-1 -1\n-1 0\n2 2", "0 0 0 2\n0\n2 2" ], "output": [ "1", "-1", "0" ] }
{ "input": [ "0 0 1 2\n1\n0 1\n2 2", "0 -1 0 2\n0\n2 2", "1 0 0 2\n0\n2 2", "0 0 0 2\n6\n0 1\n1 -1\n1 0\n0 -1\n-1 -1\n-1 0\n2 2", "1 2 0 0\n1\n-1 0\n4 2", "-11 -1 1 0\n1\n-1 -2\n21 33", "-11 -1 1 -1\n1\n-1 -2\n21 33", "-6 -1 1 -1\n1\n-1 -2\n21 33", "-17 -1 1 -1\n1\n-1 -1\n21 33", ...
p01695 JAG-channel
JAG-channel Nathan O. Davis operates an electronic bulletin board called JAG-channel. He is currently working on adding a new feature called Thread View. Like many other electronic bulletin boards, JAG-channel is thread-based. Here, a thread refers to a group of conversations consisting of a series of posts. There ar...
{ "input": [], "output": [] }
{ "input": [ "6\nhoge\n.fuga\n..foobar\n..jagjag\n...zigzag\n.piyo\n8\njagjag\n.hogehoge\n..fugafuga\n...ponyoponyo\n....evaeva\n....pokemon\n...nowawa\n.buhihi\n8\nhello\n.goodmorning\n..howareyou\n.goodafternoon\n..letshavealunch\n.goodevening\n.goodnight\n..gotobed\n3\ncaution\n.themessagelengthislessthanorequ...
{ "input": [ "6\nhoge\n.fuga\n..foobar\n..jagjag\n...zigzag\n.piyo\n8\njagjag\n.hogehoge\n..fugafuga\n...ponyoponyo\n....evaeva\n....pokemon\n...nowawa\n.buhihi\n8\nhello\n.goodmorning\n..howareyou\n.goodafternoon\n..letshavealunch\n.goodevening\n.goodnight\n..gotobed\n3\ncaution\n.themessagelengthislessthanorequ...
p01839 A-un Breathing
A-Aun's breathing Problem Statement Maeda-san and Goto-san, who will both turn 70 years old in 2060, are long-time friends and friends who fought together at the ACM-ICPC in college. The two are still excited about competitive programming, drinking tea together. When the two of us drank tea together, Mr. Maeda said...
{ "input": [], "output": [] }
{ "input": [ "4\nA\nUn\nA\nUn" ], "output": [ "YES" ] }
{ "input": [ "4\nA\nUn\nB\nUn", "4\n@\nUn\nB\nUn", "4\n@\nUn\nB\nnU", "4\n@\nUn\nB\noU", "4\n@\nUn\nA\noU", "4\n@\nUn\nA\nUo", "4\n@\nTn\nA\nUo", "4\n@\nTn\nA\nVo", "4\n@\nTo\nA\nVo", "4\n@\nUo\nA\nVo", "4\n@\noU\nA\nVo", "4\n@\noU\nA\nWo", "4\n?\nUo\nA\nVo", "4...
p01975 Mapping
problem AOR Ika made a set $ S = \\ {a_1, ..., a_N \\} $ and a map $ f: S → S $. $ f (a_i) = b_i $. For any element $ x $ in the set $ S $, all maps $ g, h: S → S $ satisfying $ g (f (x)) = h (f (x)) $ are $ g (x). ) = Determine if h (x) $ is satisfied, and if not, configure one counterexample. Example Input 5 ...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2 3 4 5\n3 4 2 5 1" ], "output": [ "Yes" ] }
{ "input": [ "5\n2 1 3 4 5\n3 4 2 5 1", "5\n1 2 3 4 5\n2 4 3 5 1", "5\n1 3 2 4 5\n3 4 2 5 1", "5\n2 1 3 4 5\n2 4 3 5 1", "5\n1 4 3 2 5\n3 4 2 5 1", "5\n2 1 3 4 5\n3 4 2 5 1", "5\n1 2 3 4 5\n2 4 3 5 1", "5\n2 1 3 4 5\n3 4 1 5 2", "5\n1 4 3 2 5\n3 4 1 5 2", "5\n1 2 4 3 5\n3 4 2 5...
p02121 Chinol Choco
Problem Chocolate company Chinor Choco has decided to build n new stores. For each store, ask each store manager to prepare two candidates for the place you want to build, and build it in either place. Chinor Choco sells m types of chocolate, each manufactured at a different factory. All types of chocolate are sold a...
{ "input": [], "output": [] }
{ "input": [ "2 2\n0 0 6 0\n7 0 3 0\n4 0\n5 0", "2 1\n0 0 5 5\n3 3 6 6\n2 2" ], "output": [ "3.0000000000", "4.2426406871" ] }
{ "input": [ "0 2\n0 0 6 0\n7 0 3 0\n4 0\n5 0", "2 1\n0 0 9 5\n3 3 6 6\n2 2", "2 1\n0 0 9 5\n5 1 6 6\n2 2", "2 2\n0 0 11 0\n7 0 3 0\n4 0\n5 0", "2 1\n0 0 9 5\n5 1 6 6\n3 2", "2 1\n0 0 9 2\n3 4 6 6\n2 2", "2 1\n-1 0 9 0\n5 1 4 6\n2 2", "2 2\n0 0 6 0\n5 1 6 6\n2 0", "2 2\n0 0 11 0\n7...
p02261 Stable Sort
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl...
{ "input": [], "output": [] }
{ "input": [ "2\nS1 H1", "5\nH4 C9 S4 D2 C3" ], "output": [ "S1 H1\nStable\nS1 H1\nStable", "D2 C3 H4 S4 C9\nStable\nD2 C3 S4 H4 C9\nNot stable" ] }
{ "input": [ "5\nH4 B9 S4 D2 C3", "5\nH4 C9 S4 D2 C2", "5\nH4 B9 S4 E2 C3", "5\nI4 C9 S4 D2 C2", "5\nH3 B9 S4 E2 C3", "5\nH3 B9 S4 E2 B3", "5\nH3 B9 S4 E3 B3", "5\nH3 A9 S4 E3 B3", "5\nH4 C9 S4 C2 C3", "5\nH4 B9 T4 D2 C3", "5\nI4 C9 S5 D2 C2", "5\nH3 B9 S4 E3 B2", "...
p02409 Official House
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1 3 8\n3 2 2 7\n4 3 8 1" ], "output": [ "0 0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n#####...
{ "input": [ "3\n1 1 3 16\n3 2 2 7\n4 3 8 1", "3\n1 1 3 8\n3 2 4 7\n4 3 8 1", "3\n1 1 3 12\n3 2 4 7\n4 3 8 1", "3\n1 1 6 12\n3 2 4 7\n4 3 8 1", "3\n1 1 10 12\n3 2 4 7\n4 3 8 1", "3\n1 1 10 12\n3 2 6 7\n4 3 8 1", "3\n1 1 10 12\n3 3 6 7\n4 3 8 1", "3\n0 1 10 12\n3 3 6 7\n4 3 8 1", "3...
candle
The chef is preparing a birthday cake for one of his guests, and his decided to write the age of the guest in candles on the cake. There are 10 types of candles, one for each of the digits '0' through '9'. The chef has forgotten the age of the guest, however, so doesn't know whether he has enough candles of the right t...
{ "input": [], "output": [] }
{ "input": [ "3\n2 1 1 4 0 6 3 2 2 2\n0 1 1 1 1 1 1 1 1 1\n2 2 1 2 1 1 3 1 1 1" ], "output": [ "4\n10\n22\n" ] }
{ "input": [ "3\n2 1 1 4 0 6 3 2 2 2\n0 1 1 1 2 1 1 1 1 1\n2 2 1 2 1 1 3 1 1 1", "3\n2 1 1 4 0 6 3 2 2 2\n0 1 1 1 2 1 1 1 1 1\n2 1 1 2 1 1 3 1 1 1", "3\n2 1 1 4 0 6 3 2 2 2\n0 1 1 1 2 1 1 1 1 1\n2 1 0 2 1 1 3 1 1 1", "3\n2 1 1 4 1 6 3 2 2 2\n0 1 1 1 2 1 1 1 1 1\n2 1 0 2 1 1 3 1 1 1", "3\n2 0 1 4 0...
cr07
POINTS - 25 Sahil is very fond of drinking juice. Every morning he drinks one full bottle of Juice. In every 'm' days, his mother buys one more bottle of juice ( i.e. on day m, 2m, 3m). She buys it in the evening. If Sahil initially has 'n' bottles of juice calculate the number of consecutive days that pass before he r...
{ "input": [], "output": [] }
{ "input": [ "9 3", "2 2" ], "output": [ "13", "3" ] }
{ "input": [], "output": [] }