@[xiaofeiji123](/user/1067515)
```cpp
#include<bits/stdc++.h>
using namespace std;
struct node{
int l, r;
} tem[114514];
int how, c, w, del;
int main(){
cin >> how;
tem[0].l = 1, tem[1].r = 1;
tem[1].l = 0, tem[1].r = 0;
for(int i = 2; i <= how; i++){
cin >> c >> w;
if(w){
tem[tem[c].r].l = i;
tem[i].r = tem[c].r;
tem[i].l = c;
tem[c].r = i;
}
else{
tem[tem[c].l].r = i;
tem[i].l = tem[c].l;
tem[i].r = c;
tem[c].l = i;
}
}
cin >> del;
for(int i = 1; i <= del; i++){
cin >> c;
if(tem[c].l == -1){
continue;
}
tem[tem[c].l].r = tem[c].r;
tem[tem[c].r].l = tem[c].l;
tem[c].l = -1;
tem[c].r = -1;
}
w = tem[0].r;
while(w != 0){
cout << w << ' ';
w = tem[w].r;
}
}
``````
你的查重不是很行,题目中没给定两个相同的数字是连续给出的,别被样例给骗了
by Tainaka_Ritsu @ 2023-10-03 10:44:58
哦有道理,谢谢大佬
by xiaofeiji123 @ 2023-10-03 18:39:43