#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n, a, b;
string s1, s2;
cin >> n >> s1 >> s2;
for(int i = 1; i<n; ++i){
cin >> a >> b;
}
bool czerwony1 = false, czarny1 = false;
for(int i = 0; i<n; ++i){
if(s1[i] == '0') czerwony1 = true;
if(s1[i] == '1') czarny1 = true;
}
bool czerwony2 = false, czarny2 = false;
for(int i = 0; i<n; ++i){
if(s2[i] == '0') czerwony2 = true;
if(s2[i] == '1') czarny2 = true;
}
bool ok = true;
if(czerwony2 == true && czerwony1 == false) ok = false;
if(czarny2 == true && czarny1 == false) ok = false;
bool wszystkie_inne = true;
for(int i = 0; i<n; ++i){
if(s1[i] == s2[i]) wszystkie_inne = false;
}
if(!ok || wszystkie_inne) cout << "NIE\n";
else cout << "TAK\n";
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; while(t--){ int n, a, b; string s1, s2; cin >> n >> s1 >> s2; for(int i = 1; i<n; ++i){ cin >> a >> b; } bool czerwony1 = false, czarny1 = false; for(int i = 0; i<n; ++i){ if(s1[i] == '0') czerwony1 = true; if(s1[i] == '1') czarny1 = true; } bool czerwony2 = false, czarny2 = false; for(int i = 0; i<n; ++i){ if(s2[i] == '0') czerwony2 = true; if(s2[i] == '1') czarny2 = true; } bool ok = true; if(czerwony2 == true && czerwony1 == false) ok = false; if(czarny2 == true && czarny1 == false) ok = false; bool wszystkie_inne = true; for(int i = 0; i<n; ++i){ if(s1[i] == s2[i]) wszystkie_inne = false; } if(!ok || wszystkie_inne) cout << "NIE\n"; else cout << "TAK\n"; } } |
English