day1
作者:
__492
,
2024-05-28 17:10:32
,
所有人可见
,
阅读 2
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7,N = 1e6+9;
typedef long long ll;
int n,m;
struct Node
{
int l,r;
int d;
}nodes[N];
void add(int a, int b, int p)
{
if (p == 1)
{
nodes[b].r = nodes[a].r;
nodes[b].l = a;
nodes[a].r = b;
nodes[nodes[b].r].l = b;
}
else
{
nodes[b].l = nodes[a].l;
nodes[b].r = a;
nodes[a].l = b;
nodes[nodes[b].l].r = b;
}
}
int main()
{
cin >> n;
nodes[0].r = 0, nodes[0].l = 0;
add(0, 1, 1);
for (int i = 2; i <= n; i++)
{
int k, p;
cin >> k >> p;
add(k, i, p);
}
cin >> m;
for (int i = 1; i <= m; i++)
{
int x;
cin >> x;
nodes[x].d = 1;
}
for (int i = nodes[0].r; i; i = nodes[i].r)
{
if(nodes[i].d!=1)
cout << i << " ";
}
return 0;
}