1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| #include <bits/stdc++.h> #define ios ios::sync_with_stdio(0),cin.tie(0) using namespace std;
int main(){ ios; int t,c=0; while(cin>>t && t){ c++; map<int,int> mp; for(int i=0;i<t;i++){ int n;cin>>n; while(n--){ int x;cin>>x; mp[x] = i; } } queue<int> Q,que[1005]; cout<<"Scenario #"<<c<<endl; string temp; while(cin>>temp){ if(temp[0]=='E'){ int x;cin>>x; if(que[mp[x]].empty())Q.push(mp[x]); que[mp[x]].push(x); } else if(temp[0]=='D'){ int team = Q.front(); cout<<que[team].front()<<endl; que[team].pop(); if(que[team].empty())Q.pop(); } else if(temp[0]=='S'){ cout<<endl; break; } } } }
|