复制代码
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//队列数组 #include<iostream> #include<queue> #include<string> #include<map> using namespace std; char cmd[15]; int main(){ int t,kase=0,x; while(scanf("%d",&t)&&t) { map<int,int> hash; queue<int> q,qp[1005]; printf("Scenario #%dn",++kase); for(int i=0;i<t;++i) { int n,d; scanf("%d",&n); while(n--) { scanf("%d",&d); hash[d]=i; } } while(~scanf("%s",cmd)&&cmd[0]!='S') { if(cmd[0]=='E') { scanf("%d",&x); if(qp[hash[x]].empty()) q.push(hash[x]); qp[hash[x]].push(x); } else { int t=q.front(); printf("%dn",qp[t].front()); qp[t].pop(); if(qp[t].empty()) q.pop(); } } puts(""); } return 0; }
最后
以上就是开心白羊最近收集整理的关于UVa540(队列数组)团体队列的全部内容,更多相关UVa540(队列数组)团体队列内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复