/* * https://sio2.mimuw.edu.pl/c/pa-2020-1/p/wyb/ */ #include <iostream> #include <vector> #include <numeric> #include <cassert> #include <string> #define assertm(exp, msg) assert(((void)msg, exp)) #define assertb(exp, msg) \ if (!(exp)) { \ std::cout << msg << std::endl; \ assert(exp); \ } using namespace std; int main() { int n; std::cin >> n; vector<int> nums(n, 0); int a; char b; vector<int> missing_values = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2}; // int missing_ctr = std::accumulate(vector.begin(), vector.end(), decltype(vector)::value_type(0)); int missing_ctr = std::accumulate(missing_values.begin(), missing_values.end(), 0); assertb(missing_values.size() == 15, "Missing values size should be 15. But is: " + std::to_string(missing_values.size())); for (int i = 0 ; i < n; ++i) { std::cin >> a >> b; int addendum = 0; if (b == 'A') { addendum = 0; } else if (b == 'B') { addendum = 1; } else if (b == 'C') { addendum = 2; } int idx = (a - 1) * 3 + addendum; if (missing_values[idx] > 0) { missing_values[idx]--; missing_ctr--; } if (missing_ctr == 0) { std::cout << "TAK" << std::endl; exit(0); } } std::cout << "NIE" << std::endl; }
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 61 62 63 64 | /* * https://sio2.mimuw.edu.pl/c/pa-2020-1/p/wyb/ */ #include <iostream> #include <vector> #include <numeric> #include <cassert> #include <string> #define assertm(exp, msg) assert(((void)msg, exp)) #define assertb(exp, msg) \ if (!(exp)) { \ std::cout << msg << std::endl; \ assert(exp); \ } using namespace std; int main() { int n; std::cin >> n; vector<int> nums(n, 0); int a; char b; vector<int> missing_values = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2}; // int missing_ctr = std::accumulate(vector.begin(), vector.end(), decltype(vector)::value_type(0)); int missing_ctr = std::accumulate(missing_values.begin(), missing_values.end(), 0); assertb(missing_values.size() == 15, "Missing values size should be 15. But is: " + std::to_string(missing_values.size())); for (int i = 0 ; i < n; ++i) { std::cin >> a >> b; int addendum = 0; if (b == 'A') { addendum = 0; } else if (b == 'B') { addendum = 1; } else if (b == 'C') { addendum = 2; } int idx = (a - 1) * 3 + addendum; if (missing_values[idx] > 0) { missing_values[idx]--; missing_ctr--; } if (missing_ctr == 0) { std::cout << "TAK" << std::endl; exit(0); } } std::cout << "NIE" << std::endl; } |