POJ 2259 Team Queue

编程入门 行业动态 更新时间:2024-10-25 18:31:20

<a href=https://www.elefans.com/category/jswz/34/1766382.html style=POJ 2259 Team Queue"/>

POJ 2259 Team Queue

目录:

  • 题目:
  • 分析:
  • 代码:


题目:

传送门


分析:

我们建出 1001 1001 个队列,将 0 0 号队列用作统计在我们所有队列中有哪几个团队。
每读入一个人,我们就在其对应的团队的队列中看这个队列是否为空,不为空就直接放进队列,否则还有在0" role="presentation">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

本文发布于:2024-02-25 21:40:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1700372.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:POJ   Queue   Team

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!