You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
queue<int> bigqueue;
|
|
queue<int> que[1000];
|
|
int team[1000000];
|
|
|
|
int main() {
|
|
int TeamN;
|
|
int FactorN;
|
|
int i, temp;
|
|
int num = 0;
|
|
string s;
|
|
int flag = 0;
|
|
while (cin >> TeamN && TeamN) {
|
|
while (!bigqueue.empty())
|
|
bigqueue.pop();
|
|
for (i = 0; i < 1000; i++)
|
|
while (!que[i].empty())
|
|
que[i].pop();
|
|
num = 0;
|
|
while (TeamN--) {
|
|
num++;
|
|
cin >> FactorN;
|
|
for (i = 0; i < FactorN; i++) {
|
|
cin >> temp;
|
|
team[temp] = num;
|
|
}
|
|
}
|
|
printf("Scenario #%d\n", ++flag);
|
|
while (cin >> s && s[0] != 'S') {
|
|
if (s == "ENQUEUE") {
|
|
cin >> num;
|
|
if (que[team[num]].empty())
|
|
bigqueue.push(team[num]);
|
|
que[team[num]].push(num);
|
|
|
|
} else if (s == "DEQUEUE") {
|
|
printf("%d\n", que[bigqueue.front()].front());
|
|
que[bigqueue.front()].pop();
|
|
if (que[bigqueue.front()].empty())
|
|
bigqueue.pop();
|
|
}
|
|
|
|
|
|
}
|
|
if (TeamN) printf("\n");
|
|
}
|
|
return 0;
|
|
}
|