tle求助
#include<bits/stdc++.h>
using namespace std;
struct node{
int val;
node* next;
node(int x):val(x),next(NULL){}
};
enum func{
_insert=1,_find,_remove
};
node* findn(node* head,int pur){
for(;head!=NULL;head=head->next)
{
if(head->val==pur)return head;
}
return NULL;
}
void insertn(node* pre,node* ins){
ins->next=pre->next;
pre->next=ins;
return;
}
void removen(node* pre){
node* tem=pre->next->next;
delete pre->next;
pre->next=tem;
return;
}
int main(){
int n;
cin>>n;
node* head=new node(1);//initialize
for(int ll=0;ll<n;ll++)
{
int type,x,y;
cin>>type;
if(type==_insert)
{
cin>>x>>y;
node* tem=new node(y);
insertn(findn(head,x),tem);
}
if(type==_find)
{
cin>>x;
node* temp=findn(head,x);
if(temp->next==NULL)
cout<<0<<endl;
else cout<<temp->next->val<<endl;
}
if(type==_remove)
{
cin>>x;
removen(findn(head,x));
}
}
return 0;
}