求条
  • 板块灌水区
  • 楼主are_you_sure
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/9/15 13:01
  • 上次更新2024/9/15 16:04:59
查看原帖
求条
1367333
are_you_sure楼主2024/9/15 13:01

rt

为什么re?

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iomanip>
using namespace std;

int main(){
    string t[3],o[5],c[5],s;
    bool flag=false,pg[5]={false,false,false,false,false};
    int n,index=0,cf=0;
    cin>>n;
    cin>>t[0]>>t[1]>>t[2];
    cin>>o[0]>>o[1]>>o[2]>>o[3]>>o[4];
    getline(cin,s);
    while(n--){
        getline(cin,s);
        for(int i=0;i<3;i++){
            if(t[i]+" came!"==s){
                flag=true;
                cf++;
                break;
            }
        }
        for(int i=0;i<3;i++){
            if(t[i]+" left!"==s){
                cf--;
                if(!cf)flag=false;
                break;
            }
        }
        for(int i=0;i<5;i++){
            if(o[i]+" started playing games!"==s){
                pg[i]=true;
                break;
            }
        }
        for(int i=0;i<5;i++){
            if(o[i]+" stopped playing games!"==s){
                pg[i]=false;
                break;
            }
        }
        for(int i=0;i<5;i++){
            if(flag&&pg[i]){c[index++]=o[i];pg[i]=0;}
        }
    }
    sort(c,c+index);
    for(int i=0;i<index;i++){
        cout<<c[i]<<' ';
    }
    if(index==5){
        cout<<"\nHow Bad Oiers Are!";
    }
    if(index==0){
        cout<<"How Good Oiers Are!";
    }
    return 0;
}

请勿直接提供AC代码,请指出我代码要改的地方,如果我的思路有误,请提供具体思路+参考AC程序

2024/9/15 13:01
加载中...