| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11514 | Queueing |
|
| 11518 | GCD and LCM |
|
| 11519 | stable_sort |
|
| 11521 | Cycle check |
|
| 11526 | Can you escape |
|
Description
You need to write a program to simulate a queue of names. Each name is a string consisting of English letters only. There are three operations:
1. “Push [name]”, which means to enque name in the queue.
2. “Pop”, which means to deque. If the queue is empty, this operation takes no effect.
3. “Front”, which means to print out the name in the front of queue. If the queue is empty, print "empty" (without quotes).
Hint: We have a very large input. Please use scanf and printf.
Input
Each line contains one of the following operations. “Push [name]” (without quotes), “Pop” (without quotes), “Front”(without quotes). The length of each name is at most 10.
Case 1: 0 < #operations <= 10^4
Case 2: 0 < #operations <= 10^5
Case 3: 0 < #operations <= 10^6
Case 4: 0 < #operations <= 10^7
Output
For each “Front” operation, print out the name in the front of the queue.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given three positive integers x, y, and z, compute their greatest common divisor (GCD) and least common multiple (LCM). The GCD of two or more numbers is the largest positive integer that can divide each of those numbers. The LCM of two or more numbers is the smallest positive integer that can be divided by each of those numbers.
hint : gcd(a,b,c) = gcd(gcd(a,b),c)
Input
The first line contains a positive integer N (N<=3000), which indicates the number of test cases in the input. In the next N lines, each line contains three positive integers x, y, and z, each of which is not greater than 10^6.
case 1 : 1<=numbers <= 10^2
case 2 : 1<=numbers <= 10^3
case 3 : 1<=numbers <= 10^5
case 4 : 1<=numbers <= 10^6
Output
For each case, output the GCD and LCM of x, y, and z in a line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given the grades of N people.
Please output the sorted result. (Increasing order)
If more people’s grades are same, output by input order.
Input
The input includes multiple test cases.
In each test case, the first line contains one integer N. The following N lines specify the name Si and the grade Gi.
1 <= N <= 105
1 <= |Si| <= 10
0 <= Gi <= 100 (Gi is an integer.)
Output
For every test case, output the result in N lines. Every line contains the name and the grade.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Please write a program to find out that whether a directed graph has cycles.
Input
There are many cases in input.
The first line in the input contains two integers: n, m, representing the number of nodes in the graph and the number of edges in the graph.
The next m lines, each line contains 2 integers, u and v (1<= u, v <= n). That means there is an edge from u to v(v to u has no edge).
Input will be terminated by EOF (End-Of-File).
There has no node connected to itself!!
Problem size
Input1: 1 <= n <= 10
Input2: 1 <= n <= 100
Input3&Input4: 1 <= n <= 1000
0 <= m <= n*(n-1)
Output
<p><span style="color:rgb(96, 103, 96); font-family:times new roman; font-size:large">For each case, print YES if there has at least one cycle in the graph, otherwise, print NO.</span></p>
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a map, how fast can you find the exit and then escape?
The map is a 2-dimensional grid of squares, each square is either free or filled with a wall. The exit is hidden among one of the free spaces.
You can move between adjacent free squares vertically or horizontally, diagonal movement is not allowed. You may not go across walls and leave the range of given map.
You have to arrive the position of button first (so that the exit appears) and then you can go to the exit.
Input
The input consists of several maps. Each map begins with a line containing two integer numbers R and C specifying the map size. Then there are R lines each containing C characters.
Each character is one of the following:
s : Your start position.
. : A free square that you can move.
b : The position of the button.
w : The wall.
e : The hidden exit.
The position of start point, button and exit are guaranteed to be difference.
There are exactly one button and exactly one exit.
There is one blank line after each map. The input is terminated by end of file.
Case 1: 1 <= R, C <= 5
Case 2: 1 <= R, C <= 100
Case 3: 1 <= R, C <= 200
Case 4: 1 <= R, C <= 1000
Output
For each map, print one line containing the sentence "Escape in S steps.", where S is the smallest possible number of step to escape. If no way to escape, output the string "No solution." instead.
One step is defined as a movement between two adjacent squares. Pressing button does not count as a step.