#include
#include
#include
#include
#include
using namespace std;
int n,team[1000001],w;
char s[40];
int main()
{
while(1)
{
w++;
int fl=0;
queueq;
queuep[1001];
scanf("%d",&n);
if(n0)
return 0;
for(int i=1;i<=n;i++)
{
int num;
scanf("%d",&num);
for(int j=1;j<=num;j++)
{
int k;
scanf("%d",&k);
team[k]=i;
}
}
while(1)
{
cin>>s;
int num;
if(s[0]‘E’)
{
scanf("%d",&num);
if(p[team[num]].empty())
{
q.push(team[num]);
p[team[num]].push(num);
}
else
p[team[num]].push(num);
}
if(s[0]‘D’)
{
if(fl0)
printf(“Scenario #%d\n”,w),fl=1;
while(p[q.front()].empty())
{
q.pop();
}
printf("%d\n",p[q.front()].front());
p[q.front()].pop();
}
if(s[0]==‘S’)
{
printf("\n");
break;
}
}
}
return 0;
}
UVA540
最新推荐文章于 2023-10-05 12:47:33 发布