rui_er
2024-11-16 10:31:58
闲话:这是 AtCoder 宣传片里的题,被我找到了!
先考虑
当
时间复杂度
核心代码:
//By: OIer rui_er
#define rep(x, y, z) for(int x = (y); x <= (z); ++x)
#define per(x, y, z) for(int x = (y); x >= (z); --x)
const int N = 2e5 + 5;
int n, m, d, a[N], p[N], f[30][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> m >> d;
rep(i, 1, m) cin >> a[i];
rep(i, 1, n) p[i] = i;
rep(i, 1, m) swap(p[a[i]], p[a[i] + 1]);
rep(i, 1, n) f[0][p[i]] = i;
rep(j, 1, 29) rep(i, 1, n) f[j][i] = f[j - 1][f[j - 1][i]];
rep(i, 1, n) {
int u = i;
per(j, 29, 0) if((d >> j) & 1) u = f[j][u];
cout << u << endl;
}
return 0;
}