| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12117 | CS_2018_FINAL-1 |
|
| 12118 | CS_2018_FINAL-2 |
|
| 12119 | CS_2018_FINAL-3 |
|
| 12120 | CS_2018_FINAL-4 |
|
| 12121 | CS_2018_FINAL-5 |
|
Description
Given two strings s and t, your task is to figure out whether there exists s’ equals to t, where we denote s’ as a left rotation or a right rotation of s.
For example, if s = “abcd”, then s’ can either equals to “abcd”, “bcda”, ”cdab” or ”dabc”.
Input
The input consists of multiple test cases. The first line of the input contains one integer T, which is the number of the test cases (1 ≤ T ≤ 100). Each of the following n lines contains a test case formatted as follows.
s t
s and t are the two string mentioned above. The length of s and t are the same, and both of them are between 1 and 100, inclusive.
Output
For each test case, print "Yes" if there exists s' equals to t, otherwise print "No".
There is a newline character ‘\n’ at the end of line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a linked list, you have to reverse it and output the result.
You have to implement four function:
1. Node* Create_List(Node*, int);
This function is used to create the linked list according to the input.
2. Node* Reverse_List(Node*);
This function is used to reverse the given linked list.
3. void Print_List(Node*);
This function is used to print out the key value in the linked list.
4. void Free_List(Node*);
This function is used to free the memory space.
Input
The first line contains one integer n, representing the number of nodes in the linked list.
The next lines contains n integers, each integer represents a node in the linked list.
It is guaranteed that :
- 1 ≤ n ≤ 10
- 0 ≤ ai ≤ 100
Output
You need to output the reversed linked lists.
Each key value is separated by "->".
You need to print '\n' in the end
Sample Input Download
Sample Output Download
Partial Judge Code
12118.cPartial Judge Header
12118.hTags
Discuss
Description
Writer: jjjjj19980806 Description: pclightyear Difficulty: ★★★☆☆
Given n numbers, you need to find a number k such that SUM is minimum,
where we define SUM = ( a1 ^ k ) + ( a2 ^ k ) + ... + ( an ^ k )
(^ stands for the "xor" bitwise operation of the two operand)
Input
The first line contains an integer n, representing the number of numbers.
The next line contains n integers ai, representing each given number.
It is guaranteed that:
- n ≤ 105
- 0 ≤ ai ≤ 106
- All numbers ( ai and k ) are unsigned numbers
Output
Please output the value of SUM.
Note SUM may exceed INT.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
There are N points in a D-dimensional Euclidean space.
Given a test point x, find its kth nearest neighbor among the N points.

Input
The first line contains three integers N, D, k representing the number of points, the dimension, and the parameter k for k-nearest neighbor. The next N lines contain the coordinates of the N points. The last line contains the coordinate of the test point x.
For example, consider the following five points in 2-dimensional space.
(0.0, 0.0), (5.0, 0.0), (5.0, 5.0), (0.0, 5.0), (2.5, 2.5)
The test point is (-1.0, 0.5). Suppose that we want to find its 3rd nearest neighbor (k=3). The answer is the point (0.0, 5.0). Use printf “%.1f” format to show the decimal values.
It is guaranteed that
- 0 < N, D ≤ 1000
- k ≤ 30
- All coordinate values can be represented by float
Output
The kth nearest neighbor of x among the N points.
(We guarantee that the kth nearest neighbor of x is unique.)
Use printf “%.1f” format to show the decimal value.
There is a newline character ‘\n’ at the end of line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
There are n factories. Each factory can be assigned to produce one of the two kinds of cars (car A& car B). The net profit of producing car A or car B for each factory will be given. The goal is to assign x factories to produce car Aand y factories to produce car B so that the net profit is maximized. It is possible that some factories do not produce any cars (i.e. x + y <= n).
Suppose that you can choose two factories and switch the profits of car A for those two factories. You need to take into consideration of all possible switches and assignments of production, and find the best way to maximize the total profit. Based on the solution, your program needs to print the names of the x factories that produce car A in lexicographical order. If there are multiple answers, you need to print the one such that the total net profit of car Ai s maximum.
Note that if two factory produce same profits, choose the one with smaller lexicographical order. The swtich of car A of any two factory can be executed once only.
Note that when switch executed, the name of factory or the profit of car B will not be changed.
Input
The first line contains four integers n, x, y, representing the total number of factories, the number of factories planned to produce car A, and the number of factories planned to produce car B.
Each of the next n lines contains one string si and two integers ai, bii, representing the name of each factory and the net profit each factory can make if it is assigned to produce car A or car B.
It is guaranteed that
- 0 < n, x, y ≤ 300
- x + y <= n
- 1 ≤ | si | ≤ 20
- 0 < ai i, bi i < 106
- ai ≠ aj, bi ≠ bj if i ≠ j.
- No duplicate names.
Output
Find the assignment of the car type for each factory so that the profit is maximized.
Print the list of x factories that need to produce car A in lexicographical order.