CodeForces

http://codeforces.com/problemset/problem/669/D

题意:n个数1~N围成一个圈。q个操作包括操作1:输入x, 所有数右移x。操作2:1,2位置上的数(swap(a[1], a[2])交换;3,4交换。。。。

题解:观察,发现所有奇数行为都是一样的,偶数同理,(对于操作1 两者相同,对于操作2 奇数位++,偶数位上--;

模拟1,2,即可,然后依次输出其它数字即可。(看清

ac代码:

#define    _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int maxn = 1e6  + 5;
const int mod= 1e9 + 5;
int a[maxn], x[maxn];
int main(){
    int n, q;
    cin >> n >> q;
    int A=1, B=2;
    for (int i = 1; i <= q; i++) {
        int x;
        scanf("%d", &x);
        
        if(x==1){
            scanf("%d", &x);
            A += x;
            B += x;
        }
        else {
            if (A & 1)A++, B--;
            else A--, B++;
        }
        A %= n;
        B %= n;
    }
    while (A <= 0)A += n;
    while (B <= 0)B += n;
    for (int i = 1; i < n; i+=2) {
        a[A] = i; a[B] = i + 1;
        A+=2; B+=2;
        if (A > n)A -= n;
        if (B > n)B -= n;
    }
    for (int i = 1; i <= n; i++)cout << a[i] << ' ';
}
成功的路并不拥挤,因为大部分人都在颓(笑)
原文地址:https://www.cnblogs.com/SuuT/p/8543196.html