复制代码
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#include<queue> #include<cstdio> #include<map> using namespace std; const int maxn=1005; int main(){ freopen("UVa540.in","r",stdin); freopen("UVa540.out","w",stdout); int kase=0;int n; while(scanf("%d",&n)==1&&n!=0){ ++kase; printf("Scenario #%d",kase); queue<int> q1,q2[maxn]; map<int,int> tea; for(int i=1;i<=n;i++){ int nn; scanf("%d",&nn); for(int j=0;j<nn;j++){ int k; scanf("%d",&k); tea[k]=i; } } char zhiling[8]; for(;;){ scanf("%s",zhiling); if(zhiling[0]=='S')break; else if(zhiling[0]=='D'){ int t=q1.front(); printf("n%d",q2[t].front()); q2[t].pop(); if(q2[t].empty())q1.pop(); } else if(zhiling[0]=='E'){ int xx; scanf("%d",&xx); int tt; tt=tea[xx]; if(q2[tt].empty())q1.push(tt); q2[tt].push(xx); } } printf("nn"); } fclose(stdin); fclose(stdout); return 0; }
最后
以上就是俊秀玫瑰最近收集整理的关于UVa540的全部内容,更多相关UVa540内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复