- 题解
队列安排不知道怎么就过了
- 2024-3-16 16:13:04 @
#include <bits/stdc++.h>
using namespace std;
const int N = 114514;
int r[N],l[N],e[N];
bool d[N];
int idx;
void init()
{
r[0] = 1;
l[1] = 0;
idx = 2;
}
void insert(int x,int k,int i)
{
e[idx] = x;
if(i == 0)
{
r[idx] = k,l[idx] = l[k];
r[l[k]] = idx,l[k] = idx++;
}
else
{
l[idx] = k,r[idx] = r[k];
l[r[k]] = idx,r[k] = idx++;
}
}
void remove(int k)
{
l[r[k]] = l[k];
r[l[k]] = r[k];
}
int m,n,k,p,z;
int main()
{
cin >> n;
r[0] = n + 1;
l[n + 1] = 0;
idx = 1;
insert(1,0,1);
for(int i = 2;i <= n;i++)
{
cin >> k >> p;
insert(i,k,p);
}
cin >> m;
while(m--)
{
cin >> z;
d[z] = 1;
}
for(int i = r[0];i != n + 1;i = r[i])
{
if(d[i] == 0)
{
cout << i << ' ';
}
}
}
0 comments
No comments so far...