text
stringlengths
424
69.5k
### Prompt Construct a Cpp code solution to the problem outlined: Colonel has n badges. He wants to give one badge to every of his n soldiers. Each badge has a coolness factor, which shows how much it's owner reached. Coolness factor can be increased by one for the cost of one coin. For every pair of soldiers one o...
### Prompt Your task is to create a Cpp solution to the following problem: We have N points in a two-dimensional plane. The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i). Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior...
### Prompt In cpp, your task is to solve the following problem: You've got an array, consisting of n integers a1, a2, ..., an. Also, you've got m queries, the i-th query is described by two integers li, ri. Numbers li, ri define a subsegment of the original array, that is, the sequence of numbers ali, ali + 1, ali + ...
### Prompt Generate a cpp solution to the following problem: By the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher: You are given a sequence of integers a1, a2, ..., an. Your task is to perform on it m consecutive operations of the following type: ...
### Prompt Generate a CPP solution to the following problem: You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely larg...
### Prompt Your challenge is to write a cpp solution to the following problem: You are given a tree T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1. Let's look at the subtree Tv of some vertex v. It is possible to read a string along each simple path starting at v...
### Prompt Construct a CPP code solution to the problem outlined: You are given a rooted undirected tree consisting of n vertices. Vertex 1 is the root. Let's denote a depth array of vertex x as an infinite sequence [d_{x, 0}, d_{x, 1}, d_{x, 2}, ...], where d_{x, i} is the number of vertices y such that both condit...
### Prompt In CPP, your task is to solve the following problem: Once Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect, however the tower he built kept falling apart. Let us consider the building process. Vasya takes a brick and puts it on top of the already bui...
### Prompt Create a solution in CPP for the following problem: Vasya is very upset that many people on the Net mix uppercase and lowercase letters in one word. That's why he decided to invent an extension for his favorite browser that would change the letters' register in every word so that it either only consisted o...
### Prompt Your task is to create a Cpp solution to the following problem: Shakespeare is a widely known esoteric programming language in which programs look like plays by Shakespeare, and numbers are given by combinations of ornate epithets. In this problem we will have a closer look at the way the numbers are descr...
### Prompt Please provide a Cpp coded solution to the problem described below: You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in t...
### Prompt Create a solution in cpp for the following problem: You are given an array a consisting of n integers. Your task is to determine if a has some subsequence of length at least 3 that is a palindrome. Recall that an array b is called a subsequence of the array a if b can be obtained by removing some (possib...
### Prompt Please create a solution in Cpp to the following problem: You are given n integers a_1, a_2, ..., a_n, such that for each 1≤ i ≤ n holds i-n≤ a_i≤ i-1. Find some nonempty subset of these integers, whose sum is equal to 0. It can be shown that such a subset exists under given constraints. If there are seve...
### Prompt Your challenge is to write a cpp solution to the following problem: Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y'). In one step Amr can put a pin to the border of th...
### Prompt Your task is to create a Cpp solution to the following problem: A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but you can cover some some cells of the map with sand so that exactly k islands appear on the map. We will call a set o...
### Prompt Create a solution in cpp for the following problem: You are given an array a1, a2, ..., an and m sets S1, S2, ..., Sm of indices of elements of this array. Let's denote Sk = {Sk, i} (1 ≤ i ≤ |Sk|). In other words, Sk, i is some element from set Sk. In this problem you have to answer q queries of the two t...
### Prompt Your challenge is to write a cpp solution to the following problem: Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up with such a problem. You are given an array a consisting of n positive integers and queries to it. The queri...
### Prompt Construct a CPP code solution to the problem outlined: In 2337, people are bored at daily life and have crazy desire of having extraordinary experience. These days,“Dungeon Adventure” is one of the hottest attractions, where brave adventurers risk their lives to kill the evil monsters and save the world. ...
### Prompt Generate a CPP solution to the following problem: Diverta City is a new city consisting of N towns numbered 1, 2, ..., N. The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided. A Hamiltonian path is a path that starts at o...
### Prompt Develop a solution in Cpp to the problem described below: Authors have come up with the string s consisting of n lowercase Latin letters. You are given two permutations of its indices (not necessary equal) p and q (both of length n). Recall that the permutation is the array of length n which contains each...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given a permutation a consisting of n numbers 1, 2, ..., n (a permutation is an array in which each element from 1 to n occurs exactly once). You can perform the following operation: choose some subarray (contiguous subsegment) of...
### Prompt Generate a Cpp solution to the following problem: An array of positive integers a1, a2, ..., an is given. Let us consider its arbitrary subarray al, al + 1..., ar, where 1 ≤ l ≤ r ≤ n. For every positive integer s denote by Ks the number of occurrences of s into the subarray. We call the power of the subar...
### Prompt Generate a CPP solution to the following problem: This problem is given in two editions, which differ exclusively in the constraints on the number n. You are given an array of integers a[1], a[2], ..., a[n]. A block is a sequence of contiguous (consecutive) elements a[l], a[l+1], ..., a[r] (1 ≤ l ≤ r ≤ n)...
### Prompt Please create a solution in cpp to the following problem: You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provide cellular network for all c...
### Prompt Your task is to create a CPP solution to the following problem: Arseny likes to organize parties and invite people to it. However, not only friends come to his parties, but friends of his friends, friends of friends of his friends and so on. That's why some of Arseny's guests can be unknown to him. He deci...
### Prompt In CPP, your task is to solve the following problem: You are given a tree with N vertices. The vertices are numbered 0 through N-1, and the edges are numbered 1 through N-1. Edge i connects Vertex x_i and y_i, and has a value a_i. You can perform the following operation any number of times: * Choose a sim...
### Prompt Your challenge is to write a cpp solution to the following problem: Andre has very specific tastes. Recently he started falling in love with arrays. Andre calls an nonempty array b good, if sum of its elements is divisible by the length of this array. For example, array [2, 3, 1] is good, as sum of its el...
### Prompt Please provide a CPP coded solution to the problem described below: Anu has created her own function f: f(x, y) = (x | y) - y where | denotes the [bitwise OR operation](https://en.wikipedia.org/wiki/Bitwise_operation#OR). For example, f(11, 6) = (11|6) - 6 = 15 - 6 = 9. It can be proved that for any nonneg...
### Prompt Please provide a CPP coded solution to the problem described below: There are N Reversi pieces arranged in a row. (A Reversi piece is a disc with a black side and a white side.) The state of each piece is represented by a string S of length N. If S_i=`B`, the i-th piece from the left is showing black; If S...
### Prompt In CPP, your task is to solve the following problem: You, the mighty Blackout, are standing in the upper-left (0,0) corner of NxM matrix. You must move either right or down each second. There are K transformers jumping around the matrix in the following way. Each transformer starts jumping from position ...
### Prompt Create a solution in CPP for the following problem: Snuke loves colorful balls. He has a total of N×K balls, K in each of his favorite N colors. The colors are numbered 1 through N. He will arrange all of the balls in a row from left to right, in arbitrary order. Then, for each of the N colors, he will pa...
### Prompt Please provide a Cpp coded solution to the problem described below: You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria. According to the regulation, the immigrant...
### Prompt Please create a solution in CPP to the following problem: The stardate is 1977 and the science and art of detecting Death Stars is in its infancy. Princess Heidi has received information about the stars in the nearby solar system from the Rebel spies and now, to help her identify the exact location of the ...
### Prompt Please provide a cpp coded solution to the problem described below: A string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is identical to the string s. For example, the string "aab" is an anagram of the string "aba" and the string "aaa" is not. The string ...
### Prompt Construct a CPP code solution to the problem outlined: You are given integers N and M. Consider a sequence a of length N consisting of positive integers such that a_1 + a_2 + ... + a_N = M. Find the maximum possible value of the greatest common divisor of a_1, a_2, ..., a_N. Constraints * All values in ...
### Prompt Create a solution in cpp for the following problem: You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the sam...
### Prompt In CPP, your task is to solve the following problem: Vasya has got n books, numbered from 1 to n, arranged in a stack. The topmost book has number a_1, the next one — a_2, and so on. The book at the bottom of the stack has number a_n. All numbers are distinct. Vasya wants to move all the books to his back...
### Prompt Please create a solution in Cpp to the following problem: Let’s define a grid to be a set of tiles with 2 rows and 13 columns. Each tile has an English letter written in it. The letters don't have to be unique: there might be two or more tiles with the same letter written on them. Here is an example of a g...
### Prompt In cpp, your task is to solve the following problem: You are given a rectangular matrix of size n × m consisting of integers from 1 to 2 ⋅ 10^5. In one move, you can: * choose any element of the matrix and change its value to any integer between 1 and n ⋅ m, inclusive; * take any column and shift it...
### Prompt In cpp, your task is to solve the following problem: The problem set at CODE FESTIVAL 20XX Finals consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As proble...
### Prompt Your challenge is to write a cpp solution to the following problem: For a sequence a of n integers between 1 and m, inclusive, denote f(a) as the number of distinct subsequences of a (including the empty subsequence). You are given two positive integers n and m. Let S be the set of all sequences of length...
### Prompt Generate a Cpp solution to the following problem: This problem is same as the previous one, but has larger constraints. Aki is playing a new video game. In the video game, he will control Neko, the giant cat, to fly between planets in the Catniverse. There are n planets in the Catniverse, numbered from 1...
### Prompt Create a solution in CPP for the following problem: Today, Mezo is playing a game. Zoma, a character in that game, is initially at position x = 0. Mezo starts sending n commands to Zoma. There are two possible commands: * 'L' (Left) sets the position x: =x - 1; * 'R' (Right) sets the position x: =x +...
### Prompt Construct a cpp code solution to the problem outlined: This problem is same as the previous one, but has larger constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power stat...
### Prompt Generate a Cpp solution to the following problem: Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".) This year, 2^N stones participated. The hardness of the i-th stone is A_i. In the contest, stones are thrown at each other in a...
### Prompt Construct a cpp code solution to the problem outlined: Alice guesses the strings that Bob made for her. At first, Bob came up with the secret string a consisting of lowercase English letters. The string a has a length of 2 or more characters. Then, from string a he builds a new string b and offers Alice t...
### Prompt Your challenge is to write a CPP solution to the following problem: A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and hold the rods high and low to resemble a flying dragon. A performer holding the rod low...
### Prompt Generate a CPP solution to the following problem: Arkady the air traffic controller is now working with n planes in the air. All planes move along a straight coordinate axis with Arkady's station being at point 0 on it. The i-th plane, small enough to be represented by a point, currently has a coordinate o...
### Prompt Create a solution in CPP for the following problem: Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. ...
### Prompt Create a solution in CPP for the following problem: Billy investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amount of n coins of different face values, and the coins ...
### Prompt Develop a solution in cpp to the problem described below: Mark and his crew are sailing across the sea of Aeolus (in Greek mythology Aeolus was the keeper of the winds). They have the map which represents the NxM matrix with land and sea fields and they want to get to the port (the port is considered as se...
### Prompt Construct a CPP code solution to the problem outlined: The fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simple pro- gram. You are given sin...
### Prompt Your task is to create a Cpp solution to the following problem: Everybody knows that the m-coder Tournament will happen soon. m schools participate in the tournament, and only one student from each school participates. There are a total of n students in those schools. Before the tournament, all students p...
### Prompt Please formulate a Cpp solution to the following problem: Alice and Bob are playing a game. The game involves splitting up game pieces into two teams. There are n pieces, and the i-th piece has a strength pi. The way to split up game pieces is split into several steps: 1. First, Alice will split the pi...
### Prompt In CPP, your task is to solve the following problem: Taro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshelf in the room, it will be quite ...
### Prompt Generate a cpp solution to the following problem: <image> My grandmother uses a balance. The balance will balance if you place the same size on both of the two dishes, otherwise it will tilt to the heavier side. The weights of the 10 weights are 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g in order of...
### Prompt Your task is to create a Cpp solution to the following problem: Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom. A bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The colum...
### Prompt Please formulate a Cpp solution to the following problem: Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on. Kyota Ootori has ...
### Prompt Please create a solution in Cpp to the following problem: Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same...
### Prompt In Cpp, your task is to solve the following problem: Alice and Bob are going to celebrate Christmas by playing a game with a tree of presents. The tree has n nodes (numbered 1 to n, with some node r as its root). There are a_i presents are hanging from the i-th node. Before beginning the game, a special i...
### Prompt Please provide a cpp coded solution to the problem described below: A little boy Petya dreams of growing up and becoming the Head Berland Plumber. He is thinking of the problems he will have to solve in the future. Unfortunately, Petya is too inexperienced, so you are about to solve one of such problems fo...
### Prompt Please create a solution in Cpp to the following problem: Vasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit. Vasya has n problems to choose from. They are numbered from 1 to n. The difficulty of the i-th problem ...
### Prompt Your task is to create a Cpp solution to the following problem: In problems on strings one often has to find a string with some particular properties. The problem authors were reluctant to waste time on thinking of a name for some string so they called it good. A string is good if it doesn't have palindrom...
### Prompt Develop a solution in CPP to the problem described below: Little Petya loves looking for numbers' divisors. One day Petya came across the following problem: You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi ...
### Prompt Please provide a cpp coded solution to the problem described below: You are given a string s, consisting of lowercase English letters, and the integer m. One should choose some symbols from the given string so that any contiguous subsegment of length m has at least one selected symbol. Note that here we c...
### Prompt In Cpp, your task is to solve the following problem: Fibonacci numbers are the sequence of integers: f0 = 0, f1 = 1, f2 = 1, f3 = 2, f4 = 3, f5 = 5, ..., fn = fn - 2 + fn - 1. So every next number is the sum of the previous two. Bajtek has developed a nice way to compute Fibonacci numbers on a blackboard....
### Prompt Construct a cpp code solution to the problem outlined: Codeforces is a wonderful platform and one its feature shows how much someone contributes to the community. Every registered user has contribution — an integer number, not necessarily positive. There are n registered users and the i-th of them has cont...
### Prompt In CPP, your task is to solve the following problem: A tourist wants to visit country Zeydabad for Zbazi (a local game in Zeydabad). The country Zeydabad is a rectangular table consisting of n rows and m columns. Each cell on the country is either 'z' or '.'. The tourist knows this country is named Zeyda...
### Prompt Please provide a cpp coded solution to the problem described below: Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each r...
### Prompt Your task is to create a Cpp solution to the following problem: Let us consider the following operations on a string consisting of `A` and `B`: 1. Select a character in a string. If it is `A`, replace it with `BB`. If it is `B`, replace with `AA`. 2. Select a substring that is equal to either `AAA` or `BB...
### Prompt Your task is to create a CPP solution to the following problem: Example Input acmicpc tsukuba Output No ### Response ```cpp #include <iostream> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <stack> #include <numeric> #include <bitset> #include <cmath...
### Prompt In Cpp, your task is to solve the following problem: There is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H). You are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the...
### Prompt Please create a solution in CPP to the following problem: There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the ...
### Prompt Please create a solution in CPP to the following problem: There are n piles of pebbles on the table, the i-th pile contains ai pebbles. Your task is to paint each pebble using one of the k given colors so that for each color c and any two piles i and j the difference between the number of pebbles of color ...
### Prompt Please create a solution in cpp to the following problem: You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provide cellular network for all c...
### Prompt Please formulate a cpp solution to the following problem: You have a sequence A composed of N positive integers: A_{1}, A_{2}, \cdots, A_{N}. You will now successively do the following Q operations: * In the i-th operation, you replace every element whose value is B_{i} with C_{i}. For each i (1 \leq ...
### Prompt Create a solution in Cpp for the following problem: A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic...
### Prompt Construct a Cpp code solution to the problem outlined: There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads. Assume that the cost o...
### Prompt In cpp, your task is to solve the following problem: The Kingdom of Aqua Canora Mystica is a very affluent and peaceful country, but around the kingdom, there are many evil monsters that kill people. So the king gave an order to you to kill the master monster. You came to the dungeon where the monster liv...
### Prompt Create a solution in cpp for the following problem: An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 1...
### Prompt In Cpp, your task is to solve the following problem: You are given two binary strings a and b of the same length. You can perform the following two operations on the string a: * Swap any two bits at indices i and j respectively (1 ≤ i, j ≤ n), the cost of this operation is |i - j|, that is, the absolute...
### Prompt Your challenge is to write a Cpp solution to the following problem: You are given a huge decimal number consisting of n digits. It is guaranteed that this number has no leading zeros. Each digit of this number is either 0 or 1. You may perform several (possibly zero) operations with this number. During ea...
### Prompt Please provide a cpp coded solution to the problem described below: You are given an array a_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j ≠ i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle an array means to reorder its elements arbitr...
### Prompt Develop a solution in Cpp to the problem described below: Little Petya likes numbers a lot. Recently his mother has presented him a collection of n non-negative integers. There's only one thing Petya likes more than numbers: playing with little Masha. He immediately decided to give a part of his new collec...
### Prompt Please provide a Cpp coded solution to the problem described below: This is an output-only problem. You shouldn't read anything from the input. In short, your task is to simulate multiplication by using only comparison (x < y) and addition (x + y). There is no input in this problem, you just print a seque...
### Prompt In CPP, your task is to solve the following problem: As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't ...
### Prompt Develop a solution in cpp to the problem described below: Billy investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amount of n coins of different face values, and the ...
### Prompt Please provide a Cpp coded solution to the problem described below: Recently a lot of students were enrolled in Berland State University. All students were divided into groups according to their education program. Some groups turned out to be too large to attend lessons in the same auditorium, so these gro...
### Prompt Your task is to create a Cpp solution to the following problem: You are given four integers n, c_0, c_1 and h and a binary string s of length n. A binary string is a string consisting of characters 0 and 1. You can change any character of the string s (the string should be still binary after the change)....
### Prompt Construct a Cpp code solution to the problem outlined: Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! However, there is no reason for disappointment, as Valery has found another ruler, its length is l centim...
### Prompt Your challenge is to write a Cpp solution to the following problem: Divide and rule Taro, Hanako, and Jiro rule the JAG Kingdom together. There are N cities in the JAG Kingdom, some of which are connected by two-way roads. You can always reach all the other cities from any city via one or more roads. One...
### Prompt Please create a solution in Cpp to the following problem: Lenny had an n × m matrix of positive integers. He loved the matrix so much, because each row of the matrix was sorted in non-decreasing order. For the same reason he calls such matrices of integers lovely. One day when Lenny was at school his litt...
### Prompt Your challenge is to write a cpp solution to the following problem: You are given a special jigsaw puzzle consisting of n⋅ m identical pieces. Every piece has three tabs and one blank, as pictured below. <image> The jigsaw puzzle is considered solved if the following conditions hold: 1. The pieces are...
### Prompt Construct a CPP code solution to the problem outlined: 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 be describ...
### Prompt Develop a solution in cpp to the problem described below: Amugae has a hotel consisting of 10 rooms. The rooms are numbered from 0 to 9 from left to right. The hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, t...
### Prompt Please provide a Cpp coded solution to the problem described below: A laser beam generator, a target object and some mirrors are placed on a plane. The mirrors stand upright on the plane, and both sides of the mirrors are flat and can reflect beams. To point the beam at the target, you may set the beam to ...
### Prompt Create a solution in CPP for the following problem: Priority queue is a container of elements which the element with the highest priority should be extracted first. For $n$ priority queues $Q_i$ ($i = 0, 1, ..., n-1$) of integers, perform a sequence of the following operations. * insert($t$, $x$): Insert...
### Prompt Please create a solution in CPP to the following problem: You are given two strings s and t. Both strings have length n and consist of lowercase Latin letters. The characters in the strings are numbered from 1 to n. You can successively perform the following move any number of times (possibly, zero): *...
### Prompt Please create a solution in CPP to the following problem: Zane once had a good sequence a consisting of n integers a1, a2, ..., an — but he has lost it. A sequence is said to be good if and only if all of its integers are non-negative and do not exceed 109 in value. <image> However, Zane remembers havin...
### Prompt Please formulate a Cpp solution to the following problem: T is a complete binary tree consisting of n vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have...