QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#769249#9726. AUSmapleKingWA 0ms3588kbC++201.2kb2024-11-21 16:45:542024-11-21 16:45:58

Judging History

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

  • [2024-11-21 16:45:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-11-21 16:45:54]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize(2)

// using namespace std;

using i64 = long long;
using u32 = unsigned int;
using u64 = unsigned long long;

void solve() {
    std::string s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;
    std::vector<int> f(26);
    std::iota(f.begin(), f.end(), 0);
    auto find =[&](auto self, int x) -> int{
        if (x != f[x]) f[x] = self(self, f[x]);
        return f[x];
    };
    int n = s1.size();
    int st = 1;
    for(int i = 0; i < n; i++){
        int a = s1[i] - 'a';
        int b = s2[i] - 'a';
        int fa = find(find, a), fb = find(find, b);
        if (fa == fb){
            continue;
        }
        f[fa] = fb;
    }
    for(int i = 0; i < n; i++){
        int a = s1[i] - 'a';
        int b = s3[i] - 'a';
        int fa = find(find, a), fb = find(find, b);
        if (fa == fb){
            st = 0;
            break;
        }
    }
    std::cout << (st ? "YES" : "NO") << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // std::cout << std::fixed << std::setprecision(10); // 固定输出精度
    int t = 1;
    std::cin >> t;

    while (t--) {
        solve();
    }
    

    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3588kb

input:

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

output:

NO
NO
NO
YES

result:

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