/*
* POJ_2259.cpp
*
* Created on: 2013年10月30日
* Author: Administrator
*/ #include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <map> using namespace std; const int maxn = 1010;
int main(){
int n;
bool visited[maxn]; int counter = 1;
while(scanf("%d",&n)!=EOF,n){
int i; /**
* que: 总队列,里面存的是子队列的编号
* q[i]: 第i个子队列,里面存的是元素值
*/
queue<int> q[maxn],que;
map<int,int> team;
for(i = 0 ; i < n ; ++i){
int m;
scanf("%d",&m); int t;
while(m--){
scanf("%d",&t);
team[t] = i;
}
} memset(visited,false,sizeof(visited));
printf("Scenario #%d\n",counter++); char str[25];
while(scanf("%s",str)!=EOF){ if(strcmp(str,"STOP") == 0){
printf("\n");
break;
}
if(strcmp(str,"ENQUEUE") == 0){
int t;
scanf("%d",&t); q[team[t]].push(t);
if(visited[team[t]] == false){
que.push(team[t]);
visited[team[t]] = true;
}
}else if(strcmp(str,"DEQUEUE") == 0){
printf("%d\n",q[que.front()].front());
q[que.front()].pop(); if(q[que.front()].empty()){
visited[que.front()] = false;
que.pop();
}
}
} } return 0;
}

(队列的应用5.3.2)POJ 2259 Team Queue(队列数组的使用)的更多相关文章

  1. POJ 2259 - Team Queue - [队列的邻接表]

    题目链接:http://poj.org/problem?id=2259 Queues and Priority Queues are data structures which are known t ...

  2. POJ 2259 Team Queue(队列)

    题目原网址:http://poj.org/problem?id=2259 题目中文翻译: Description 队列和优先级队列是大多数计算机科学家已知的数据结构. 然而,Team Queue并不是 ...

  3. poj 2259 Team Queue

    Team Queue Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 2977   Accepted: 1092 Descri ...

  4. queue POJ 2259 Team Queue

    题目传送门 题意:先给出一些小组成员,然后开始排队.若前面的人中有相同小组的人的话,直接插队排在同小组的最后一个,否则只能排在最后面.现在有排队和出队的操作. 分析:这题关键是将队列按照组数分组,用另 ...

  5. UVA.540 Team Queue (队列)

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

  6. POJ 3125 Printer Queue(队列,水题)

    题意:有多组数据,每组数据给出n,m,n表示需要打印的文件个数,m表示要打印的目标位置(m为0~n-1).    接下来给出n个数,第i个值对应第i-1个位置的优先级大小.    打印规则如下:    ...

  7. (队列的应用5.3.3)POJ 3125 Printer Queue(优先队列的使用)

    /* * POJ_3125.cpp * * Created on: 2013年10月31日 * Author: Administrator */ #include <iostream> # ...

  8. [POJ2259]Team Queue (队列,模拟)

    2559是栈,2259是队列,真的是巧啊 题意 模拟队列 思路 水题 代码 因为太水,不想打,发博客只是为了与2559照应,于是附上lyd的std #include <queue> #in ...

  9. 团体队列UVA540 Team Queue(队列简单用法)

    题目背景 队列和优先级队列是大多数计算机科学家都知道的数据结构.但是团队队列却不被人熟知,尽管在生活中经常出现.比如,午餐时间的食堂门口的队列就是一个团队队列.在一个团队队列中,每个元素属于一个团队. ...

随机推荐

  1. Codeforces Round #360 (Div. 2) D. Remainders Game 数学

    D. Remainders Game 题目连接: http://www.codeforces.com/contest/688/problem/D Description Today Pari and ...

  2. oracle开发学习篇之集合函数

    集合函数; declare type list_nested ) not null; v_all list_nested := list_nested('changan','hubei','shang ...

  3. systemtap 2.8 安装说明书

    systemtap: a linux trace/probe tool Visit the project web site at <http://sourceware.org/systemta ...

  4. 经常使用哈希函数的比較及其C语言实现

    基本概念 所谓完美哈希函数.就是指没有冲突的哈希函数.即对随意的 key1 != key2 有h(key1) != h(key2). 设定义域为X,值域为Y, n=|X|,m=|Y|.那么肯定有m&g ...

  5. JAVA JDOM解析XML 带CDATA数据

    import java.io.StringReader;import java.util.*; import org.jdom.Document;import org.jdom.Element;imp ...

  6. 算法:Rate of Growth

    Rate of growth describes how an algorithm’s complexity changes as the input size grows. This is comm ...

  7. LDAP Error Codes

    Error / Data Code Error Description 0 LDAP_SUCCESS Indicates the requested client operation complete ...

  8. java 数据流的处理

    字节流类 功能简单介绍 DataInputStream 包含了读取Java标准数据类型的输入流 DataOutputStream 包含了写Java标准数据类型的输出流 ByteArrayInputSt ...

  9. 解决hiveserver2报错:java.io.IOException: Job status not available - Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

    用户使用的sql: select count( distinct patient_id ) from argus.table_aa000612_641cd8ce_ceff_4ea0_9b27_0a3a ...

  10. JDBC操作数据库的批处理

    在JDBC开发中,操作数据库需要与数据库建立连接,然后将要执行的SQL语句传送到数据库服务器,最后关闭数据库连接,都是按照这样一个流程进行操作的.如果按照该流程执行多条SQL语句,那么就需要建立多个数 ...