vector的使用会使代码变得很简单
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
vector <int>a;
vector<int>::iterator it; int main(){int n , q, cmd, k, num;while(scanf("%d%d", &n,&q) != EOF){a.clear(); a.push_back(0); while(n--){scanf("%d", &num);a.push_back(num);}while(q--){scanf("%d%d", &cmd, &k);if(cmd == 1){scanf("%d", &num);a.insert(a.begin() + k, num);}else if(cmd == 2){a.erase(a.begin() + k);}else if(cmd == 3){it = a.begin() + k;printf("%d\n", *it);}}} return 0;
}