QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784878#9726. AUSLonelyperWA 1ms3708kbC++171.5kb2024-11-26 16:13:222024-11-26 16:13:28

Judging History

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

  • [2024-11-26 16:13:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-11-26 16:13:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;
#define endl '\n'
#define x first
#define y second
const int N = 2e5 + 10;
const LL INF = 1e18, mod = 1e9 + 7;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

string s1, s2, s3;
int f[27];

void init(){
    for(int i = 0; i < 26; i ++) f[i] = i;
}

int find(int a){
    if(a == f[a]) return a;
    else return f[a] = find(f[a]);
}

void merge(int a, int b){
    int fa = find(a), fb = find(b);
    if(fa == fb) return;
    if(fa != fb) f[fb] = fa;
}

void Lonelyper(){
    init();
    cin >> s1 >> s2 >> s3;
    if(s1.size() != s2.size() || s2 == s3){
        cout << "NO" << endl;
        return;
    }
    int n = s1.size();
    for(int i = 0; i < n; i ++){
        if(s1[i] != s2[i]){
            merge(s1[i] - 'a', s2[i] - 'a');
        }
    }
    for(int i = 0; i < n; i ++) s1[i] = f[s1[i] - 'a'] + 'a';
    n = s2.size();
    for(int i = 0; i < n; i ++) s2[i] = f[s2[i] - 'a'] + 'a';
    n = s3.size();
    for(int i = 0; i < n; i ++) s3[i] = f[s3[i] - 'a'] + 'a';
    // cout << s1 << endl << s2 << endl << s3 << endl;
    if(s1 == s2 && s1 != s3){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t --) {
        Lonelyper();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

input:

100
dntfvviytogwqljvoksaovstrqwpovkncxvmytnvcaoikctmgukaxlivmwahenydtswyowpdvggeeyzykdiojltpxuzzwphdqfsh
anbbtriynochhmrtsmjifvatlfsmwiimvxbmyoavcmfiioxatckaxcikmwazenjmdleyjwndvggqkazikdeofaqpbuzkupshfhgh
anbflviytfylqlpvvmjaovajllwpoukmvwemgtivvaonkoxagukaxriyuvmypnymtdqyocpdvcgqkazykrihjbipxquzup...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO

result:

wrong answer 1st lines differ - expected: 'YES', found: 'NO'