#include <cmath> #include <iostream> using namespace std; int main() { // Create and open a text file int n_samples; cin >> n_samples; char letter; int number; int addition; bool is_provided[18]; for (int i=0; i<18; i++) { is_provided[i] = false; } for (int i=0; i<n_samples; i++) { cin >> number; cin >> letter; if (letter == 'A') { addition = 0; } if (letter == 'B') { addition = 1; } if (letter == 'C') { addition = 2; } if (number == 5) { if (is_provided[number + addition * 6 - 1] == true) { number++; } } is_provided[number + addition * 6 - 1] = true; } bool all_provided = true; for (int i=0; i<18; i++) { if (is_provided[i] == false) { all_provided = false; } } if (all_provided) { 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 45 46 47 48 49 50 51 52 53 54 55 56 | #include <cmath> #include <iostream> using namespace std; int main() { // Create and open a text file int n_samples; cin >> n_samples; char letter; int number; int addition; bool is_provided[18]; for (int i=0; i<18; i++) { is_provided[i] = false; } for (int i=0; i<n_samples; i++) { cin >> number; cin >> letter; if (letter == 'A') { addition = 0; } if (letter == 'B') { addition = 1; } if (letter == 'C') { addition = 2; } if (number == 5) { if (is_provided[number + addition * 6 - 1] == true) { number++; } } is_provided[number + addition * 6 - 1] = true; } bool all_provided = true; for (int i=0; i<18; i++) { if (is_provided[i] == false) { all_provided = false; } } if (all_provided) { cout << "TAK"; } else { cout << "NIE"; } return 0; } |