text stringlengths 424 69.5k |
|---|
### Prompt
Create a solution in Cpp for the following problem:
Pavel plays a famous computer game. A player is responsible for a whole country and he can travel there freely, complete quests and earn experience.
This country has n cities connected by m bidirectional roads of different lengths so that it is possible ... |
### Prompt
Create a solution in Cpp for the following problem:
We have a magic tree: a rooted tree on n vertices. The vertices are numbered 1 through n. Vertex 1 is the root.
The magic tree gives us magic fruit. The fruit only grows in vertices of the tree other than the root. Each vertex contains at most one piece ... |
### Prompt
Create a solution in Cpp for the following problem:
Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.
Hongcow has decided to try to make new words from this one. He starts by taking the... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Let's call a list of positive integers a_0, a_1, ..., a_{n-1} a power sequence if there is a positive integer c, so that for every 0 ≤ i ≤ n-1 then a_i = c^i.
Given a list of n positive integers a_0, a_1, ..., a_{n-1}, you are allowed to:... |
### Prompt
Please provide a cpp coded solution to the problem described below:
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got th... |
### Prompt
Please create a solution in CPP to the following problem:
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller.
* Determine the largest element in the sequence (if ... |
### Prompt
In cpp, your task is to solve the following problem:
In the country of Never, there are n cities and a well-developed road system. There is exactly one bidirectional road between every pair of cities, thus, there are as many as <image> roads! No two roads intersect, and no road passes through intermediate ... |
### Prompt
Please formulate a CPP solution to the following problem:
You are given an integer m, and a list of n distinct integers between 0 and m - 1.
You would like to construct a sequence satisfying the properties:
* Each element is an integer between 0 and m - 1, inclusive.
* All prefix products of the seq... |
### Prompt
Your task is to create a cpp solution to the following problem:
Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".
Chris arranges n dominoes in a line, placing each piece vertic... |
### Prompt
Please create a solution in CPP to the following problem:
A famous sculptor Cicasso goes to a world tour!
Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he? Otherwise there will be no any exclusivity. So Cicasso will entirely hold th... |
### Prompt
Please create a solution in cpp to the following problem:
Requirements
* All inputs are of non-negative integer value.
* T_{\text{max}} = 10000
* 200 \leq |V| \leq 400
* 1.5 |V| \leq |E| \leq 2 |V|
* 1 \leq u_{i}, v_{i} \leq |V| (1 \leq i \leq |E|)
* 1 \leq d_{u_i, v_i} \leq \lceil 4\sqrt{2|V|} \rceil (1 ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Tokitsukaze and CSL are playing a little game of stones.
In the beginning, there are n piles of stones, the i-th pile of which has a_i stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a... |
### Prompt
Develop a solution in CPP to the problem described below:
problem
President K decided to make a flag for IOI 2016 in Russia. Chairman K first took out the old flag from the warehouse. This flag is divided into squares of N rows and M columns, and each square is painted in one of white, blue, and red.
Cha... |
### Prompt
Construct a CPP code solution to the problem outlined:
Recently you've discovered a new shooter. They say it has realistic game mechanics.
Your character has a gun with magazine size equal to k and should exterminate n waves of monsters. The i-th wave consists of a_i monsters and happens from the l_i-th m... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Let us define the beauty of a sequence (a_1,... ,a_n) as the number of pairs of two adjacent elements in it whose absolute differences are d. For example, when d=1, the beauty of the sequence (3, 2, 3, 10, 9) is 3.
There are a total of n^... |
### Prompt
In CPP, your task is to solve the following problem:
It's the turn of the year, so Bash wants to send presents to his friends. There are n cities in the Himalayan region and they are connected by m bidirectional roads. Bash is living in city s. Bash has exactly one friend in each of the other cities. Since... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
As you know, Hogwarts has four houses: Gryffindor, Hufflepuff, Ravenclaw and Slytherin. The sorting of the first-years into houses is done by the Sorting Hat. The pupils are called one by one in the alphabetical order, each of them should ... |
### Prompt
Please formulate a cpp solution to the following problem:
There is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N.
Takahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) and can only be traversed in ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
Twin adventurers Rin and Len are searching for treasure in the Mirror Cave. The cave has two pairs of rooms, the Hall of Mirrors, and an expensive treasure lies behind the door of the room.
For convenience, each of the two rooms is consid... |
### Prompt
Generate a cpp solution to the following problem:
One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of n non-negative integers.
If there are exac... |
### Prompt
Develop a solution in CPP to the problem described below:
In a far away galaxy there is war again. The treacherous Republic made k precision strikes of power ai on the Empire possessions. To cope with the republican threat, the Supreme Council decided to deal a decisive blow to the enemy forces.
To succe... |
### Prompt
Construct a CPP code solution to the problem outlined:
Let's call a positive integer n ordinary if in the decimal notation all its digits are the same. For example, 1, 2 and 99 are ordinary numbers, but 719 and 2021 are not ordinary numbers.
For a given number n, find the number of ordinary numbers among ... |
### Prompt
Develop a solution in Cpp to the problem described below:
The Elements of Harmony are six supernatural artifacts representing subjective aspects of harmony. They are arguably the most powerful force in Equestria. The inside of Elements of Harmony can be seen as a complete graph with n vertices labeled from... |
### Prompt
Develop a solution in Cpp to the problem described below:
Do you know "sed," a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.
1. Within the ... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
BitHaval (the m... |
### Prompt
Please formulate a Cpp solution to the following problem:
Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.
Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out c... |
### Prompt
Please provide a cpp coded solution to the problem described below:
problem
In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions... |
### Prompt
Please create a solution in cpp to the following problem:
Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a ... |
### Prompt
Please provide a cpp coded solution to the problem described below:
The hero of the Cut the Rope game is a little monster named Om Nom. He loves candies. And what a coincidence! He also is the hero of today's problem.
<image>
One day, Om Nom visited his friend Evan. Evan has n candies of two types (fruit... |
### Prompt
In cpp, your task is to solve the following problem:
Snuke has a permutation (P_0,P_1,\cdots,P_{N-1}) of (0,1,\cdots,N-1).
Now, he will perform the following operation exactly once:
* Choose K consecutive elements in P and sort them in ascending order.
Find the number of permutations that can be produ... |
### Prompt
In cpp, your task is to solve the following problem:
You can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following game to warm up: initially a piece of paper has an integer q. During a move a player should write any integer number that is a non-trivial divisor o... |
### Prompt
Generate a Cpp solution to the following problem:
Xenia has a set of weights and pan scales. Each weight has an integer weight from 1 to 10 kilos. Xenia is going to play with scales and weights a little. For this, she puts weights on the scalepans, one by one. The first weight goes on the left scalepan, th... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high e... |
### Prompt
Please formulate a cpp solution to the following problem:
You are given three integers, A, B and C.
Among them, two are the same, but the remaining one is different from the rest.
For example, when A=5,B=7,C=5, A and C are the same, but B is different.
Find the one that is different from the rest among the... |
### Prompt
In CPP, your task is to solve the following problem:
There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and... |
### Prompt
Please formulate a CPP solution to the following problem:
This problem is interactive.
We have hidden an array a of n pairwise different numbers (this means that no two numbers are equal). You can get some information about this array using a new device you just ordered on Amazon.
This device can answer... |
### Prompt
Construct a CPP code solution to the problem outlined:
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 1,000
* 0 ≤ wi ≤ 10,000
* G has arborescence(s) with the root r
Input
|V|... |
### Prompt
Your task is to create a CPP solution to the following problem:
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can b... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Nick's company employed n people. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that each employee, except one, has exactly one supervisor). There are m applications written i... |
### Prompt
Generate a CPP solution to the following problem:
Blake is a CEO of a large company called "Blake Technologies". He loves his company very much and he thinks that his company should be the best. That is why every candidate needs to pass through the interview that consists of the following problem.
We defi... |
### Prompt
Please formulate a Cpp solution to the following problem:
You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally conne... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
You are given a weighted tree (undirected connected graph with no cycles, loops or multiple edges) with n vertices. The edge \\{u_j, v_j\} has weight w_j. Also each vertex i has its own value a_i assigned to it.
Let's call a path starting... |
### Prompt
Construct a Cpp code solution to the problem outlined:
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. Paul can ta... |
### Prompt
In Cpp, your task is to solve the following problem:
Yeah, we failed to make up a New Year legend for this problem.
A permutation of length n is an array of n integers such that every integer from 1 to n appears in it exactly once.
An element y of permutation p is reachable from element x if x = y, or p... |
### Prompt
Create a solution in cpp for the following problem:
There is a grid of square cells with H horizontal rows and W vertical columns. The cell at the i-th row and the j-th column will be denoted as Cell (i, j).
In Cell (i, j), a_{ij} coins are placed.
You can perform the following operation any number of ti... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Karen has just arrived at school, and she has a math test today!
<image>
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test.... |
### Prompt
In CPP, your task is to solve the following problem:
Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U an... |
### Prompt
Please create a solution in cpp to the following problem:
Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — concatenation of letters, ... |
### Prompt
Please provide a CPP coded solution to the problem described below:
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence a consisting of n integers. The player can make several steps. I... |
### Prompt
Generate a cpp solution to the following problem:
You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeo... |
### Prompt
Please formulate a CPP solution to the following problem:
Create a program that outputs all leap years between the year a and year b.
The leap year conditions are as follows. However, 0 <a ≤ b <3,000. If there is no leap year in the given period, output "NA".
* The year is divisible by 4.
* However, a ye... |
### Prompt
Your task is to create a CPP solution to the following problem:
Leha is planning his journey from Moscow to Saratov. He hates trains, so he has decided to get from one city to another by car.
The path from Moscow to Saratov can be represented as a straight line (well, it's not that straight in reality, bu... |
### Prompt
Construct a cpp code solution to the problem outlined:
Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.
There are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0... |
### Prompt
Generate a CPP solution to the following problem:
You are given a string S consisting of `0` and `1`. Find the maximum integer K not greater than |S| such that we can turn all the characters of S into `0` by repeating the following operation some number of times.
* Choose a contiguous segment [l,r] in S w... |
### Prompt
Please formulate a Cpp solution to the following problem:
You are developing frog-shaped robots, and decided to race them against each other.
First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn bas... |
### Prompt
Generate a CPP solution to the following problem:
The Holmes children are fighting over who amongst them is the cleverest.
Mycroft asked Sherlock and Eurus to find value of f(n), where f(1) = 1 and for n ≥ 2, f(n) is the number of distinct ordered positive integer pairs (x, y) that satisfy x + y = n and g... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Instructors of Some Informatics School make students go to bed.
The house contains n rooms, in each room exactly b students were supposed to sleep. However, at the time of curfew it happened that many students are not located in their ass... |
### Prompt
Generate a CPP solution to the following problem:
Bizon the Champion isn't just friendly, he also is a rigorous coder.
Let's define function f(a), where a is a sequence of integers. Function f(a) returns the following sequence: first all divisors of a1 go in the increasing order, then all divisors of a2 g... |
### Prompt
Create a solution in cpp for the following problem:
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').
You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (consecutive) character... |
### Prompt
In CPP, your task is to solve the following problem:
There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordi... |
### Prompt
Your task is to create a Cpp solution to the following problem:
<image>
While trading on his favorite exchange trader William realized that he found a vulnerability. Using this vulnerability he could change the values of certain internal variables to his advantage. To play around he decided to change the ... |
### Prompt
Create a solution in cpp for the following problem:
After playing Neo in the legendary "Matrix" trilogy, Keanu Reeves started doubting himself: maybe we really live in virtual reality? To find if this is true, he needs to solve the following problem.
Let's call a string consisting of only zeroes and ones ... |
### Prompt
Create a solution in CPP for the following problem:
Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe so... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Lee bought some food for dinner time, but Lee's friends eat dinner in a deadly way. Lee is so scared, he doesn't want to die, at least not before seeing Online IOI 2020...
There are n different types of food and m Lee's best friends. Lee ... |
### Prompt
Your task is to create a Cpp solution to the following problem:
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 take... |
### Prompt
Create a solution in CPP for the following problem:
There are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree.
You have a map of that network, so for each railway section you know which... |
### Prompt
Please formulate a Cpp solution to the following problem:
<image>
Input
The input consists of four lines, each line containing a single digit 0 or 1.
Output
Output a single digit, 0 or 1.
Example
Input
0
1
1
0
Output
0
### Response
```cpp
#include <bits/stdc++.h>
#pragma warning(disable : 4996)... |
### Prompt
Create a solution in cpp for the following problem:
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.
She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly... |
### Prompt
Create a solution in CPP for the following problem:
Little Petya was given this problem for homework:
You are given function <image> (here <image> represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x) = x.
It is a pity that Pety... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.
The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X... |
### Prompt
Construct a Cpp code solution to the problem outlined:
You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices.
A set of edges is called a matching if no two edges share an endpoint.
A set of vertices is called an independent set i... |
### Prompt
Please provide a Cpp coded solution to the problem described below:
Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or eq... |
### Prompt
Generate a cpp solution to the following problem:
Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of the problem be... |
### Prompt
Your challenge is to write a Cpp solution to the following problem:
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are int... |
### Prompt
Please formulate 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 w... |
### Prompt
Construct a Cpp code solution to the problem outlined:
Find the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:
* The sum of the digits in base ten is a multiple of D.
Constraints
* All values in input are integers.
* 1 \leq K < 10^{10000}
* 1 \leq D \... |
### Prompt
Please formulate a CPP solution to the following problem:
Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.
Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one k... |
### Prompt
Your task is to create a Cpp solution to the following problem:
Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Li... |
### Prompt
Your task is to create a CPP solution to the following problem:
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character.
Let's introduce several definitions:
* A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string sisi + 1...sj.
* The prefix of string... |
### Prompt
Create a solution in CPP for the following problem:
Mislove had an array a_1, a_2, ⋅⋅⋅, a_n of n positive integers, but he has lost it. He only remembers the following facts about it:
* The number of different numbers in the array is not less than l and is not greater than r;
* For each array's elemen... |
### Prompt
Please create a solution in cpp to the following problem:
The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement.
UCDHP stores some secret information about meteor... |
### Prompt
Construct a cpp code solution to the problem outlined:
Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.
Alice initially has a token on some cell on the line, and Bob tries to guess where it is.
Bo... |
### Prompt
Your task is to create a cpp solution to the following problem:
Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≤ u < v < n, vertex u and vertex v are ... |
### Prompt
Your task is to create a cpp solution to the following problem:
Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already built and Kris wants to tes... |
### Prompt
In CPP, your task is to solve the following problem:
Example
Input
anagram
grandmother
Output
4
### Response
```cpp
#include <bits/stdc++.h>
using namespace std;
typedef array<int, 26> Vec;
char buf[114514];
int cnt[2][114514][26];
string S[2];
vector<int> appear[2][26];
int main() {
scanf("%s"... |
### Prompt
Your task is to create a Cpp solution to the following problem:
You are given an array of n elements, you must make it a co-prime array in as few moves as possible.
In each move you can insert any positive integral number you want not greater than 109 in any place in the array.
An array is co-prime if an... |
### Prompt
Construct a CPP code solution to the problem outlined:
A ball will bounce along a number line, making N + 1 bounces. It will make the first bounce at coordinate D_1 = 0, and the i-th bounce (2 \leq i \leq N+1) at coordinate D_i = D_{i-1} + L_{i-1}.
How many times will the ball make a bounce where the coor... |
### Prompt
In cpp, your task is to solve the following problem:
The tournament «Sleepyhead-2010» in the rapid falling asleep has just finished in Berland. n best participants from the country have participated in it. The tournament consists of games, each of them is a match between two participants. n·(n - 1) / 2 gam... |
### Prompt
Please provide a cpp coded solution to the problem described below:
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"... |
### Prompt
Your challenge is to write a cpp solution to the following problem:
Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and partici... |
### Prompt
Please formulate a CPP solution to the following problem:
Takahashi has decided to hold fastest-finger-fast quiz games. Kizahashi, who is in charge of making the scoreboard, is struggling to write the program that manages the players' scores in a game, which proceeds as follows.
A game is played by N play... |
### Prompt
Please create a solution in cpp to the following problem:
Let us define the FizzBuzz sequence a_1,a_2,... as follows:
* If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.
* If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.
* If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.
* If none of... |
### Prompt
Please create a solution in cpp to the following problem:
Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes.
More formally, you are given an odd numer n... |
### Prompt
Please create a solution in cpp to the following problem:
problem
You are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, there is a possibility that extra... |
### Prompt
Construct a CPP code solution to the problem outlined:
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i distinct v... |
### Prompt
Please create a solution in Cpp to the following problem:
One day in the IT lesson Anna and Maria learned about the lexicographic order.
String x is lexicographically less than string y, if either x is a prefix of y (and x ≠ y), or there exists such i (1 ≤ i ≤ min(|x|, |y|)), that xi < yi, and for any j (... |
### Prompt
Your challenge is to write a CPP solution to the following problem:
Lee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called "Critic"...
The game is a one versus one ga... |
### Prompt
Create a solution in cpp for the following problem:
The only difference between easy and hard versions is constraints.
There are n kids, each of them is reading a unique book. At the end of any day, the i-th kid will give his book to the p_i-th kid (in case of i = p_i the kid will give his book to himself... |
### Prompt
Please formulate a Cpp solution to the following problem:
New AtCoder City has an infinite grid of streets, as follows:
* At the center of the city stands a clock tower. Let (0, 0) be the coordinates of this point.
* A straight street, which we will call East-West Main Street, runs east-west and passes th... |