QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#833987#9726. AUSremain11#RE 0ms3556kbC++201.2kb2024-12-27 09:37:062024-12-27 09:37:08

Judging History

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

  • [2024-12-27 09:37:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3556kb
  • [2024-12-27 09:37:06]
  • 提交

answer

#include <iostream>
#include <cassert>
using namespace std;

void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    int cat[26], cnt = 0;
    for (int i = 0; i < 26; ++i) cat[i] = -1;
    if (a.length() != b.length()) {
        cout << "NO\n";
        return;
    }
    if (a.length() != c.length()) {
        cout << "YES\n";
        return;
    }
    int n = a.length();
    for (int i = 0; i < n; ++i) {
        int aa = a[i] - 'a';
        int bb = b[i] - 'a';
        if (cat[aa] == -1 && cat[bb] == -1) {
            cat[aa] = cat[bb] = cnt++;
        } else if (cat[aa] == -1) {
            cat[aa] = cat[bb];
        } else if (cat[bb] == -1) {
            cat[bb] = cat[aa];
        } else {
            assert(cat[bb] == cat[aa]);
        }
    }

    for (int i = 0; i < n; ++i) {
        int aa = a[i] - 'a';
        int cc = c[i] - 'a';
        if (cat[aa] != cat[cc]) {
            cout << "YES\n";
            return;
        }
    }
    cout << "NO\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T; cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Runtime Error

input:

10
ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...

output:


result: