#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> pos;
string options[] = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C"};
bool solve() {
if (n < 18)
return false;
else {
int *a = new int[15];
int valid[] = {1,1,1,1,1,1,1,1,1,1,1,1,2,2,2};
for(int i = 0; i < 15; ++i)
a[i] = 0;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < 15; ++j) {
if(pos[i] == options[j]) {
a[j]++;
break;
}
}
}
for(int i = 0; i < 15; ++i) {
if(a[i] < valid[i])
return false;
}
return true;
}
}
void read() {
cin >> n;
string val;
for(int i = 0; i < n; ++i) {
cin >> val;
pos.push_back(val);
}
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
read();
cout << (solve() ? "TAK" : "NIE") << endl;
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 | #include <bits/stdc++.h> using namespace std; int n; vector<string> pos; string options[] = {"1A", "1B", "1C", "2A", "2B", "2C", "3A", "3B", "3C", "4A", "4B", "4C", "5A", "5B", "5C"}; bool solve() { if (n < 18) return false; else { int *a = new int[15]; int valid[] = {1,1,1,1,1,1,1,1,1,1,1,1,2,2,2}; for(int i = 0; i < 15; ++i) a[i] = 0; for(int i = 0; i < n; ++i) { for(int j = 0; j < 15; ++j) { if(pos[i] == options[j]) { a[j]++; break; } } } for(int i = 0; i < 15; ++i) { if(a[i] < valid[i]) return false; } return true; } } void read() { cin >> n; string val; for(int i = 0; i < n; ++i) { cin >> val; pos.push_back(val); } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); read(); cout << (solve() ? "TAK" : "NIE") << endl; return 0; } |
English