text stringlengths 424 69.5k |
|---|
### Prompt
Create a solution in CPP for the following problem:
All space-time unified dimension sugoroku tournament. You are representing the Earth in the 21st century in the tournament, which decides only one Sugoroku absolute champion out of more than 500 trillion participants.
The challenge you are currently chal... |
### Prompt
Please formulate a CPP solution to the following problem:
Polycarpus has got n candies and m friends (n ≥ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choos... |
### Prompt
Please create a solution in Cpp to the following problem:
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts 1 minute.
He was ask... |
### Prompt
Please provide a CPP coded solution to the problem described below:
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on ... |
### Prompt
Your task is to create a CPP solution to the following problem:
During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known traditi... |
### Prompt
Your task is to create a CPP solution to the following problem:
The R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke.
R2 has m Spyke chats just to dis... |
### Prompt
Create a solution in Cpp for the following problem:
You have unweighted tree of n vertices. You have to assign a positive weight to each edge so that the following condition would hold:
* For every two different leaves v_{1} and v_{2} of this tree, [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_ope... |
### Prompt
Please formulate a cpp solution to the following problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).
For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.
We say a set of c... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Berland has n cities, some of which are connected by roads. Each road is bidirectional, connects two distinct cities and for each two cities there's at most one road connecting them.
The president of Berland decided to split country into r states in s... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.
Though there are lots and lots of victories in history of Berland, there is the one that stand o... |
### Prompt
In Cpp, your task is to solve the following problem:
There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.
On this sequence, Snuke can perform the following operation:
* Choose K consecutive elements in the sequence. Then, replace the value of eac... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Of course you have heard the famous task about Hanoi Towers, but did you know that there is a special factory producing the rings for this wonderful game? Once upon a time, the ruler of the ancient Egypt ordered the workers of Hanoi Factor... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
We have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added.
We will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infinitely many edges to... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Rick and Morty are playing their own version of Berzerk (which has nothing in common with the famous Berzerk game). This game needs a huge space, so they play it with a computer.
In this game there are n objects numbered from 1 to n arran... |
### Prompt
Create a solution in cpp for the following problem:
Example
Input
2 1
WE
Output
1 2
### Response
```cpp
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int ... |
### Prompt
In CPP, your task is to solve the following problem:
Take the'IOI'train
A new railway has been laid in IOI. Trains running on railways in IOI are a combination of several vehicles, and there are two types of vehicles, I and O. Vehicles can only be connected to different types of vehicles. Also, because th... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Recently Anton found a box with digits in his room. There are k2 digits 2, k3 digits 3, k5 digits 5 and k6 digits 6.
Anton's favorite integers are 32 and 256. He decided to compose this integers from digits he has. He wants to make the su... |
### Prompt
Develop a solution in cpp to the problem described below:
Due to atheistic Soviet past, Christmas wasn't officially celebrated in Russia for most of the twentieth century. As a result, the Russian traditions for Christmas and New Year mixed into one event celebrated on the New Year but including the tree, ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
The polar bears are going fishing. They plan to sail from (sx, sy) to (ex, ey). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at... |
### Prompt
Your task is to create a cpp solution to the following problem:
One day, the lord ordered a carpenter to "build a sturdy and large building where the townspeople could evacuate in the event of a typhoon or earthquake." However, large thick pillars are needed to complete the sturdy and large building. There... |
### Prompt
Please create a solution in CPP to the following problem:
[Thanos sort](https://codegolf.stackexchange.com/questions/182221/implement-the-thanos-sorting-algorithm) is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers* to remove the first or the second h... |
### Prompt
Develop a solution in Cpp to the problem described below:
There are two rooted trees, each with N vertices. The vertices of each tree are numbered 1 through N. In the first tree, the parent of Vertex i is Vertex A_i. Here, A_i=-1 if Vertex i is the root of the first tree. In the second tree, the parent of ... |
### Prompt
Develop a solution in CPP to the problem described below:
You are given two huge binary integer numbers a and b of lengths n and m respectively. You will repeat the following process: if b > 0, then add to the answer the value a~ \&~ b and divide b by 2 rounding down (i.e. remove the last digit of b), and ... |
### Prompt
In Cpp, your task is to solve the following problem:
This is the easy version of the problem. The difference between the versions is that in the easy version all prices a_i are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go s... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Peter decided to lay a parquet in the room of size n × m, the parquet consists of tiles of size 1 × 2. When the workers laid the parquet, it became clear that the tiles pattern looks not like Peter likes, and workers will have to re-lay it.
The worker... |
### Prompt
Please create a solution in CPP to the following problem:
We are given a permutation sequence a1, a2, ..., an of numbers from 1 to n. Let's assume that in one second, we can choose some disjoint pairs (u1, v1), (u2, v2), ..., (uk, vk) and swap all aui and avi for every i at the same time (1 ≤ ui < vi ≤ n).... |
### Prompt
In CPP, your task is to solve the following problem:
Consider the following game for two players. There is one white token and some number of black tokens. Each token is placed on a plane in a point with integer coordinates x and y.
The players take turn making moves, white starts. On each turn, a player ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Matrix of given integers
a1,1 a1,2 ... a1, n
a2,1 a2,2 ... a2, n
::
an, 1 an, 2 ... an, n
Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directio... |
### Prompt
Create a solution in cpp for the following problem:
Peace, which was supposed to last forever, suddenly ended. The Demon King, who had been sealed long ago, has finally revived. But when the world was about to be covered in darkness, a brave man appeared. The hero then set out on a journey to collect legen... |
### Prompt
Please formulate a cpp solution to the following problem:
Example
Input
3 3 1 2 4
1 2
2 3
3 1
Output
IMPOSSIBLE
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
struct Node {
int d, x;
Node(int _x = 0, int _d = 0):d(_d), x(_x) {}
};
int n, m, X[5], ... |
### Prompt
Please formulate a Cpp solution to the following problem:
In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a to ci... |
### Prompt
Generate a CPP solution to the following problem:
Yaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign of exactly n elements in the array. In other words, in one operation Yaroslav can select exactly n array elements, and multiply each of them by -1.
... |
### Prompt
Develop a solution in cpp to the problem described below:
Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to an apple store.
Jzzhu will pack his apples into groups and then sell them. Each group must contain two apples, and the greates... |
### Prompt
Your task is to create a Cpp solution to the following problem:
A balancing network is an abstract device built up of N wires, thought of as running from left to right, and M balancers that connect pairs of wires. The wires are numbered from 1 to N from top to bottom, and the balancers are numbered from 1 ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Nagini, being a horcrux You-know-who created with the murder of Bertha Jorkins, has accumulated its army of snakes and is launching an attack on Hogwarts school.
Hogwarts' entrance can be imagined as a straight line (x-axis) from 1 to 10... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a positive integer n. In one move, you can increase n by one (i.e. make n := n + 1). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.
Yo... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer.
Snuke's objective is to permute the element in a so that the following condition is satisfied:
* For each 1 ≤ i ≤ N - 1, the product of a_i and a_{... |
### Prompt
Construct a cpp code solution to the problem outlined:
You are given an integer n and an integer k.
In one step you can do one of the following moves:
* decrease n by 1;
* divide n by k if n is divisible by k.
For example, if n = 27 and k = 3 you can do the following steps: 27 → 26 → 25 → 24 → ... |
### Prompt
Develop a solution in CPP to the problem described below:
Some days ago, WJMZBMR learned how to answer the query "how many times does a string x occur in a string s" quickly by preprocessing the string s. But now he wants to make it harder.
So he wants to ask "how many consecutive substrings of s are cycl... |
### Prompt
Generate a Cpp solution to the following problem:
This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers a_1, a_2, ..., a_n.
A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken ship lyin... |
### Prompt
Create a solution in Cpp for the following problem:
Dragon's Cruller is a sliding puzzle on a torus. The torus surface is partitioned into nine squares as shown in its development in Figure E.1. Here, two squares with one of the sides on the development labeled with the same letter are adjacent to each oth... |
### Prompt
Develop a solution in CPP to the problem described below:
Bob is an avid fan of the video game "League of Leesins", and today he celebrates as the League of Leesins World Championship comes to an end!
The tournament consisted of n (n ≥ 5) teams around the world. Before the tournament starts, Bob has made... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card.
The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from th... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P_i ≤ 1000
* 1 ≤ Q ≤ 10000
* The input consists of alphabetical char... |
### Prompt
Please formulate a Cpp solution to the following problem:
Well, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched it, or he is unsure, has he wat... |
### Prompt
Create a solution in cpp for the following problem:
Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:
You are given an array a of n integers. ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes.
<image>
Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes ... |
### Prompt
Create a solution in Cpp for the following problem:
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order.
After checking some examples, she found out that sometimes ... |
### Prompt
Create a solution in CPP for the following problem:
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi and Aoki will arrange these integers in a row, as follows:
* First, Takahashi will arrange the integers as he wishes.
* Then, Aoki will repeatedly swap two adjacent integer... |
### Prompt
Please create a solution in Cpp to the following problem:
You should process m queries over a set D of strings. Each query is one of three kinds:
1. Add a string s to the set D. It is guaranteed that the string s was not added before.
2. Delete a string s from the set D. It is guaranteed that the str... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
You are given a weighted tree consisting of n vertices. Recall that a tree is a connected graph without cycles. Vertices u_i and v_i are connected by an edge with weight w_i.
You are given m queries. The i-th query is given as an integer ... |
### Prompt
Please create a solution in cpp to the following problem:
You are both a shop keeper and a shop assistant at a small nearby shop. You have n goods, the i-th good costs a_i coins.
You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Vasya came up with a password to register for EatForces — a string s. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits.
But since EatForces takes care of the security of its user... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You've got another geometrical task. You are given two non-degenerate polygons A and B as vertex coordinates. Polygon A is strictly convex. Polygon B is an arbitrary polygon without any self-intersections and self-touches. The vertices of both... |
### Prompt
Construct a CPP code solution to the problem outlined:
Mahmoud wants to send a message to his friend Ehab. Their language consists of n words numbered from 1 to n. Some words have the same meaning so there are k groups of words such that all the words in some group have the same meaning.
Mahmoud knows tha... |
### Prompt
Construct a CPP code solution to the problem outlined:
According to a new ISO standard, a flag of every country should have, strangely enough, a chequered field n × m, each square should be wholly painted one of 26 colours. The following restrictions are set:
* In each row at most two different colours... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Vanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got grade ai for the i-th... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Toastman came up with a very complicated task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?
Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o', or nothing... |
### Prompt
Construct a CPP code solution to the problem outlined:
There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters ... |
### Prompt
Construct a CPP code solution to the problem outlined:
Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.
You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct... |
### Prompt
Your task is to create a cpp solution to the following problem:
Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum of n... |
### Prompt
Your task is to create a cpp solution to the following problem:
Furlo and Rublo play a game. The table has n piles of coins lying on it, the i-th pile has ai coins. Furlo and Rublo move in turns, Furlo moves first. In one move you are allowed to:
* choose some pile, let's denote the current number of co... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
In some country live wizards. They love to ride trolleybuses.
A city in this country has a trolleybus depot with n trolleybuses. Every day the trolleybuses leave the depot, one by one and go to the final station. The final station is at a... |
### Prompt
Please formulate a cpp solution to the following problem:
Dreamoon likes coloring cells very much.
There is a row of n cells. Initially, all cells are empty (don't contain any color). Cells are numbered from 1 to n.
You are given an integer m and m integers l_1, l_2, …, l_m (1 ≤ l_i ≤ n)
Dreamoon will p... |
### Prompt
Please create a solution in cpp to the following problem:
Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a square. In ot... |
### Prompt
Develop a solution in CPP to the problem described below:
An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:
* Form groups consisting of A_i children each!
Then the children who are still in the game form a... |
### Prompt
Please create a solution in CPP to the following problem:
You are given a prime number p, n integers a_1, a_2, …, a_n, and an integer k.
Find the number of pairs of indexes (i, j) (1 ≤ i < j ≤ n) for which (a_i + a_j)(a_i^2 + a_j^2) ≡ k mod p.
Input
The first line contains integers n, p, k (2 ≤ n ≤ 3 ⋅... |
### Prompt
Please formulate a CPP solution to the following problem:
George loves graphs. Most of all, he loves interesting graphs. We will assume that a directed graph is interesting, if it meets the following criteria:
* The graph doesn't contain any multiple arcs;
* There is vertex v (we'll call her the cen... |
### Prompt
Generate a Cpp solution to the following problem:
Harry, upon inquiring Helena Ravenclaw's ghost, came to know that she told Tom Riddle or You-know-who about Rowena Ravenclaw's diadem and that he stole it from her.
Harry thought that Riddle would have assumed that he was the only one to discover the Room... |
### Prompt
Your task is to create a cpp solution to the following problem:
There is a chain consisting of multiple circles on a plane. The first (last) circle of the chain only intersects with the next (previous) circle, and each intermediate circle intersects only with the two neighboring circles.
Your task is to f... |
### Prompt
In Cpp, your task is to solve the following problem:
Takahashi loves the number 7 and multiples of K.
Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)
If the sequence contains no multiples of K, print `-1` instead.
Constra... |
### Prompt
In cpp, your task is to solve the following problem:
Polycarp studies in Berland State University. Soon he will have to take his exam. He has to pass exactly n exams.
For the each exam i there are known two days: a_i — day of the first opportunity to pass the exam, b_i — day of the second opportunity to p... |
### Prompt
Please create a solution in Cpp to the following problem:
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.
The problem is ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Today the kindergarten has a new group of n kids who need to be seated at the dinner table. The chairs at the table are numbered from 1 to 4n. Two kids can't sit on the same chair. It is known that two kids who sit on chairs with numbers a and... |
### Prompt
Your task is to create a Cpp solution to the following problem:
In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and m... |
### Prompt
In CPP, your task is to solve the following problem:
Lee is going to fashionably decorate his house for a party, using some regular convex polygons...
Lee thinks a regular n-sided (convex) polygon is beautiful if and only if he can rotate it in such a way that at least one of its edges is parallel to the ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
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 ... |
### Prompt
Develop a solution in CPP to the problem described below:
Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.
Kuro challenged Katie to create a... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
There is a robot in a warehouse and n packages he wants to collect. The warehouse can be represented as a coordinate grid. Initially, the robot stays at the point (0, 0). The i-th package is at the point (x_i, y_i). It is guaranteed that t... |
### Prompt
Create a solution in Cpp for the following problem:
You are given an integer L. Construct a directed graph that satisfies the conditions below. The graph may contain multiple edges between the same pair of vertices. It can be proved that such a graph always exists.
* The number of vertices, N, is at most ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
* deletes ... |
### Prompt
Construct a cpp code solution to the problem outlined:
Greg has a pad. The pad's screen is an n × m rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to n from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to m... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Vasya is a Greencode wildlife preservation society proponent. One day he found an empty field nobody owned, divided it into n × m squares and decided to plant a forest there. Vasya will plant nm trees of all different heights from 1 to nm.... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
There are N arrays. The length of each array is M and initially each array contains integers (1,2,...,M) in this order.
Mr. Takahashi has decided to perform Q operations on those N arrays. For the i-th (1≤i≤Q) time, he performs the follow... |
### Prompt
Please formulate a cpp solution to the following problem:
Momiji has got a rooted tree, consisting of n nodes. The tree nodes are numbered by integers from 1 to n. The root has number 1. Momiji decided to play a game on this tree.
The game consists of several steps. On each step, Momiji chooses one of the... |
### Prompt
Please formulate a Cpp solution to the following problem:
Polycarp's phone book contains n phone numbers, each of them is described by s_i — the number itself and m_i — the number of times Polycarp dials it in daily.
Polycarp has just bought a brand new phone with an amazing speed dial feature! More preci... |
### Prompt
Your task is to create a CPP solution to the following problem:
Chris the Rabbit found the traces of an ancient Martian civilization. The brave astronomer managed to see through a small telescope an architecture masterpiece — "A Road to the Sun". The building stands on cubical stones of the same size. The ... |
### Prompt
Please create a solution in Cpp to the following problem:
Recently Vasya found a golden ticket — a sequence which consists of n digits a_1a_2... a_n. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket 350178 is lucky sin... |
### Prompt
Create a solution in CPP for the following problem:
Marcin is a coach in his university. There are n students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.
Let's focus on the students. They are indexed with integers... |
### Prompt
Create a solution in cpp for the following problem:
Word s of length n is called k-complete if
* s is a palindrome, i.e. s_i=s_{n+1-i} for all 1 ≤ i ≤ n;
* s has a period of k, i.e. s_i=s_{k+i} for all 1 ≤ i ≤ n-k.
For example, "abaaba" is a 3-complete word, while "abccba" is not.
Bob is given ... |
### Prompt
In cpp, your task is to solve the following problem:
There are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball. The integer written on the i-th ball from the left... |
### Prompt
Create a solution in cpp for the following problem:
You have a grid with n rows and n columns. Each cell is either empty (denoted by '.') or blocked (denoted by 'X').
Two empty cells are directly connected if they share a side. Two cells (r1, c1) (located in the row r1 and column c1) and (r2, c2) are conn... |
### Prompt
Your task is to create a CPP solution to the following problem:
The only difference between easy and hard versions is the size of the input.
You are given a string s consisting of n characters, each character is 'R', 'G' or 'B'.
You are also given an integer k. Your task is to change the minimum number o... |
### Prompt
Generate a CPP solution to the following problem:
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of t... |
### Prompt
Generate a Cpp solution to the following problem:
A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For e... |
### Prompt
Develop a solution in cpp to the problem described below:
There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a non-negative integer.
Snuke can repeatedly perform the following operation:
* Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i... |
### Prompt
Generate a CPP solution to the following problem:
Vasya plays the Power Defence.
He must pass the last level of the game. In order to do this he must kill the Main Villain, who moves in a straight line at speed 1 meter per second from the point ( - ∞, 0) to the point ( + ∞, 0) of the game world. In the p... |
### Prompt
Your task is to create a cpp solution to the following problem:
You are given set of n points in 5-dimensional space. The points are labeled from 1 to n. No two points coincide.
We will call point a bad if there are different points b and c, not equal to a, from the given set such that angle between vecto... |
### Prompt
In Cpp, your task is to solve the following problem:
Kenus, the organizer of International Euclidean Olympiad, is seeking a pair of two integers that requires many steps to find its greatest common divisor using the Euclidean algorithm.
You are given Q queries. The i-th query is represented as a pair of t... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
N people run a marathon. There are M resting places on the way. For each resting place, the i-th runner takes a break with probability P_i percent. When the i-th runner takes a break, he gets rest for T_i time.
The i-th runner runs at con... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.