#include <iostream> using namespace std; int main() { int t; cin >> t; bool major[t]; for (int i = 0; i < t; i++) { int n; cin >> n; int minimum,maximum = 0,min_id,max_id; for (int j = 0; j < n; j++) { int w_max,w_min,h_min,h_max; cin >> w_min >> w_max >> h_min >> h_max; if (j == 0) { minimum = w_min*h_min; min_id = j; } if (w_min*h_min < minimum) { minimum = w_min*h_min; min_id = j; } if (w_max*h_max > maximum) { maximum = w_max*h_max; max_id = j; } } if (min_id == max_id) { major[i] = true; } else { major[i] = false; } } for (int i = 0; i < t; i++) { if (major[i] == true) { cout << "TAK\n"; } else { cout << "NIE\n"; } } 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() { int t; cin >> t; bool major[t]; for (int i = 0; i < t; i++) { int n; cin >> n; int minimum,maximum = 0,min_id,max_id; for (int j = 0; j < n; j++) { int w_max,w_min,h_min,h_max; cin >> w_min >> w_max >> h_min >> h_max; if (j == 0) { minimum = w_min*h_min; min_id = j; } if (w_min*h_min < minimum) { minimum = w_min*h_min; min_id = j; } if (w_max*h_max > maximum) { maximum = w_max*h_max; max_id = j; } } if (min_id == max_id) { major[i] = true; } else { major[i] = false; } } for (int i = 0; i < t; i++) { if (major[i] == true) { cout << "TAK\n"; } else { cout << "NIE\n"; } } return 0; } |