QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#864980 | #9726. AUS | tsai | WA | 1ms | 3968kb | C++14 | 1.3kb | 2025-01-21 12:51:51 | 2025-01-21 12:51:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
map<char,int>mp;
bool check(string s1,string s2,string goal){
mp.clear();
int jd=0;
int len1=s1.length();
int len2=s2.length();
int len3=goal.length();
if(len1==len2&&len1!=len3){
return 1;
}
if(len1!=len2){
return 0;
}
int cnt=0;
//len1==len2==len3
for(int i=0;i<len1;i++){
assert(cnt<=26);
if(s1[i]==s2[i]){
if(!mp[s1[i]]){
mp[s1[i]]=++cnt;
}
}else{
if(!mp[s1[i]]){
if(!mp[s2[i]]){
mp[s1[i]]=++cnt;
mp[s2[i]]=cnt;
}else{//s2[i]标过
mp[s1[i]]=mp[s2[i]];
}
}else{//s1[i]标过
if(!mp[s2[i]]){
mp[s2[i]]=mp[s1[i]];
}else{//s2[i]也标过
if(mp[s1[i]]!=mp[s2[i]]){
return 0;
}
}
}
}
}
assert(cnt<=26);
for(int i=0;i<len3;i++){
if(!mp[goal[i]]){
mp[goal[i]]=++cnt;
}
assert(cnt<=26);
}
for(int i=0;i<len1;i++){
if(mp[s1[i]]==mp[s2[i]]){
if(mp[goal[i]]!=mp[s1[i]]){
return 1;
}
}else{
return 0;
}
}
return 0;
}
void solve(){
string s1;
string s2;
string s3;
cin>>s1;
cin>>s2;
cin>>s3;
if(check(s1,s2,s3)){
printf("YES");
return ;
}
printf("NO");
return ;
}
int main(){
int t=1;
scanf("%d",&t);
while(t--){
solve();
printf("\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3840kb
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: 3968kb
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: 3968kb
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'