题目大意
输入:
团队数t
接下来t行开头m,后跟m个数为这个团队成员;
接下来是操作STOP表示结束
复制代码
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87#include <iostream> #include<cstring> #include<cstdlib> #include<string> #include<cstdio> #include<queue> #include<stack> #include<vector> #include<map> #include<list> #include<set> #define INF 1<<30 using namespace std; const int maxp=1000000; const int maxt=1000; const int maxn=200000+10; struct node { int p,pre,next; }r[maxn]; int used,belong[maxp],pos[maxt],st,ed; int main() { int t,loop=0; scanf("%d",&t); while(t) { for(int i=0;i<t;i++) { int m; scanf("%d",&m); for(int j=0;j<m;j++) { int x; scanf("%d",&x); belong[x]=i; } pos[i]=-1; } used=0;st=ed=-1; if(loop) puts(""); printf("Scenario #%dn",++loop); string s; cin>>s; while(s!="STOP") { if(s=="ENQUEUE") { int x; cin>>x; r[used].p=x; int s=pos[belong[x]]; if(s<0) { r[used].pre=ed; r[used].next=-1; if(ed>=0) r[ed].next=used; ed=used; if(st<0) st=used; } else { r[used].pre=s; r[used].next=r[s].next; if(s==ed) ed=used; r[s].next=used; if(r[used].next>=0) r[r[used].next].pre=used; } pos[belong[x]]=used++; } else { cout<<r[st].p<<endl; if(st==pos[belong[r[st].p]]) pos[belong[r[st].p]]=-1; st=r[st].next; } cin>>s; } cin>>t; } return 0; }
最后
以上就是稳重鞋子最近收集整理的关于poj2259(团队队列)的全部内容,更多相关poj2259(团队队列)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复