QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#755538 | #9726. AUS | hxsj# | WA | 2ms | 3840kb | C++14 | 1.4kb | 2024-11-16 17:36:21 | 2024-11-16 17:36:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 30;
int p[N];
void init()
{
for(int i = 0;i<=N;i++)
{
p[i] = i;
}
}
int find(int x) // 并查集
{
if (p[x] != x) p[x] = find(p[x]);
return p[x];
}
void merge(int x,int y)
{
x = find(x),y = find(y);
if(x!=y)
{
p[x] = p[y];
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
init();
string s1,s2,s3;
cin>>s1>>s2>>s3;
map<char,int>mmp;
if(s1.size()!=s2.size())
{
cout<<"NO"<<endl;
continue;
}
if(s1.size()!=s3.size())
{
cout<<"YES"<<endl;
continue;
}
for(int i= 0;i<s1.size();i++)
{
mmp[s1[i]] = 1;
mmp[s2[i]] = 1;
merge(s1[i]-'a',s2[i]-'a');
}
bool ok = 0;
for(int i = 0;i<s3.size();i++)
{
if(mmp[s3[i]]==0)
{
cout<<"YES"<<endl;
ok= 1;
break;
}
if(find(s1[i]-'a')!=find(s3[i]-'a'))
{
cout<<"YES!"<<endl;
ok= 1;
break;
}
}
if(!ok)
{
cout<<"NO"<<endl;
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
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: 3552kb
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: 2ms
memory: 3840kb
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 YES 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 YES! YES! YES! NO YES! NO NO Y...
result:
wrong answer 2nd lines differ - expected: 'YES', found: 'YES!'