求debug(#25=>WA)
查看原帖
求debug(#25=>WA)
1197260
dzy1004xsxdg楼主2024/1/1 19:59

自造144位数据出错,是要开long long吗?

源代码

#include<bits/stdc++.h>
using namespace std;
char s[200010],t[200010];
int main(){
    int n1=0,n2=0;
    int y1=0,y2=0;
    int other_w1=0,other_w2=0;
    string a;
    cin>>a;
    int l=a.size();
    for(int i=0;i<l;i++){
        s[i]=a[i];
        if(s[i]=='@'){
            y1+=1;
        }
        else if(s[i]=='a'||s[i]=='t'||s[i]=='c'||s[i]=='o'||s[i]=='d'||s[i]=='e'||s[i]=='r'){
            n1+=1;
        }
        else if(s[i]!='a'&&s[i]!='t'&&s[i]!='c'&&s[i]!='o'&&s[i]!='d'&&s[i]!='e'&&s[i]!='r'){
            other_w1+=1;
        }
    }
    for(int i=0;i<l;i++){
        cin>>t[i];
        if(t[i]=='@'){
            y2+=1;
        }
        else if(t[i]=='a'||t[i]=='t'||t[i]=='c'||t[i]=='o'||t[i]=='d'||t[i]=='e'||t[i]=='r'){
            n2+=1;
        }
        else if(t[i]!='a'||t[i]!='t'||t[i]!='c'||t[i]!='o'||t[i]!='d'||t[i]!='e'||t[i]!='r'){
            other_w2+=1;
        }
    }
    if(s==t){
        cout<<"Yes";
        return 0;
    }
    if(other_w1!=other_w2){
        cout<<"No";
        return 0;
    }
    if(n1!=n2&&other_w1==other_w2){
        if(n1>n2){
            if(y2>=n1-n2&&y1==y2-n1+n2){
                cout<<"Yes";
                return 0;   
            }
            else{
                cout<<"No";
                return 0;
            }
        }
        if(n1<n2){
            if(y1>=n2-n1&&y2==y1-n2+n1){
                cout<<"Yes";
                return 0;   
            }
            else{
                cout<<"No";
                return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}

详情请参照ABC301—C复盘1

2024/1/1 19:59
加载中...