【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

用两个队列模拟就好。
记录某个队在不在队列里面。
模拟

【错的次数】

在这里输入错的次数

【反思】

在这里输入反思

【代码】

#include <bits/stdc++.h>
using namespace std; const int N = 1e3; int t;
queue <int> team[N+10];
queue <int> dl;
map <int,int> dic;
bool inq[N+10]; int main()
{
//freopen("F:\\rush.txt","r",stdin);
int kase = 0;
while (~scanf("%d",&t) && t)
{
printf("Scenario #%d\n",++kase);
for (int i = 1;i <= N;i++) while (!team[i].empty()) team[i].pop();
while (!dl.empty()) dl.pop();
for (int i = 1;i <= N;i++) inq[i] = false;
dic.clear(); for (int i = 1;i <= t;i++)
{
int num;
scanf("%d",&num);
for (int j = 0;j < num;j++)
{
int x;
scanf("%d",&x);
dic[x] = i;
}
} string s1;
while (cin >> s1)
{
if (s1[0]=='S') break;
if (s1[0]=='E')
{
int x;
scanf("%d",&x);
int b = dic[x];
if (inq[b]==false)
{
inq[b] = true;
dl.push(b);
}
team[b].push(x);
}else
{
int x = dl.front();
printf("%d\n",team[x].front());
team[x].pop();
if (team[x].empty())
{
dl.pop();
inq[x] = false;
}
}
}
puts("");
}
return 0;
}

【例题5-6 UVA 540 】Team Queue的更多相关文章

  1. UVA.540 Team Queue (队列)

    UVA.540 Team Queue (队列) 题意分析 有t个团队正在排队,每次来一个新人的时候,他可以插入到他最后一个队友的身后,如果没有他的队友,那么他只能插入到队伍的最后.题目中包含以下操作: ...

  2. uva 540 - Team Queue(插队队列)

    首发:https://mp.csdn.net/mdeditor/80294426 例题5-6 团体队列(Team Queue,UVa540) 有t个团队的人正在排一个长队.每次新来一个人时,如果他有队 ...

  3. UVA 540 Team Queue(模拟+队列)

    题目代号:UVA 540 题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page ...

  4. UVa 540 Team Queue 【STL】

    题意:给出t个团体,这t个团体排在一起,每次新来一个x排队,如果在整个的团体队列中,有x的队友,那么x排在它的队友的后面,如果他没有队友,则排在长队的队尾 求给出的每一个出队命令,输出出队的人的编号 ...

  5. UVA 540 Team Queue

    思路:使用优先队列,按队伍出现的时刻和自身出现的时刻定义优先级,同时记录此时刻队列里是否有自己队伍的人,一开始没注意,wa了两发. #include<map> #include<qu ...

  6. uva 540 (Team Queue UVA - 540)

    又是一道比较复杂的模拟题.题中有两种队列,一种是总队列,从前向后.其他的是各个团体的小队列,因为入队的人如果有队友的话,会优先进入团体队列. 所以我们先设置两个队列和一个map,设置map倒是可以不用 ...

  7. 【UVA - 540】Team Queue (map,队列)

    Team Queue Descriptions: Queues and Priority Queues are data structures which are known to most comp ...

  8. Team Queue UVA - 540

      Queues and Priority Queues are data structures which are known to most computer scientists. The Te ...

  9. UVA Team Queue

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u013840081/article/details/26180081 题目例如以下: Team Qu ...

  10. hdu 1387(Team Queue) STL

    Team Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

随机推荐

  1. 5.cocos2d锚点

    创建一个层T1LayerAnchorPoint AppDelegate.cpp bool AppDelegate::applicationDidFinishLaunching() { // initi ...

  2. Spark scheduler

    触发Spark scheduler的入口是调用者代码中的action操作,如groupByKey,first,take,foreach等操作.这些action操作最终会调用SparkContext.r ...

  3. kafka删除主题

    hdp集群默认不能删除kafka主题,如果要删除,需要在ambari上进行配置,将enable delete设置为true.

  4. ajax起步 (二)

    Ajax的关键在于XMLHttpRequest对象,如下基本用法: <!DOCTYPE html> <html> <head> <meta charset=& ...

  5. python 补0的方法

    # 方法一 z = 'bb' z.zfill(6) ----'0000bb' n = ' n.zfill(5) ----' # 方法二 ' " ---- '报错' # 方法的区别 方法二只能 ...

  6. Python 3 下载安装和环境搭建

    Python3 下载 由于博主使用的平台是Windows10,以下方法仅限win10系统 Python 官网:https://www.python.org/ 找到跟系统相应的版本瞎子: Python ...

  7. c# 用代码来设置程序的PrivatePath

    原文:c# 用代码来设置程序的PrivatePath 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sweety820/article/detail ...

  8. 18/9/22NOIP模拟考

    18/9/22NOIP模拟考 其实本来是有多组数据的,出题人忘记在题面上加了   斜眼笑 期望得分:100:实际得分:100 由于种种原因,拿到题的时候已经过去了0.5h+... 然后因为这道题数据范 ...

  9. bash的启动文件

    文件名称 功能描写叙述 /etc/profile 登录时自己主动运行 ~/.bash_profile,~/.bash_login,~/.profile 登录时自己主动运行 ~/.bashrc shel ...

  10. Android记录16-友盟第三方登录、分享实现

    Android开发记录16-友盟第三方登录.分享实现 2014年博客之星,投票地址username=wwj_748#content" style="font-family: Kai ...