站外题求助(悬关)
  • 板块灌水区
  • 楼主Zebraj
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/10/1 12:03
  • 上次更新2024/10/1 15:38:11
查看原帖
站外题求助(悬关)
1277913
Zebraj楼主2024/10/1 12:03

代码

#include<bits/stdc++.h>
using namespace std;
bool hs(string s,string t) {
    if (s.length()!= t.length()) return 0;
    vector<char> a(26,'\0');
    for (int i=0;i<s.length();i++) {
        int S=s[i]-'a';
        int T=t[i]-'a';
        if (a[S]=='\0') {
            a[S]=t[i];
        } else if(a[S]!=t[i]) {
            return 0;
        }
        if(a[T]=='\0') {
            a[T]=s[i];
        }else if(a[T]!=s[i]) {
            return 0;
        }
    }
    return 1;
}
int main() {
    int p;
    cin>>p;
    while(p--){
        string s,t;
        cin>>s>>t;
        if(hs(s,t)){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

为什么和样例不一样,求大佬帮改

2024/10/1 12:03
加载中...