#include <cstdio> #include <cstring> #include <set> const int MAX_N = 100000; typedef unsigned int Measurements; int main() { Measurements heights_table[MAX_N] = {0}; int max_indexes[MAX_N] = {0}; unsigned int max_indexes_size; int t; scanf("%d", &t); for (int ti = 0;ti < t;ti++) { max_indexes_size = 0; int n; scanf("%d", &n); Measurements max_width = 0; Measurements max_height = 0; for (int i = 0;i < n;i++) { Measurements w1, w2, h1, h2, w, h; scanf("%u %u %u %u", &w1, &w2, &h1, &h2); w = w2 - w1; h = h2 - h1; if (w > max_width) { max_width = w; max_indexes_size = 0; } if (h > max_height) max_height = h; if (w == max_width) max_indexes[max_indexes_size++] = i; heights_table[i] = h; } bool found = false; for (int i = 0;i < max_indexes_size;i++) { if (heights_table[max_indexes[i]] == max_height) { found = true; printf("TAK\n"); break; } } if (!found) printf("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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #include <cstdio> #include <cstring> #include <set> const int MAX_N = 100000; typedef unsigned int Measurements; int main() { Measurements heights_table[MAX_N] = {0}; int max_indexes[MAX_N] = {0}; unsigned int max_indexes_size; int t; scanf("%d", &t); for (int ti = 0;ti < t;ti++) { max_indexes_size = 0; int n; scanf("%d", &n); Measurements max_width = 0; Measurements max_height = 0; for (int i = 0;i < n;i++) { Measurements w1, w2, h1, h2, w, h; scanf("%u %u %u %u", &w1, &w2, &h1, &h2); w = w2 - w1; h = h2 - h1; if (w > max_width) { max_width = w; max_indexes_size = 0; } if (h > max_height) max_height = h; if (w == max_width) max_indexes[max_indexes_size++] = i; heights_table[i] = h; } bool found = false; for (int i = 0;i < max_indexes_size;i++) { if (heights_table[max_indexes[i]] == max_height) { found = true; printf("TAK\n"); break; } } if (!found) printf("NIE\n"); } return 0; } |