QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#776444 | #9726. AUS | cbdsopa | ML | 0ms | 3828kb | C++14 | 1.7kb | 2024-11-23 18:43:09 | 2024-11-23 18:43:09 |
Judging History
answer
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define db double
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)
#define sky fflush(stdout)
#define gc getchar
#define pc putchar
namespace IO{
template<class T>
inline void read(T &s){
s = 0;char ch = gc();bool f = 0;
while(ch < '0' || '9'<ch) {if(ch == '-') f = 1; ch = gc();}
while('0'<=ch && ch<='9') {s = s * 10 + (ch ^ 48); ch = gc();}
if(ch == '.'){
T p = 0.1;ch = gc();
while('0' <= ch && ch <= '9') {s = s + p * (ch ^ 48);p /= 10;ch = gc();}
}
s = f ? -s : s;
}
template<class T,class ...A>
inline void read(T &s,A &...a){
read(s); read(a...);
}
template<class T>
inline void print(T x){
if(x<0) {x = -x; pc('-');}
static char st[40];
static int top;
top = 0;
do{st[++top] = x - x / 10 * 10 + '0';} while(x /= 10);
while(top) {pc(st[top--]);}
}
template<class T,class ...A>
inline void print(T s,A ...a){
print(s); print(a...);
}
};
using IO::read;
using IO::print;
const int N = 1e3;
char s[N + 3], t[N + 3], c[N + 3];
int fa[26];
int find(int x){
return x == fa[x] ? x : fa[x] = find(fa[x]);
}
inline void solve(){
scanf("%s%s%s", s + 1, t + 1, c + 1);
int n = strlen(s + 1);
if(n != strlen(t + 1) ){
printf("NO\n");
return;
}
if(n != strlen(c + 1) ){
printf("YES\n");
return;
}
for(int i = 0; i < 26; ++i) fa[i] = i;
for(int i = 1; i <= n; ++i){
fa[s[i] - 'a'] = t[i] - 'a';
}
for(int i = 1; i <= n; ++i){
if(find(s[i] - 'a') != find(c[i] - 'a') ){
printf("YES\n");
return;
}
}
printf("NO\n");
}
int main(){
#ifdef LOCAL
file(a);
#endif
int T; read(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: 3828kb
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
Memory Limit Exceeded
input:
10 ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...