#include <iostream> #include <string> using namespace std; #define TASK(a,b) tasks[(b)-'A'][a-'1'] #ifdef HOME_ #define PRINT(x) cerr<<x #else #define PRINT(x) #endif int n; string s; bool solve() { ios_base::sync_with_stdio(0); short tasks[3][5] = { {1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {1, 1, 1, 1, 2} }; cin>>n; for(int i=0;i<n;++i) { cin>>s; --TASK(s[0], s[1]); PRINT(s << " -> " << TASK(s[0], s[1]) << endl); } for(int i=0;i<3;++i) for(int j=0;j<5;++j) { PRINT(i << " " << j << "->" << tasks[i][j] << endl); if (tasks[i][j]>0) return false; } return true; } int main() { if (solve()) cout << "TAK"; else cout << "NIE"; 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 | #include <iostream> #include <string> using namespace std; #define TASK(a,b) tasks[(b)-'A'][a-'1'] #ifdef HOME_ #define PRINT(x) cerr<<x #else #define PRINT(x) #endif int n; string s; bool solve() { ios_base::sync_with_stdio(0); short tasks[3][5] = { {1, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {1, 1, 1, 1, 2} }; cin>>n; for(int i=0;i<n;++i) { cin>>s; --TASK(s[0], s[1]); PRINT(s << " -> " << TASK(s[0], s[1]) << endl); } for(int i=0;i<3;++i) for(int j=0;j<5;++j) { PRINT(i << " " << j << "->" << tasks[i][j] << endl); if (tasks[i][j]>0) return false; } return true; } int main() { if (solve()) cout << "TAK"; else cout << "NIE"; return 0; } |