40分求助
查看原帖
40分求助
911491
fanchenghao201061楼主2024/7/21 11:22
#include <iostream>
#include<cstring>
#include<math.h>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
int x,y,q,o,ta=2;
struct qwer 
{
	int n,w=0;
}a[100050];
int main()
{
	cin>>q;
	a[1].n=1;
	for(int i=1;i<=q;i++)
	{
		cin>>o;
		if(o==1)
		{
			cin>>x>>y;
			int nw=1;
			while(a[nw].n!=x&&a[nw].n!=0)
			{
				nw++;
			}
			a[ta].n=y;
			a[ta].w=a[nw].w;
			a[nw].w=ta;
			ta++;
		}
		if(o==2)
		{
			cin>>x;
			int nw=1;
			while(a[nw].n!=x&&a[nw].n!=0)
			{
				nw++;
			}
			cout<<a[a[nw].w].n<<endl;
		}
		if(o==3)
		{
			cin>>x;
			int nw=1;
			while(a[nw].n!=x&&a[nw].n!=0)
			{
				nw++;
			}
			a[nw].w=a[a[nw].w].w;
		}
	}
	return 0;
}
//6 1 1 99 1 99 50 1 99 75 2 99 3 75 2 1

提交记录

2024/7/21 11:22
加载中...