QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#768431 | #9726. AUS | TauLee01# | WA | 1ms | 3588kb | C++23 | 1.6kb | 2024-11-21 10:28:58 | 2024-11-21 10:29:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f3f3f3f3f
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
void solve()
{
string s1, s2, s3;
cin >> s1 >> s2 >> s3;
map<int, int> mp;
if (s1.size() != s2.size())
{
cout << "NO" << endl;
return;
}
if (s1.size() != s3.size())
{
cout << "YES" << endl;
return;
}
int n = s1.size();
int cnt = 0;
for (int i = 0; i < n; i++)
{
if (mp[s1[i]] && mp[s2[i]])
{
if (mp[s1[i]] == mp[s2[i]])
continue;
else
{
cout << "NO" << endl;
return;
}
}
if (mp[s1[i]])
{
mp[s2[i]] = mp[s1[i]];
}
else if (mp[s2[i]])
{
mp[s1[i]] = mp[s2[i]];
}
else
mp[s1[i]] = mp[s2[i]] = ++cnt;
}
// cout << s1[1] << " " << s2[1] << " " << s3[1] << "\n";
// cout << cnt << endl;
if (cnt > 26)
{
// cout << "NO" << endl;
return;
}
for (int i = 0; i < n; i++)
{
if (!mp[s3[i]] || mp[s3[i]] != mp[s1[i]])
{
cout << "YES" << endl;
return;
}
else
{
continue;
}
}
cout << "NO" << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
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: 3588kb
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: 0ms
memory: 3464kb
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: 3524kb
input:
100 dntfvviytogwqljvoksaovstrqwpovkncxvmytnvcaoikctmgukaxlivmwahenydtswyowpdvggeeyzykdiojltpxuzzwphdqfsh anbbtriynochhmrtsmjifvatlfsmwiimvxbmyoavcmfiioxatckaxcikmwazenjmdleyjwndvggqkazikdeofaqpbuzkupshfhgh anbflviytfylqlpvvmjaovajllwpoukmvwemgtivvaonkoxagukaxriyuvmypnymtdqyocpdvcgqkazykrihjbipxquzup...
output:
YES NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO YES NO NO NO YES NO YES NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES NO NO ...
result:
wrong answer 2nd lines differ - expected: 'YES', found: 'NO'