题意:1~n的一个初始序列,m个操作(ai, bi),表示将(ai, bi + ai - 1)区间移到最前面,让你求最后的序列;
分析:
伸展树?不会呀,直接rope+输入挂 搞过!
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <ext/rope>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
using namespace __gnu_cxx;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const LL INF = 1LL << 60;
const int mod = 1e9 + 7;
const int MAXN = 1e4 + 10;
rope<int> rop;//定义方式
template <class T> inline void scan_d(T &ret) {
char c; ret = 0;
while ((c = getchar()) < '0' || c > '9');
while (c >= '0' && c <= '9') {
ret = ret * 10 + (c - '0'), c = getchar();
}
}
int main() {
int n, m, a, b;
scanf("%d %d", &n, &m);
for(int i = 1; i <= n; ++i) rop.push_back(i);
for(int i = 1; i <= m; ++i) {
scan_d(a);
scan_d(b);
rop = rop.substr(a - 1, b) + rop.substr(0, a - 1) + rop.substr(a + b - 1, n - a - b + 1);//直接序列拼接
}
for(int i = 0; i < n; ++i) {
printf("%d%c", rop[i], (i == n - 1) ? '\n' : ' ');
}
return 0;
}