question stringlengths 31 7.12k | source stringclasses 5
values | dataset stringclasses 3
values | index stringlengths 1 5 |
|---|---|---|---|
Problem description.
Vipul is a hardworking super-hero who maintains the bracket ratio of all the strings in the world. Recently he indulged himself in saving the string population so much that he lost his ability for checking brackets (luckily, not permanently ).Being his super-hero friendΒ help him in his time of hard... | codechef | taco | 20120 |
The Chef likes to stay in touch with his staff. So, the Chef, the head server, and the sous-chef all carry two-way transceivers so they can stay in constant contact. Of course, these transceivers have a limited range so if two are too far apart, they cannot communicate directly.
The Chef invested in top-of-the-line t... | codechef | code_contests | 1 |
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD
of two numbers. Then Felman implements it algorithm
int gcd(int a, int b)
{
if (b==0)
return a;
else
return gcd(b,a%b);
}
and it proposes to Frank that makes it
but with a little integer and another integer that has up to 250 d... | codechef | taco | 18022 |
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 calls some string T of the length M balanced if there exists at least one integer X (1 β€ X β€ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n... | codechef | apps | 1449 |
Given a string s. Can you make it a palindrome by deleting exactly one character? Note that size of the string after deletion would be one less than it was before.
Input
First line of the input contains a single integer T denoting number of test cases.
For each test case, you are given a single line containing string... | codechef | code_contests | 4 |
An established group of scientists are working on finding solution to NP hard problems. They claim Subset Sum as an NP-hard problem. The problem is to determine whether there exists a subset of a given set S whose sum is a given number K.
You are a computer engineer and you claim to solve this problem given that all... | codechef | taco | 8896 |
There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.
We want to plan a trip for every evening of m days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the following should hold:
* ... | codeforces | code_contests | 7 |
Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit.
For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not.
You have n cards with digits, and you want to use them to make as many phone n... | codeforces | code_contests | 8 |
You are given q queries in the following form:
Given three integers l_i, r_i and d_i, find minimum positive integer x_i such that it is divisible by d_i and it does not belong to the segment [l_i, r_i].
Can you answer all the queries?
Recall that a number x belongs to segment [l, r] if l β€ x β€ r.
Input
The first l... | codeforces | code_contests | 10 |
In Byteland, there are two political parties fighting for seats in the Parliament in the upcoming elections: Wrong Answer Party and Time Limit Exceeded Party. As they want to convince as many citizens as possible to cast their votes on them, they keep promising lower and lower taxes.
There are n cities in Byteland, co... | codeforces | taco | 13255 |
Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.
You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x to values written on al... | codeforces | taco | 217 |
An array of integers p_{1},p_{2}, β¦,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not permutations: [2], [1,1], [2,3,4].
There is a hidden permutation of length n.
... | codeforces | code_contests | 15 |
This is the easier version of the problem. In this version 1 β€ n, m β€ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing zero or more elements from the sequence a (they do not necessarily... | codeforces | taco | 19584 |
You are given a permutation p_1, p_2, β¦, p_n.
In one move you can swap two adjacent values.
You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,β¦, k, in other words in the end there should be an integer i, 1 β€ i β€ n-k+1 such that p_i = 1, p_{i+1} = 2, β¦, p_{i+k-1}=k.
... | codeforces | taco | 9956 |
Easy and hard versions are actually different problems, so read statements of both problems completely and carefully.
Summer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they have to read some amount of books before all entertainments. Alice and Bob will ... | codeforces | code_contests | 23 |
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to... | codeforces | code_contests | 24 |
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha... | codeforces | taco | 4550 |
You are given an integer n. You have to apply m operations to it.
In a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 after applying the operation once.
You have to find the length of n after applying m operations. Since... | codeforces | taco | 4587 |
Some country is populated by wizards. They want to organize a demonstration.
There are n people living in the city, x of them are the wizards who will surely go to the demonstration. Other city people (n - x people) do not support the wizards and aren't going to go to the demonstration. We know that the city administr... | codeforces | taco | 2150 |
You are given an equation:
Ax2 + Bx + C = 0.
Your task is to find the number of distinct roots of the equation and print all of them in ascending order.
Input
The first line contains three integer numbers A, B and C ( - 105 β€ A, B, C β€ 105). Any coefficient may be equal to 0.
Output
In case of infinite root cou... | codeforces | taco | 13702 |
A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-".
We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say tha... | codeforces | taco | 8005 |
There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any bett... | codeforces | apps | 965 |
Advertising has become part of our routine. And now, in the era of progressive technologies, we need your ideas to make advertising better!
In this problem we'll look at a simplified version of context advertising. You've got a text, consisting of exactly n words. A standard advertising banner has exactly r lines, eac... | codeforces | taco | 18870 |
We know that lucky digits are digits 4 and 7, however Vasya's got another favorite digit 0 and he assumes it also is lucky! Lucky numbers are such non-negative integers whose decimal record only contains lucky digits. For example, numbers 0, 47, 7074 are lucky, but 1, 7377, 895, -7 are not.
Vasya has t important posi... | codeforces | taco | 15944 |
Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.
Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like... | codeforces | apps | 811 |
Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn... | codeforces | taco | 16369 |
Sereja has painted n distinct points on the plane. The coordinates of each point are integers. Now he is wondering: how many squares are there with sides parallel to the coordinate axes and with points painted in all its four vertexes? Help him, calculate this number.
Input
The first line contains integer n (1 β€ n β€ ... | codeforces | taco | 5089 |
To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two... | codeforces | taco | 22940 |
A and B are preparing themselves for programming contests.
B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.
Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix s... | codeforces | apps | 1824 |
Every day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of points, such that there is at least one point from the set inside or on the border of each of the i... | codeforces | taco | 28 |
Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up all the bulbs?
If Va... | codeforces | apps | 1146 |
A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles during this time, but ... | codeforces | apps | 2405 |
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.
-----Input-----
The only line of the input co... | codeforces | apps | 3887 |
In Walrusland public transport tickets are characterized by two integers: by the number of the series and by the number of the ticket in the series. Let the series number be represented by a and the ticket number β by b, then a ticket is described by the ordered pair of numbers (a, b).
The walruses believe that a tic... | codeforces | taco | 10332 |
Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} β€ b_{i}).
Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x u... | codeforces | apps | 3767 |
Dasha is fond of challenging puzzles: Rubik's Cube 3 Γ 3 Γ 3, 4 Γ 4 Γ 4, 5 Γ 5 Γ 5 and so on. This time she has a cyclic table of size n Γ m, and each cell of the table contains a lowercase English letter. Each cell has coordinates (i, j) (0 β€ i < n, 0 β€ j < m). The table is cyclic means that to the right of cell (i, j... | codeforces | taco | 22928 |
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.
The killer starts with two potential victims on his first day, selects one of these two, kills selected ... | codeforces | apps | 2108 |
There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β the memory manager is among them. According to the developers' plan, in the first release the memory manager will be very simple and rectilinear. It will support three operations:
... | codeforces | taco | 10154 |
Igor is a post-graduate student of chemistry faculty in Berland State University (BerSU). He needs to conduct a complicated experiment to write his thesis, but laboratory of BerSU doesn't contain all the materials required for this experiment.
Fortunately, chemical laws allow material transformations (yes, chemistry i... | codeforces | apps | 2047 |
Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a_{i} each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ... | codeforces | apps | 162 |
You and your friend are participating in a TV show "Run For Your Prize".
At the start of the show n prizes are located on a straight line. i-th prize is located at position a_{i}. Positions of all prizes are distinct. You start at position 1, your friend β at position 10^6 (and there is no prize in any of these two po... | codeforces | apps | 567 |
You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges).
A vertex can be destroyed if this vertex has even degree. If you destroy a vertex, all edges connected to it are also deleted.
Destroy all vertices in the given tree or... | codeforces | taco | 17706 |
Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they correspond to the integer numbers from 0 to n - 1 on the OX axis. However, some positions are blocked an... | codeforces | code_contests | 66 |
As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu satisfied??. No,
He wants all his sugar canes to be of the same height. He g... | hackerearth | taco | 921 |
In the previous problem Chandu bought some unsorted arrays and sorted them (in non-increasing order). Now, he has many sorted arrays to give to his girlfriend. But, the number of sorted arrays are very large so Chandu decided to merge two sorted arrays into one sorted array. But he is too lazy to do that. So, he asked ... | hackerearth | taco | 11239 |
You are given an array A of size N, and Q queries to deal with. For each query, you are given an integer X, and you're supposed to find out if X is present in the array A or not.
Input:
The first line contains two integers, N and Q, denoting the size of array A and number of queries. The second line contains N space s... | hackerearth | taco | 4305 |
A certain business maintains a list of all its customers' names. The list is arranged in order of importance, with the last customer in the list being the most important. Now, he want to create a new list sorted alphabetically according to customers' last names, but among customers with the same last name he want the m... | hackerearth | taco | 22888 |
Monk loves cakes! He visits the Binary Bakery to buy some of his favorite cheesecakes.
The owner of the bakery, Bob, is a clever man. He does not want Monk to finish all his cheesecakes. Hence, he plays a game.
The Monk is given N numbers and has to select K of these numbers. For each number that Monk chooses, he wil... | hackerearth | taco | 1043 |
Roy is going through the dark times of his life. Recently his girl friend broke up with him and to overcome the pain of acute misery he decided to restrict himself to Eat-Sleep-Code life cycle. For N days he did nothing but eat, sleep and code.
A close friend of Roy kept an eye on him for last N days. For every sing... | hackerearth | taco | 735 |
Problem:
Rani and Nandu decide to play a number game. Both play alternately, Rani playing the first move.
In each of their moves, they can subtract a maximum of k and a minimun of 1 from n ( ie.each of them must subtract from n, any natural number less than or equal to k) , and the new value of n will be the result ... | hackerearth | taco | 14303 |
Rakesh have learn about vowel in school and is given an assignment by his teacher in which he has to list all vowel together from the word's given to him,but he is busy in watching cricket match and want your help to solve the assignment.
5 vowel (a,e,i,o,u) and you should also take care of uppercase vowel (A,E,I,O,U)... | hackerearth | taco | 11035 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,... | atcoder | code_contests | 77 |
In this problem, we only consider strings consisting of lowercase English letters.
Strings s and t are said to be isomorphic when the following conditions are satisfied:
* |s| = |t| holds.
* For every pair i, j, one of the following holds:
* s_i = s_j and t_i = t_j.
* s_i \neq s_j and t_i \neq t_j.
For example, `a... | atcoder | taco | 15805 |
Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.
Given are two integers A and B.
If Takahashi can calculate A \times B, print the result; if he cannot, print `-1` instead.
Constraints
* 1 \leq A \leq 20
* 1 \leq B ... | atcoder | code_contests | 79 |
There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time.
However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps.
How many are there to climb ... | atcoder | code_contests | 80 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
Constraints
* 1 β€ a,b β€ 10000
* a and b are integers.
Input
Input is given from Standard Input in the following format:
a b
Output
If the product is odd, print `Odd`; if it is even, print `Even`.
E... | atcoder | code_contests | 83 |
There are N students and M checkpoints on the xy-plane.
The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).
When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance.
T... | atcoder | code_contests | 85 |
Two students of AtCoder Kindergarten are fighting over candy packs.
There are three candy packs, each of which contains a, b, and c candies, respectively.
Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.
Not... | atcoder | code_contests | 86 |
4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle $ ABCD $ with the coordinates as the vertices, and NO if there is a dent.
A quadrangle with a de... | aizu | taco | 8648 |
Sorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of "sorting the elements of an array of integer values ββin ascending order" is alignment.
<image>
Many alignment algorithms have been devised, but one of the basic alg... | aizu | taco | 17682 |
PCK, which recycles Aizu's precious metal, Aizunium, has a network all over the country and collects Aizunium with many collection vehicles. This company standardizes the unit of weight and number of lumps for efficient processing.
A unit called "bokko" is used for the weight of the lump. x Bocco's Aidunium weighs 2 x... | aizu | taco | 24609 |
problem
If you write a positive integer in decimal notation (without leading 0) and look at the digit numbers in order, when the number increases and decreases alternately, the number is "zigza". Let's call it. For example, 2947 is a zigzag number because the digit numbers are in the order of 2 β 9 β 4 β 7 and increas... | aizu | taco | 19854 |
Problem
KND is a student programmer at the University of Aizu. There are N towns around his town. He loves cream so he built a factory in a town to eat cream every day. The factory produces F liters of fresh cream daily. Every time you carry the cream, it will be damaged by the absolute difference between the temperat... | aizu | taco | 18178 |
You are the God of Wind.
By moving a big cloud around, you can decide the weather: it invariably rains under the cloud, and the sun shines everywhere else.
But you are a benign God: your goal is to give enough rain to every field in the countryside, and sun to markets and festivals. Small humans, in their poor vocabu... | aizu | taco | 5161 |
Example
Input
2 1
1 2 2
Output
1 | aizu | taco | 3827 |
Short Phrase
A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition:
> (The Condition for a Short Phrase)
> The sequence of words can be divided into five sections ... | aizu | taco | 21549 |
I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n β 1, and you can use the k ticket to go to pβ
ak + qβ
bk station.
Rabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station, but wants to walk as short as possible. The stations are lined up ... | aizu | taco | 12533 |
Taro is an elementary school student who has just learned multiplication. Somehow, he likes multiplication, so when he sees numbers, he wants to multiply. He seems to like to do the following for integers greater than or equal to 0. (Processing flow)
* Procedure 1. If a certain integer n greater than or equal to 0 is ... | aizu | taco | 10629 |
Step up and down
Kazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participate in the ICPC (International Collegiate Potchari Contest). ICPC is a sports contest and requires a high degree of athletic ability. However, Mr. Kerr was always in front of the computer, and... | aizu | taco | 13876 |
Example
Input
4 3
1 3 4 7
Output
6 | aizu | taco | 16708 |
problem
Given $ N $ different natural numbers $ a_i $. I decided to make a pair by choosing a different natural number from the given natural numbers. Output one pair that can be created with a value difference that is a multiple of $ N -1 $.
It should be noted that such a pair always exists.
Example
Input
5
1... | aizu | taco | 13383 |
Problem
A large-scale cluster β type supercomputer (commonly known as "SAKURA") cluster at Maze University consists of $ N $ computers (nodes) and $ M $ physical communication channels that can communicate with each other. .. In addition, each node is assigned an identification number from 1 to $ N $.
This time, the ... | aizu | taco | 8636 |
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
SelectionSort(A)
1 for i = 0 to A.length-1
2 mini = i
3 for j = i to A.length-1
4 if A[j] < A[mini]
5 mini = j
6 swap A[i] and A[mini]... | aizu | taco | 17640 |
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).
The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
Note
θ§£θͺ¬
Input
In the first line, the number of cards n (n β€ 52) is given.
In the following n line... | aizu | taco | 15931 |
Your task is very simple. Given K numbers A1, A2, ..., AK. You need to find f(N) mod max(A1, A2, ..., AK) .
f(N)=N!
Input
First line contains single integer T denoting the number of test cases..
First line of each test case contains two integers N and K.
Next line contains K integers Ak
Output
For each test case,... | codechef | taco | 4862 |
Problem Desrcription
Shil likes to play with trees a lot.He is playing with an undirected tree containing N nodes.He wants to find out total number of unordered triplets (A,B,C) such that A is not connected to B, B is not connected to C and A is not connected to C by a direct edge (No two of A, B, C are mutually conne... | codechef | taco | 20293 |
This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A's in one name and one A in the other would cancel one A in each name), coun... | codechef | taco | 8664 |
Now that Chef has finished baking and frosting his cupcakes, it's time to package them. Chef has N cupcakes, and needs to decide how many cupcakes to place in each package. Each package must contain the same number of cupcakes. Chef will choose an integer A between 1 and N, inclusive, and place exactly A cupcakes into ... | codechef | apps | 945 |
You are given a simple code of a function and you would like to know what it will return.
F(N, K, Answer, Operator, A[N]) returns int;
begin
for iK do
for jN do
AnswerAnswer operator Aj)
return Answer
end
Here N, K, Answer and the value returned by the function F are integers;... | codechef | code_contests | 108 |
Chef and his girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed one by one. Before walking Chef and his girlfriend stay at the beginning of the first segment, they want to achieve the end of the last segment.
There are few problems:
- At the beginnin... | codechef | apps | 838 |
At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector Π:
* Turn the vector by 90 degrees clockwise.
* Add to the vector a certain vector C.
Operations could be performed in any order any number of times.
... | codeforces | taco | 437 |
Awruk is taking part in elections in his school. It is the final round. He has only one opponent β Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from t... | codeforces | code_contests | 111 |
You are given a tree with n vertices; its root is vertex 1. Also there is a token, initially placed in the root. You can move the token to other vertices. Let's assume current vertex of token is v, then you make any of the following two possible moves:
* move down to any leaf in subtree of v;
* if vertex v is a ... | codeforces | taco | 8957 |
This is an interactive problem!
Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b). Laggy can ask a pair of integers (c,d) and Ehab will reply with:
* 1 if a β c>b β d.
* 0 if a β c=b β d.
* -1 if a β c<b β d.
Operation a β b is the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise... | codeforces | taco | 504 |
You are given a binary matrix A of size n Γ n. Let's denote an x-compression of the given matrix as a matrix B of size n/x Γ n/x such that for every i β [1, n], j β [1, n] the condition A[i][j] = B[β i/x β][β j/x β] is met.
Obviously, x-compression is possible only if x divides n, but this condition is not enough. For... | codeforces | code_contests | 114 |
At the big break Nastya came to the school dining room. There are n pupils in the school, numbered from 1 to n. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya, but she is not going to de... | codeforces | code_contests | 115 |
You are given a string s consisting of n lowercase Latin letters.
Let's define a substring as a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position 3 and ends in position 6), but "aa" or "d" aren't substrings of this string. So the substring of the string s from po... | codeforces | code_contests | 116 |
You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.
The boss battle consists of n turns. During each turn, you will get several cards. Each card has two parameters: its cost c_i and damage d_i. You may play some of your cards during each turn i... | codeforces | code_contests | 117 |
Alice is playing with some stones.
Now there are three numbered heaps of stones. The first of them contains a stones, the second of them contains b stones and the third of them contains c stones.
Each time she can do one of two operations:
1. take one stone from the first heap and two stones from the second heap (... | codeforces | code_contests | 120 |
There are n cities in Berland and some pairs of them are connected by two-way roads. It is guaranteed that you can pass from any city to any other, moving along the roads. Cities are numerated from 1 to n.
Two fairs are currently taking place in Berland β they are held in two different cities a and b (1 β€ a, b β€ n; a ... | codeforces | taco | 2823 |
Polycarp plays a well-known computer game (we won't mention its name). Every object in this game consists of three-dimensional blocks β axis-aligned cubes of size 1 Γ 1 Γ 1. These blocks are unaffected by gravity, so they can float in the air without support. The blocks are placed in cells of size 1 Γ 1 Γ 1; each cell ... | codeforces | taco | 20140 |
Piet is one of the most known visual esoteric programming languages. The programs in Piet are constructed from colorful blocks of pixels and interpreted using pretty complicated rules. In this problem we will use a subset of Piet language with simplified rules.
The program will be a rectangular image consisting of col... | codeforces | taco | 23 |
You are given two arrays of integers a_1,β¦,a_n and b_1,β¦,b_m.
Your task is to find a non-empty array c_1,β¦,c_k that is a subsequence of a_1,β¦,a_n, and also a subsequence of b_1,β¦,b_m. If there are multiple answers, find one of the smallest possible length. If there are still multiple of the smallest possible length, f... | codeforces | code_contests | 127 |
Alice had a permutation p_1, p_2, β¦, p_n. Unfortunately, the permutation looked very boring, so she decided to change it and choose some non-overlapping subranges of this permutation and reverse them. The cost of reversing a single subrange [l, r] (elements from position l to position r, inclusive) is equal to r - l, a... | codeforces | taco | 25018 |
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... | codeforces | taco | 7176 |
Monocarp and Polycarp are learning new programming techniques. Now they decided to try pair programming.
It's known that they have worked together on the same file for n + m minutes. Every minute exactly one of them made one change to the file. Before they started, there were already k lines written in the file.
Ever... | codeforces | code_contests | 134 |
Polycarpus enjoys studying Berland hieroglyphs. Once Polycarp got hold of two ancient Berland pictures, on each of which was drawn a circle of hieroglyphs. We know that no hieroglyph occurs twice in either the first or the second circle (but in can occur once in each of them).
Polycarpus wants to save these pictures o... | codeforces | taco | 2844 |
Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the si... | codeforces | taco | 1313 |
A string is called a k-string if it can be represented as k concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.
You are given a string s, ... | codeforces | taco | 9968 |
The black king is standing on a chess field consisting of 10^9 rows and 10^9 columns. We will consider the rows of the field numbered with integers from 1 to 10^9 from top to bottom. The columns are similarly numbered with integers from 1 to 10^9 from left to right. We will denote a cell of the field that is located in... | codeforces | apps | 1847 |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 12