比赛 2022级数学专题练习赛2 评测结果 AAAAAAAAAA
题目名称 Swapity Swapity Swap 最终得分 100
用户昵称 yrtiop 运行时间 0.339 s
代码语言 C++ 内存使用 12.29 MiB
提交时间 2022-12-19 19:22:05
显示代码纯文本
// Problem: P6148 [USACO20FEB] Swapity Swapity Swap S
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P6148
// Memory Limit: 250 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

const int maxn = 1e5 + 5;
int n,m,k,a[maxn],f[maxn][30];

int main() {
	freopen("usaco_Feb_swap.in","r",stdin);
	freopen("usaco_Feb_swap.out","w",stdout);
	scanf("%d %d %d",&n,&m,&k);
	for(int i = 1;i <= n;++ i)
		a[i] = i;
	for(int i = 1;i <= m;++ i) {
		int l,r;
		scanf("%d %d",&l,&r);
		std::reverse(a + l , a + r + 1);
	}
	for(int i = 1;i <= n;++ i)
		f[a[i]][0] = i;
	for(int j = 1;j < 30;++ j)
		for(int i = 1;i <= n;++ i)
			f[i][j] = f[f[i][j - 1]][j - 1];
	for(int i = 1;i <= n;++ i)
		a[i] = i;
	for(int j = 29;~ j;-- j) {
		if(k >> j & 1) {
			for(int i = 1;i <= n;++ i)
				a[i] = f[a[i]][j];
		}
	}
	for(int i = 1;i <= n;++ i)
		f[a[i]][0] = i;
	for(int i = 1;i <= n;++ i)
		printf("%d\n",f[i][0]);
	return 0;
}