2241 - I2P(I)2020_Hu_lab11 Scoreboard

Time

2021/01/04 18:30:00 2021/01/04 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13082 Merge sorted lists
13087 Implement Linked List 2

13082 - Merge sorted lists   

Description

This is a partial judge problem.

Given two sorted linked lists which length are N and M respectively, you need to merge them into one sorted list and delete the duplicated numbers.

function.h

typedef struct _Node {
    int data;
    struct _Node *next;
} Node;

Node* Merge_lists(Node*, Node*);

You only need to implement the Merge_lists(Node*, Node*) function which take two sorted linked list as input.

 

Input

First line contains two integers which denote the number of the integers of two sorted lists. (1 <= N.M <= 10, 1 <= each integer <= 30)

Second line contains N integers which denote the first given sorted list.

Third line contains M integers which denote the second given sorted list.

Output

One merged sorted linked list result.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13082.c

Partial Judge Header

13082.h

Tags




Discuss




13087 - Implement Linked List 2   

Description

Given a link list structure named Node.

typedef struct _Node {

    int data;

    struct _Node *next;

} Node;

In this problem, you need to implement seven operations for the linked list. 

func1: Node* createList(int *a, int size);

func2: void push_front(Node** head, int val);

func3: Node* copyList(Node* head);

func4: void deleteElementByIdx(Node** head, int idx);

func5: void SwapElementByIdx(Node** head, int idx1, int idx2);

func6: void ReverseList(Node** head);

func7: void ShiftListByK(Node ** head, int k);

func1: using an array to build the link list

func2: append the input value to the first element in the linked list

ex:  origin linked list : [0, 1, 2, 3], when call the function push_front(&head, 5). the final linked list will be [5 ,0 ,1, 2, 3]

func3: copy the original link list (not directly to assign it)

func4: delete the element by its index (begin from 0)

ex: origin linked list : [0, 1, 2, 3], when call the function deleteElementByIdx(&head, 0). the final linked list will be [1,2,3]

note that: if the idx out of range. you should ignore the delete operation

func5: swap the element in linked list by given idx1 and idx2 (both begin from 0)

ex: origin linked list: [0, 1, 2, 3], when call the function SwapElementByIdx(&head, 0, 3). the final linked list will be [3, 1, 2, 0]

note that: if the idx1 or idx2 out of range, you should ignore the swap operation  

func6: reverse the linked list.

ex: origin linked list: [0, 1, 2, 3],when call function ReverseList(&head), the final linked list will be [3, 2, 1, 0]

func7: right shift the linked list by the given integer K.

ex: origin linked list: [0, 1, 2, 3], K: 1, when call function ShiftListByK(&head, 1), the final linked list will be [3, 0, 1, 2].

Note: We guarantee that function 1, 3~7 will not operate on an empty list.

Input

T M

S1 .. SM

t1_command

...

tT_command

T: the number of command ( 0 <= T < 200)

M: the number of initial linked size (0 <= M <= 2000)

Si: the value of the initial array (0 <= Si <= 1000)

ti_command: the command description

K: the value of the shift length for the function 7 (0 <= K <= 10^9)

(0: push_front, 1: clone, 2: delete, 3: swap, 4: reverse, 5: shift)

Hint: 

testcase1 : contain only function 1

testcase2: contain only function 2

testcase3: contain function 1~3

testcase4: contain function 1~4

testcase5: contain function 1~5

testcase6: contain only function 1,6

testcase7: contain only function 1.6,7

testcase8: contain all functions

Output

Output the element in linked list whenever the operation be called.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13087.c

Partial Judge Header

13087.h

Tags




Discuss