考察点:map和queue的使用。
原题链接:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=481
题意:
有t个团队的人在排一个长队。每次新来一个人时,如果有队友排队,则新人会插到最后一个队友的身后。如果没有一个队友排队,则他会排到长队的队尾。
输入每个团队的所有队员的编号,要求支持如下三种指令(前两种可以穿插进行)。
- ENQUEUE x:编号为x的人进入长队
- DEQUEUE x:长队的队首出队
- STOP :停止模拟。
题目分析:
涉及到队员编号和团队编号,故可以采用map<int,int>
完成队员编号到所在团队编号的映射。采用两个队列来完成模拟即可。
代码如下:
#include<cstdio>
#include<queue>
#include<map>
#include<iostream>
using namespace std;
const int maxn=1010;
int main(){
int t,kase=0;
while(~scanf