QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#833987 | #9726. AUS | remain11# | RE | 0ms | 3556kb | C++20 | 1.2kb | 2024-12-27 09:37:06 | 2024-12-27 09:37:08 |
Judging History
answer
#include <iostream>
#include <cassert>
using namespace std;
void solve() {
string a, b, c;
cin >> a >> b >> c;
int cat[26], cnt = 0;
for (int i = 0; i < 26; ++i) cat[i] = -1;
if (a.length() != b.length()) {
cout << "NO\n";
return;
}
if (a.length() != c.length()) {
cout << "YES\n";
return;
}
int n = a.length();
for (int i = 0; i < n; ++i) {
int aa = a[i] - 'a';
int bb = b[i] - 'a';
if (cat[aa] == -1 && cat[bb] == -1) {
cat[aa] = cat[bb] = cnt++;
} else if (cat[aa] == -1) {
cat[aa] = cat[bb];
} else if (cat[bb] == -1) {
cat[bb] = cat[aa];
} else {
assert(cat[bb] == cat[aa]);
}
}
for (int i = 0; i < n; ++i) {
int aa = a[i] - 'a';
int cc = c[i] - 'a';
if (cat[aa] != cat[cc]) {
cout << "YES\n";
return;
}
}
cout << "NO\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T; cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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
Runtime Error
input:
10 ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...