我hack我自己
查看原帖
我hack我自己
538243
123rrc楼主2022/6/13 10:27

AC代码:

#include<bits/stdc++.h>
using namespace std;
string a[3]={},b[5]={},s;
int flag[5]={},pl[5]={},tea=0,n;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2]>>b[3]>>b[4];
    sort(b,b+5);
    getline(cin,s);
    while(n--){
        getline(cin,s);
        for(int i=0;i<3;i++){
            if(a[i]+" came!"==s){
                tea=1;
            }
            if(a[i]+" left!"==s){
                tea=0;
            }
        }
        for(int i=0;i<5;i++){
            if(b[i]+" started playing games!"==s){
                pl[i]=1;
            }
            if(tea==1&&pl[i]==1){
                flag[i]=1;
            }
            if(b[i]+" stopped playing games!"==s){
                pl[i]=0;
            }
        }
    }
    int cnt=0;
    for(int i=0;i<5;i++){
        if(flag[i]==1){
            cout<<b[i]<<" ";
            cnt++;
        }
    }
    if(cnt==0){
        cout<<"How Good Oiers Are!";
    }
    if(cnt==5){
        cout<<endl<<"How Bad Oiers Are!";
    }
    return 0;
}

hack数据:

3
A B C
a b c d e
A came!
a started playing games!
A left!

我的输出(在洛谷在线IDE中):

How Good Oiers Are!

正确输出:

a
2022/6/13 10:27
加载中...