实在想不出来什么东西去de这个bug了
#include <cstdio>
const int MAXN = int(1e6) + 6;
struct node
{
int left = 0;
int right = 0;
}Node[MAXN];
int main()
{
int n;
int head = 1;
scanf("%d", &n);
for(int i = 2; i <= n; i++)
{
int k, p;
scanf("%d %d", &k, &p);
if(p)
{
Node[k].right = i;
Node[i].left = k;
}
else
{
Node[k].left = i;
Node[i].right = k;
}
if(k == head && !p)
head = i;
}
int m;
scanf("%d", &m);
for(int i = 1; i <= m; i++)
{
int x;
scanf("%d", &x);
if(head == x)
{
head = Node[x].right;
}
Node[x].right = Node[Node[x].right].left;
Node[x].left = Node[Node[x].left].right;
}
do
{
printf("%d ", head);
head = Node[head].right;
}while(Node[head].right);
printf("\n");
return 0;
}