标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1889 Accepted Submission(s): 639
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 map<int, int> mp; 5 char op[10]; 6 int t, n, p, cn = 0; 7 8 int main() 9 { 10 while(scanf("%d", &t), t){ 11 mp.clear(); 12 printf("Scenario #%d\n", ++cn); 13 for(int i = 0; i < t; ++i){ 14 scanf("%d", &n); 15 while(n--){ 16 scanf("%d", &p); 17 mp[p] = i; 18 } 19 } 20 queue<int> q1[1005]; 21 queue<int> q2; 22 while(scanf("%s", op), op[0] != ‘S‘){ 23 if(op[0] == ‘E‘){ 24 scanf("%d", &p); 25 int id = mp[p]; 26 if(q1[id].empty()) 27 q2.push(id); 28 q1[id].push(p); 29 } 30 else if(op[0] == ‘D‘){ 31 int id = q2.front(); 32 printf("%d\n", q1[id].front()); 33 q1[id].pop(); 34 if(q1[id].empty()) 35 q2.pop(); 36 } 37 } 38 printf("\n"); 39 } 40 return 0; 41 }
标签:
原文地址:http://www.cnblogs.com/inmoonlight/p/5701685.html