rt,
#include<iostream>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
string teach[15],stu[15];//老师名字,学生名字
string incmd,inname,inother;//分别为输入的指令,(分割后)的名字和操作
bool acmark=0;
map<string,bool> play,come,ansmark;
//play -> 现在学生在玩的情况, come->老师来没来, ansmark -> 统计是bad oier还是good oier
int n,cnt=0;
int main(){
cin>>n;
for(int i=1;i<=3;++i){
cin>>teach[i];
}
for(int i=1;i<=5;++i){
cin>>stu[i];
}
getline(cin,incmd);//这里读掉stu的换行 (没读掉50pts)
sort(stu+1,stu+5+1);
while(n--){
acmark=0;
inname.erase();
inother.erase();//清除两个分割后的内容
getline(cin,incmd);
if((int)incmd.find(' ')==-1) continue;//如果连' '都没找到,不符合要求,continue
for(int i=0;i<incmd.length();++i){
if(incmd[i]==' '){
for(int j=0;j<i;++j){
inname+=incmd[j];
}
for(int j=i+1;j<incmd.length();++j){
inother+=incmd[j];
}
//cout<<inname<<" ||| "<<inother<<"\n";
break;
}
}//分割name和操作
for(int i=1;i<=3;++i){
if(inname==teach[i]){
//acmark = 1;
if(inother=="came!"){//如果老师来了
come[inname] = true;
for(auto iter=play.begin();iter!=play.end();++iter){
if(iter->second==true){
if(ansmark[iter->first]==true) continue; //如果之前输出过就不输出
ansmark[iter->first] = true;//标记
cout<<iter->first<<" ";//输出学生名字
}
}
}else if(inother=="left!"){
come[inname] = false;//老师走了
}
}
}
//if(acmark==1) continue;
for(int i=1;i<=5;++i){
if(inname==stu[i]){
if(inother=="started playing games!"){//学生开始玩游戏
play[inname] = true;
for(auto iter=come.begin();iter!=come.end();++iter){
if(iter->second==true){
if(ansmark[inname]==true) continue;
ansmark[inname] = true;
cout<<inname<<" ";//如果有老师来,输出学生名字
}
}
}else if(inother=="stopped playing games!"){
play[inname] = false;//停止玩游戏
}
}
}
}
cout<<"\n";
for(auto iter=ansmark.begin();iter!=ansmark.end();++iter){
if(iter->second==true) cnt++;//统计多少人被老师抓到
}
if(cnt==5) cout<<"How Bad Oiers Are!"<<"\n";//全部抓到
if(cnt==0) cout<<"How Good Oiers Are!"<<"\n";//都没抓到
return 0;
}
求助