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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| #include <cstdio> #include <cstring> #include <cmath> #include <iostream> #include <iomanip> #include <set> #include <queue> #include <stack> #include <vector> #include <map> #include <string> #include <sstream> #include <bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;++i) #define per(i,a,n) for(int i=n-1;i>=a;--i); #define ms(x,a) memset((x),a,sizeof((x))) #define all(x) x.begin(),x.end() #define ins(x) inserter(x,x.begin()) #define INF 0x3f3f3f3f #define eps 1e-8 #define fi first #define e 2.718281828459045235360287471352662497757247093699959574966967627724076630353 #define se second #define mp make_pair #define pb push_back #define np next_permutation #define gapline cout<<"##======================##"<<endl using namespace std; const int maxn=1e3+5; const int maxl=26; const int maxm=1e5+5; typedef long long ll; typedef unsigned long long ull;
int t,n,kase; map<int,int> mmp; int main(){ ios::sync_with_stdio(false); while(cin>>t&&t){ cout<<"Scenario #"<<++kase<<endl; mmp.clear(); int x; rep(i,0,t){ cin>>n; rep(j,0,n){ cin>>x; mmp[x]=i; } } queue<int> q,q2[maxn]; string c; while(cin>>c && c[0]!='S'){ if(c[0]=='E'){ cin>>x; int id=mmp[x]; if(q2[id].empty()){ q.push(id); } q2[id].push(x); } else{ int num=q2[q.front()].front(); cout<<num<<endl; q2[q.front()].pop(); if(q2[q.front()].empty()) q.pop(); } } cout<<endl; } }
|