-
Notifications
You must be signed in to change notification settings - Fork 2
/
团队队列.cpp
46 lines (41 loc) · 784 Bytes
/
团队队列.cpp
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
#include<cstdio>
#include<queue>
#include<map>
using namespace std;
int main(){
int n, kase = 0;
while(scanf("%d", &n)==1 && n){
printf("Scenario #%d\n", ++kase);
map<int, int> team;
for(int i = 0; i< n; i++){
int x;
scanf("%d", &x);
while(x--) {
int num;
scanf("%d", &num);
team[num] = i;
}
}
queue<int> q; //¶ÓºÅµÄ¶ÓÁÐ
queue<int> qu[1000+10];
while(1){
int x;
char cmd[100];
scanf("%s", cmd);
if(cmd[0] == 'S') break;
else if(cmd[0] == 'D'){
int w = q.front();
printf("%d\n", qu[w].front());
qu[w].pop();
if(qu[w].empty()) q.pop();
}else if(cmd[0] == 'E') {
scanf("%d", &x);
int t = team[x];
if(qu[t].empty()) q.push(t);
qu[t].push(x);
}
}
printf("\n");
}
return 0;
}