text stringlengths 424 69.5k |
|---|
### Prompt
Generate a cpp solution to the following problem:
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 Bitland) l... |
### Prompt
In Cpp, your task is to solve the following problem:
Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the center of the city with a nice price.
Plan of the apartment found by Arthur looks like a rectangle n × m consisting of squares of size 1 × 1. ... |
### Prompt
Create a solution in CPP for the following problem:
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:
* The graph is simple and connected.
* There exists an integer S such that, for every vertex, the sum of the indices of... |
### Prompt
Generate a Cpp solution to the following problem:
Recently Monocarp got a job. His working day lasts exactly m minutes. During work, Monocarp wants to drink coffee at certain moments: there are n minutes a_1, a_2, ..., a_n, when he is able and willing to take a coffee break (for the sake of simplicity let'... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
For an array a of integers let's denote its maximal element as max(a), and minimal as min(a). We will call an array a of k integers interesting if max(a) - min(a) ≥ k. For example, array [1, 3, 4, 3] isn't interesting as max(a) - min(a) = ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Given is a string S of length N-1. Each character in S is `<` or `>`.
A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1):
* If S_i= `<`: a... |
### Prompt
Please provide a cpp coded solution to the problem described below:
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; ... |
### Prompt
Generate a Cpp solution to the following problem:
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x... |
### Prompt
Construct a cpp code solution to the problem outlined:
In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.
More precisely, two different numbers a and b are friends if gcd(a,b), (a)/(gcd(a,b)), (b)/(gcd(a,b)) can form sides of a triangle.
T... |
### Prompt
Generate a Cpp solution to the following problem:
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence a that consists of n intege... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (which, as wikipedia st... |
### Prompt
Develop a solution in CPP to the problem described below:
Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from 1 to n and then 3n times takes a ra... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Edo has got a collection of n refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator do... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has ai coins.
Polycarpus and Vasily move in turns. Polycarpus moves first. D... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You have a bag of size n. Also you have m boxes. The size of i-th box is a_i, where each a_i is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example... |
### Prompt
Generate a Cpp solution to the following problem:
User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below.
1. At first, the score is 0.
2. For each block of c... |
### Prompt
Generate 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 in the path u-... |
### Prompt
Please formulate a Cpp solution to the following problem:
Berland scientists face a very important task - given the parts of short DNA fragments, restore the dinosaur DNA! The genome of a berland dinosaur has noting in common with the genome that we've used to: it can have 26 distinct nucleotide types, a n... |
### Prompt
Please formulate a CPP solution to the following problem:
Little Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is ai. The mood can be positive, zero or negative.
Let's define a subarray as a segment of consecutive flowers. Th... |
### Prompt
Please provide a cpp coded solution to the problem described below:
While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should find the number of d... |
### Prompt
In cpp, your task is to solve the following problem:
There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exactly z swords of some single type. ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
There was once young lass called Mary,
Whose jokes were occasionally scary.
On this April's Fool
Fixed limerick rules
Allowed her to trip the unwary.
Can she fill all the lines
To work... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Vasya has written some permutation p_1, p_2, …, p_n of integers from 1 to n, so for all 1 ≤ i ≤ n it is true that 1 ≤ p_i ≤ n and all p_1, p_2, …, p_n are different. After that he wrote n numbers next_1, next_2, …, next_n. The number next_i is equal to... |
### Prompt
Please formulate a Cpp solution to the following problem:
Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.
Artem wants to create a basic multiset o... |
### Prompt
Create a solution in CPP for the following problem:
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.
One day i... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:
"Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to ... |
### Prompt
Please create a solution in cpp to the following problem:
You are given an integer x of n digits a_1, a_2, …, a_n, which make up its decimal notation in order from left to right.
Also, you are given a positive integer k < n.
Let's call integer b_1, b_2, …, b_m beautiful if b_i = b_{i+k} for each i, such ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Let's consider an n × n square matrix, consisting of digits one and zero.
We'll consider a matrix good, if it meets the following condition: in each row of the matrix all ones go in one group. That is, each row of the matrix looks like th... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion:
* An 'L' indicates he should move one unit left.
* An 'R' indicates he should move one unit righ... |
### Prompt
Please create a solution in Cpp to the following problem:
In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the si... |
### Prompt
Please provide a cpp coded solution to the problem described below:
The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows.
There are two armies on the playin... |
### Prompt
Construct a cpp code solution to the problem outlined:
Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers.
Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all num... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
What are you doing at the end of the world? Are you busy? Will you save us?
<image>
Nephren is playing a game with little leprechauns.
She gives them an infinite array of strings, f0... ∞.
f0 is "What are you doing at the end of the wo... |
### Prompt
Please formulate a Cpp solution to the following problem:
While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the... |
### Prompt
Your task is to create a CPP solution to the following problem:
To stay woke and attentive during classes, Karen needs some coffee!
<image>
Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books... |
### Prompt
Please create a solution in cpp to the following problem:
We define x mod y as the remainder of division of x by y (\% operator in C++ or Java, mod operator in Pascal).
Let's call an array of positive integers [a_1, a_2, ..., a_k] stable if for every permutation p of integers from 1 to k, and for every no... |
### Prompt
Your task is to create a CPP solution to the following problem:
Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.
There were n classes of that subject dur... |
### Prompt
Your task is to create a CPP solution to the following problem:
The Cereal Guy's friend Serial Guy likes to watch soap operas. An episode is about to start, and he hasn't washed his plate yet. But he decided to at least put in under the tap to be filled with water. The plate can be represented by a paralle... |
### Prompt
Develop a solution in CPP to the problem described below:
Petya and Vasya are playing a game. Petya's got n non-transparent glasses, standing in a row. The glasses' positions are indexed with integers from 1 to n from left to right. Note that the positions are indexed but the glasses are not.
First Petya ... |
### Prompt
In cpp, your task is to solve the following problem:
On Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. They use only a single stone. The purpose of the g... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You are given an array s consisting of n integers.
You have to find any array t of length k such that you can cut out maximum number of copies of array t from array s.
Cutting out the copy of t means that for each element t_i of array t you have to f... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter.
The garland must... |
### Prompt
Develop a solution in CPP to the problem described below:
Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from 1 to n. For every edge e of this tree, Monocarp has written two numbers: the maximum indices of the vert... |
### Prompt
Your task is to create a cpp solution to the following problem:
Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight road across the farm and n hills along the road, numbered from 1 to n from left to right. The distance between hill i and (i - 1) is di meters. ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it.
But I also don't want to use many numbers, so I'll choose three positive integers (they do... |
### Prompt
Create a solution in CPP for the following problem:
Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:
* for the array [0, 0, 1, 0, 2] MEX equals to 3 because numbers 0, 1 and 2 are presented in the array and 3 is the minimum non-negative integer n... |
### Prompt
Your task is to create a cpp solution to the following problem:
The sequence of integers a_1, a_2, ..., a_k is called a good array if a_1 = k - 1 and a_1 > 0. For example, the sequences [3, -1, 44, 0], [1, -99] are good arrays, and the sequences [3, 7, 8], [2, 5, 4, 1], [0] — are not.
A sequence of intege... |
### Prompt
Construct a CPP code solution to the problem outlined:
This is the easy version of this problem. The only difference is the limit of n - the length of the input string. In this version, 1 ≤ n ≤ 2000. The hard version of this challenge is not offered in the round for the second division.
Let's define a co... |
### Prompt
Please formulate a CPP solution to the following problem:
Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed an... |
### Prompt
Please provide a cpp coded solution to the problem described below:
There are n bears in the inn and p places to sleep. Bears will party together for some number of nights (and days).
Bears love drinking juice. They don't like wine but they can't distinguish it from juice by taste or smell.
A bear doesn'... |
### Prompt
Construct a cpp code solution to the problem outlined:
And here goes another problem on arrays. You are given positive integer len and array a which consists of n integers a1, a2, ..., an. Let's introduce two characteristics for the given array.
* Let's consider an arbitrary interval of the array with l... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Opposite to Grisha's nice behavior, Oleg, though he has an entire year at his disposal, didn't manage to learn how to solve number theory problems in the past year. That's why instead of Ded Moroz he was visited by his teammate Andrew, who... |
### Prompt
Please formulate a CPP solution to the following problem:
You have n devices that you want to use simultaneously.
The i-th device uses ai units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·ai units of power. The i-th device currently has bi units of power sto... |
### Prompt
Create a solution in cpp for the following problem:
Simon has a prime number x and an array of non-negative integers a1, a2, ..., an.
Simon loves fractions very much. Today he wrote out number <image> on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a f... |
### Prompt
Please formulate a cpp solution to the following problem:
The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from numbe... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Pasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.
Pasha didn't like ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and ... |
### Prompt
Develop a solution in CPP to the problem described below:
There is an infinite board of square tiles. Initially all tiles are white.
Vova has a red marker and a blue marker. Red marker can color a tiles. Blue marker can color b tiles. If some tile isn't white then you can't use marker of any color on it. ... |
### Prompt
Please formulate a Cpp solution to the following problem:
Find bridges of an undirected graph G(V, E).
A bridge (also known as a cut-edge) is an edge whose deletion increase the number of connected components.
Constraints
* 1 ≤ |V| ≤ 100,000
* 0 ≤ |E| ≤ 100,000
* The graph is connected
* There are no pa... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
There are A slimes lining up in a row. Initially, the sizes of the slimes are all 1.
Snuke can repeatedly perform the following operation.
* Choose a positive even number M. Then, select M consecutive slimes and form M / 2 pairs from tho... |
### Prompt
Develop a solution in Cpp to the problem described below:
We have a grid with N rows and M columns of squares. Each integer from 1 to NM is written in this grid once. The number written in the square at the i-th row from the top and the j-th column from the left is A_{ij}.
You need to rearrange these numb... |
### Prompt
Create a solution in cpp for the following problem:
Sagheer is playing a game with his best friend Soliman. He brought a tree with n nodes numbered from 1 to n and rooted at node 1. The i-th node has ai apples. This tree has a special property: the lengths of all paths from the root to any leaf have the sa... |
### Prompt
Create a solution in cpp for the following problem:
This is an interactive problem. Remember to flush your output while communicating with the testing program. You may use fflush(stdout) in C++, system.out.flush() in Java, stdout.flush() in Python or flush(output) in Pascal to flush the output. If you use ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t.
Help Chewbacca to transform the initial number x to the mini... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Problem D: Mr. Rito Post Office
You are a programmer working at a post office on a remote island. The area you live in consists of multiple islands. There is one or more port towns on each island. There may be other towns and villages in addition to t... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
In this problem you will write a simple code generator for a 2D programming language derived from [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck).
The code in this language is a rectangular grid of characters '.' and 'X'. The code is... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
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
Your task is to create a Cpp solution to the following problem:
An electrical grid in Berland palaces consists of 2 grids: main and reserve. Wires in palaces are made of expensive material, so selling some of them would be a good idea!
Each grid (main and reserve) has a head node (its number is 1). Every ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
The last stage of Football World Cup is played using the play-off system.
There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their i... |
### Prompt
Generate a cpp solution to the following problem:
You are given a table consisting of n rows and m columns.
Numbers in each row form a permutation of integers from 1 to m.
You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than once you are al... |
### Prompt
In CPP, your task is to solve the following problem:
Berhattan is the capital of Berland. There are n streets running parallel in the east-west direction (horizontally), and there are m avenues running parallel in the south-north direction (vertically). Each street intersects with each avenue, forming a cr... |
### Prompt
Please create a solution in Cpp to the following problem:
There are some ambiguities when one writes Berland names with the letters of the Latin alphabet.
For example, the Berland sound u can be written in the Latin alphabet as "u", and can be written as "oo". For this reason, two words "ulyana" and "ooly... |
### Prompt
Your task is to create a CPP solution to the following problem:
Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4 pieces, each of size n by n, n is always odd. And what's even worse, some squares were of wrong color. j-th s... |
### 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 a weighted directed graph, consisting of n vertices and m edges. You should answer q queries of two types:
* 1 v — find the length of shortest path from vertex 1 to vertex v.
* 2 c l1 l2 ... lc — add 1 to weights of edg... |
### Prompt
Your task is to create a Cpp solution to the following problem:
There are three cells on an infinite 2-dimensional grid, labeled A, B, and F. Find the length of the shortest path from A to B if:
* in one move you can go to any of the four adjacent cells sharing a side;
* visiting the cell F is forbi... |
### Prompt
Your task is to create a cpp solution to the following problem:
A festival will be held in a town's main street. There are n sections in the main street. The sections are numbered 1 through n from left to right. The distance between each adjacent sections is 1.
In the festival m fireworks will be launched... |
### Prompt
Generate a Cpp solution to the following problem:
There are N cities on a number line. The i-th city is located at coordinate x_i.
Your objective is to visit all these cities at least once.
In order to do so, you will first set a positive integer D.
Then, you will depart from coordinate X and perform Mo... |
### Prompt
Your task is to create a cpp solution to the following problem:
One day, Takahashi was given the following problem from Aoki:
* You are given a tree with N vertices and an integer K. The vertices are numbered 1 through N. The edges are represented by pairs of integers (a_i, b_i).
* For a set S of vertices... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it No... |
### Prompt
Create a solution in CPP for the following problem:
You are given an n × m table, consisting of characters «A», «G», «C», «T». Let's call a table nice, if every 2 × 2 square contains all four distinct characters. Your task is to find a nice table (also consisting of «A», «G», «C», «T»), that differs from t... |
### Prompt
Generate a CPP solution to the following problem:
Create a program that calculates and outputs the surface distance by inputting the north latitude and east longitude of two cities on the earth. However, the earth is a sphere with a radius of 6,378.1 km, and the surface distance between two points is the s... |
### Prompt
Create a solution in cpp for the following problem:
Inaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≤ i < n) are adjacent, and so are points n and 1.
There are m straight segments on t... |
### Prompt
Generate a CPP solution to the following problem:
Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is described b... |
### Prompt
Your task is to create a CPP solution to the following problem:
There are N squares in a row, numbered 1 through N from left to right. Snuke and Rng are playing a board game using these squares, described below:
1. First, Snuke writes an integer into each square.
2. Each of the two players possesses one p... |
### Prompt
Please formulate a cpp solution to the following problem:
Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that c... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given a sequence of n integers a1, a2, ..., an.
Determine a real number x such that the weakness of the sequence a1 - x, a2 - x, ..., an - x is as small as possible.
The weakness of a sequence is defined as the maximum value of ... |
### Prompt
Please create a solution in Cpp to the following problem:
Limak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.
He considers a polynomial valid if its degree is n and its coefficients are integers not exceeding k by the absolute value. More formally:
Let a0, a1... |
### Prompt
Please create a solution in CPP to the following problem:
You are given a tree with n vertices. You are allowed to modify the structure of the tree through the following multi-step operation:
1. Choose three vertices a, b, and c such that b is adjacent to both a and c.
2. For every vertex d other tha... |
### Prompt
Generate a Cpp solution to the following problem:
Little Petya loves counting. He wants to count the number of ways to paint a rectangular checkered board of size n × m (n rows, m columns) in k colors. Besides, the coloring should have the following property: for any vertical line that passes along the gri... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 1 to... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
<image>
As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-por... |
### Prompt
Generate a cpp solution to the following problem:
Iahub is very proud of his recent discovery, propagating trees. Right now, he invented a new tree, called xor-tree. After this new revolutionary discovery, he invented a game for kids which uses xor-trees.
The game is played on a tree having n nodes, numbe... |
### Prompt
Please formulate a Cpp solution to the following problem:
Two countries, Country A and Country B, are at war. As a soldier in Country A, you will lead n soldiers to occupy the territory of Country B.
The territory of Country B is represented by a two-dimensional grid. The first place you occupy is a squar... |
### Prompt
In cpp, your task is to solve the following problem:
Leonid wants to become a glass carver (the person who creates beautiful artworks by cutting the glass). He already has a rectangular w mm × h mm sheet of glass, a diamond glass cutter and lots of enthusiasm. What he lacks is understanding of what to ca... |
### Prompt
Please create a solution in CPP to the following problem:
Cosmic market, commonly known as Kozumike, is the largest coterie spot sale in the universe. Doujin lovers of all genres gather at Kozumike. In recent years, the number of visitors to Kozumike has been increasing. If everyone can enter from the begi... |
### Prompt
Please create a solution in Cpp to the following problem:
You are given an array a_1, a_2, ... , a_n and two integers m and k.
You can choose some subarray a_l, a_{l+1}, ..., a_{r-1}, a_r.
The cost of subarray a_l, a_{l+1}, ..., a_{r-1}, a_r is equal to ∑_{i=l}^{r} a_i - k ⌈ (r - l + 1)/(m) ⌉, where ⌈ x... |
### Prompt
Please create a solution in Cpp to the following problem:
You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for exampl... |
### Prompt
Generate a cpp solution to the following problem:
Nezzar loves the game osu!.
osu! is played on beatmaps, which can be seen as an array consisting of distinct points on a plane. A beatmap is called nice if for any three consecutive points A,B,C listed in order, the angle between these three points, center... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.