跳到正文

题解

B3631solution+code

codingHe约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
获赞
1
题目
B3631

版本

  1. v1当前

直接实现链表 方便你们抄无注释

100分(long long不必开)

C++
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct stu{
	int next;
}lis[10000001];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int q;
	cin>>q;
	while(q--){
		int pd;
		cin>>pd;
		if(pd==1){
			int a,b;
			cin>>a>>b;
			int p=lis[a].next;
			lis[a].next=b;
			lis[b].next=p;
		}
		else if(pd==2){
			int a;
			cin>>a;
			cout<<lis[a].next<<endl;
		}
		else{
			int a;
			cin>>a;
			lis[a].next=lis[lis[a].next].next;
		}
	}
	return 0;
}
原文