0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-03 19:16:27 +00:00

P1160 队列安排

R58926378
This commit is contained in:
Baoshuo Ren 2021-10-02 16:38:05 +08:00 committed by Baoshuo Ren
parent ad44e32e09
commit 463d3ce984
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -2,26 +2,30 @@
using namespace std;
int n, k, p, x;
vector<int> a;
map<int, bool> m;
int n, k, p, m, x, t;
list<int> a;
list<int>::iterator b[100005];
int main() {
scanf("%d", &n);
a.push_back(0);
cin >> n;
a.push_back(1);
b[1] = a.begin();
for (int i = 2; i <= n; i++) {
scanf("%d%d", &k, &p);
a.insert(find(a.begin(), a.end(), k) + p, i);
cin >> k >> p;
auto it = b[k];
b[i] = a.insert(p ? next(it) : it, i);
}
scanf("%d", &n);
while (n--) {
scanf("%d", &x);
m[x] = 1;
cin >> m;
for (int i = 1; i <= m; i++) {
cin >> x;
if (b[x] != a.end()) {
a.erase(b[x]);
b[x] = a.end();
}
for (vector<int>::iterator it = a.begin() + 1; it != a.end(); it++) {
if(!m[*it]) printf("%d ", *it);
}
printf("\n");
for (auto it = a.begin(); it != a.end(); it++) {
cout << *it << ' ';
}
cout << endl;
return 0;
}