QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#855934#9726. AUSshi2uku#WA 1ms3548kbC++141.0kb2025-01-13 13:09:132025-01-13 13:09:24

Judging History

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

  • [2025-01-13 13:09:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3548kb
  • [2025-01-13 13:09:13]
  • 提交

answer

#include <iostream>
#include <vector>
using namespace std;
struct DSU {
    vector<int> a;
    DSU(int n) : a(vector<int>(n)) {
        for (int i = 0; i < n; ++i) a[i] = i;
    }
    int find(int x) { return a[x] = x == a[x] ? x : find(a[x]); }
    int merge(int u, int v) {
        u = find(u);
        v = find(v);
        if (u < v) swap(u, v);
        if (u == v) return 0;
        a[v] = u;
        return 1;
    }
};
bool solve() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a.size() != b.size()) return 0;
    if (a.size() != c.size()) return 1;
    DSU f(30);
    for (int i = 0; i < a.size(); ++i) f.merge(a[i] - 'a', b[i] - 'a');
    for (int i = 0; i < a.size(); ++i)
        if (f.find(a[i] - 'a') != f.find(c[i] - 'a')) return 1;
    return 0;
}
int main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--) cout << (solve() ? "Yes" : "No") << '\n';
}
/*
4
abab
cdcd
abce
abab
cdcd
abcd
abab
cdcd
abc
x
yz
def
*/

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3548kb

input:

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

output:

Yes
No
Yes
No

result:

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