UVA - 540 Team Queue
来源:互联网 发布:祸害成患妖成灾网络剧1 编辑:程序博客网 时间:2024/06/05 21:52
题目大意:t 个队伍排队,若队伍中已经有自己队伍的人,则排到这个人的后面,若没有,排到整个队列的后面。
解题思路:模拟,映射把每个人和队伍号对应起来,定义两个队列,一个排队,另一个记录某个队伍已排人数。本来是自己写数组模拟的,TLE,看了小紫学 STL。
#include<iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<ctype.h>#include<queue>#include<map>using namespace std;int cnt = 0;int main() { int t; while (scanf("%d", &t) != EOF && t) { printf("Scenario #%d\n", ++cnt); map<int, int> team; for (int i = 0; i < t; i++) { int n, x; scanf("%d", &n); while (n--) { scanf("%d", &x); team[x] = i; } } queue<int> q, q2[1010]; char cmd[10]; while (scanf("%s", cmd) != EOF && cmd[0] != 'S') { if (cmd[0] == 'E') { int t, x; scanf("%d", &x); t = team[x]; if (q2[t].empty()) q.push(t); q2[t].push(x); } else if (cmd[0] == 'D') { int t = q.front(); printf("%d\n", q2[t].front()); q2[t].pop(); if (q2[t].empty()) q.pop(); } } printf("\n"); }return 0;}
0 0
- UVa 540 Team Queue
- uva 540 team queue
- Uva 540 Team Queue
- uva 540 - Team Queue
- UVa 540 - Team Queue
- UVA 540 Team Queue
- uva 540 Team Queue
- uva 540 Team Queue
- Uva 540 Team Queue
- UVa 540 - Team Queue
- UVa 540 - Team Queue
- uva 540 Team Queue
- UVA 540 Team Queue
- Team Queue UVA 540
- uva 540 - Team Queue
- UVa 540 - Team Queue
- UVA - 540 - Team Queue
- UVA 540 team queue
- STM32自学笔记——外部中断
- SpringAOP注解方式记录操作日志(操作模块,操作功能,调用方法,主键信息等)支持多笔操作时记录
- I/O流之File类常用方法(2)
- Object 详解
- java工具类开发之json工具类JsonUtils和写数据回页面工具类ResponseUtils
- UVA - 540 Team Queue
- .net 执行多条cmd 命令方法与大批量CSV文件合并成一个文件方法
- 使用Gallery控件实现个人相簿功能
- 1130数据结构上机测试1:顺序表的应用
- 终于决定对自己学的东西做一个总结
- UVA - 101 The Blocks Problem
- cacti
- HDU 2602 0-1背包问题
- JavaWeb学习总结(十三)——使用Session防止表单重复提交