比赛 |
2024暑假C班集训E |
评测结果 |
AAAAAAAAAA |
题目名称 |
Swapity Swapity Swap |
最终得分 |
100 |
用户昵称 |
darkMoon |
运行时间 |
0.358 s |
代码语言 |
C++ |
内存使用 |
6.05 MiB |
提交时间 |
2024-07-14 09:41:17 |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
// #define fin cin
// #define fout cout
ifstream fin("usaco_Feb_swap.in");
ofstream fout("usaco_Feb_swap.out");
auto mread = [](){
int x;
fin >> x;
return x;
};
const int N = 1e5 + 5, M = 105;
int n = mread(), m = mread(), k = mread(), l[M], r[N];
struct node{
int a[N] = {0};
node(){
for(int i = 1; i <= n; i ++){
a[i] = i;
}
return;
}
friend node operator *(node a, node b){
for(int i = 1; i <= n; i ++){
a.a[i] = b.a[a.a[i]];
}
return a;
}
}g, tmp, ans;
signed main(){
for(int i = 1, l, r; i <= m; i ++){
l = mread(), r = mread();
for(int j = 1; j <= n; j ++){
if(j >= l && j <= r){
g.a[j] = r - (j - l);
}
else{
g.a[j] = j;
}
}
tmp = g * tmp;
}
while(k){
if(k & 1){
ans = ans * tmp;
}
tmp = tmp * tmp;
k >>= 1;
}
for(int i = 1; i <= n; i ++){
fout << ans.a[i] << "\n";
}
return 0;
}