uva 540
来源:互联网 发布:界面设计软件 编辑:程序博客网 时间:2024/06/05 04:10
题目大意:
有个所谓的team排序, 给出t个队伍,以及这些队伍的成员。 然后进行排队。
ENQUEUE x: 把x插入队列中时。如果队列没有该元素的队员,则插入队列的最后面。如果队列中已经有了他的队员,那么插入最后一个队员之后。
DEQUEUE: 把队头的元素删除,并且输出
STOP: 停止
#include <iostream>#include <cstdio>#include <cstring>#include <list>#include <iterator>using namespace std;const int MAXN = 1000000;int t ;int ele[MAXN]; //记录元素(element)所在的team.list<int >lst;list<int >::iterator team[1001];//指向每个team在lst中排最后一个的元素的位置。若lst中没有team中的元素,则指向lst.end().int main(){int ca = 0 ;while (cin >> t && t){lst.clear();int num,tmp;for (int i = 1 ; i <= t ; i++){team[i] = lst.end();cin>>num;for (int j = 0 ; j < num ; j++){cin>>tmp;ele[tmp] = i ;}}cout << "Scenario #" << ++ca << endl;string s;while (cin >> s && s != "STOP"){if ( s == "ENQUEUE"){cin>>tmp;if (team[ele[tmp]] != lst.end()){team[ele[tmp]]++;team[ele[tmp]] = lst.insert(team[ele[tmp]], tmp);}else team[ele[tmp]] = lst.insert(team[ele[tmp]], tmp);}else if (s == "DEQUEUE"){int top = lst.front(); // 第一个元素的引用if (team[ele[top]] == lst.begin()) //第一个元素的迭代器team[ele[top]] = lst.end(); //如果队首元素所属的队列只有一个元素只有回归初始化lst.pop_front();cout<<top<<endl;}}cout<<endl;}return 0;}
- uva 540
- uva 540
- Uva 540
- uva 540
- uva 540
- uva 540
- UVA 540
- uva 540
- UVA - 540
- UVa 540
- UVA 540
- UVa 540 Team Queue
- uva 540 team queue
- Uva 540 Team Queue
- uva 540 - Team Queue
- UVa 540 - Team Queue
- UVA 540 小团体队列
- UVA 540 Team Queue
- HttpURLConnection POST/GET 处理方式
- poj 3050 搜索
- linux 操作系统的page fault处理
- hdu1142A Walk Through the Forest (最短路+BFS+DFS )
- HDU--1455 -- Sticks [DFS] [剪枝优化]
- uva 540
- Uva11489 Integer Game
- 《启示录》读书笔记系列--笔记十
- Java实现的一个旋转效果(旋转太极)
- bootloader
- POJ1185+状态压缩DP
- VIM列编辑
- 求两条线交点
- poj1001 Exponentiation --高精度