我是靠谱客的博主 贪玩毛巾,这篇文章主要介绍例题5-6 UVA540 团体队列 (queue的使用),现在分享给大家,希望可以做个参考。

复制代码
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
#include<iostream> #include<cstdio> #include<string> #include<map> #include<queue> using namespace std; int t,n,x,a; int num=1; string s; int main() { while((cin>>t)&&t) { cout<<"Scenario #"<<num++<<endl; map<int,int>team; queue<int>q;//q[]里面存放的是每个队列的编号 queue<int>qnum[1005];//qnum[][]里面存放的是每个队列里每个元素的值 for(int i=0;i<t;i++) { cin>>n; while(n--) { cin>>x; team[x]=i; } } while(cin>>s) { if(s[0]=='S') { break; } else if(s[0]=='E') { cin>>x; //team[x]是队列的编号 if(qnum[team[x]].empty()) { q.push(team[x]); } qnum[team[x]].push(x); } else if(s[0]=='D') { a=q.front();//整个队列的队首所在的队列编号 cout<<qnum[a].front()<<endl; qnum[a].pop(); if(qnum[a].empty()) { q.pop(); } } } cout<<endl; } return 0; }

 

最后

以上就是贪玩毛巾最近收集整理的关于例题5-6 UVA540 团体队列 (queue的使用)的全部内容,更多相关例题5-6内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(126)

评论列表共有 0 条评论

立即
投稿
返回
顶部