在本机编译通过,在洛谷编译错误
查看原帖
在本机编译通过,在洛谷编译错误
749222
lianghaofeng楼主2024/7/20 21:19
#include<bits/stdc++.h>
using namespace std;
int n;
int next[1000001];

void insert(int x,int y){
	next[y]=next[x];
	next[x]=y;
}

void remove(int x){
	next[x]=next[next[x]];
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++){
		int s,x,y;
		cin>>s;
		if(s==1){
			cin>>x>>y;
			insert(x,y);
		}
		if(s==2){
			cin>>x;
			cout<<next[x]<<endl;
		}
		if(s==3){
			cin>>x;
			remove(x);
		}
	}
	
} 
2024/7/20 21:19
加载中...