#include <iostream>
#include <cstdio>
using namespace std;
struct lb
{
int n;
lb *next;
};
lb *p, *t, *r, *p2;
void find(int n)
{
p = t;
for (; p->next != NULL; p = p->next)
{
if (p->n == n)
{
return;
}
}
}
int main()
{
t = new lb;
t->n = 1;
t->next = NULL;
r = t;
int n;
cin >> n;
int x, y, z;
for (int i = 1; i <= n; i++)
{
cin >> x;
switch (x)
{
case 1:
{
cin >> y >> z;
find(y);
p2 = new lb;
p2->n = z;
p2->next = p->next;
p->next = p2;
break;
}
case 2:
{
cin >> y;
find(y);
if (p->next == NULL)
{
printf("0\n");
}
else
{
printf("%d\n", p->next->n);
}
break;
}
case 3:
{
cin >> y;
find(y);
p->next = p->next->next;
break;
}
}
}
return 0;
}
不出意外的超时了,80分