QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#769249 | #9726. AUS | mapleKing | WA | 0ms | 3588kb | C++20 | 1.2kb | 2024-11-21 16:45:54 | 2024-11-21 16:45:58 |
Judging History
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'