QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#746173#9726. AUSxbzxzn#WA 1ms3808kbC++171.1kb2024-11-14 13:42:552024-11-14 13:42:56

Judging History

你现在查看的是最新测评结果

  • [2024-11-14 13:42:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3808kb
  • [2024-11-14 13:42:55]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define Pa pair<int,int>
using namespace std;
const int N=2e6+10,mod=1e9+7,inf=1e18;
struct DSU{
    int fa[N];
    void init(int n){
        for(int i=1;i<=n;i++)fa[i]=i;
    }
    int find(int x){
        if(fa[x]==x)return x;
        return fa[x]=find(fa[x]);
    }
    void merge(int x,int y){
        x=find(x),y=find(y);
        if(x!=y)fa[y]=x;
    }
}dsu;
void solve(){
    string s1,s2,s3;cin>>s1>>s2>>s3;
    if(s1.size()!=s2.size()){
        cout<<"NO\n";
        return;
    }
    if(s3.size()!=s1.size()){
        cout<<"YES\n";
        return;
    }
    dsu.init(27);
    for(int i=0;i<s1.size();i++){
        if(s1[i]!=s2[i]){
            int x=s1[i]-'a',y=s2[i]-'a';
            dsu.merge(x,y);
        }
    }
    for(int i=0;i<s3.size();i++){
        int x=s3[i]-'a',y=s1[i]-'a';
        if(dsu.find(x)!=dsu.find(y)){
            cout<<"YES\n";
            return;
        }
    }
    cout<<"NO\n";
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T=1;cin>>T;
    while(T--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3808kb

input:

4
abab
cdcd
abce
abab
cdcd
abcd
abab
cdcd
abc
x
yz
def

output:

YES
NO
YES
NO

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

10
ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO

result:

ok 10 lines

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3560kb

input:

100
dntfvviytogwqljvoksaovstrqwpovkncxvmytnvcaoikctmgukaxlivmwahenydtswyowpdvggeeyzykdiojltpxuzzwphdqfsh
anbbtriynochhmrtsmjifvatlfsmwiimvxbmyoavcmfiioxatckaxcikmwazenjmdleyjwndvggqkazikdeofaqpbuzkupshfhgh
anbflviytfylqlpvvmjaovajllwpoukmvwemgtivvaonkoxagukaxriyuvmypnymtdqyocpdvcgqkazykrihjbipxquzup...

output:

YES
YES
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
YES
NO
YES
NO
YES
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
YES
YES
NO
YES
NO
NO
NO
YES
NO
NO
NO
NO
NO
YES
NO
YES
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO...

result:

wrong answer 38th lines differ - expected: 'YES', found: 'NO'