2281 - I2P(II)2021_Yang_lab1 Scoreboard

Time

2021/03/12 13:20:00 2021/03/12 15:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13135 Got You! Suicune!
13136 Band Ya Rou Ze - Reverse

13135 - Got You! Suicune!   

Description

This is a partial judge problem OwO

Finally, Spongebob and Patrick have successfully escaped from the police capture. So it’s unnecessary for Patrick to cosplay as an usagi, aka Pekotrick. (To know what happened before, you can refer to 12885 - Pekotrick and Spongebob run away.)

In order to enjoy their life of leisure, they decided to go catch some jellyfish for fun. But due to their poor reading ability, they eventually go to the "Suicune" Field ????? ("Suicune" is also known as 水君 in Chinese.)


After arriving the Suicune Field, they observed that some Suicune would form a circle. And they always move regularly: two groups of consecutive Suicune would exchange their position without messing up the order inside a group.

Now you need to help Spongebob and Patrick record the information of Suicune circle. Formally there are N Suicune. For convenience, we always number all the Suicune from 1 to N in clockwise order. In the beginning, we know the Combat Power of the i-th Suicune is vi.
Then there are Q events. In the i-th event, two groups of consecutive Suicune would exchange their position. And the number of Suicune of these two groups is leni. One group is the leni consecutive Suicune which start from the ai-th Suicune(in clockwise order). Another group is the leni consecutive Suicune which start from the bi-th Suicune(in clockwise order). They will exchange their position simultaneously. Note we always number all the Suicune from 1 to N in clockwise order. So after one event, you may need to re-number all the Suicune.

And sometimes there may be a Suicune which is in the two groups simultaneously in some events. For this situation, we just ignore all the this kind of events(i.e Suicune would not exchange their position in those strange events).

In the end, tell Spongebob and Patrick the Combat Power of all the Suicune (in clockwise order).

Sample #2 Explanation

Let's take Sample #2 as an example. In Sample #2, N = 5 and Q = 1.

The first event: the 1st, the 2nd and the 3rd Suicune exchange their postion with the 2nd, the 3rd and the 4th Suicune. But the 2nd Suicune (or the 3rd Suicune ) is in the two groups simultaneously. So we just ignore this event(i.e the two groups don't exchange their position).

Finally the Combat Power of all the Suicune are still the same : 4 8 7 6 3.

Partial Code

Let's solve this problem with a circular linked list.

main.c

#include <stdio.h>
#include "function.h"
#define MAXN 100005
int arr[MAXN];
int main() {
    int N;
    scanf("%d", &N);
    for(int i=1;i<=N;i++)
        scanf("%d", &arr[i]);

    Node *head = NULL;
    createLinkedList(&head, N, arr);

    int Q;
    scanf("%d", &Q);
    for(int i=1;i<=Q;i++) {
        int a,b,len;
        scanf("%d %d %d", &a, &b, &len);
        swapTwoSegment(&head, N, a, b, len);
    }

    for(int i=1;i<=N;i++) {
        if(i > 1)    printf(" ");
        printf("%d", head->val);
        head = head->next;
    }
    printf("\n");
    return 0;
}

function.h

typedef struct node {
    struct node* next;
    int val;
} Node;
void createLinkedList(Node **head, int N, int *arr);
void swapTwoSegment(Node **head, int N, int a, int b, int len);

You need to implement the two functions: createLinkedList and swapTwoSegment.

Input

The first line contains one integer N (2 ≤ N ≤ 105) – the number of Suicune.

The second line contains N integers v1v2, ..., vN (1 ≤ vi ≤ N) – the Combat Power of each Suicune.

The third line contains one integer Q (1 ≤ Q ≤ 100) – the number of events.

Then Q lines follow. The i+3-th line contains three integer aibi and leni (1 ≤ aibi ≤ N, 1 ≤ 2 x leni ≤ N) – the number of the starting Suicune of two groups and the number of Suicune in these two groups.

 

It's guaranteed that:

  • The 1st testcase must be identical to the Sample #1 below
  • For the first six testcases: there must not be such a Suicune which is in the two groups simultaneously in each event.

Output

After all the events output the Combat Power of all the Suicune(in clockwise order).

 

Note: there are two sample below. "# Sample Input 1/2" and "# Sample Output 1/2" are not the part of input and output.

They are just for marking that the following content corresponds to which sample.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13135.c

Partial Judge Header

13135.h

Tags




Discuss




13136 - Band Ya Rou Ze - Reverse   

Description

After catching Suicune, Spongebob and Patrick thought they were happy enough so they went home. And then they found that Squidward had come home already (:

Squidward told them he need to drum up a marching band fast(for some reason). So he needed their help. Hence Spongebob and Patrick joined Squidward's band.

Today is their practicing day. Squidward is teaching all the members how to move at a performance. At a performance there are N rows. And in the i-th row, there are szi people. Note row may be empty(i.e. szi = 0). Everyone plays exactly one musical instrument. The musical instrument played by the j-th people in the i-th row is represented by a lower case letter cij.

Squidward ask them to move Q times. In each move, there are four types of moving:

  1. all the people in the ai-th row move to the front of the bi-th row (without messing up the original order)
  2. all the people in the ai-th row move to the back of the bi-th row (without messing up the original order)
  3. exchange all the people in the ai-th row and the bi-th row (without messing up the original order)
  4. reverse the order of all the people in the ai-th row

Now it’s your turn! You need to help them to move and tell Squidward the final formation in the end.

 

Hint for reverse:

1. Easy way , but you can only get 2 more correct answers.

But, you should think another way to accelerate your performance to get AC.

Input

The first line contains one integer N (1 ≤ N ≤ 105) – the number of rows.

Then N lines follow. First the i+1-th line contains one integer szi – the number of people in the i-th row. If there are some people in the row, a space character and szi characters cij are followed where cij is the musical instrument played by the j-th people in the i-th row. The sum of all the szi is less than or equal to 106.

The N+2-th line contains one integer Q (1 ≤ Q ≤ 105) – the times they need to move.

Then Q lines follow. The i+N+3-th line contains two integer typeiai. If typei isn't equal to 4, then a integer bi follows(1 ≤ typei ≤ 4, 1 ≤ aibi ≤ Nai ≠ bi) – they are the corresponding information for each moving.

 

It's guaranteed that:

  • The 1st testcase must be identical to the Sample #1 below
  • For the first three testcases: 1 ≤ NQ ≤ 103, the sum of all the szi ≤ 104, all the typei ≠ 4
  • For the first six testcases: all the typei ≠ 4
  • For the first eight testcases: the number of the fourth type of moving ≤ 100

Output

After all the moving, for each row output all the musical instrument played in that row and then print a newline('\n') character.

If there is no people in some row, just output an empty line.

 

Note: there are two sample below. "# Sample Input 1/2" and "# Sample Output 1/2" are not the part of input and output.

They are just for marking that the following content corresponds to which sample.

Sample Input  Download

Sample Output  Download

Tags

musukashi ne~QQ 統神端火鍋 Add Tag AC struct node* adj[2];



Discuss