1881 - I2P(I)2019_Hu_final_practice Scoreboard

Time

2019/12/24 01:00:00 2020/01/06 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10893 Moving Cars(4 direction)
11315 Reverse Linked List
12544 Simple Web Crawer
12578 Smart Thief
12580 Chain of Ancestors
12581 Investigating the Abyss
12582 Function Pointer Practice

10893 - Moving Cars(4 direction)   

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

main.c

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

10893.c

Partial Judge Header

10893.h

Tags




Discuss




11315 - Reverse Linked List   

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

11315.c

Partial Judge Header

11315.h

Tags




Discuss




12544 - Simple Web Crawer   

Description

A Web crawler, sometimes called a spider or spiderbot and often shortened to crawler, is an Internet bot that systematically browses the World Wide Web.

Generally, a Web crawler visits a website, reads the HTML code of the website, gathers information it wants, and probably wants to visit the links it found in this website.

For example, if a Web Crawler visits the wikipedia webpage introducing "Web crawer" (the webpage is shown in the left part of the image) ...

  1. It reads the html code of the webpage (shown in the right part of the image)

  2. It gathers information. For example,

    1. It finds the definition of "Web Crawler"

    2. It finds several links (i.e. the blue words in the webpage), such as links to "Internet bot", "World Wide Web", etc.

  3. It probably wants to visit the links "Internet bot", "World Wide Web", ... one by one to get more information.

In this problem, you are going to implement a simple Web crawler. Given the html code of some website, you are going to output several information :

  • Title of the website

The title of the website is the string placed within <title> and </title>, for example, the title in sample input is "This is the title".

  • Numbers of links in this webpage

A link in html is in the following syntax : <a href="url">link text</a>, where url is the link address and link text is the text of the link.

Refer to the to Sample IO for output format.

Hints

  • What is html code?

    • In this problem, you only need to know that html code are several lines of strings in some special format.

    • html code are tags in the following format : <tagname>contents of tag</tagname>

    • In Chrome, you can press F12 key to see the html code of the website

  • How to read in html codes?

    • Some useful functions you've learned in previous homework 12507 - Searching Remark :

    • char *strtok(char *str, const char *delim) - to break string str into a series of tokens using the delimiter delim, which is defined under string.h

    • char *fgets(char *str, int n, FILE *stream) - to read a string of length n into string str from a file stream stream (e.g. stdin), which is defined under stdio.h

  • How to find title?

    • Why not start with finding the position of <title> and </title> ? The substring between <title> and </title> is the title of the website.

  • How to count links?

    • For every link in html, it must contains the substring </a>. This problem can be solved by counting the number of occurrence of </a>.

 

Input

You will be given a HTML code. Input contains at most 100 lines. Each line contains at most 1000 characters.

Technical Restrictions

Only the following tags will appear in the input :

  • <html> </html>

  • <head> </head>

  • <body> </body>

  • <title> </title>

  • <a> </a>

  • <h1> </h1>

  • <p> </p>

All tags except for <head></head> and <body></body> will be on the same line.

In each case, there will be exactly one <head></head>, one <body></body>, one <title></title>.

It is guaranteed that the contents of tags will not contain '<' or '>'.

Output

For the first line, please output the title of the given website.

For the second line, please output the number of links in the given website.

Remember to add new line character in the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12578 - Smart Thief   

Description

You are a smart thief who broke into sombody's house and found all the valuables.

You know the value of each item in the house, but kind as you are decided to take as few items as possible, as long as the sum of values you take is strictly greater than the sum of values of the remaining valuables.

Determine the number of items you will take.

Input

N

V_1 V_2 ... V_N

(N is a positive integer not exceeding 5000, and each V_i is a positive integer not exceeding 100000)

Output

The number of items to take, as an integer, followed by a newline character

Sample Input  Download

Sample Output  Download

Tags




Discuss




12580 - Chain of Ancestors   

Description

You are being reported about some relations in the form "x is the parent of y".

It is safe to assume that there will not be cycle relations (e.g., x is parent of y, y is parent of z, z is parent of x).

You are now curious about the maximum number of people you can choose, such that every person but one is the parent of exactly one other person (among those you chose), and every person but one is parented by exactly one other person (among those you chose).

Input

N M

X_1 Y_1

X_2 Y_2

...

X_M Y_M

 

(N and M are positive integers not exceeding 1000000, and X_i, Y_i are integers between 1 and N, it is guaranteed that no circular relationships will occur)

(X_i Y_i means X_i is the parent of Y_i)

Output

The desired output as an integer, followed by a newline character

Sample Input  Download

Sample Output  Download

Tags




Discuss




12581 - Investigating the Abyss   

Description

You are a great adventurer investingating the abyss.

The abyss can be described as a set of nodes, where each node may connect to some other nodes.

The abyss is known to imprison any creature to deeper levels, i.e., if it is possible to reach node v from node u, then it is impossible to reach node u from node v. However, you are not some ordinary creature, so you are not affected by this during your journey.

The abyss has only one entrance, node 1, and there is exactly one simple path (a path without visiting duplicate nodes) from node 1 to any other node.

You are curious for each node, the number of reachable nodes.

Input

N

X_1 Y_1

X_2 Y_2

...

X_{N-1} Y_{N-1}

 

(N is a positive integer not exceeding 100000, and X_i, Y_i are integers between 1 and N, it is guaranteed that no circular relationship will occur)

(X_i Y_i means there is a path between X_i and Y_i, and the direction is X_i to Y_i).

Output

A_1 A_2 A_3 ... A_N

, where A_i is the number of reachable nodes (excluding i itself) from node i.

Do put a newline character after the last number.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12582 - Function Pointer Practice   

Description

This is the practice for function pointer, you are be required to finish a task execulator using function pointer.

Given the below struct

 typedef struct{
    void (*func)(void *);
    void *argument;
}Task;

typedef struct{
    int* arr;
    int lower;
    int upper;
}Data;

typedef struct{
    Task **tasks;
    int size;
}Task_List;

and you need to implement 5 functions to pass this practice.

func1 :  void job1(void* argument);  // reverse

func2 :  void job2(void* argument);  // minus

func3 :  void job3(void* argument);  // double

func4 :  void initTask(Task* task, void(*func)(void*),void* argument);

func5 : void executeTasks(Task_List *task_list);

For this problem, we will give you a global array and you need to modify the value in global array with different job using function pointer

Take two simple cases for example:

case 1 : when user input lower = 0, upper = 5 and method = 0 (job1) for an array A = {1,2,3,4,5,6,7}

output: 6, 5, 4, 3, 2, 1, 7

case 2: when user input lower = 2, upper = 4 and method = 1 (job2) for an array A = {1,2,3,4,5,6,7}

output: 1, 2, -3, -4, -5, 6, 7

case 3: when user input lower = 0, upper = 0 and method = 2 (job3) for an array A = {1,2,3,4,5,6,7}

output: 2, 2, 3, 4, 5, 6, 7

main.c

function.h

 

Input

T

Mi Li Ui

...

T:  the number of task (2 < T < 100)

Mi: the type of job (Mi = {0, 1, 2})

Li: the lower bound of the array (0 <= Li < 25)

Ui: the upper bound of the array (Li <= Ui < 25)

Output

Output the global array after finishing all tasks.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12582.c

Partial Judge Header

12582.h

Tags




Discuss