题目重现:
代码详解:
#include <bits/stdc++.h>
using namespace std;
int main()
{
queue<string>vip;
queue<string>normal;
int num;
string str1,str2,str3; //进出、名字、身份
cin >> num;
cin.ignore();
for(int i=0; i<num; i++)
{
cin >> str1;
if(str1=="IN")
{
cin >> str2;
cin >> str3;
if(str3=="N")
{
normal.push(str2);
}
else
{
vip.push(str2);
}
}
else
{
cin >> str3;
if(str3=="N")
{
normal.pop();
}
else
{
vip.pop();
}
}
}
while(!vip.empty())
{
cout << vip.front() << endl;
vip.pop();
}
while(!normal.empty())
{
cout << normal.front() << endl;
normal.pop();
}
return 0;
}