QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#864978 | #9726. AUS | tsai | WA | 1ms | 3968kb | C++14 | 1.5kb | 2025-01-21 12:45:48 | 2025-01-21 12:45:48 |
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 ;
}else if(check(s1,s3,s2)){
printf("YES");
return ;
}else if(check(s2,s3,s1)){
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: -100
Wrong Answer
time: 1ms
memory: 3968kb
input:
10 ekkzjwextuoazxsosiiiditwrjiztfvxtzaztmdfhxroaqkjcdgsgiitkfglcrtgjquspjyjtodyhxetldbhvxampcvbinzgksxkunduhvbddakqswurshbnuazthfnxmsuyypznmxmatsnvpqovscnkkcjphtcmcsqteeikwggnugskjjwttvlrxmmrkyltxjhfiqicttcfumurdrmiqauruywgdomxxpbeunliyvsutrneexoyckjflhnmmaaovxubnptlemptxbhrflbnfcowktydgbugdxvkvegza...
output:
NO NO YES NO NO NO NO NO NO NO
result:
wrong answer 3rd lines differ - expected: 'NO', found: 'YES'