Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int N = 1e4 + 10;
- int n, k;
- int a[N];
- int b[N];
- int main(){
- cin >> n >> k;
- for (int i = 1; i <= n; i ++) cin >> a[i];
- while (k --) {
- int ki, kn;
- cin >> ki >> kn;
- for (int i = 1; i <= kn; i ++) cin >> b[i];
- for (int i = n, j = n + kn; i >= ki; i --, j --) { // 后移
- a[j] = a[i];
- }
- n += kn;
- for (int i = ki, j = 1; j <= kn; i ++, j ++) { // 插入
- a[i] = b[j];
- }
- }
- for (int i = 1; i <= n; i ++) cout << a[i] << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement