text stringlengths 424 69.5k |
|---|
### Prompt
Develop a solution in CPP to the problem described below:
This is an interactive problem.
Bob lives in a square grid of size n × n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know the exact ... |
### Prompt
Create a solution in Cpp for the following problem:
Alice and Bob are playing One Card Poker.
One Card Poker is a two-player game using playing cards.
Each card in this game shows an integer between `1` and `13`, inclusive.
The strength of a card is determined by the number written on it, as follows:
Wea... |
### Prompt
Please create a solution in cpp to the following problem:
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 oth... |
### Prompt
Please formulate a Cpp solution to the following problem:
Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.
Input
An integer n (1 ≤ n ≤ 20) in a line.
Output
Print the factorial of n in a line.
Example
Input
5
Output
120
### Response
```cpp
#i... |
### Prompt
Please create a solution in Cpp to the following problem:
There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.
Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repea... |
### Prompt
Please formulate a CPP solution to the following problem:
Polycarp wrote on the board a string s containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.
After that, he erased some letters from the string s, and he rewrote the remaining letters in any order. ... |
### Prompt
Generate a Cpp solution to the following problem:
Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and ... |
### Prompt
Generate a CPP solution to the following problem:
There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought n carrots with lengths a_1, a_2, a_3, …, a_n. However, rabbits are very fertile and multiply very quickly. Zookeeper now has k rabbits and does not have enough carrots to feed all of th... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Farmer John is obsessed with making Bessie exercise more!
Bessie is out grazing on the farm, which consists of n fields connected by m directed roads. Each road takes some time w_i to cross. She is currently at field 1 and will return to ... |
### Prompt
Develop a solution in Cpp to the problem described below:
It's been long after the events of the previous problems, and Karen has now moved on from student life and is looking to relocate to a new neighborhood.
<image>
The neighborhood consists of n houses in a straight line, labelled 1 to n from left to... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Bob is a competitive programmer. He wants to become red, and for that he needs a strict training regime. He went to the annual meeting of grandmasters and asked n of them how much effort they needed to reach red.
"Oh, I just spent x_i hou... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Seyyed and MoJaK are friends of Sajjad. Sajjad likes a permutation. Seyyed wants to change the permutation in a way that Sajjad won't like it. Seyyed thinks more swaps yield more probability to do that, so he makes MoJaK to perform a swap ... |
### Prompt
Construct a cpp code solution to the problem outlined:
E869120 has A 1-yen coins and infinitely many 500-yen coins.
Determine if he can pay exactly N yen using only these coins.
Constraints
* N is an integer between 1 and 10000 (inclusive).
* A is an integer between 0 and 1000 (inclusive).
Input
Input ... |
### Prompt
Construct a Cpp code solution to the problem outlined:
The Little Elephant is playing with the Cartesian coordinates' system. Most of all he likes playing with integer points. The Little Elephant defines an integer point as a pair of integers (x; y), such that 0 ≤ x ≤ w and 0 ≤ y ≤ h. Thus, the Little Elep... |
### Prompt
Create a solution in cpp for the following problem:
You are policeman and you are playing a game with Slavik. The game is turn-based and each turn consists of two phases. During the first phase you make your move and during the second phase Slavik makes his move.
There are n doors, the i-th door initially... |
### Prompt
In Cpp, your task is to solve the following problem:
Bob is playing a game called "Dungeon 2" which is the sequel to the popular "Dungeon" released last year. The game is played on a map consisting of $N$ rooms and $N-1$ roads connecting them. The roads allow bidirectional traffic and the player can start ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Usoperanto is an artificial spoken language designed and regulated by Usoperanto Academy. The academy is now in study to establish Strict Usoperanto, a variation of the language intended for formal documents.
In Usoperanto, each word can ... |
### Prompt
Develop a solution in CPP to the problem described below:
Takahashi loves takoyaki - a ball-shaped snack.
With a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.
How long does it take to make N takoyaki?
Constraints
* 1 \... |
### Prompt
Construct a CPP code solution to the problem outlined:
While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick's personal stuff and found a sequence a1, a2, ..., am of length m, consisting of integers from 1 to n, not necessarily d... |
### Prompt
In CPP, your task is to solve the following problem:
Little girl Susie accidentally found her elder brother's notebook. She has many things to do, more important than solving problems, but she found this problem too interesting, so she wanted to know its solution and decided to ask you about it. So, the pr... |
### Prompt
Generate a cpp solution to the following problem:
There is a sequence X of length N, where every element is initially 0. Let X_i denote the i-th element of X.
You are given a sequence A of length N. The i-th element of A is A_i. Determine if we can make X equal to A by repeating the operation below. If we... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
Co... |
### Prompt
Generate a cpp solution to the following problem:
The Smart Beaver from ABBYY was offered a job of a screenwriter for the ongoing TV series. In particular, he needs to automate the hard decision: which main characters will get married by the end of the series.
There are n single men and n single women amo... |
### Prompt
Please create a solution in cpp to the following problem:
You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.
We define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consona... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
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 o... |
### Prompt
Please provide a CPP coded solution to the problem described below:
On vacations n pupils decided to go on excursion and gather all together. They need to overcome the path with the length l meters. Each of the pupils will go with the speed equal to v1. To get to the excursion quickly, it was decided to re... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Kolya has a string s of length n consisting of lowercase and uppercase Latin letters and digits.
He wants to rearrange the symbols in s and cut it into the minimum number of parts so that each part is a palindrome and all parts have the same lengths. ... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Iahub wants to meet his girlfriend Iahubina. They both live in Ox axis (the horizontal axis). Iahub lives at point 0 and Iahubina at point d.
Iahub has n positive integers a1, a2, ..., an. The sum of those numbers is d. Suppose p1, p2, ..... |
### Prompt
Please formulate a CPP solution to the following problem:
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
In Cpp, your task is to solve the following problem:
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identi... |
### Prompt
Construct a CPP code solution to the problem outlined:
Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to follow his ... |
### Prompt
Create a solution in cpp for the following problem:
DZY loves planting, and he enjoys solving tree problems.
DZY has a weighted tree (connected undirected graph without cycles) containing n nodes (they are numbered from 1 to n). He defines the function g(x, y) (1 ≤ x, y ≤ n) as the longest edge in the sho... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are n planes on Earth, numbered from 1 to n, and the plane with number i likes the plane with number fi, where 1 ≤ fi ... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: "There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number".
Unfortunately, Poland... |
### Prompt
Construct a cpp code solution to the problem outlined:
Vasya had a strictly increasing sequence of positive integers a1, ..., an. Vasya used it to build a new sequence b1, ..., bn, where bi is the sum of digits of ai's decimal representation. Then sequence ai got lost and all that remained is sequence bi.
... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Egor came up with a new chips puzzle and suggests you to play.
The puzzle has the form of a table with n rows and m columns, each cell can contain several black or white chips placed in a row. Thus, the state of the cell can be described ... |
### Prompt
Please create a solution in Cpp to the following problem:
Vasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present — the clock that shows not only the time, but also the date.
The clock's face can display any number from 1 to d. It is guaranteed th... |
### Prompt
In CPP, your task is to solve the following problem:
The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows.
<image>
The event coordinator ha... |
### Prompt
Please formulate a Cpp solution to the following problem:
The morning of office workers is early. When I went through the elite course, joined a first-class company, and graduated from the title of newcomer, the resignation I received was a business activity on an undeveloped planet. I have been forced to ... |
### Prompt
Your task is to create a CPP solution to the following problem:
There is a square grid of size n × n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs min(h, w) to color a rectangle of size h × w. You... |
### Prompt
Construct a CPP code solution to the problem outlined:
Baby Ehab is known for his love for a certain operation. He has an array a of length n, and he decided to keep doing the following operation on it:
* he picks 2 adjacent elements; he then removes them and places a single integer in their place: the... |
### Prompt
Construct a cpp code solution to the problem outlined:
Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they correspond to the integer numbers fr... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
There are N squares arranged in a row. The squares are numbered 1, 2, ..., N, from left to right.
Snuke is painting each square in red, green or blue. According to his aesthetic sense, the following M conditions must all be satisfied. The... |
### Prompt
Create a solution in CPP for the following problem:
Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the splitting the edge... |
### Prompt
Please create a solution in CPP to the following problem:
Student Arseny likes to plan his life for n days ahead. He visits a canteen every day and he has already decided what he will order in each of the following n days. Prices in the canteen do not change and that means Arseny will spend ci rubles durin... |
### Prompt
Develop a solution in CPP to the problem described below:
Let's play Amidakuji.
In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.
<image>
In the starting points (top of the figure), numbers are assigne... |
### Prompt
Please create a solution in Cpp to the following problem:
A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, "abcba", "a", and "abba" are palindromes, while "abab" and "xy" are not.
A string is called a substring of another... |
### Prompt
Generate a Cpp solution to the following problem:
Let A = {a1, a2, ..., an} be any permutation of the first n natural numbers {1, 2, ..., n}. You are given a positive integer k and another sequence B = {b1, b2, ..., bn}, where bi is the number of elements aj in A to the left of the element at = i such that... |
### Prompt
Please formulate a cpp solution to the following problem:
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
Your task is to create a CPP solution to the following problem:
Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged.
Input
A single line contains a n... |
### Prompt
Your task is to create a cpp solution to the following problem:
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 world?... |
### Prompt
Please formulate a CPP solution to the following problem:
Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule:
... |
### Prompt
Create a solution in cpp for the following problem:
Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special.
Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the a... |
### Prompt
Construct a Cpp code solution to the problem outlined:
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of t... |
### Prompt
Please create a solution in CPP to the following problem:
Treeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town.
In Treeland there are 2k universities which are located in different towns.
Recently, the president ... |
### Prompt
Please create a solution in Cpp to the following problem:
There is unrest in the Galactic Senate. Several thousand solar systems have declared their intentions to leave the Republic. Master Heidi needs to select the Jedi Knights who will go on peacekeeping missions throughout the galaxy. It is well-known t... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
Calculate the minimum number of characters you need to change in the string s, so that it contains at least k different letters, or print that it is impossible.
String s consists only of lowercase Latin letters, and it is allowed to chang... |
### Prompt
Please formulate a cpp solution to the following problem:
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbe... |
### Prompt
Generate a CPP solution to the following problem:
Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least a minutes to feel refreshed.
Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in b minutes.... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a string q. A sequence of k strings s1, s2, ..., sk is called beautiful, if the concatenation of these strings is string q (formally, s1 + s2 + ... + sk = q) and the first characters of these strings are distinct.
Find any beautiful sequ... |
### Prompt
Your task is to create a CPP solution to the following problem:
For each string s consisting of characters '0' and '1' one can define four integers a00, a01, a10 and a11, where axy is the number of subsequences of length 2 of the string s equal to the sequence {x, y}.
In these problem you are given four ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
This is an easy version of the problem. In this version, all numbers in the given array are distinct and the constraints on n are less than in the hard version of the problem.
You are given an array a of n integers (there are no equals el... |
### Prompt
In cpp, your task is to solve the following problem:
Consider the function p(x), where x is an array of m integers, which returns an array y consisting of m + 1 integers such that yi is equal to the sum of first i elements of array x (0 ≤ i ≤ m).
You have an infinite sequence of arrays A0, A1, A2..., wher... |
### Prompt
Generate a CPP solution to the following problem:
One day, n people (n is an even number) met on a plaza and made two round dances, each round dance consists of exactly n/2 people. Your task is to find the number of ways n people can make two round dances if each round dance consists of exactly n/2 people.... |
### Prompt
Develop a solution in CPP to the problem described below:
A tree is an undirected connected graph without cycles.
Let's consider a rooted undirected tree with n vertices, numbered 1 through n. There are many ways to represent such a tree. One way is to create an array with n integers p1, p2, ..., pn, wher... |
### Prompt
Please create a solution in CPP to the following problem:
D: Country In Distortion-
story
Alice was completely bored. This is because the White Rabbit, who is always playing with him, is out to Trump Castle. (Ah, I wish I had gone out with him in this case.) Alice thought. However, this is a country of d... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Creatnx has n mirrors, numbered from 1 to n. Every day, Creatnx asks exactly one mirror "Am I beautiful?". The i-th mirror will tell Creatnx that he is beautiful with probability (p_i)/(100) for all 1 ≤ i ≤ n.
Some mirrors are called chec... |
### Prompt
Your task is to create a cpp solution to the following problem:
Sereja and his friends went to a picnic. The guys had n soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles.
Sereja knows that the i-th bottle is from brand ai, besid... |
### Prompt
Construct a CPP code solution to the problem outlined:
The height of the student was measured at the medical examination. Create a program that takes height data as input, creates a frequency distribution, and outputs it. The frequency distribution is divided into 6 classes in 5 cm increments, and the numb... |
### Prompt
Please formulate a Cpp solution to the following problem:
<image>
One evening. As usual, when you were watching TV in the living room, my sister in fifth grade offered me a consultation. When I listened to the story, I couldn't understand the math problem that was presented at school today, so I want you ... |
### Prompt
Please create a solution in Cpp to the following problem:
We have N ID cards, and there are M gates.
We can pass the i-th gate if we have one of the following ID cards: the L_i-th, (L_i+1)-th, ..., and R_i-th ID cards.
How many of the ID cards allow us to pass all the gates alone?
Constraints
* All val... |
### Prompt
Please create a solution in cpp to the following problem:
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 disti... |
### Prompt
Please provide a CPP coded solution to the problem described below:
You are given a string s consisting of the characters 0, 1, and ?.
Let's call a string unstable if it consists of the characters 0 and 1 and any two adjacent characters are different (i. e. it has the form 010101... or 101010...).
Let's ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should be a nonem... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road.
We assume that the action tak... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
n robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous!
Fortunately, even though your robots have... |
### Prompt
Generate a cpp solution to the following problem:
One day Natalia was walking in the woods when she met a little mushroom gnome. The gnome told her the following story:
Everybody knows that the mushroom gnomes' power lies in the magic mushrooms that grow in the native woods of the gnomes. There are n tree... |
### Prompt
Create a solution in cpp for the following problem:
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).
We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation:
* Choose a ball rem... |
### Prompt
Your task is to create a CPP solution to the following problem:
You are given a sequence a consisting of n integers. Find the maximum possible value of <image> (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.
First of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.
Next, the program should r... |
### Prompt
Construct a CPP code solution to the problem outlined:
Snuke has N strings. The i-th string is s_i.
Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
Constraints
* 1 \leq N \leq 10^{4}
* 2... |
### Prompt
Generate a CPP solution to the following problem:
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empt... |
### Prompt
Please create a solution in cpp to the following problem:
There are n startups. Startups can be active or acquired. If a startup is acquired, then that means it has exactly one active startup that it is following. An active startup can have arbitrarily many acquired startups that are following it. An activ... |
### Prompt
Please formulate a cpp solution to the following problem:
You are given a string s consisting of exactly n characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.
Your task is to replace minimum number of characters in this string with other characters to obtain ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
The game of Berland poker is played with a deck of n cards, m of which are jokers. k players play this game (n is divisible by k).
At the beginning of the game, each player takes n/k cards from the deck (so each card is taken by exactly o... |
### Prompt
Construct a CPP code solution to the problem outlined:
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a := a - x, b := b - 2x or a := a - 2x, b := b - x. Note that you may choose d... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
The heat during the last few days has been really intense. Scientists from all over the Berland study how the temperatures and weather change, and they claim that this summer is abnormally hot. But any scientific claim sounds a lot more re... |
### Prompt
Please formulate a cpp solution to the following problem:
You are given a positive integer n, it is guaranteed that n is even (i.e. divisible by 2).
You want to construct the array a of length n such that:
* The first n/2 elements of a are even (divisible by 2);
* the second n/2 elements of a are o... |
### Prompt
Please formulate a CPP solution to the following problem:
Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the beauty of the tower as follows:
* The beau... |
### Prompt
Please provide a CPP coded solution to the problem described below:
An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. ... |
### Prompt
Please formulate a Cpp solution to the following problem:
Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it.
The player chooses a square as a starting point and pla... |
### Prompt
Construct a CPP code solution to the problem outlined:
Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
There are k sensors located in the rectangular room of size n × m meters. The i-th sensor is located at point (xi, yi). All sensors are located at distinct points strictly inside the rectangle.
Opposite corners of the room are located at... |
### Prompt
Develop a solution in CPP to the problem described below:
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
Create a solution in Cpp for the following problem:
You are given two sequences a and b, both of length 2N. The i-th elements in a and b are a_i and b_i, respectively. Using these sequences, Snuke is doing the job of calculating the beauty of pairs of balanced sequences of parentheses (defined below) of le... |
### Prompt
In CPP, your task is to solve the following problem:
VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.
The latest A/B test sugge... |
### Prompt
Generate a CPP solution to the following problem:
You are given a string S consisting of lowercase English letters. Determine whether we can turn S into a palindrome by repeating the operation of swapping two adjacent characters. If it is possible, find the minimum required number of operations.
Constrain... |
### Prompt
Please create a solution in CPP to the following problem:
Nikita likes tasks on order statistics, for example, he can easily find the k-th number in increasing order on a segment of an array. But now Nikita wonders how many segments of an array there are such that a given number x is the k-th number in inc... |
### Prompt
Construct a CPP code solution to the problem outlined:
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help.
Innokentiy decides that new password should satisfy the following conditions:
* the len... |
### Prompt
Please create a solution in CPP to the following problem:
My name is James diGriz, I'm the most clever robber and treasure hunter in the whole galaxy. There are books written about my adventures and songs about my operations, though you were able to catch me up in a pretty awkward moment.
I was able to hi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.