求助!10分,悬赏关注
查看原帖
求助!10分,悬赏关注
632311
huyangmu楼主2023/9/6 22:11
#include<bits/stdc++.h>
using namespace std;
const int N=0;
const int M=1e6+1;
int n,id,x,y,pre[1000005],nxt[1000005];
void link (int x,int y){
	nxt[x]=y;
	pre[y]=x;
}
void del (int x){
	link(pre[x],nxt[x]);
}
void insert_l (int x,int y){
	link(pre[y],x);
	link(x,y);
}
void insert_r (int x,int y){
	link(x,nxt[y]);
	link(y,x);
}
int main (){
	cin>>n;
	link(N,1);	
	link(1,M);	
	while (n--){	
		cin>>id;
		if (id==1){
			cin>>x>>y;
			link(x,y);
		}else if (id==2){
			cin>>x;			
			cout<<nxt[x]<<'\n';
		}else{
			cin>>x;
			del(nxt[x]);
		}
	}
	return 0;
} 
2023/9/6 22:11
加载中...