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

【题意】

在这里输入题意

【题解】

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

【错的次数】

在这里输入错的次数

【反思】

在这里输入反思

【代码】

#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. vim 基础学习之重复

    重复命令 .: 这个命令可以重复之前的操作.例如你执行了dd操作,然后. 就会删除当前行还有从进入插入模式到退出插入模式,之间的修改也算是一次操作.比如,你执行了i aaa <Esc>然后 ...

  2. ie中 专有的注释

    http://www.cnblogs.com/liluping860122/p/3539165.html

  3. watch---周期性的方式执行给定的指令

    watch命令以周期性的方式执行给定的指令,指令输出以全屏方式显示. 选项 -n:指定指令执行的间隔时间(秒): -d:高亮显示指令输出信息不同之处: -t:不显示标题.

  4. 今日SGU 5.5

    SGU 114 题意:求一个点到其他点的距离总和最小,距离的定义是x轴距离乘以那个点的人数p 收获:带权中位数,按坐标排序,然后扫一遍,最后权值超过或等于总权值的一半时的那个点就是答案,证明暂无 #i ...

  5. [Angular & Unit Testing] TestBed.get vs Injector

    Both what "TestBed.get" & "injector" trying to do is get service for the tes ...

  6. WINDOWS 安装 M2Crypto for Python2.7

    WINDOWS 安装 M2Crypto for Python2.7运行环境 WIN8.1 + Python2.7 + VS2008(Microsoft Visual C++ 9.0) VS2008 可 ...

  7. 6lession-基本数据类型

    因为自己是根据网上教程学习的,所以以下内容参考自 http://www.w3cschool.cc/python/python-variable-types.html python支持物种数据类型,分别 ...

  8. modal模态框插件

    用法: <!--模态框--> <div class="modal fade" id="myModal"> <div class=& ...

  9. Java 批量修改文件后缀

    import java.io.*; public class test { public void reName(String path, String from, String to) { File ...

  10. Spring学习总结(9)——Spring AOP总结

    spring IOC和AOP是Spring框架的两大核心基石,本文将对Spring AOP做一个系统的总结. 什么是AOP AOP(Aspect-Oriented Programming,面向切面编程 ...