比赛 2024暑假C班集训E 评测结果 AAAAAAAAAA
题目名称 Swapity Swapity Swap 最终得分 100
用户昵称 ┭┮﹏┭┮ 运行时间 0.169 s
代码语言 C++ 内存使用 5.24 MiB
提交时间 2024-07-14 09:10:33
显示代码纯文本
#include <bits/stdc++.h> 
using namespace std;
#define ll long long
const int N = 1e5+10;

ll read(){
    ll x = 0,f = 1;char c = getchar();
    for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
    for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
    return x * f;
}


int n,m,k;
struct group{
    int a[N];
    group operator * (const group x)const{
        group y;
        for(int i = 1;i <= n;i++)y.a[i] = x.a[a[i]];
        return y;
    }
}F,U;
int a[N];

int main(){
    freopen("usaco_Feb_swap.in","r",stdin);
    freopen("usaco_Feb_swap.out","w",stdout);
    n = read(),m = read(),k = read();
    for(int i = 1;i <= n;i++)F.a[i] = i,U.a[i] = i;
    for(int i = 1;i <= m;i++){
        int l = read(),r = read();
        for(int j = l;j <= r;j++)a[j] = F.a[r - (j - l)];
        for(int j = l;j <= r;j++)F.a[j] = a[j];
    }
    while(k){
        if(k & 1)U = U * F;
        F = F * F,k >>= 1;
    }
    for(int i = 1;i <= n;i++)printf("%d\n",U.a[i]);
    
    
    return 0;
    
}