Advertisement
wym1111

Untitled

Nov 18th, 2023
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 1e4 + 10;
  5.  
  6. int n, k;
  7. int a[N];
  8. int b[N];
  9.  
  10. int main(){
  11.     cin >> n >> k;
  12.     for (int i = 1; i <= n; i ++) cin >> a[i];
  13.     while (k --) {
  14.         int ki, kn;
  15.         cin >> ki >> kn;
  16.         for (int i = 1; i <= kn; i ++) cin >> b[i];
  17.         for (int i = n, j = n + kn; i >= ki; i --, j --) { // 后移
  18.             a[j] = a[i];
  19.         }
  20.         n += kn;
  21.         for (int i = ki, j = 1; j <= kn; i ++, j ++) { // 插入
  22.             a[i] = b[j];
  23.         }
  24.     }
  25.     for (int i = 1; i <= n; i ++) cout << a[i] << ' ';
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement