uva 540117 页

xiaoxiao2021-02-28  96

#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; }
转载请注明原文地址: https://www.6miu.com/read-34807.html

最新回复(0)