QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#746209#9726. AUSthe_fool#WA 1ms3780kbC++201.0kb2024-11-14 13:51:092024-11-14 13:51:18

Judging History

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

  • [2024-11-14 13:51:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3780kb
  • [2024-11-14 13:51:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

void solve() {
    string a, b, c;
    cin >> a >> b >> c;

    if (a.size() != b.size()) {
        cout << "NO\n";
        return;
    }

    if (b == c) {
        cout << "NO\n";
        return;
    }

    if (a.size() != c.size()) {
        cout << "YES\n";
        return;
    }

    int n = a.size();
    set<int> p[26];

    for (int i = 0; i < n; i++) {
        char x = a[i], y = b[i];
        p[x - 'a'].emplace(y - 'a');
        p[y - 'a'].emplace(x - 'a');
    }

    for (int i = 0; i < n ;i++) {
        int x = a[i] - 'a', y = c[i] - 'a';
        if (x == y) continue;
        if (p[x].contains(y)) {
            continue;
        }
        cout << "YES\n";
        return;
    }

    cout << "NO\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}

/*
4
abab
cdcd
abce
abab
cdcd
abcd
abab
cdcd
abc
x
yz
def
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: -100
Wrong Answer
time: 1ms
memory: 3780kb

input:

10
ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...

output:

YES
YES
NO
YES
YES
YES
YES
YES
YES
YES

result:

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