POJ 2259 Team Queue"/>
POJ 2259 Team Queue
目录:
- 题目:
- 分析:
- 代码:
题目:
传送门
分析:
我们建出 1001 1001 个队列,将 0 0 号队列用作统计在我们所有队列中有哪几个团队。
每读入一个人,我们就在其对应的团队的队列中看这个队列是否为空,不为空就直接放进队列,否则还有在
而输出也同样的道理。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<stack>
#define LL long long
using namespace std;
inline LL read() {LL d=0,f=1;char s=getchar();while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}while(s>='0'&&s<='9'){d=d*10+s-'0';s=getchar();}return d*f;
}
int x[1000010];
queue<int>q[1001];
string s;
int main()
{int n=read(),a,w=0;while(n!=0) {for(int i=0;i<=1000;i++)while(q[i].size()>0) q[i].pop();w++;printf("Scenario #%d\n",w);for(int i=1;i<=n;i++){int m=read();for(int j=1;j<=m;j++){a=read();x[a]=i;}}while(cin>>s,s[0]!='S'){if(s[0]=='E'){a=read();if(q[x[a]].empty()) q[0].push(x[a]);q[x[a]].push(a);}else{int king=q[0].front();printf("%d\n",q[king].front());q[king].pop();if(q[king].empty()) q[0].pop();}}n=read();printf("\n");}return 233;
}
更多推荐
POJ 2259 Team Queue
发布评论