使用STL
#include <bits/stdc++.h>
#define yuansheng int main(){
#define qidong return 0;}
using namespace std;
list<int> arr(1,1);
yuansheng
int T,x,y;char op;
scanf("%d",&T);
list<int>::iterator it;
++T;while (--T){
scanf("%hhd",&op);
it=arr.begin();
if (op==1){
scanf("%d%d",&x,&y);
while (*it!=x){++it;}
arr.insert(++it,y);
}else if (op==2){
scanf("%d",&x);
while (*it!=x){++it;}++it;
printf("%d\n",(it==arr.end())?0:*it);
}else{
scanf("%d",&x);
while (*it!=x){++it;}
arr.erase(++it);
}
}
return 0;
qidong