2459 - I2P(I)2021_Hu_Hw13 Scoreboard

Time

2021/12/23 18:00:00 2022/01/03 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13072 Gugulo
13411 Do something to the linked-list
13412 I hate Christmas

13072 - Gugulo   

Description

You are given N integers a1a2, ..., aN, may contains same integers.

You need to answer Q queries: output how many integers of a1a2, ..., aN is less than or equal to xi.

Note: Be careful of the efficiency of your strategy.

Input

The first line contains one integer N (1 ≤ N ≤ 105) – the number of integers you are given.

The second line contains N integers a1a2, ..., aN (-2 x 109 ≤ ai ≤ 2 x 109).

The third line contains one integer Q (1 ≤ Q ≤ 105) – the number of queries you need to answer.

Then Q lines follow. The i+3-th line contains one integer xi (-2 x 109 ≤ xi ≤ 2 x 109) – the i-th query.

It's guaranteed that:

  • For every i < N,  xi ≥ xi+1(i.e every xi must be less than or equal to the previous xi).
  • For the first five testcases: 1 ≤ N ≤ 1000

Output

For every query output how many integers of a1a2, ..., aN is less than or equal to xi.

Sample Input  Download

Sample Output  Download

Tags




Discuss




13411 - Do something to the linked-list   

Description

In this partial-judge problem, you are asked to implement 2 functions:

Node* insert_sorted_list(Node* head, int val);
Node* merge_sorted_list(Node** heads);

 

For insert_sorted_list , you are given the head of a linked list and a integer val .You have to create a node with value val and insert it into the linked list so it can remain sorted.

The insertion operation will be like:

For merge_sorted_list , you have to merge 2 linked-list stored in the pointer array heads and remain the merged list sorted.

 

Input

There will be 2 lines of integers(1<= val <=100000000), which are the values of the 2 linked-lists.

The input stops when read in '-1' ('-1' is not a part of the 2 linked-lists).

 

Output

The values of the merged linked-list.

The values are separated by a whitespace and the output is also ended with a whitespace.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13411.c

Partial Judge Header

13411.h

Tags




Discuss




13412 - I hate Christmas   

Description

One day, you become a santa claus and have to send everyone gifts.

 

There is a line of people, and each one has a non-unique number card which represents what gifts they will receive.

(Because you are a smart santa claus, you use linked-list to record the numbers)

However, when you see there are so many couples standing together, you feel so angry and decide to rearrange the order with the following rule:

 

Given the head of the linked list containing multiple groups (the size of each group is k ), reverse the nodes inside each group at a time.

k is a positive integer and is less than or equal to the length of the linked list.

If the number of nodes is not a multiple of k, then the left-out nodes in the end should remain the same order.

You are not allowed to alter the values in each node.

 

For example, when k = 2:

 

Note that it is a partial-judge problem that you need to implement the function:

Node* Solver(Node* head, int k)

Input

The first line is composed of a sequence of integer(1<= val <=100000000), which represents the values of the linked list.

The input stops when read in '-1' ('-1' is not a part of the 2 linked-lists).

The second line is k,  the size of the group that will be reversed.(1 <= k <= length of the linked list)

Output

The values of the group-based reversed linked-list.

The values are separated by a whitespace and the output is also ended with a whitespace.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13412.c

Partial Judge Header

13412.h

Tags




Discuss