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).
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.
Let's solve this problem with a circular linked list.
#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; }
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.
The first line contains one integer N (2 ≤ N ≤ 105) – the number of Suicune.
The second line contains N integers v1, v2, ..., 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 ai, bi and leni (1 ≤ ai, bi ≤ 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:
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.