0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-20 09:05:25 +00:00
OI-codes/Luogu/P1160/P1160.cpp

32 lines
609 B
C++
Raw Normal View History

2020-12-03 23:33:31 +00:00
#include <bits/stdc++.h>
using namespace std;
2021-10-02 08:38:05 +00:00
int n, k, p, m, x, t;
list<int> a;
list<int>::iterator b[100005];
2020-12-03 23:33:31 +00:00
int main() {
2021-10-02 08:38:05 +00:00
cin >> n;
2020-12-03 23:33:31 +00:00
a.push_back(1);
2021-10-02 08:38:05 +00:00
b[1] = a.begin();
2020-12-03 23:33:31 +00:00
for (int i = 2; i <= n; i++) {
2021-10-02 08:38:05 +00:00
cin >> k >> p;
auto it = b[k];
b[i] = a.insert(p ? next(it) : it, i);
2020-12-03 23:33:31 +00:00
}
2021-10-02 08:38:05 +00:00
cin >> m;
for (int i = 1; i <= m; i++) {
cin >> x;
if (b[x] != a.end()) {
a.erase(b[x]);
b[x] = a.end();
}
2020-12-03 23:33:31 +00:00
}
2021-10-02 08:38:05 +00:00
for (auto it = a.begin(); it != a.end(); it++) {
cout << *it << ' ';
2020-12-03 23:33:31 +00:00
}
2021-10-02 08:38:05 +00:00
cout << endl;
2020-12-03 23:33:31 +00:00
return 0;
}