uva 540 117 页

来源:互联网 发布:教育平台软件 编辑:程序博客网 时间:2024/06/09 18:31
#include <iostream>#include <cstdio>#include <algorithm>#include <vector>#include <queue>#include <map>using namespace std;int main() {//  freopen("input.txt","r",stdin);    int cmt;    int cas=1;    while(scanf("%d",&cmt)!=EOF,cmt) {        printf("Scenario #%d\n",cas++);        map<int,int> m;        for(int i=1;i<=cmt;i++) {            int n;            scanf("%d",&n);            int tmp;            for(int j=1;j<=n;j++) {                scanf("%d",&tmp);                m[tmp]=i;            }        }        queue<int> q,q2[1005];        char cmd[10];        while(scanf("%s",cmd)!=EOF) {            if(cmd[0]=='S') break;            else if(cmd[0]=='E') {                int x;                scanf("%d",&x);                int t=m[x];                if(q2[t].empty()) q.push(t);                q2[t].push(x);            }            else {                int t=q.front();                printf("%d\n",q2[t].front());q2[t].pop();                if(q2[t].empty()) q.pop();            }        }        printf("\n");    }    return 0;}
原创粉丝点击