| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11240 | license |
|
| 11241 | Simple Addition |
|
| 11704 | Deliver gifts |
|
| 11712 | Morse code |
|
| 12071 | Traveling mail carrier |
|
| 12073 | character replacement |
|
Description
There are N license. Each license has four-digit integer, each integer between 1 to 9. For example, if N=7, the input may look like
7
1324
5566
3578
4123
5656
4312
9847
We want to get the licenses that use the same digits and the digits should be sorted from small to large. For example, 1324, 4123, and 4312 are the combination of the same digits (1, 2, 3, and 4). We want to get 1234. Similarly, 5566 and 5656 are the combination of the same digits (5, 5, 6, and 6). We want to get 5566.
For output, we list the modified licenses in an increasing order line by line, so the output will look
1234
5566
<Hint>
You may consider the following algorithm:
0. Create a character array (char str[5];) for storing the input integers and create an array which is initialed to zero (int HIT[10000];) to record the occurrences of input integers.
1. Read the number of input integers and store it in variable N (scanf("%d", &N);).
2. For each of the next N integers, do
2.1 Read the four-digit integer and store it as a four-character string in str.
2.2 Use the bubble sort algorithm to rearrange the four characters.
2.3 Convert the rearranged string to an integer m and increase the value of the corresponding element of the HIT array by 1 (HIT[m]++;).
3. Check each element of the HIT array; if its value is larger than 2, print the corresponding integer.
The bubble sort algorithm:
/* Using bubble sort to rearrange an array A[n] */
for (i = n; i > 0; i--) {
for (j = 1; j < i; j++) {
if (A[j-1] > A[j]) {
/* swap A[j-1] A[j] */
}
}
}
Input
The first line contains a number N (1<=N<=100).
The next N lines provide the N four-digit integers.
Output
Each line shows a modified unique integer as explained in the problem description.
Remember to print a newline at the end of each line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Four arrays A, B, C and D with size MxN. B, C, D are stored in an array of pointers, and A is stored in a separated array. The task is to add the designated elements of A and the corresponding element from a chosen array of B, C, D, and output the result.
Take sample input as an example. Size of the arrays are 3 rows by 2 columns, initial values are as the form below. Input number “2” in the sixth line indicates D is chosen array and we want the sum of elements with two indices (1,0), (2,0)
Therefore, the answer is A(1,0)+D(1,0)+A(2,0)+D(2,0)=2+8+4+10=24
You will be provided with the following sample code, and asked to implement function "addition".
#include <stdio.h>
int addition(int*, int, int*[], int*, int);
int main(void) {
int a[50][50], b[50][50], c[50][50], d[50][50];
int index_to_add[20];
int *entry[3];
int i, j, m, n, array_num, num_ind;
scanf("%d %d", &m, &n);
for(i=0; i<m; i++)
for(j=0; j<n; j++)
scanf("%d", &a[i][j]);
for(i=0; i<m; i++)
for(j=0; j<n; j++)
scanf("%d", &b[i][j]);
for(i=0; i<m; i++)
for(j=0; j<n; j++)
scanf("%d", &c[i][j]);
for(i=0; i<m; i++)
for(j=0; j<n; j++)
scanf("%d", &d[i][j]);
scanf("%d", &array_num);
scanf("%d", &num_ind);
for(i=0; i<num_ind*2; i=i+2)
scanf("%d %d", &index_to_add[i], &index_to_add[i+1]);
entry[0] = &b[0][0];
entry[1] = &c[0][0];
entry[2] = &d[0][0];
printf("%d\n", addition(&a[0][0], array_num, entry, index_to_add, num_ind));
return 0;
}
int addition(int* ptr_a, int array_num, int* entry[], int* index_to_add, int num_ind){
/*your code*/
}
Input
The first line is the size of arrays, M rows by N columns. The following four lines are initial values arranged by row major. The sixth line tells B, C or D is chose. The next line is the number of elements k to be summed. And the last k lines are the row and column indices of elements to be add. 0 < M, N < 50. 0 < k < 10. Index starts from 0.
Output
An integer, sum of desired elements.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
A teacher is going to deliver N gifts to N students in the class. Every student can get exactly one gift. Since the value of each gift is different, the teacher decides to deliver the gifts based on student ranks. Thus, he evaluates each gift with a value T, which means only the students who rank higher than or equal to T are allowed to receive that gift. You are asked to write a program counting how many ways there are for the teacher to deliver those gifts.
For example, there are 3 students in the class (N=3), and the 3 gifts are valued as 2, 3, 3. So there are 4 different ways to deliver those gifts: {1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, where a solution {a, b, c} means the first gift (with value 2) is delivered to the student with rank a, the second gift (with value 3) is delivered to the student with rank b, and the last gift (with value 3) is delivered to the student with rank c.
P.S. The problem is from 2015 網際網路程式設計全國大賽
Input
The first line contains a positive integer N.
The second line consists of N positive integers, indicating the value Ti of the N gifts.
1 ≤ N ≤ 20
1 ≤ Ti ≤ N
Output
Please output an integer, indicating how many ways there are to deliver those gifts.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Morse code is a way to represent English letters (here we only consider capital letters). The code is composed of some long signals and some short signals. For convenience, we represent a long signal as '-' and represent a short signal as '*'. Then ‘/’ is used to serve as a blank that distinguishes each word that consists of several letters.
For example, ''NPSC GG'' is ''-* *--* *** -*-* / --* --*", where “-*” = N and “*--*” = P, and the code for other letters is shown below.

However, these long and short signals in the Morse code cannot be represented using gesture. A way to simulate the long and short signals is as follows:
- “===” represents a long signal. (hitting table for 3 times)
- “=” represents a short signal. (hitting table for 1 time)
- For a letter, “.” is used as a pause to separate signals.
- In a word, “…” is used as a pause to separate letters.
- “…….” is used to separate words (that is, to represent ‘/’ as mentioned above).
For example, “NPSC GG" can be encoded as follows:

P.S the problem is from 2015 網際網路程式設計全國大賽
Input
There are two lines. The first line is an integer N, meaning the second line will give a string with length N, and this string is only composed of '=' and '.'.
.N <= 999.
.The output string begins and ends with a non-blank letter.
Output
Print the result after decoding
Following is a sample test case:
Input:
57
=.===...===.=.=.=...===.=.===.=...===.=.=...=...=.=.===.=
Output:
ABCDEF
Sample Input Download
Sample Output Download
Tags
Discuss
Description
A mail carrier needs to deliver letters to multiple places and goes back to the post office to take a rest.
Traveling outside makes him feel tired, so he would like to come up with a shortest path.
Given all distances between every pair of places (including the post office and all destinations), please help the mail carrier figure out the best shortest path, which starts from the post office and ends at the post office.
An additional requirement is that the mail carrier can just go to each place only one time (excluding the starting point, he can go to the start point at the beginning and in the end).
Input
The first line contains an integer N, indicates there are N places (including the post office).
Then there is one N*N martix occupies N lines, with each line contains N integers (>= 0).
ith row jth column = Matrix(i,j) = distance between place i and place j.
The place with index = 0 is the post office.
For all i, j >= 0, Matrix(i,j) = Matrix(j,i), Matrix(i,i) = 0.
N is at most 10 among all test cases.
Output
Print out the minimum distance the mail carrier has to travel to complete his task.
'\n' at the end of output.Sample Input Download
Sample Output Download
Tags
Discuss
Description
There will be some sample code for this problem .
The first line contains a string s.
There will be only lowercase Latin characters in s.
The second line will be an integer T, which is the change time. And T< 107.
For the next T line , each line will contains two character x, y , which means for any x in s should be replacement as y .
- function.h: Function definition of changeCharacter.
- function.c: Function describe of changeCharacter.
- main.c: A driver program to test your implementation.
Input
| s | < 10000
x, y will be lowercase Latin characters
For the testcase one , there is no change to original string s.
If you get any Runtime error in testcase one, think twice what's wrong with your pointer :D .
Output
In the end , output the string s one time !
'\n' at the end of output.