text stringlengths 424 69.5k |
|---|
### Prompt
In Cpp, your task is to solve the following problem:
Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digits (for example, 12-34-56). Each friend has a phonebook of si... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
As you know, Bob's brother lives in Flatland. In Flatland there are n cities, connected by n - 1 two-way roads. The cities are numbered from 1 to n. You can get from one city to another moving along the roads.
The «Two Paths» company, whe... |
### Prompt
Please formulate a cpp solution to the following problem:
You are given an array a consisting of n positive integers. Find a non-empty subset of its elements such that their sum is even (i.e. divisible by 2) or determine that there is no such subset.
Both the given array and required subset may contain eq... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
When the curtains are opened, a canvas unfolds outside. Kanno marvels at all the blonde colours along the riverside — not tangerines, but blossoms instead.
"What a pity it's already late spring," sighs Mino with regret, "one more drizzlin... |
### Prompt
Create a solution in cpp for the following problem:
Furik and Rubik love playing computer games. Furik has recently found a new game that greatly interested Rubik. The game consists of n parts and to complete each part a player may probably need to complete some other ones. We know that the game can be ful... |
### Prompt
Generate a Cpp solution to the following problem:
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Bandits appeared in the city! One of them is trying to catch as many citizens as he can.
The city consists of n squares connected by n-1 roads in such a way that it is possible to reach any square from any other square. The square number ... |
### Prompt
Your task is to create a cpp solution to the following problem:
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes... |
### Prompt
Generate a CPP solution to the following problem:
Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.
The area looks like a strip of cells 1 × n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first... |
### Prompt
Please formulate a cpp solution to the following problem:
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first pl... |
### Prompt
Develop a solution in Cpp to the problem described below:
Consider a tree (that is, an undirected connected graph without loops) T_1 and a tree T_2. Let's define their cartesian product T_1 × T_2 in a following way.
Let V be the set of vertices in T_1 and U be the set of vertices in T_2.
Then the set of ... |
### Prompt
Please formulate a CPP solution to the following problem:
You are given an array a consisting of n integers (it is guaranteed that n is even, i.e. divisible by 2). All a_i does not exceed some integer k.
Your task is to replace the minimum number of elements (replacement is the following operation: choose... |
### Prompt
Please create a solution in cpp to the following problem:
To satisfy his love of matching socks, Phoenix has brought his n socks (n is even) to the sock store. Each of his socks has a color c_i and is either a left sock or right sock.
Phoenix can pay one dollar to the sock store to either:
* recolor ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Little John aspires to become a plumber! Today he has drawn a grid consisting of n rows and m columns, consisting of n × m square cells.
In each cell he will draw a pipe segment. He can only draw four types of segments numbered from 1 to ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Furik and Rubik take part in a relay race. The race will be set up on a large square with the side of n meters. The given square is split into n × n cells (represented as unit squares), each cell has some number.
At the beginning of the race ... |
### Prompt
Construct a CPP code solution to the problem outlined:
<image>
Arrange integers (0 or more and 99 or less) in a rhombus as illustrated in Fig. 1. Create a program that reads the data representing the rhombus and outputs the maximum value of the sum of the integers that pass when starting from the top and... |
### Prompt
Please create a solution in CPP to the following problem:
There are n persons located on a plane. The i-th person is located at the point (x_i, y_i) and initially looks at the point (u_i, v_i).
At the same moment of time, all persons will start to rotate clockwise synchronously with the same angular speed... |
### Prompt
Your task is to create a cpp solution to the following problem:
<image>
Matryoshka is a wooden doll in the shape of a female figure and is a typical Russian folk craft. Matryoshka has a nested structure in which smaller dolls are contained inside a large doll, and is composed of multiple dolls of differen... |
### Prompt
In cpp, your task is to solve the following problem:
problem
You have to play a darts game with the following rules.
You can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in e... |
### Prompt
Create a solution in Cpp for the following problem:
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (xi, yi). We know that no two bombs are at the same point and that no bomb is at point with coo... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.
Its most important components are a button and a lin... |
### Prompt
Please provide a cpp coded solution to the problem described below:
The Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The problem is as follows.
There is a collection of n pro... |
### Prompt
Construct a CPP code solution to the problem outlined:
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other ... |
### Prompt
Generate a CPP solution to the following problem:
You are given an array a_1, a_2, …, a_n.
You need to perform q queries of the following two types:
1. "MULTIPLY l r x" — for every i (l ≤ i ≤ r) multiply a_i by x.
2. "TOTIENT l r" — print \varphi(∏ _{i=l}^{r} a_i) taken modulo 10^9+7, where \varphi d... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N.
In order to collect these balls, Snuke prepared 2N robots, N of type A and N of ty... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is D. When she input a number x to the vehicle, it will travel in the direction of the destinati... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a boolean function of three variables which is defined by its truth table. You need to find an expression of minimum length that equals to this function. The expression may consist of:
* Operation AND ('&', ASCII code 38)
* Operati... |
### Prompt
Please formulate a CPP solution to the following problem:
You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.
You need to permute the array elements so that value
<image> became minimal possible. In particular, it is allowed not to change or... |
### Prompt
Develop a solution in Cpp to the problem described below:
Before the start of the football season in Berland a strange magic ritual is held. The most experienced magicians have to find a magic matrix of the size n × n (n is even number). Gods will never allow to start the championship without it. Matrix sh... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another.... |
### Prompt
In CPP, your task is to solve the following problem:
Attention: we lost all the test cases for this problem, so instead of solving the problem, we need you to generate test cases. We're going to give you the answer, and you need to print a test case that produces the given answer. The original problem is i... |
### Prompt
Please create a solution in CPP to the following problem:
Little Petya likes to play very much. And most of all he likes to play the following game:
He is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. The goal of the game... |
### Prompt
Generate a Cpp solution to the following problem:
Dr .: Peter, I've finally done it.
Peter: What's wrong, Dr. David? Is it a silly invention again?
Dr .: This table, this table.
| Character | Sign
--- | ---
(Blank) | 101
'| 000000
, | 000011
-| 10010001
. | 010001
? | 000001
A | 100101
B | 10011010
| Cha... |
### Prompt
Your task is to create a cpp solution to the following problem:
There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimete... |
### Prompt
Please formulate a CPP solution to the following problem:
One day, BThero decided to play around with arrays and came up with the following problem:
You are given an array a, which consists of n positive integers. The array is numerated 1 through n. You execute the following procedure exactly once:
* Y... |
### Prompt
Please formulate a Cpp solution to the following problem:
You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.
Whil... |
### Prompt
Develop a solution in CPP to the problem described below:
At the children's festival, children were dancing in a circle. When music stopped playing, the children were still standing in a circle. Then Lena remembered, that her parents gave her a candy box with exactly k candies "Wilky May". Lena is not a gr... |
### Prompt
Generate a CPP solution to the following problem:
For a set $S$ of integers, perform a sequence of the following operations. Note that each value in $S$ must be unique.
* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.
* find($x$): Report the number of $x$ in $... |
### Prompt
Please formulate a CPP solution to the following problem:
You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Your task is to choose at most ⌊n/2⌋ vertices in this graph so each unc... |
### Prompt
Generate a Cpp solution to the following problem:
We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result.
Constraints
* ... |
### Prompt
Construct a cpp code solution to the problem outlined:
Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly ai bugs in every line of code that he writes.
Let's call a sequence of non... |
### Prompt
Please provide a CPP coded solution to the problem described below:
In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with t... |
### Prompt
Your task is to create a CPP solution to the following problem:
problem
You decide to invite your friends of the school and your friends of a friend to the Christmas party. The number of students in your school is n, and each student is assigned a number from 1 to n. Your number is 1. You have a list of w... |
### Prompt
Please create a solution in CPP to the following problem:
Little X has n distinct integers: p1, p2, ..., pn. He wants to divide all of them into two sets A and B. The following two conditions must be satisfied:
* If number x belongs to set A, then number a - x must also belong to set A.
* If number x... |
### Prompt
Your task is to create a Cpp solution to the following problem:
A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.
Limak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n... |
### Prompt
Develop a solution in cpp to the problem described below:
Consider a square grid with h rows and w columns with some dominoes on it. Each domino covers exactly two cells of the grid that share a common side. Every cell is covered by at most one domino.
Let's call a placement of dominoes on the grid perfec... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
You have a simple and connected undirected graph consisting of n nodes and m edges.
Consider any way to pair some subset of these n nodes such that no node is present in more than one pair.
This pairing is valid if for every pair of pai... |
### Prompt
In Cpp, your task is to solve the following problem:
In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short.
The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.
Given a string S of length N and an inte... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Ye... |
### Prompt
Your task is to create a CPP solution to the following problem:
There are n + 1 cities, numbered from 0 to n. n roads connect these cities, the i-th road connects cities i - 1 and i (i ∈ [1, n]).
Each road has a direction. The directions are given by a string of n characters such that each character is ei... |
### Prompt
Generate a Cpp solution to the following problem:
A monopole magnet is a magnet that only has one pole, either north or south. They don't actually exist since real magnets have two poles, but this is a programming contest problem, so we don't care.
There is an n× m grid. Initially, you may place some nort... |
### Prompt
Develop a solution in CPP to the problem described below:
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
BitHaval (the mayor of Bi... |
### Prompt
Create a solution in Cpp for the following problem:
Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the wo... |
### Prompt
Create a solution in cpp for the following problem:
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 of water into the... |
### Prompt
Your task is to create a cpp solution to the following problem:
Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number giv... |
### Prompt
Create a solution in cpp for the following problem:
There's a famous museum in the city where Kleofáš lives. In the museum, n exhibits (numbered 1 through n) had been displayed for a long time; the i-th of those exhibits has value vi and mass wi.
Then, the museum was bought by a large financial group and... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to... |
### Prompt
Your task is to create a cpp solution to the following problem:
In the city of Ultima Thule job applicants are often offered an IQ test.
The test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted ... |
### Prompt
Develop a solution in CPP to the problem described below:
Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given below:
//input: integers x, k, p
a = x;
for(step = 1; step <= k; step = step + 1){
rnd = [random integer from ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on t... |
### Prompt
Please formulate a cpp solution to the following problem:
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 r... |
### Prompt
Please formulate a Cpp solution to the following problem:
Cucumber boy is fan of Kyubeat, a famous music game.
Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.
Each panel has a timing to press (the preffered time when a player should press it)... |
### Prompt
Please provide a CPP coded solution to the problem described below:
On the math lesson a teacher asked each pupil to come up with his own lucky numbers. As a fan of number theory Peter chose prime numbers. Bob was more original. He said that number t is his lucky number, if it can be represented as:
t = ... |
### Prompt
Your task is to create a CPP solution to the following problem:
The Metropolis computer network consists of n servers, each has an encryption key in the range from 0 to 2^k - 1 assigned to it. Let c_i be the encryption key assigned to the i-th server. Additionally, m pairs of servers are directly connected... |
### Prompt
Please formulate a CPP solution to the following problem:
ZS the Coder is playing a game. There is a number displayed on the screen and there are two buttons, ' + ' (plus) and '<image>' (square root). Initially, the number 2 is displayed on the screen. There are n + 1 levels in the game and ZS the Coder st... |
### Prompt
Develop a solution in Cpp to the problem described below:
Due to the coronavirus pandemic, city authorities obligated citizens to keep a social distance. The mayor of the city Semyon wants to light up Gluharniki park so that people could see each other even at night to keep the social distance.
The park i... |
### Prompt
Develop a solution in Cpp to the problem described below:
Cat Snuke is learning to write characters. Today, he practiced writing digits `1` and `9`, but he did it the other way around.
You are given a three-digit integer n written by Snuke. Print the integer obtained by replacing each digit `1` with `9` a... |
### Prompt
In CPP, your task is to solve the following problem:
Programmer Sasha is a student at MIPT (Moscow Institute of Physics and Technology) and he needs to make a laboratory work to pass his finals.
A laboratory unit is a plane with standard coordinate axes marked on it. Physicists from Moscow Institute of Ph... |
### Prompt
Create a solution in Cpp for the following problem:
"Eat a beaver, save a tree!" — That will be the motto of ecologists' urgent meeting in Beaverley Hills.
And the whole point is that the population of beavers on the Earth has reached incredible sizes! Each day their number increases in several times and ... |
### Prompt
Please formulate a Cpp solution to the following problem:
Yeah, we failed to make up a New Year legend for this problem.
A permutation of length n is an array of n integers such that every integer from 1 to n appears in it exactly once.
An element y of permutation p is reachable from element x if x = y,... |
### Prompt
Please create a solution in CPP to the following problem:
Guy-Manuel and Thomas are going to build a polygon spaceship.
You're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by ve... |
### Prompt
Develop a solution in CPP to the problem described below:
The prestigious Codeforces kindergarten consists of n kids, numbered 1 through n. Each of them are given allowance in rubles by their parents.
Today, they are going to the most famous candy shop in the town. The shop sells candies in packages: for ... |
### Prompt
Your task is to create a CPP solution to the following problem:
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. Fi... |
### Prompt
Please create a solution in CPP to the following problem:
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You are given an integer sequence of length N: A_1,A_2,...,A_N. Let us perform Q operations in order. The i-th operation is described by two integers X_i and Y_i. In this operation, we will choose one of the following two actions and perform it:
* Swa... |
### Prompt
Generate a cpp solution to the following problem:
The Smart Beaver has recently designed and built an innovative nanotechnologic all-purpose beaver mass shaving machine, "Beavershave 5000". Beavershave 5000 can shave beavers by families! How does it work? Very easily!
There are n beavers, each of them has... |
### Prompt
Develop a solution in Cpp to the problem described below:
It turns out that you are a great fan of rock band AC/PE. Peter learned that and started the following game: he plays the first song of the list of n songs of the group, and you have to find out the name of the song. After you tell the song name, Pe... |
### Prompt
Please create a solution in CPP to the following problem:
Gosha's universe is a table consisting of n rows and m columns. Both the rows and columns are numbered with consecutive integers starting with 1. We will use (r, c) to denote a cell located in the row r and column c.
Gosha is often invited somewher... |
### Prompt
Construct a CPP code solution to the problem outlined:
Let's consider all integers in the range from 1 to n (inclusive).
Among all pairs of distinct integers in this range, find the maximum possible greatest common divisor of integers in pair. Formally, find the maximum value of gcd(a, b), where 1 ≤ a < b... |
### Prompt
Please provide a CPP coded solution to the problem described below:
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i.
Consider painting each of these edges white or black. There are 2^{N-1} such ways to paint the edges. Among them, how many satis... |
### Prompt
Your task is to create a Cpp solution to the following problem:
In AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows:
* Rating 1-399 : gray
* Rating 400-799 : brown
* Rating 800-1199 : green
* Rating 1200-1599 : cyan
* Rating 1600-199... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Takahashi loves sorting.
He has a permutation (p_1,p_2,...,p_N) of the integers from 1 through N. Now, he will repeat the following operation until the permutation becomes (1,2,...,N):
* First, we will define high and low elements in the permutation,... |
### Prompt
Please formulate a CPP solution to the following problem:
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
Initially all vertices contain number 0. Then come q queries, each query has one of the two types:
* The format of the query: 1... |
### Prompt
Your task is to create a Cpp solution to the following problem:
In 2300, the Life Science Division of Federal Republic of Space starts a very ambitious project to complete the genome sequencing of all living creatures in the entire universe and develop the genomic database of all space life. Thanks to scie... |
### Prompt
In cpp, your task is to solve the following problem:
Once upon a time, there was a traveler.
He plans to travel using stagecoaches (horse wagons). His starting point and destination are fixed, but he cannot determine his route. Your job in this problem is to write a program which determines the route for ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You have a directed acyclic graph G, consisting of n vertexes, numbered from 0 to n - 1. The graph contains n edges numbered from 0 to n - 1. An edge with number i connects vertexes i and (i + 1) mod n, and it can be directed in either dir... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
There are N balls in a row. Initially, the i-th ball from the left has the integer A_i written on it.
When Snuke cast a spell, the following happens:
* Let the current number of balls be k. All the balls with k written on them disappear ... |
### Prompt
Develop a solution in cpp to the problem described below:
Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob takes one of the other two piles. The last pile is split between Alice... |
### Prompt
Construct a CPP code solution to the problem outlined:
Akira, the student council president of A High School, decided to investigate which club activities the A High School students belong to. A High School has N students numbered 1 to N and M types of club activities numbered 1 to M. There is no limit to ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You are given a tree (an undirected connected acyclic graph) consisting of n vertices and n - 1 edges. A number is written on each edge, each number is either 0 (let's call such edges 0-edges) or 1 (those are 1-edges).
Let's call an ordered p... |
### Prompt
Please create a solution in cpp to the following problem:
In Berland the opposition is going to arrange mass walking on the boulevard. The boulevard consists of n tiles that are lain in a row and are numbered from 1 to n from right to left. The opposition should start walking on the tile number 1 and the f... |
### Prompt
In cpp, your task is to solve the following problem:
DZY has a sequence a, consisting of n integers.
We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such... |
### Prompt
Please create a solution in Cpp to the following problem:
Consider a tree (that is, an undirected connected graph without loops) T_1 and a tree T_2. Let's define their cartesian product T_1 × T_2 in a following way.
Let V be the set of vertices in T_1 and U be the set of vertices in T_2.
Then the set of ... |
### Prompt
Construct a cpp code solution to the problem outlined:
B: Nakajima, let's do that! --Match Peas War -
problem
Nakajima "Uhh ..."
Isono "Nakajima, are you okay?"
Nakajima "... I feel like I was having an unpleasant dream."
Isono "What kind of dream do you have?"
Nakajima "Dream to play infinitely"
Is... |
### Prompt
Construct a CPP code solution to the problem outlined:
Snuke has a string s. From this string, Anuke, Bnuke, and Cnuke obtained strings a, b, and c, respectively, as follows:
* Choose a non-empty (contiguous) substring of s (possibly s itself). Then, replace some characters (possibly all or none) in it wi... |
### Prompt
Please formulate a cpp solution to the following problem:
Your company’s next product will be a new game, which is a three-dimensional variant of the classic game “Tic-Tac-Toe”. Two players place balls in a three-dimensional space (board), and try to make a sequence of a certain length.
People believe tha... |
### Prompt
Create a solution in Cpp for the following problem:
Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so he can return and take the deceased Aemon's place a... |
### Prompt
In Cpp, your task is to solve the following problem:
In this problem, your task is to use ASCII graphics to paint a cardiogram.
A cardiogram is a polyline with the following corners:
<image>
That is, a cardiogram is fully defined by a sequence of positive integers a1, a2, ..., an.
Your task is to pain... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Limak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.
There are n candidates, including Limak. We know how many citizens are going to vote for each candidate. Now i-th c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.