text stringlengths 424 69.5k |
|---|
### Prompt
Please provide a Cpp coded solution to the problem described below:
You're given an array a. You should repeat the following operation k times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print ... |
### Prompt
Generate a cpp solution to the following problem:
A flowerbed has many flowers and two fountains.
You can adjust the water pressure and set any values r1(r1 β₯ 0) and r2(r2 β₯ 0), giving the distances at which the water is spread from the first and second fountain respectively. You have to set such r1 and r... |
### Prompt
Develop a solution in CPP to the problem described below:
There are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the local library decided to make an exposition of the works of this famous science-fiction writer. It was decided as well that it is ... |
### Prompt
Construct a cpp code solution to the problem outlined:
Your math teacher gave you the following problem:
There are n segments on the x-axis, [l_1; r_1], [l_2; r_2], β¦, [l_n; r_n]. The segment [l; r] includes the bounds, i.e. it is a set of such x that l β€ x β€ r. The length of the segment [l; r] is equal t... |
### Prompt
Create a solution in Cpp for the following problem:
Snuke found a record of a tree with N vertices in ancient ruins. The findings are as follows:
* The vertices of the tree were numbered 1,2,...,N, and the edges were numbered 1,2,...,N-1.
* Edge i connected Vertex a_i and b_i.
* The length of each edge wa... |
### Prompt
In Cpp, your task is to solve the following problem:
After his birthday party, Timofey went to his favorite tree alley in a park. He wants to feed there his favorite birds β crows.
It's widely known that each tree is occupied by a single crow family. The trees in the alley form a row and are numbered from... |
### Prompt
Please create a solution in CPP to the following problem:
After the Search Ultimate program that searched for strings in a text failed, Igor K. got to think: "Why on Earth does my program work so slowly?" As he double-checked his code, he said: "My code contains no errors, yet I know how we will improve Se... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
There is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left.
Each of the central (N-2) \times (N-2) squares in the grid has a black stone on it. Each of the... |
### Prompt
Develop a solution in Cpp to the problem described below:
E: Do You Divide It? / Do you want to chop it up?
story
Mr. T has been terribly troubled by the problem of plane figures in programming contests he has participated in in the past, and has had a strong grudge against plane figures ever since.
Abo... |
### Prompt
In CPP, your task is to solve the following problem:
After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known "Heroes of Might & Magic". A part of the game is turn-based fig... |
### Prompt
Please create a solution in Cpp to the following problem:
You are given an array a, consisting of n positive integers.
Let's call a concatenation of numbers x and y the number that is obtained by writing down numbers x and y one right after another without changing the order. For example, a concatenation ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed u... |
### Prompt
Develop a solution in cpp to the problem described below:
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the elemen... |
### Prompt
Construct a CPP code solution to the problem outlined:
You have array a1, a2, ..., an. Segment [l, r] (1 β€ l β€ r β€ n) is good if ai = ai - 1 + ai - 2, for all i (l + 2 β€ i β€ r).
Let's define len([l, r]) = r - l + 1, len([l, r]) is the length of the segment [l, r]. Segment [l1, r1], is longer than segment ... |
### Prompt
Please create a solution in CPP to the following problem:
Nezzar's favorite digit among 1,β¦,9 is d. He calls a positive integer lucky if d occurs at least once in its decimal representation.
Given q integers a_1,a_2,β¦,a_q, for each 1 β€ i β€ q Nezzar would like to know if a_i can be equal to a sum of sever... |
### Prompt
Please formulate a Cpp solution to the following problem:
Notice that the memory limit is non-standard.
Recently Arthur and Sasha have studied correct bracket sequences. Arthur understood this topic perfectly and become so amazed about correct bracket sequences, so he even got himself a favorite correct b... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a string s consisting of characters "1", "0", and "?". The first character of s is guaranteed to be "1". Let m be the number of characters in s.
Count the number of ways we can choose a pair of integers a, b that satisfies t... |
### Prompt
Please provide a CPP coded solution to the problem described below:
From beginning till end, this message has been waiting to be conveyed.
For a given unordered multiset of n lowercase English letters ("multi" means that a letter may appear more than once), we treat all letters as strings of length 1, and... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Mr. Schwarz was a famous powerful pro wrestler. He starts a part time job as a warehouseman. His task is to move a cargo to a goal by repeatedly pushing the cargo in the warehouse, of course, without breaking the walls and the pillars of t... |
### Prompt
Please formulate a Cpp solution to the following problem:
Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.
The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the s... |
### Prompt
Create a solution in Cpp for the following problem:
Polycarp has invited n friends to celebrate the New Year. During the celebration, he decided to take a group photo of all his friends. Each friend can stand or lie on the side.
Each friend is characterized by two values h_i (their height) and w_i (their ... |
### Prompt
Generate a cpp solution to the following problem:
Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on.
Iahub has the following scheme of pai... |
### Prompt
Create a solution in Cpp for the following problem:
Bob is a duck. He wants to get to Alice's nest, so that those two can duck!
<image> Duck is the ultimate animal! (Image courtesy of See Bang)
The journey can be represented as a straight line, consisting of n segments. Bob is located to the left of the ... |
### Prompt
Generate a Cpp solution to the following problem:
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following... |
### Prompt
Please create a solution in Cpp to the following problem:
You are given a string s consisting of exactly n characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.
Your task is to replace minimum number of characters in this string with other characters to obtain ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special ru... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes to the party, sends messages to his contacts... |
### Prompt
Develop a solution in CPP to the problem described below:
Btoh yuo adn yuor roomatme lhoate wianshg disehs, btu stlil sdmoeboy msut peorrfm tihs cohre dialy. Oen dya yuo decdie to idourtcne smoe syestm. Yuor rmmotaoe sstgegus teh fooniwllg dael. Yuo argee on tow arayrs of ientgres M adn R, nmebur upmicnog ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hot... |
### Prompt
Please create a solution in Cpp to the following problem:
Little Chris is having a nightmare. Even in dreams all he thinks about is math.
Chris dreams about m binary strings of length n, indexed with numbers from 1 to m. The most horrifying part is that the bits of each string are ordered in either ascend... |
### Prompt
Create a solution in CPP for the following problem:
You are given two segments [l_1; r_1] and [l_2; r_2] on the x-axis. It is guaranteed that l_1 < r_1 and l_2 < r_2. Segments may intersect, overlap or even coincide with each other.
<image> The example of two segments on the x-axis.
Your problem is to fi... |
### Prompt
In cpp, your task is to solve the following problem:
Polycarp wants to cook a soup. To do it, he needs to buy exactly n liters of water.
There are only two types of water bottles in the nearby shop β 1-liter bottles and 2-liter bottles. There are infinitely many bottles of these two types in the shop.
Th... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You might have remembered Theatre square from the [problem 1A](https://codeforces.com/problemset/problem/1/A). Now it's finally getting repaved.
The square still has a rectangular shape of n Γ m meters. However, the picture is about to ge... |
### Prompt
Generate a CPP solution to the following problem:
Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help.
Artem wants to paint an n Γ m board. Each cell of the board should be colored in white or black.
Lets B be the n... |
### Prompt
Please formulate a Cpp solution to the following problem:
You have an integer variable x. Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented ... |
### Prompt
Create a solution in cpp for the following problem:
BCPC stands for Byteforces Collegiate Programming Contest, and is the most famous competition in Byteforces.
BCPC is a team competition. Each team is composed by a coach and three contestants. Blenda is the coach of the Bit State University(BSU), and she... |
### Prompt
Please formulate a cpp solution to the following problem:
The annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2N teams participating in the tournament, numbered from 1 to 2N. The tournament lasts N rounds, with e... |
### Prompt
Please formulate a cpp solution to the following problem:
Vanya got an important task β he should enumerate books in the library and label each book with its number. Each of the n books should be assigned with a number from 1 to n. Naturally, distinct books should be assigned distinct numbers.
Vanya wants... |
### Prompt
Construct a CPP code solution to the problem outlined:
Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.
The term is coming to an end and students start th... |
### Prompt
Please provide a CPP coded solution to the problem described below:
A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.
Limak is a little polar bear. He once had a tree with n vertices but he lost it. He still remembers something about the lo... |
### Prompt
Your task is to create a cpp solution to the following problem:
Daniel has a string s, consisting of lowercase English letters and period signs (characters '.'). Let's define the operation of replacement as the following sequence of steps: find a substring ".." (two consecutive periods) in string s, of all... |
### Prompt
In CPP, your task is to solve the following problem:
There are N panels arranged in a row in Takahashi's house, numbered 1 through N. The i-th panel has a number A_i written on it. Takahashi is playing by throwing balls at these panels.
Takahashi threw a ball K times. Let the panel hit by a boll in the i-... |
### Prompt
Create a solution in CPP for the following problem:
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand.
How many grams of sand will the upper bulb contains after t seconds?
Constraints
... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
We have a sequence of N \times K integers: X=(X_0,X_1,\cdots,X_{N \times K-1}). Its elements are represented by another sequence of N integers: A=(A_0,A_1,\cdots,A_{N-1}). For each pair i, j (0 \leq i \leq K-1,\ 0 \leq j \leq N-1), X_{i \t... |
### Prompt
In CPP, your task is to solve the following problem:
Takahashi and Aoki are going to together construct a sequence of integers.
First, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:
* The length of a is N.
* Each element in a is an integer between 1 and K, in... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Vasya has got n books, numbered from 1 to n, arranged in a stack. The topmost book has number a_1, the next one β a_2, and so on. The book at the bottom of the stack has number a_n. All numbers are distinct.
Vasya wants to move all the bo... |
### Prompt
Create a solution in Cpp for the following problem:
There are N white balls arranged in a row, numbered 1,2,..,N from left to right. AtCoDeer the deer is thinking of painting some of these balls red and blue, while leaving some of them white.
You are given a string s of length K. AtCoDeer performs the fol... |
### Prompt
Develop a solution in Cpp to the problem described below:
You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong.
Inna and Dima are now in one room. Inna tells Dima off for everything he does in her presence. After Inna... |
### Prompt
Please create a solution in Cpp to the following problem:
There are n chips arranged in a circle, numbered from 1 to n.
Initially each chip has black or white color. Then k iterations occur. During each iteration the chips change their colors according to the following rules. For each chip i, three chips... |
### Prompt
In CPP, your task is to solve the following problem:
One day a highly important task was commissioned to Vasya β writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as ... |
### Prompt
Develop a solution in cpp to the problem described below:
Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful nu... |
### Prompt
Please provide a cpp coded solution to the problem described below:
You have been offered a job in a company developing a large social network. Your first task is connected with searching profiles that most probably belong to the same user.
The social network contains n registered profiles, numbered from ... |
### Prompt
Construct a cpp code solution to the problem outlined:
There are 2N balls in the xy-plane. The coordinates of the i-th of them is (x_i, y_i). Here, x_i and y_i are integers between 1 and N (inclusive) for all i, and no two balls occupy the same coordinates.
In order to collect these balls, Snuke prepared ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
It is known that fleas in Berland can jump only vertically and horizontally, and the length of the jump is always equal to s centimeters. A flea has found herself at the center of some cell of the checked board of the size n Γ m centimeter... |
### Prompt
Generate a Cpp solution to the following problem:
In Doodle Jump the aim is to guide a four-legged creature called "The Doodler" up a never-ending series of platforms without falling. β Wikipedia.
It is a very popular game and xiaodao likes it very much. One day when playing the game she wondered whether... |
### Prompt
In CPP, your task is to solve the following problem:
Π‘ity N. has a huge problem with roads, food and IT-infrastructure. In total the city has n junctions, some pairs of them are connected by bidirectional roads. The road network consists of n - 1 roads, you can get from any junction to any other one by the... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Artem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value a_{i,j} written in it.
If two adjacent cells contain the sam... |
### Prompt
Develop a solution in Cpp to the problem described below:
Let f_{x} = c^{2x-6} β
f_{x-1} β
f_{x-2} β
f_{x-3} for x β₯ 4.
You have given integers n, f_{1}, f_{2}, f_{3}, and c. Find f_{n} mod (10^{9}+7).
Input
The only line contains five integers n, f_{1}, f_{2}, f_{3}, and c (4 β€ n β€ 10^{18}, 1 β€ f_{1}, ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal ba... |
### Prompt
Please provide a CPP coded solution to the problem described below:
There are n seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from 1 to n from left to right. The trip is long, so each passenger will become hungry at some moment of time and will go ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Vasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.
The exceptions are processed by try-... |
### Prompt
Create a solution in Cpp for the following problem:
You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied:
For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Wr... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an ... |
### Prompt
Generate a CPP solution to the following problem:
Little C loves number Β«3Β» very much. He loves all things about it.
Now he is playing a game on a chessboard of size n Γ m. The cell in the x-th row and in the y-th column is called (x,y). Initially, The chessboard is empty. Each time, he places two chessme... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given integer n. You have to arrange numbers from 1 to 2n, using each of them exactly once, on the circle, so that the following condition would be satisfied:
For every n consecutive numbers on the circle write their sum on the bl... |
### Prompt
Develop a solution in Cpp to the problem described below:
Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.
What is the minimum number of minutes she needs to... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations.
* Operation 1: Pour 100A grams o... |
### Prompt
Your task is to create a CPP solution to the following problem:
During their New Year holidays, Alice and Bob play the following game using an array a of n integers:
* Players take turns, Alice moves first.
* Each turn a player chooses any element and removes it from the array.
* If Alice chooses... |
### Prompt
In CPP, your task is to solve the following problem:
Tyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!
The popularity of the new browser is growing daily. And the secret is not even the Tyndex.Bar installed (the Ty... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.
A game is played... |
### Prompt
In CPP, your task is to solve the following problem:
We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to care about what "yu... |
### Prompt
Please formulate a CPP solution to the following problem:
The annual college sports-ball tournament is approaching, which for trademark reasons we'll refer to as Third Month Insanity. There are a total of 2N teams participating in the tournament, numbered from 1 to 2N. The tournament lasts N rounds, with e... |
### Prompt
Construct a Cpp code solution to the problem outlined:
There are N blocks arranged in a row. Let us paint these blocks.
We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.
Find the number of ways to paint the blocks under ... |
### Prompt
In CPP, your task is to solve the following problem:
You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Snuke received an integer sequence a of length 2N-1.
He arbitrarily permuted the elements in a, then used it to construct a new integer sequence b of length N, as follows:
* b_1 = the median of (a_1)
* b_2 = the median of (a_1, a_2, a_3)... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Polycarpus has a computer with n processors. Also, his computer has n memory cells. We'll consider the processors numbered by integers from 1 to n and that the memory cells are consecutively numbered by integers from 1 to n.
Polycarpus ne... |
### Prompt
Develop a solution in CPP to the problem described below:
You want to perform the combo on your opponent in one popular fighting game. The combo is the string s consisting of n lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in s. I.e. if s="abca" then ... |
### Prompt
Construct a cpp code solution to the problem outlined:
On one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game.
It is well known that one month on this planet consists of n^2 days, so calendars, represented as square matrix n by n are extremely popular.
Weath... |
### Prompt
Develop a solution in cpp to the problem described below:
Vasya has recently developed a new algorithm to optimize the reception of customer flow and he considered the following problem.
Let the queue to the cashier contain n people, at that each of them is characterized by a positive integer ai β that is... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Heidi's friend Jenny is asking Heidi to deliver an important letter to one of their common friends. Since Jenny is Irish, Heidi thinks that this might be a prank. More precisely, she suspects that the message she is asked to deliver states... |
### Prompt
Develop a solution in Cpp to the problem described below:
A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year shall ... |
### Prompt
Construct a cpp code solution to the problem outlined:
Theseus has just arrived to Crete to fight Minotaur. He found a labyrinth that has a form of a rectangular field of size n Γ m and consists of blocks of size 1 Γ 1.
Each block of the labyrinth has a button that rotates all blocks 90 degrees clockwise.... |
### Prompt
Please formulate a Cpp solution to the following problem:
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.
Takahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap... |
### Prompt
In cpp, your task is to solve the following problem:
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an int... |
### Prompt
Generate a cpp solution to the following problem:
Let x be a string of length at least 1. We will call x a good string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, `a`, `bbc` and `cdcdc` are good strings, while `aa`,... |
### Prompt
Generate a Cpp solution to the following problem:
A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.
There are n schools numerated from 1 to n. One can travel between each pair of them, to do so, ... |
### Prompt
Develop a solution in CPP to the problem described below:
You are given m sets of integers A_1, A_2, β¦, A_m; elements of these sets are integers between 1 and n, inclusive.
There are two arrays of positive integers a_1, a_2, β¦, a_m and b_1, b_2, β¦, b_n.
In one operation you can delete an element j from ... |
### Prompt
Generate a CPP solution to the following problem:
In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers.
Even though it is a university competition, multiple teams from one... |
### Prompt
Create a solution in CPP for the following problem:
A new pack of n t-shirts came to a shop. Each of the t-shirts is characterized by three integers pi, ai and bi, where pi is the price of the i-th t-shirt, ai is front color of the i-th t-shirt and bi is back color of the i-th t-shirt. All values pi are di... |
### Prompt
In Cpp, your task is to solve the following problem:
You are given two multisets A and B. Each multiset has exactly n integers each between 1 and n inclusive. Multisets may contain multiple copies of the same number.
You would like to find a nonempty subset of A and a nonempty subset of B such that the su... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You are given an undirected graph consisting of n vertices and <image> edges. Instead of giving you the edges that exist in the graph, we give you m unordered pairs (x, y) such that there is no edge between x and y, and if some pair of vertices is not ... |
### Prompt
Develop a solution in Cpp to the problem described below:
There are N children, numbered 1, 2, \ldots, N.
They have decided to share K candies among themselves. Here, for each i (1 \leq i \leq N), Child i must receive between 0 and a_i candies (inclusive). Also, no candies should be left over.
Find the n... |
### Prompt
Generate a cpp solution to the following problem:
The nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum of the first n triangular numbers. It is easy to show that the nth tetrahedral number is equal to n(n+1)(n+2) β 6. For example... |
### Prompt
In cpp, your task is to solve the following problem:
You are given a set of n elements indexed from 1 to n. The weight of i-th element is wi. The weight of some subset of a given set is denoted as <image>. The weight of some partition R of a given set into k subsets is <image> (recall that a partition of a... |
### Prompt
In cpp, your task is to solve the following problem:
It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 β€ w2 β€ ... β€ wk holds.
Po... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
After his birthday party, Timofey went to his favorite tree alley in a park. He wants to feed there his favorite birds β crows.
It's widely known that each tree is occupied by a single crow family. The trees in the alley form a row and ar... |
### Prompt
Your task is to create a CPP solution to the following problem:
The legend of the foundation of Vectorland talks of two integers x and y. Centuries ago, the array king placed two markers at points |x| and |y| on the number line and conquered all the land in between (including the endpoints), which he decla... |
### Prompt
Please create a solution in CPP to the following problem:
Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience.
In that country there are n islands and m bridges between them, so you can travel from any island to... |
### Prompt
Your task is to create a Cpp solution to the following problem:
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 β€ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 β€ u, v < N), we define the distance d(u, v) as the number of edges ... |
### Prompt
Your task is to create a CPP solution to the following problem:
Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph.
Ostap's tree now has n vertices. He wants to paint some vertices of the tree black such... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.