QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751439#9726. AUSProaes#WA 0ms3684kbC++202.7kb2024-11-15 18:41:492024-11-15 18:41:50

Judging History

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

  • [2024-11-15 18:41:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3684kb
  • [2024-11-15 18:41:49]
  • 提交

answer

/**
 *    title:  a.cpp
 *    author:  Proaes Meluam
 *    created:  2024-11-15 17:36:55
**/
#include <bits/stdc++.h>
#ifdef LOCAL
#include "algo/debug.h" 
#else
#define debug(...) 42
#endif
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double pi = acos(-1);
const double E = exp(1);
constexpr ll mod = 1e9 + 7;
// constexpr int inf = 0x3f3f3f3f;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    auto equal = [&](vector<int> a, vector<int> b) {
        int n = a.size();
        for (int i = 1; i < n; ++ i) {
            if (a[i] != b[i]) {
                return 0;
            }
        }
        return 1;
    };

    const int m = 3;
    int tt = 1;
    cin >> tt;
    while (tt--) {
        vector<string> s(m + 1);
        vector<int> n(m + 1);
        for (int i = 1; i <= m; ++ i) {
            cin >> s[i];
            n[i] = s[i].size();
        }
        if (n[1] != n[2]) {
            cout << "NO\n";
        } else {
            if (n[1] != n[3]) {
                cout << "YES\n";
            } else {
                bool flag = 0;
                int len = n[1];
                vector<int> mp(26);
                vector<vector<int>> a(m + 2, vector<int>(len + 1));
                for (int i = 1; i <= m; ++ i) {
                    for (int j = 1; j <= len; ++ j) {
                        a[i][j] = s[i][j - 1] - 'a';
                    }
                }
                auto f = [&]() {
                    bool tag = 1;
                    iota(mp.begin(), mp.end(), 0);
                    for (int i = 1;i <= len; ++ i) {
                        if (mp[a[1][i]] == a[1][i] || mp[a[1][i]] == a[2][i]) {
                            mp[a[1][i]] = a[2][i];
                        } else {
                            tag = 0;
                            break;
                        }
                    }
                    for (int i = 1; i <= len; ++ i) {
                        a[4][i] = mp[a[3][i]];
                    }
                    // debug(a[1]);
                    // debug(a[2]);
                    // debug(a[3]);
                    // debug(a[4]);
                    if (tag == 1 && equal(a[2], a[4]) != 0) {
                        flag = 1;
                    }
                };
                f();
                swap(a[1], a[2]);
                f();
                // debug(a[1]);
                // debug(a[2]);
                // debug(a[3]);
                if (flag == 1) {
                    cout << "NO\n";
                } else {
                    cout << "YES\n";
                }
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0ms
memory: 3684kb

input:

10
ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...

output:

YES
YES
NO
YES
YES
YES
YES
YES
YES
YES

result:

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