#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = a; i < b;++i)
#define pb push_back
using namespace std;
map<vector<int>,int> mapa;
int stala = 12;
void solve(){
vector<int> V,V1;
int n;
cin>>n;
FOR(i,0,n){
int x;
cin>>x;
V.pb(x);
V1.pb(x);
}
while(V1.size() < stala + 1){
V1.pb(0);
}
if(mapa[V1] == 0){
cout<<"NIE";
}else{
cout<<"TAK";
}
cout<<"\n";
}
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
int n;
cin>>n;
FOR(i,0,stala){
FOR(j,0,(1 << stala)){
vector<int> V(stala + 1,0);
V[i] = 1;
int poz = i;
mapa[V] = 1;
FOR(k,0,stala){
int ruch = 0;
if(((1 << k) & j)){
ruch = -1;
}else{
ruch = 1;
}
if(ruch == 1 && poz == stala){
ruch = -1;
}
if(ruch == -1 && poz == 0){
ruch = 1;
}
poz+=ruch;
V[poz]++;
mapa[V] = 1;
}
}
}
FOR(i,0,n){
solve();
}
}
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 56 57 58 59 60 | #include <bits/stdc++.h> #define FOR(i,a,b) for(int i = a; i < b;++i) #define pb push_back using namespace std; map<vector<int>,int> mapa; int stala = 12; void solve(){ vector<int> V,V1; int n; cin>>n; FOR(i,0,n){ int x; cin>>x; V.pb(x); V1.pb(x); } while(V1.size() < stala + 1){ V1.pb(0); } if(mapa[V1] == 0){ cout<<"NIE"; }else{ cout<<"TAK"; } cout<<"\n"; } int main(){ cin.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; FOR(i,0,stala){ FOR(j,0,(1 << stala)){ vector<int> V(stala + 1,0); V[i] = 1; int poz = i; mapa[V] = 1; FOR(k,0,stala){ int ruch = 0; if(((1 << k) & j)){ ruch = -1; }else{ ruch = 1; } if(ruch == 1 && poz == stala){ ruch = -1; } if(ruch == -1 && poz == 0){ ruch = 1; } poz+=ruch; V[poz]++; mapa[V] = 1; } } } FOR(i,0,n){ solve(); } } |
English