2956 - 2024_IDS_Spring_Lab2 Scoreboard

Time

2024/03/04 00:00:00 2024/03/11 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

14227 - 2024_IDS_Spring_Lab2_Bracket matching   

Description

You are given n string, each string Si consisting of parentheses '(', ')', '[' and ']'.
A string S is said to be *correct* if:
1. S is the empty string
2. A and B are correct, S = AB
3. A is correct, S = (A) or S = [A]

Judge each of n string is *correct* or not. If yes, print a line "Y". Otherwise, print a line "N".

Input

The first line contains an integer n — the total number of string you have to judge it is correct or not.

Each of the following n lines contains a string Si.

Restrictions

  • 1 ≤ n ≤ 103
  • 1 ≤ ∣Si∣ ≤ 104 for i=1,2,⋯ ,n
  • For testcase 1, 1 ≤ n ≤ 10,1 ≤ ∣Si∣ ≤ 102

Output

For each string, output one line following problem description.

Please add a newline at the end of the output. (Beside the last case)

Sample Input  Download

Sample Output  Download

Tags




Discuss




14228 - 2024_IDS_Spring_Lab2_Josephus Problem   

Description

Consider a game where there are n children (numbered 1,2,⋯ ,n) in a circle. During the game, every second child is removed from the circle, until there are no children left. Counting begins at child 1 in the circle and proceeds around the circle in clockwise direction (where the number of the children is increasing except child n and child 1). In which order will the children be removed?

Input

The only input line has an integer nn.

Constraints

  • 1≤n≤2⋅105

Output

Print n integers: the removal order.

Do not include any spaces at the end of line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




14229 - 2024_IDS_Spring_Lab2_Basic Linked List Problem   

Description

Maintain a linked list, which supports the following operations:

  • IH i : Insert head. Insert a new node with integer i to the head of the linked list.

  • IT i : Insert tail. Insert a new node with integer i to the tail of the linked list.

  • RH : Remove head. Remove the node at the head of the linked list. (If the linked list is empty, don't do anything.)

  • RT : Remove tail. Remove the node at the tail of the linked list. (If the linked list is empty, don't do anything.)

  • S i : Search. Traverse the linked list and find if there exists a node with integer i. If yes, print a line "Y". Otherwise, print a line "N". (If the linked list is empty, print a line "E".)

  • O : Output. Traverse the linked list from head to tail. Print the integers saved in the nodes sequentially. (If the linked list is empty, print a line "E".)

Input

The first line is an integer n, being the number of operations. Following n lines, each line contains one operation described above.

Restrictions

  • For testcase 1, 1≤n≤104
  • For testcase 2, 1≤n≤105
  • For testcase 3, testcase 4 and testcase 5, 1≤n≤106
  • In each testcase, 1≤i≤99 for every i in "Insert head", "Insert tail" and "Search" operations
  • In each testcase, it is guaranteed that the total number of "Search" operations and "Output" operations will not exceed 50

Note that:

  • In single testcase, the integers i of "Insert head" and "Insert tail" operations may duplicate.
  • You may receive operations "Remove head", "Remove tail", "Search" or "Output" when the linked list is empty.

HINT:

You may reference following structure to construct your linked list.

struct Node
{
    int data;
    Node *prev;
    Node *next;
};

Output

For each "Search" operation and "Output" operation, output one line.

Remember to print a ‘\n’ at the end of the output.

Do not include any spaces at the end of line.

Sample Input  Download

Sample Output  Download

Tags




Discuss