task stringlengths 0 154k | __index_level_0__ int64 0 39.2k |
|---|---|
A subway scheme, classic for all Berland cities is represented by a set of n stations connected by n passages, each of which connects exactly two stations and does not pass through any others. Besides, in the classic scheme one can get from any station to any other one along the passages. The passages can be used to mo... | 23,800 |
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these collectors. Right now she wants to get one of k-special tables. In case you for... | 23,801 |
You're given a tree consisting of n nodes. Every node u has a weight a_u. You want to choose an integer k (1 β€ k β€ n) and then choose k connected components of nodes that don't overlap (i.e every node is in at most 1 component). Let the set of nodes you chose be s. You want to maximize:
$$$\frac{β_{u β s} a_u}{k}$$$
... | 23,802 |
When Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A good way to determine the equilibrium intensity would be choosing a sufficiently large number of consecutive data points that seems as constant as possible and taking their aver... | 23,803 |
Taro went to a toy store to buy a game of life made by Aizu Hobby. Life games are played using a board with squares and roulette. As shown in the figure, the board has one start point and one goal point, which are connected by a single grid. First, the pieces are placed in the square at the starting point, and the piec... | 23,804 |
Zombies seem to have become much more intelligent lately β a few have somehow wandered into the base through the automatic gate. Heidi has had to beef up security, and a new gate has been installed. Unfortunately, now the questions being asked are more complicated, and even humans have trouble answering them. Can you s... | 23,805 |
Multiplication of Big Integers
Given two integers $A$ and $B$, compute the product, $A \times B$.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the product in a line.
Constraints
* $-1 \times 10^{1000} \leq A, B \leq 10^{1000}$
Sample Input 1
5 8
Sample Ou... | 23,806 |
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 \... | 23,807 |
Problem
If you bring an empty bottle of $ a $ milk, you can exchange it for a new bottle of $ b $ milk.
How many bottles of milk can Mr. Kawabayashi, who initially has a bottle of $ x $ milk, drink? Output the remainder after dividing by $ 1000000007 $.
Constraints
The input satisfies the following conditions.
* $ ... | 23,808 |
You are given 4n sticks, the length of the i-th stick is a_i.
You have to create n rectangles, each rectangle will consist of exactly 4 sticks from the given set. The rectangle consists of four sides, opposite sides should have equal length and all angles in it should be right. Note that each stick can be used in only... | 23,809 |
A prime number is one which is divisible by exactly two numbers 1 and itself.
Given a number, find out if the number obtained by summing all digits of that number is a prime.
Input Format:
The input begins with number of test-cases t in a single line. In each of next tlines there is a number n.
Output Format
In each ... | 23,810 |
On the way to school, Karen became fixated on the puzzle game on her phone!
<image>
The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0.
One move consists of choosing one row or column, and adding 1 to all of the cells in that row or col... | 23,811 |
You are given an array a consisting of n integers.
Your task is to say the number of such positive integers x such that x divides each number from the array. In other words, you have to find the number of common divisors of all elements in the array.
For example, if the array a will be [2, 4, 6, 2, 10], then 1 and 2 ... | 23,812 |
The great Shaass is the new king of the Drakht empire. The empire has n cities which are connected by n - 1 bidirectional roads. Each road has an specific length and connects a pair of cities. There's a unique simple path connecting each pair of cities.
His majesty the great Shaass has decided to tear down one of the ... | 23,813 |
Each employee of the "Blake Techologies" company uses a special messaging app "Blake Messenger". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already announced that the new feature ... | 23,814 |
BerOilGasDiamondBank has branches in n cities, at that n is an even number. The bank management wants to publish a calendar with the names of all those cities written in two columns: the calendar should consist of exactly n / 2 lines of strictly equal length, each of which contains exactly two names and exactly one sep... | 23,815 |
Note that the difference between easy and hard versions is that in hard version unavailable cells can become available again and in easy version can't. You can make hacks only if all versions are solved.
Ildar and Ivan are tired of chess, but they really like the chessboard, so they invented a new game. The field is a... | 23,816 |
You're given a matrix A of size n Γ n.
Let's call the matrix with nonnegative elements magic if it is symmetric (so aij = aji), aii = 0 and aij β€ max(aik, ajk) for all triples i, j, k. Note that i, j, k do not need to be distinct.
Determine if the matrix is magic.
As the input/output can reach very huge size it is r... | 23,817 |
For each positive integer n consider the integer Ο(n) which is obtained from n by replacing every digit a in the decimal notation of n with the digit (9 - a). We say that Ο(n) is the reflection of n. For example, reflection of 192 equals 807. Note that leading zeros (if any) should be omitted. So reflection of 9 equals... | 23,818 |
Kuldeep's girlfriend Christie recently got her PhD in Maths. So to celebrate, they both decided to play games with mathematical sequences for their date nights.
The game they are playing today is "Jackpot Palindrome", the objective of the game is to find out length of the largest palindrome which only contains the dig... | 23,819 |
Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.
During the last lesson the teacher has provided two strings s and t to Vitaly. The strings have the same length, they consist of lowercase English l... | 23,820 |
Ciel, an idol whose appearance and behavior are similar to a fox, is participating in a rehearsal for the live concert which takes place in a few days. To become a top idol, a large amount of effort is required!
The live stage can be expressed as a two-dimensional surface. The live stage has N spotlights to illuminate... | 23,821 |
Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should match trees to some sequences and then compare these sequences instead of tree... | 23,822 |
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where it is.
Bob guesses a sequence of line cell numbers x_1, x_2, β¦, x_k in order.... | 23,823 |
Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.
CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders whether he can buy exactly th... | 23,824 |
Polycarpus just has been out of luck lately! As soon as he found a job in the "Binary Cat" cafe, the club got burgled. All ice-cream was stolen.
On the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character "+" in his notes. Similarly, ... | 23,825 |
Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother.
As Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the ma... | 23,826 |
Problem statement
There is a rooted tree of size N. Each vertex is numbered from 0 to N-1, with a root of 0. For the vertices at both ends of any side, the assigned integer is smaller closer to the root. Initially, the weights of all edges are 0.
Process Q queries on this tree in sequence. There are two types of quer... | 23,827 |
A grid of r Γ c is given.
Numbers from 1 to 8 are written on some squares on the grid.
<image>
It is necessary to connect the squares with numbers and the squares with other numbers with a line.
For the squares with numbers written on them, it is necessary to connect lines with other squares as many as the number wr... | 23,828 |
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor of the last written number. Then he should run this number of circl... | 23,829 |
Phoebe and Joey are playing cards. They have N decks of cards.
Each deck of cards contain 52 cards:
26 Red cards (2 Aces + 6 Faces + 18 Ranks)
26 Black cards (2 Aces + 6 Faces + 18 Ranks)
They have decided to play with M cards out of these N*52 cards. Phoebe asks Joey to select M cards with following restrictions:... | 23,830 |
You are given two trees (connected undirected acyclic graphs) S and T.
Count the number of subtrees (connected subgraphs) of S that are isomorphic to tree T. Since this number can get quite large, output it modulo 109 + 7.
Two subtrees of tree S are considered different, if there exists a vertex in S that belongs to ... | 23,831 |
After a long vacation due to Swine Flu, 1st Year SVNIT students have returned back to Gajjar Bhavan. Students in Gajjar Bhavan generally handshake to greet each other but due to Swine Flu it's still risky to handshake so students greet each other by just words instead of handshakes.
Bagha is an interesting(really?) Ma... | 23,832 |
Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.
Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.
Limak wants to prove how responsible a bear he is. He is going to regularly save candies for ... | 23,833 |
Aparna recently created a random number generator and now she wants Harsh to check if it works fine.
She gives Harsh an array containing N numbers generated from this random number generator of hers, and two integers K and P. If the given array contains more than or equal to K numbers in the range X-P to X+P (both inc... | 23,834 |
You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend and cnt2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the fir... | 23,835 |
You are given n sequences. Each sequence consists of positive integers, not exceeding m. All integers in one sequence are distinct, but the same integer may appear in multiple sequences. The length of the i-th sequence is ki.
Each second integers in each of the sequences are shifted by one to the left, i.e. integers a... | 23,836 |
Vasya likes to travel by train, but doesn't like when the car he travels in is located in the tail of the train.
Vasya gets on the train at the station. The train consists of n cars indexed from 1 to n counting from the locomotive (head of the train). Three types of events occur while the train is moving:
1. Some n... | 23,837 |
You have an unbiased dice which you want to keep rolling until you get N consecutive even numbers. You've rolled the dice M times and surprisingly, all rolls resulted in even numbers. What is the expected number of additional rolls needed until you get N consecutive even numbers?
Input:
The first line contains the n... | 23,838 |
You are given a string of characters, or numbers. Find the minimum number of characters to be inserted into the string in order to obtain a palindrome.
A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same forward or reversed.
For example, the string abcbd can be transf... | 23,839 |
Our code monk, high on excitement after solving the rest of the problems , goes on a trek in the mountains .
On his way, he encounters Janemba, the evil magician! Janemba takes our monk to a poison field and plays a game with him described as follows:
The poison field is described as NxN matrix,divided into N * N c... | 23,840 |
A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as x points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.
He knows that the con... | 23,841 |
It is known that passages in Singer house are complex and intertwined. Let's define a Singer k-house as a graph built by the following process: take complete binary tree of height k and add edges from each vertex to all its successors, if they are not yet present.
<image> Singer 4-house
Count the number of non-empty ... | 23,842 |
Employees of JebTrains are on their way to celebrate the 256-th day of the year! There are n employees and k teams in JebTrains. Each employee is a member of some (exactly one) team. All teams are numbered from 1 to k. You are given an array of numbers t_1, t_2, ..., t_n where t_i is the i-th employee's team number.
J... | 23,843 |
In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval I2 from our set if there is a sequence of successive moves starting from I1 so ... | 23,844 |
A sequence of non-negative integers a_1, a_2, ..., a_n is called growing if for all i from 1 to n - 1 all ones (of binary representation) in a_i are in the places of ones (of binary representation) in a_{i + 1} (in other words, a_i \:\&\: a_{i + 1} = a_i, where \& denotes [bitwise AND](http://tiny.cc/xpy9uz)). If n = 1... | 23,845 |
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | 23,846 |
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t... | 23,847 |
At Akabe High School, a programmer training school, there is a unique study session run by the students themselves. It is important for programmers to constantly adopt new technologies, so the aim of this activity is to develop the habit of self-study through this study session.
There are a total of N students, each w... | 23,848 |
Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then... | 23,849 |
After years of hard work scientists invented an absolutely new e-reader display. The new display has a larger resolution, consumes less energy and its production is cheaper. And besides, one can bend it. The only inconvenience is highly unusual management. For that very reason the developers decided to leave the e-read... | 23,850 |
Balph is learning to play a game called Buma. In this game, he is given a row of colored balls. He has to choose the color of one new ball and the place to insert it (between two balls, or to the left of all the balls, or to the right of all the balls).
When the ball is inserted the following happens repeatedly: if so... | 23,851 |
It is Bubble Cup finals season and farmer Johnny Bubbles must harvest his bubbles. The bubbles are in a rectangular bubblefield formed of N x M square parcels divided into N rows and M columns. The parcel in i^{th} row and j^{th} column yields A_{i,j} bubbles.
Johnny Bubbles has available a very special self-driving b... | 23,852 |
ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.
Initially, tree i has color ci. ZS the Coder and Chris the Baboon recognizes only m dif... | 23,853 |
After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size n. Let's call them a and b.
Note that a permutation of n elements is a sequence of numbers a_1, a_2, β¦, a_n, in ... | 23,854 |
We have an old building with n + 2 columns in a row. These columns support the ceiling. These columns are located in points with coordinates 0 = x0 < x1 < ... < xn < xn + 1. The leftmost and the rightmost columns are special, we will call them bearing, the other columns are ordinary.
For each column we know its durab... | 23,855 |
Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.
Iroha is looking for X,Y,Z-Haiku (defined below) in integer sequences.
Consider all integer sequences of length N whose elements are between 1 and 10, inclusive. Out of those 10^N sequences, how many ... | 23,856 |
Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1, x2, ..., xk (k > 1) is such maximum element xj, that the following inequality holds: <image>.
The lucky number of the sequence of distinct positive integers x1, x2, ..., xk (k > 1) is t... | 23,857 |
Gerda is travelling to the palace of the Snow Queen.
The road network consists of n intersections and m bidirectional roads. Roads are numbered from 1 to m. Snow Queen put a powerful spell on the roads to change the weather conditions there. Now, if Gerda steps on the road i at the moment of time less or equal to i, s... | 23,858 |
HQ9+ is a joke programming language which has only four one-character instructions:
* "H" prints "Hello, World!",
* "Q" prints the whole source code of the program itself (at each call),
* "9" prints the lyrics of "99 Bottles of Beer" song,
* "+" increments the value stored in the internal accumulator.
Ins... | 23,859 |
There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.
The initial term is A, and the common difference is B. That is, s_i = A + B \times i holds.
Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 woul... | 23,860 |
Statement
Given N,A,B,C, find how many solutions exist to the equation : a + b + c β€ N, such that 0 β€ a β€ A, 0 β€ b β€ B, 0 β€ c β€ C.
Input
The first line contains the number of test cases T. Each test case contains 4 integers, N,A,B,C. 0 β€ N,A,B,C β€ 2500
Output
Output T lines, one for each test case.
Sample I... | 23,861 |
Oleg the bank client lives in Bankopolia. There are n cities in Bankopolia and some pair of cities are connected directly by bi-directional roads. The cities are numbered from 1 to n. There are a total of m roads in Bankopolia, the i-th road connects cities ui and vi. It is guaranteed that from each city it is possible... | 23,862 |
Traveling around the universe Benny saw some strange numbers. These numbers are called Universal numbers.
Benny asks you to help her to calculate the number of Universal numbers on some segments.
First of all, you are given 15 numbers called remsi.
The number is Universal if and only if it satisfies the following c... | 23,863 |
B: Cram School Schedule / Cram School Timetable
story
You are the owner of a cram school. Your cram school is a private lesson system with one student and one teacher. The teachers at this cram school are very good and can teach all classes regardless of the subject. Also, because teachers and students are very tough... | 23,864 |
You are given a tree with N vertices numbered 1, 2, ..., N. The i-th edge connects Vertex a_i and Vertex b_i. You are also given a string S of length N consisting of `0` and `1`. The i-th character of S represents the number of pieces placed on Vertex i.
Snuke will perform the following operation some number of times:... | 23,865 |
You are given a permutation p_1, p_2, ..., p_n. Recall that sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Find three indices i, j and k such that:
* 1 β€ i < j < k β€ n;
* p_i < p_j and p_j > p_k.
Or say that there are no such indices.
Input
The first lin... | 23,866 |
Think of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of H restaurants also located at some street... | 23,867 |
This problem is split into two tasks. In this task, you are required to find the maximum possible answer. In the task Village (Minimum) you are required to find the minimum possible answer. Each task is worth 50 points.
There are N houses in a certain village. A single villager lives in each of the houses. The houses ... | 23,868 |
Taro loves a game called Vongress. Vongress is a camp game played on a board that is a convex polygon consisting of n vertices.
In this game, m players place one piece each inside the board. The position of the piece is represented by a set of x-coordinate and y-coordinate, and the size of the piece is not considered.... | 23,869 |
A string is said to be "SUPER STRING" if the number of times the character appeared in the string is equal to its ASCII value. Given the conditions that the ASCII value of βaβ is 26 and z is β1β.
Input
First line takes number of test cases βNβ.
Following βNβ lines take string as input.
Output
βYesβ if the string i... | 23,870 |
In the Bus of Characters there are n rows of seat, each having 2 seats. The width of both seats in the i-th row is w_i centimeters. All integers w_i are distinct.
Initially the bus is empty. On each of 2n stops one passenger enters the bus. There are two types of passengers:
* an introvert always chooses a row whe... | 23,871 |
Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Petya got fed up with correcting his mistakes himself, thatβs why he d... | 23,872 |
Priority queue is a container of elements which the element with the highest priority should be extracted first.
For $n$ priority queues $Q_i$ ($i = 0, 1, ..., n-1$) of integers, perform a sequence of the following operations.
* insert($t$, $x$): Insert $x$ to $Q_t$.
* getMax($t$): Report the maximum value in $Q_t$. ... | 23,873 |
This problem only differs from the next problem in constraints.
This is an interactive problem.
Alice and Bob are playing a game on the chessboard of size n Γ m where n and m are even. The rows are numbered from 1 to n and the columns are numbered from 1 to m. There are two knights on the chessboard. A white one init... | 23,874 |
Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from ai to bi. Of course, Famil Door wants to have as many friends celebrating together with him as possible.
Far cars are as weird as Far Far A... | 23,875 |
You had an array of integer numbers. You also had a beautiful operations called "Copy-Paste" which allowed you to copy any contiguous subsequence of your array and paste it in any position of your array. For example, if you have array [1, 2, 3, 4, 5] and copy it's subsequence from the second to the fourth element and p... | 23,876 |
Print the circumference of a circle of radius R.
Constraints
* 1 \leq R \leq 100
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
R
Output
Print the circumference of the circle. Your output is considered correct if and only if its absolute or relative error ... | 23,877 |
One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2.
The author would need to spend too much time and effort to make the sum of his marks strictly more than k. That could have s... | 23,878 |
The Smart Beaver from ABBYY has a lot of hobbies. One of them is constructing efficient hash tables. One of the most serious problems in hash tables is resolving collisions. The Beaver is interested in this problem very much and he decided to explore it in detail.
We assume that the hash table consists of h cells numb... | 23,879 |
There are a total of n people in Prateek's class, numbered from 1 to n.
Every person has some field of interest for their projects.
There are a number people who have the same field of interest.
Now, you are given a number of pairs of the form (x,y).
This means that the students numbered x and y have interest in the ... | 23,880 |
Ever since Kalevitch, a famous Berland abstractionist, heard of fractals, he made them the main topic of his canvases. Every morning the artist takes a piece of graph paper and starts with making a model of his future canvas. He takes a square as big as n Γ n squares and paints some of them black. Then he takes a clean... | 23,881 |
I and my flatmate ,Sayan, went to see the magnificient fountains in the Jubilee park on 3rd March.It was the eve of the 184rd Bithday of the late Mr. J.N.Tata and the fountains were set to blow at regular intervals.
I sat down praising the scenic beauty of the fountains.But Sayan, who is a bit wierd, came up with a cha... | 23,882 |
problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 23,883 |
The only difference between easy and hard versions is constraints.
You are given a sequence a consisting of n positive integers.
Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are a and b, a can be equal b) and is as follows: [\underbrace{a, a, ... | 23,884 |
Dark with his love for the prime numbers wanted to do some arithmetic so he decided to do some additions.
He wants to generate all prime numbers between two given numbers and add them up and decide whether that addition of numbers is a prime number or not?
Confused, Simply print "YES"(without quotes) if the sum of pr... | 23,885 |
After a terrifying forest fire in Berland a forest rebirth program was carried out. Due to it N rows with M trees each were planted and the rows were so neat that one could map it on a system of coordinates so that the j-th tree in the i-th row would have the coordinates of (i, j). However a terrible thing happened and... | 23,886 |
A permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).
Let p be any permutation of length ... | 23,887 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.
She will concatenate all of the strings in some order, to produce a long string.
Among all strings that she can produce in this way, find the lexicographically smallest one.
Here, a string s=s_1s_2s_3...s_n is lexicographically sma... | 23,888 |
Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.
There is a rooted tree on n nodes, m of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to children. In the leaves of ... | 23,889 |
Given are a positive integer N and a sequence of length 2^N consisting of 0s and 1s: A_0,A_1,\ldots,A_{2^N-1}. Determine whether there exists a closed curve C that satisfies the condition below for all 2^N sets S \subseteq \\{0,1,\ldots,N-1 \\}. If the answer is yes, construct one such closed curve.
* Let x = \sum_{i ... | 23,890 |
You were lucky enough to get a map just before entering the legendary magical mystery world. The map shows the whole area of your planned exploration, including several countries with complicated borders. The map is clearly drawn, but in sepia ink only; it is hard to recognize at a glance which region belongs to which ... | 23,891 |
Consider a grid with H rows and W columns of squares. Let (r, c) denote the square at the r-th row from the top and the c-th column from the left. Each square is painted black or white.
The grid is said to be good if and only if the following condition is satisfied:
* From (1, 1), we can reach (H, W) by moving one sq... | 23,892 |
Ujan needs some rest from cleaning, so he started playing with infinite sequences. He has two integers n and k. He creates an infinite sequence s by repeating the following steps.
1. Find k smallest distinct positive integers that are not in s. Let's call them u_{1}, u_{2}, β¦, u_{k} from the smallest to the largest.... | 23,893 |
Dr. Kay Em, a genius scientist, developed a new missile named "Ikan-no-i." This missile has N jet engines. When the i-th engine is ignited, the missile's velocity changes to (vxi, vyi) immediately.
Your task is to determine whether the missile can reach the given target point (X, Y ). The missile can be considered as ... | 23,894 |
Continuing the trend, this year too we present a 'Mystery' for you to solve!
You will be given two numbers: a and b; and you have to output a single integer. See the sample test cases for hints.
Input:
The first line of the input will contain an integer t : the number of test cases. Each of the next t lines contain ... | 23,895 |
There are N mountains ranging from east to west, and an ocean to the west.
At the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.
The height of the i-th mountain from the west is H_i.
You can certainly see the ocean from the inn at the top of the westmost mountain.
F... | 23,896 |
When naming identifiers (variables and functions) in programming, compound words that concatenate words are used. However, if you concatenate them as they are, you will not be able to understand the word breaks, so in general, select and apply the one that is unified from the following naming conventions:
* Set to Upp... | 23,897 |
As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked each one: "Which one committed the crime?". Suspect number i answe... | 23,898 |
Vasya is a big fish lover, and his parents gave him an aquarium for the New Year. Vasya does not have a degree in ichthyology, so he thinks that filling a new aquarium with eels is a good idea. Unfortunately, eels are predators, so Vasya decided to find out how dangerous this idea was.
Getting into one aquarium, eels ... | 23,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.