QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#855934 | #9726. AUS | shi2uku# | WA | 1ms | 3548kb | C++14 | 1.0kb | 2025-01-13 13:09:13 | 2025-01-13 13:09:24 |
Judging History
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'