#include<bits/stdc++.h> #define f first #define s second #define mp make_pair #define pb push_back #define pii pair<long long, long long> #define pll pair<long long, long long> #define ll long long #define vi vector<long long> #define vl vector<ll> #define rep(i,p,k) for(ll i=p; i<k; i++) #define per(i,p,k) for (ll i=k-1;i>=p;i--) ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;} using namespace std; string tab[105]; int t[100]; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; rep(i, 0, n) { cin >> tab[i]; int x = (int)(tab[i][0]-'1'); int d = (int)(tab[i][1]-'A'); t[x*3+d] += 1; } bool possible = true; rep(i, 0, 12) { if(t[i] < 1) possible = false; } rep(i, 12, 15) { if(t[i] < 2) possible = false; } if(possible) cout<<"TAK"; else cout<<"NIE"; }
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 | #include<bits/stdc++.h> #define f first #define s second #define mp make_pair #define pb push_back #define pii pair<long long, long long> #define pll pair<long long, long long> #define ll long long #define vi vector<long long> #define vl vector<ll> #define rep(i,p,k) for(ll i=p; i<k; i++) #define per(i,p,k) for (ll i=k-1;i>=p;i--) ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;} using namespace std; string tab[105]; int t[100]; int main() { ios_base::sync_with_stdio(0); int n; cin >> n; rep(i, 0, n) { cin >> tab[i]; int x = (int)(tab[i][0]-'1'); int d = (int)(tab[i][1]-'A'); t[x*3+d] += 1; } bool possible = true; rep(i, 0, 12) { if(t[i] < 1) possible = false; } rep(i, 12, 15) { if(t[i] < 2) possible = false; } if(possible) cout<<"TAK"; else cout<<"NIE"; } |