QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#746173 | #9726. AUS | xbzxzn# | WA | 1ms | 3808kb | C++17 | 1.1kb | 2024-11-14 13:42:55 | 2024-11-14 13:42:56 |
Judging History
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'