Time limit: 0.5 seconds Memory limit: 256 MB Mustafa, who is a business person, is…
- User
Time limit: 0.5 seconds Memory limit: 256 MB Mustafa, who is a business person, is responsible for the company's typing. Because Mustafa is very busy, he has typed so much that the company's servers are all full. Now he plans to compress these texts so that he can type again. For this, he must perform the following operations for each word:
If there were an equal number of consecutive letters in the word, it prints that letter once instead of them and then prints their number in front of it. For example, instead of the word wwwsoo, Mustafa prints w3so2.
Pay attention that the small and large letters are important. Also, if the number of repetitions is one, the number one is not printed.
In the same way, if Mustafa wants to use typed files, he expands them first and then uses them.
Now you will be given a number of words and for each one you have to compress or expand that word.
input In the first line of the input n n comes to represent the number of words.
in 2 x n 2xn next row n n times a number and a word appear, if the number is equal to one, that word should be compressed, and if it is two, it should be expanded. The characters used in these words are lowercase and uppercase English letters. The total length of all words does not exceed 1000 characters. 1 ≤ n ≤ 100 1≤n≤100
output Output included n n is the row that is in the row i The word "im" should be compressed or expanded i The input is printed. The total length of the outputs is less than 1000.
Example Sample entry 1 2 1 hhpwwwBbTTTTnnP 2 h2pw3BbT4n2P Plain text Sample output 1 h2pw3BbT4n2P hhpwwwBbTTTTnnP write in c++
- Assistant
- User
- Assistant
- User
Time limit: 1 second Memory limit: 256 MB Kian is stuck in a room and can't see anywhere. We know that the floor of this room is square n x n n×n square tiles are tiled. Also, each tile has a unique number and the numbering of the tiles is spiral. For example, the numbering of tiles in the following figure n
5 It shows n=5.
13 12 11 10 9 14 23 22 21 8 15 24 25 20 7 16 17 18 19 6 1 2 3 4 5 13 14 15 16 1
12 23 24 17 2
11 22 25 18 3
10 21 20 19 4
9 8 7 6 5
Kian knows that there is a candle inside this room and wants to reach it, but because the room is dark, he cannot see anywhere. He asks you to guide him how far he needs to move in each direction to reach the candle by taking the number of the tile Kian is standing on and the tile the candle is on.
- Assistant
- User
Time limit: 2 seconds Memory limit: 256 MB Mamed and Reza play a doubles game together. Mamad n puts n points on the screen and asks Reza to connect some of these points in such a way that a complete binary tree with height k be k The only condition is that the edges of the tree should not intersect each other.
A binary tree is a tree whose vertices have exactly two or zero children. Complete binary tree with height k k is a binary tree up to height k
1 k−1 all its vertices have exactly two children and vertices of height k They have no children. Binary tree vertices from 1 to 2 k
1 2 k We number -1 so that the children of the vertex i iam two vertices 2 i 2i and 2 i + 1 be 2i+1.
Help Reza to draw a suitable picture. You have to say for each point which vertex should be placed in it, so that by drawing the edges of the tree, the edges do not intersect.
input In the first line of input numbers n n, k k has arrived. which is the number of points and the height of the tree, respectively. in each of n Next n lines, two integers in each line x i , y i x i ,y i It turns out that the coordinates of the point i Shows the page number. 3 ≤ n ≤ 1
- Assistant
- User
Time limit: 1 second Memory limit: 256 MB The distant family went to the chocolate shop to buy chocolates for their children. In the chocolate shop n There are n packages of chocolates i iam a i a i Contains chocolate (a package may not contain any chocolate.) Children of distant relatives, how many m m are happy to see the chocolate packages. Far family knows that in order not to have a fight between children, everyone should get the same number of chocolates. At the same time, he knows that he has to buy a whole package of chocolates and cannot buy a part of a package. He must buy at least one pack of chocolates so that the children will be happy when they see the chocolate packs. The distant family wants to know if they can choose a number of packages that will make both the kids happy and fight-free.
input In the first line of the input, two numbers n n (number of chocolate packages) and m m (number of children) has come. In the second line n n number comes that number i The number indicates the number of packed chocolates i is i
1 ≤ n ≤ 5 x 1 0 5 1≤n≤5×10 5
2 ≤ m ≤ 5 x 1 0 3 2≤m≤5×10 3
0 ≤ a i ≤ 1 0 9 0≤a i ≤10 9
output In the only output line, print YES if the distant family can buy chocolates on their terms and NO otherwise.
- Assistant
- User
Time limit: 1 second Memory limit: 256 MB On Floki Island k k different tribes are located in k They live in different places. The map of Floki Island is in the form of a connected graph that has n n place (top) and n
1 n−1 is the road (edge).
Due to the differences of opinion that occurred between the tribes of this island during this period, the process of their civil wars has started; Every day, each of the tribes infiltrates all the places adjacent to their road and takes possession of that place. If two tribes reach a common place or one of the tribes reaches a place that is already occupied by another tribe, these two tribes negotiate with each other and as a result unite together and henceforth act as one. They act as a single clan (maybe even more than two clans are united at the same time!).
- Assistant