这题写了3遍了,用唐伯虎的话说就是,熟得很
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pa;
const int N = 1e6 + 5;
int Hash[N];
int main() {
int t;
int cnt = 1;
while (cin >> t && t) {
cout << "Scenario #" << cnt++ << endl;
for (int i = 0; i < t; i++) {
int x;
cin >> x;
for (int j = 0; j < x; j++) {
int num;
cin >> num;
Hash[num] = i;
}
}
string s;
queue<int> qq, q[1005];
while (cin >> s && s != "STOP") {
if (s == "ENQUEUE") {
int x;
cin >> x;
if (sz(q[Hash[x]]) == 0) qq.push(Hash[x]);
q[Hash[x]].push(x);
} else {
int n = qq.front();
cout << q[n].front() << endl;
q[n].pop();
if (!sz(q[n])) qq.pop();
}
}
cout << endl;
}
return 0;
}