| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11289 | reverse linked list |
|
| 11290 | Moving Cars(4 direction) |
|
| 11291 | Mouse Maze |
|
| 11292 | Find/Revision |
|
Description
Given a link list structure named Node.
typedef struct _Node {
int data;
struct _Node *next;
} Node;
Use this structure to implement a reversing linked list.
You will be provided with main.c and function.h, and asked to implement function.c.
For OJ submission:
Step 1. Submit only your function.c into the submission block. (Please choose c compiler)
Step 2. Check the results and debug your program if necessary.
Input
The input contains a sequence of positive integers as the linklist and the order, except the last one, which is -1, indicating the end of the sequence.
Output
The output contains the sequence of resulting linklist.
Sample Input Download
Sample Output Download
Partial Judge Code
11289.cPartial Judge Header
11289.hTags
Discuss
Description
Given the position of N cars on a map, we have to list the valid moves of each car along 4 directions (i.e. right, down, left and up).
Note that all cars can move horizontally and vertically.
For example, a map with 10 cars is shown below:
Given the coordinate of car 2 is 2 3 2 6, it means car 2 occupies the position of (2,3) to (2,6) in the map.
The valid moves of car 2 is 1 0 0 2, which means it can move right 1 grid but can’t move down, left and it can move up 2 grid.
HINTS:
function.h
#ifndef FUNCTION_H #define FUNCTION_H #define MAP_SIZE 9 #define MAX_CARS 10 #define SPACE '.' char map[MAP_SIZE][MAP_SIZE]; int cars[MAX_CARS][4]; void list_moves(int); #endif
main.c
#include <stdio.h>
#include "function.h"
int main(void)
{
int i,j,k;
int num_cars;
scanf("%d",&num_cars);
//reset map
for (i=0; i<MAP_SIZE; i++) {
for (j=0; j<MAP_SIZE; j++) {
map[i][j] = SPACE;
}
}
//read coordinates of cars and put them on the map
for (i=0; i<num_cars; i++) {
scanf("%d%d%d%d", &cars[i][0], &cars[i][1], &cars[i][2], &cars[i][3]);
for (j=cars[i][0]; j<=cars[i][2]; j++) {
for (k=cars[i][1]; k<=cars[i][3]; k++) {
map[j][k] = i+'0';
}
}
}
list_moves(num_cars);
return 0;
}
Input
The first line is a number N (1<=N<=10), which means the total number of cars.
The following N lines are the coordinates of all cars.
Each line consists of 4 numbers. The first two numbers are the row and column of the head of the car. The other two numbers are the row and column of the tail of the car.
Output
Print out the valid moves of the cars in each line.
Each line consists of 4 number, the valid moves along right, down, left and up.
All of the numbers in the same line are separated by a space, and there is a '\n' at the end of each line.
Sample Input Download
Sample Output Download
Partial Judge Code
11290.cPartial Judge Header
11290.hTags
Discuss
Description
Write a program that simulates a mouse in a maze. The program must count the steps taken by the mouse from the starting point to the final point.
The maze type is shown in following figure:
S$###
$$#$$
$$$##
##$$F
it consists of S (starting point), #(walls), $(road) and F (final point).
In above case, it needs 7 steps from S to F as following figure,
S$###
$$#$$
$$$##
##$$F
and the mouse can move in the four directions: up, down, left, right. There may be more than one way to reach final point, the program only need to print the least steps.
If there is no way from S to F, then print -1.
Input
The first line has an integer N(1<=N<=10^6), which means the number of test cases.
For each case, the first line has two integers. The first and second integers R and C (3<=R, C<=500) represent the numbers of rows and columns of the maze, respectively. The total number of elements in the maze is thus R x C.
The following R lines, each containing C characters, specify the elements of the maze.
Output
Print out the least steps for each case, and there is a new line character at the end of each line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a bunch of data which are composed of each student’s name, height (cm), and weight (kg), in this problem, you are asked to design a simple system. The operation of the system is described as follows:
Firstly, the instruction 'F' denotes “Find”, which means the system would print out the results containing the keyword for which the user wants to search in lexicographical order of students’ name. Noted that uppercase alphabet is different from lowercase alphabet when finding the keyword. Also, note that if there does not exist the data containing the keyword, the system would output “NOT FOUND”. Secondly, the instruction 'R' denotes “Revision”, which means the user can revise the ith raw/modified data accordingly. Note that if there are repeated student name after revision, the system would delete both sets of the data. Finally, the program terminates if the user enters character ‘E’ no matter in uppercase or lowercase. For instance,
Raw data
Instruction
Since there are two students named Benny after revision, both of the data #2 and data #4 would be automatically deleted by the system. Then, the user uses 'R' to update the data and wants to find whether there is any data containing keyword “70”. If exist, output the results in lexicographical order of students’ name.
Modified data
Output
Note that
1. This problem involves three files.
- function.h: Function definition of Find_Revise.
- function.c: Function describe of Find_Revise.
- main.c: A driver program to test your implementation.
You will be provided with main.c and function.h, and asked to implement function.c.
2. For OJ submission:
Step 1. Submit only your function.c into the submission block. (Please choose c compiler)
Step 2. Check the results and debug your program if necessary.
Hints:
function.h
#ifndef FUNCTION_H_INCLUDED
#define FUNCTION_H_INCLUDED
#define SIZE 50
typedef struct{
char Name[15];
char Height[15];
char Weight[15];
} Info;
void Find_Revise(Info* , int , char , int* );
#endif // FUNCTION_H_INCLUDED
main.c
#include <stdio.h>
#include <stdlib.h>
#include "function.h"
int main()
{
int num, i;
char instr;
int isEnd=0;
Info List[SIZE];
scanf("%d", &num);
for(i=0;i<num;i++){
scanf("%s%s%s", List[i].Name, List[i].Height, List[i].Weight);
}
while(!isEnd){
scanf(" %c", &instr);
Find_Revise(List, num, instr, &isEnd);
}
return 0;
}
Input
1. The first line N is the number of the students, N ≦ 50.
2. The following N lines are sets of data, where length of Name ≦ 8 characters(alphabet), Height is a 3-digits integer, and Weight is a 2-digit integer.
3. The remaining lines are instructions, where instruction 'F' is followed by a string (length ≦ 8), instruction 'R' is followed by a integer representing the ith raw data, Name, Height, and Weight.
Output
1. Each Name in the output takes 10 characters space, each Height and Weight take 8 characters space. (i.e. %-10s......)
2. Note that there is a newline ‘\n’ at the end of each line.