Why TLE???
//自己测样例输到
1 99 50
的时候卡住了
测试点全部TLE
#include<bits/stdc++.h>
#pragma GCC optimeze(1)
#pragma GCC optimeze(2)
#pragma GCC optimeze(3,"Ofast","inline")
using namespace std;
struct node {
int num;
node *next;
};
node *head,*p,*tail;
void add() {
int x,y;
cin>>x>>y;
node *it;
it=head->next;
while(it->num!=x) {
it=head->next;
}
p=new node;
p->num=y;
p->next=it->next;
it->next=p;
return;
}
void ask() {
node *it;
int x;
cin>>x;
it=head->next;
while(it->num!=x) {
if(it->next==NULL) {
cout<<"0"<<endl;
return;
}
it=it->next;
}
it=it->next;
cout<<it->num;
return;
}
void del() {
node *it;
it=head;
int x;
cin>>x;
while(it->num!=x) {
it=it->next;
}
p=it->next;
it->next=p->next;
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
head=new node;
tail=head;
p=new node;
p->num=1;
p->next=NULL;
tail->next=p;
tail=p;
int n;
cin>>n;
for(int i=1;i<=n;i++) {
int op;
cin>>op;
switch(op) {
case 1: {
add();
break;
}
case 2: {
ask();
break;
}
case 3: {
del();
break;
}
}
}
return 0;
}