QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#834508#9726. AUSPinkychowWA 1ms3816kbC++141.1kb2024-12-27 19:23:402024-12-27 19:23:41

Judging History

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

  • [2024-12-27 19:23:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3816kb
  • [2024-12-27 19:23:40]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int fa1[30],fa2[30];
int findfa1(int x){
	if(x==fa1[x])return x;
	return fa1[x]=findfa1(fa1[x]);
}
int findfa2(int x){
	if(x==fa2[x])return x;
	return fa2[x]=findfa2(fa2[x]);
}
void mergefa1(int a,int b){
	int faa=findfa1(a),fab=findfa1(b);
	if(fab>faa)fa1[faa]=fab;
	else fa1[fab]=faa;
}
void mergefa2(int a,int b){
	int faa=findfa2(a),fab=findfa2(b);
	if(fab>faa)fa2[faa]=fab;
	else fa2[fab]=faa;
}
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		string s1,s2,s3;
		cin>>s1>>s2>>s3;
		if(s1.size()!=s2.size())cout<<"NO"<<endl;
		else{
			if(s1.size()!=s3.size())cout<<"YES"<<endl;
			else{
				for(int i=1;i<=26;i++){
					fa1[i]=fa2[i]=i;
				}
				for(int i=0;i<s1.size();i++){
					if(s1[i]!=s2[i])mergefa1(s1[i]-'a'+1,s2[i]-'a'+1);
					if(s1[i]!=s3[i])mergefa2(s1[i]-'a'+1,s3[i]-'a'+1);
				}
				int flag=0;
				for(int i=1;i<=26;i++){
					if(findfa1(i)!=findfa2(i))flag=1;
				}
				if(flag)cout<<"YES"<<endl;
				else cout<<"NO"<<endl;
			}
		}
	} 
	return 0;
}

详细

Test #1:

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

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: 1ms
memory: 3628kb

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: 3620kb

input:

100
dntfvviytogwqljvoksaovstrqwpovkncxvmytnvcaoikctmgukaxlivmwahenydtswyowpdvggeeyzykdiojltpxuzzwphdqfsh
anbbtriynochhmrtsmjifvatlfsmwiimvxbmyoavcmfiioxatckaxcikmwazenjmdleyjwndvggqkazikdeofaqpbuzkupshfhgh
anbflviytfylqlpvvmjaovajllwpoukmvwemgtivvaonkoxagukaxriyuvmypnymtdqyocpdvcgqkazykrihjbipxquzup...

output:

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

result:

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