#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); short t[5][3]; bool instant[] = {false,false,false,false,false}; for(short i=0;i<4;i++) for(short j=0;j<3;j++){ t[i][j] = 1; } t[4][0] = 2; t[4][1] = 2; t[4][2] = 2; short ile = 0; short runda = 0; short dywizja = 0; short check = 0; string current = "AB"; cin >> ile; if(0.9*ile >= 18) check = short(0.9*ile)-1; else check = 17; for(short i=0;i<ile;i++){ cin >> current; runda = short(current[0])-49; dywizja = short(current[1])-65; t[runda][dywizja]--; if(t[runda][0]<= 0 && t[runda][1]<= 0 && t[runda][2]<= 0) instant[runda] = true; if(i>=check) if(instant[0]&&instant[1]&&instant[2]&&instant[3]&&instant[4]){ cout << "TAK"; break; }else{ if(i==ile-1) 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 45 46 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); short t[5][3]; bool instant[] = {false,false,false,false,false}; for(short i=0;i<4;i++) for(short j=0;j<3;j++){ t[i][j] = 1; } t[4][0] = 2; t[4][1] = 2; t[4][2] = 2; short ile = 0; short runda = 0; short dywizja = 0; short check = 0; string current = "AB"; cin >> ile; if(0.9*ile >= 18) check = short(0.9*ile)-1; else check = 17; for(short i=0;i<ile;i++){ cin >> current; runda = short(current[0])-49; dywizja = short(current[1])-65; t[runda][dywizja]--; if(t[runda][0]<= 0 && t[runda][1]<= 0 && t[runda][2]<= 0) instant[runda] = true; if(i>=check) if(instant[0]&&instant[1]&&instant[2]&&instant[3]&&instant[4]){ cout << "TAK"; break; }else{ if(i==ile-1) cout << "NIE"; } } return 0; } |