QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#865041 | #9726. AUS | surenjamts# | WA | 1ms | 3712kb | C++20 | 1.6kb | 2025-01-21 14:10:46 | 2025-01-21 14:10:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// --- Your macros/aliases ---
using ll = long long;
using uint = unsigned int;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define put(x) cout << (x) << '\n'
const int N = 2e5 + 5;
const int MOD = 998244353;
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U> p) {
return os << "(" << p.first << ", " << p.second << ")";
}
template<typename T, typename U = char>
void print(const T &v, U end = ' '){
for(auto it : v) cout << it << end;
cout << '\n';
}
map<char, set<char>> mp;
map<char, int> comp;
void dfs(char v, int label){
// cout << "vis " << v << endl;
comp[v] = label;
for(char u : mp[v]){
if(!comp[u]) dfs(u, label);
}
}
void solve(){
mp.clear();
comp.clear();
string s1, s2, s3;
cin >> s1 >> s2 >> s3;
if(s1.size() != s2.size()){
put("NO");
return;
}
if(s1.size() != s3.size()){
put("YES");
return;
}
for(int i = 0; i < s1.size(); i++){
mp[s1[i]].insert(s2[i]);
}
int it = 1;
for(char c = 'a'; c <= 'z'; c++){
if(!comp[c]){
dfs(c, it++);
}
}
// print(comp, "\n");
for(int i = 0; i < s1.size(); i++){
if(comp[s1[i]] != comp[s3[i]]){
put("YES");
return;
}
}
put("NO");
}
int32_t main(){
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
int t = 1;
cin >> t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
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: 0
Accepted
time: 1ms
memory: 3584kb
input:
10 ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...
output:
NO NO NO NO NO NO NO NO NO NO
result:
ok 10 lines
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3712kb
input:
100 dntfvviytogwqljvoksaovstrqwpovkncxvmytnvcaoikctmgukaxlivmwahenydtswyowpdvggeeyzykdiojltpxuzzwphdqfsh anbbtriynochhmrtsmjifvatlfsmwiimvxbmyoavcmfiioxatckaxcikmwazenjmdleyjwndvggqkazikdeofaqpbuzkupshfhgh anbflviytfylqlpvvmjaovajllwpoukmvwemgtivvaonkoxagukaxriyuvmypnymtdqyocpdvcgqkazykrihjbipxquzup...
output:
YES YES YES YES YES YES NO YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES NO NO YES YES YES NO YES NO YES YES YES YES YES YES YES NO YES YES YES NO NO YES NO YES YES YES YES YES YES YES YES YES YES NO YES YES NO YES NO YES YES YES YES YES YES YES YES ...
result:
wrong answer 3rd lines differ - expected: 'NO', found: 'YES'