mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
46 lines
881 B
C++
46 lines
881 B
C++
#include <iostream>
|
|
#include <queue>
|
|
#include <string>
|
|
using namespace std;
|
|
struct pack
|
|
{
|
|
string man,woman;
|
|
};
|
|
int main()
|
|
{
|
|
int n;
|
|
cin>>n;
|
|
queue<string> manbus;
|
|
queue<string> womanbus;
|
|
string name,sexual;
|
|
while(n--)
|
|
{
|
|
cin>>name>>sexual;
|
|
if(sexual=="M")
|
|
{
|
|
manbus.push(name);
|
|
}
|
|
else
|
|
{
|
|
womanbus.push(name);
|
|
}
|
|
}
|
|
cout<<"The dancing partners are:"<<endl;
|
|
while(!manbus.empty()&&!womanbus.empty())
|
|
{
|
|
cout<<womanbus.front()<<" "<<manbus.front()<<endl;
|
|
manbus.pop();
|
|
womanbus.pop();
|
|
}
|
|
if(!manbus.empty())
|
|
{
|
|
cout<<"The first man to get a partner is:"<<manbus.front()<<endl;
|
|
}
|
|
else if(!womanbus.empty())
|
|
{
|
|
cout<<"The first woman to get a partner is:"<<womanbus.front()<<endl;
|
|
}
|
|
|
|
return 0;
|
|
}
|