#include <iostream> using namespace std; int main() { int n; cin >> n; bool wynik[n] = {}; for (int i = 0; i < n; ++i) { int k; int max_a, max_b; int min_a, min_b; cin >> k; for (int j = 0; j < k; ++j) { int a, b, c; cin >> a >> b >> c; if(j == 0) { max_a = b; min_a = b; max_b = c; min_b = c; } if(b > max_a) max_a = b; if(c > max_b) max_b = c; if(b < min_a) min_a = b; if(c < min_b) min_b = c; } if(max_a < max_b || min_a > min_b) wynik[i] = false; else wynik[i] = true; } for (int i = 0; i < n; ++i) { if(wynik[i] == 1) cout << "TAK" << endl; else cout << "NIE" << 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 | #include <iostream> using namespace std; int main() { int n; cin >> n; bool wynik[n] = {}; for (int i = 0; i < n; ++i) { int k; int max_a, max_b; int min_a, min_b; cin >> k; for (int j = 0; j < k; ++j) { int a, b, c; cin >> a >> b >> c; if(j == 0) { max_a = b; min_a = b; max_b = c; min_b = c; } if(b > max_a) max_a = b; if(c > max_b) max_b = c; if(b < min_a) min_a = b; if(c < min_b) min_b = c; } if(max_a < max_b || min_a > min_b) wynik[i] = false; else wynik[i] = true; } for (int i = 0; i < n; ++i) { if(wynik[i] == 1) cout << "TAK" << endl; else cout << "NIE" << endl; } } |