#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
string a,b,c,d,e,A,B,C;
int n;
string f[6][3],F[3];
string na,nb,nd;
string ans[6];
int tot=0;
bool as[6];
bool st[6];
bool g;
void doa(int x)
{
if(x==1) as[1]=1;
else as[1]=0;
}
void dob(int x)
{
if(x==1) as[2]=1;
else as[2]=0;
}
void doc(int x)
{
if(x==1) as[3]=1;
else as[3]=0;
}
void dod(int x)
{
if(x==1) as[4]=1;
else b[4]=0;
}
void doe(int x)
{
if(x==1) as[5]=1;
else b[5]=0;
}
void die()
{
for(int i=1;i<=5;i++)
{
if(as[i]&&!st[i])
{
st[i]=1;
b[i]=1;
if(i==1) ans[++tot]=a;
else if(i==2) ans[++tot]=b;
else if(i==3) ans[++tot]=c;
else if(i==4) ans[++tot]=d;
else if(i==5) ans[++tot]=e;
}
}
}
int main()
{
cin>>n;
cin>>A>>B>>C;
cin>>a>>b>>c>>d>>e;
f[1][1]=a+" started playing games!";f[1][2]=a+" stopped playing games!";
f[2][1]=b+" started playing games!";f[2][2]=b+" stopped playing games!";
f[3][1]=c+" started playing games!";f[3][2]=c+" stopped playing games!";
f[4][1]=d+" started playing games!";f[4][2]=d+" stopped playing games!";
f[5][1]=e+" started playing games!";f[5][2]=e+" stopped playing games!";
F[1]=" came!";F[2]=" left!";
for(int i=1;i<=n;i++)
{
cin>>na;
getline(cin,nb);
nd=na+nb;
if(na==a)
{
if(nd==f[1][1])
doa(1);
else if(nd==f[1][2])
doa(2);
}
else if(na==b)
{
if(nd==f[2][1])
dob(1);
else if(nd==f[2][2])
dob(2);
}
else if(na==c)
{
if(nd==f[3][1])
doc(1);
else if(nd==f[3][2])
doc(2);
}
else if(na==d)
{
if(nd==f[4][1])
dod(1);
else if(nd==f[4][2])
dod(2);
}
else if(na==e)
{
if(nd==f[5][1])
doe(1);
else if(nd==f[5][2])
doe(2);
}
else if(na==A||na==B||na==c)
{
if(nb==F[1])
g=1;
else if(nb==F[2])
g=0;
}
if(g)
die();
}
if(tot==0)
{
cout<<"How Good Oiers Are!";
return 0;
}
sort(ans+1,ans+tot+1);
for(int i=1;i<=tot;i++) cout<<ans[i]<<" ";
if(tot==5) cout<<endl<<"How Bad Oiers Are!";
return 0;
}
评测记录
https://www.luogu.com.cn/record/39268832