Problem:1922A
The code with char array:
#include <iostream>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
int flag = 0;
cin>>n;
char a[n];
char b[n];
char c[n];
cin>>a;
cin>>b;
cin>>c;
for (int i = 0; i < n; ++i) {
if(a[i] != c[i] && b[i] != c[i]) {
flag = 1;
break;
}
}
if(flag)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
Error: wrong answer expected NO, found YES [503rd token]
The code with string:
#include <iostream>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
int flag = 0;
cin>>n;
string a;
string b;
string c;
cin>>a;
cin>>b;
cin>>c;
for (int i = 0; i < n; ++i) {
if(a[i] != c[i] && b[i] != c[i]) {
flag = 1;
break;
}
}
if(flag)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
Result: Accepted
The compiler I selected was C++17 for both of the code.