#include <bits/stdc++.h>
#include <set>
using namespace std;
int n;
//int pomysly[18];
//#define hashM unordered_map
//hashM<int, char> mapa;
set<int> A, B, C;
int fiveA, fiveB, fiveC;
bool czy_wszystkie(set<int> s) {
for (int i = 1; i <= 5; ++i) {
if (s.count(i) == 0)
return false;
}
return true;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
int a;
char b;
for (int i = 0; i < n; ++i) {
cin >> a;
cin >> b;
if (b == 'A') {
A.insert(a);
if (a == 5)
++fiveA;
} else if (b == 'B') {
B.insert(a);
if (a == 5)
++fiveB;
} else if (b == 'C') {
C.insert(a);
if (a == 5)
++fiveC;
}
}
/*for (int const &liczba : A) {
cout << liczba;
}*/
if (fiveA < 2 || fiveB < 2 || fiveC < 2) {
cout << "NIE";
} else {
if (!czy_wszystkie(A) || !czy_wszystkie(B) || !czy_wszystkie(C))
cout << "NIE";
else
cout << "TAK";
}
return 0;
}
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 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include <bits/stdc++.h> #include <set> using namespace std; int n; //int pomysly[18]; //#define hashM unordered_map //hashM<int, char> mapa; set<int> A, B, C; int fiveA, fiveB, fiveC; bool czy_wszystkie(set<int> s) { for (int i = 1; i <= 5; ++i) { if (s.count(i) == 0) return false; } return true; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; int a; char b; for (int i = 0; i < n; ++i) { cin >> a; cin >> b; if (b == 'A') { A.insert(a); if (a == 5) ++fiveA; } else if (b == 'B') { B.insert(a); if (a == 5) ++fiveB; } else if (b == 'C') { C.insert(a); if (a == 5) ++fiveC; } } /*for (int const &liczba : A) { cout << liczba; }*/ if (fiveA < 2 || fiveB < 2 || fiveC < 2) { cout << "NIE"; } else { if (!czy_wszystkie(A) || !czy_wszystkie(B) || !czy_wszystkie(C)) cout << "NIE"; else cout << "TAK"; } return 0; } |
English