#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
inline int min(int a, int b)
{
return a < b ? a : b;
}
inline int max(int a, int b)
{
return a > b ? a : b;
}
void solveCase()
{
int n;
cin >> n;
struct Zaklad
{
int w1, w2;
int h1, h2;
inline bool operator == (const Zaklad& other) const
{
return w1 == other.w1 && w2 == other.w2 && h1 == other.h1 && h2 == other.h2;
}
};
Zaklad major;
vector<Zaklad> zaklady;
zaklady.reserve(n);
for (int i = 0; i < n; i++)
{
Zaklad z;
cin >> z.w1 >> z.w2 >> z.h1 >> z.h2;
zaklady.push_back(z);
if (!i)
major = z;
else
{
major.h1 = min(major.h1, z.h1);
major.h2 = max(major.h2, z.h2);
major.w1 = min(major.w1, z.w1);
major.w2 = max(major.w2, z.w2);
}
}
bool haveMajor = false;
for (int i = 0; i < n; i++)
{
if (zaklady[i] == major)
{
haveMajor = true;
break;
}
}
cout << (haveMajor ? "TAK\n" : "NIE\n");
}
int main()
{
int t;
cin >> t;
for (int i = 0; i < t; i++)
solveCase();
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #include <stdio.h> #include <stdlib.h> #include <iostream> #include <vector> using namespace std; inline int min(int a, int b) { return a < b ? a : b; } inline int max(int a, int b) { return a > b ? a : b; } void solveCase() { int n; cin >> n; struct Zaklad { int w1, w2; int h1, h2; inline bool operator == (const Zaklad& other) const { return w1 == other.w1 && w2 == other.w2 && h1 == other.h1 && h2 == other.h2; } }; Zaklad major; vector<Zaklad> zaklady; zaklady.reserve(n); for (int i = 0; i < n; i++) { Zaklad z; cin >> z.w1 >> z.w2 >> z.h1 >> z.h2; zaklady.push_back(z); if (!i) major = z; else { major.h1 = min(major.h1, z.h1); major.h2 = max(major.h2, z.h2); major.w1 = min(major.w1, z.w1); major.w2 = max(major.w2, z.w2); } } bool haveMajor = false; for (int i = 0; i < n; i++) { if (zaklady[i] == major) { haveMajor = true; break; } } cout << (haveMajor ? "TAK\n" : "NIE\n"); } int main() { int t; cin >> t; for (int i = 0; i < t; i++) solveCase(); return 0; } |
English