QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#755538#9726. AUShxsj#WA 2ms3840kbC++141.4kb2024-11-16 17:36:212024-11-16 17:36:22

Judging History

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

  • [2024-11-16 17:36:22]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3840kb
  • [2024-11-16 17:36:21]
  • 提交

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!'