#include<iostream>
using namespace std;
class Prost {
public:
int wMin, wMax, hMin, hMax;
friend bool operator < (const Prost & prost1, const Prost & prost2) {
if(prost1.wMin == prost2.wMin) {
if(prost1.wMax == prost2.wMax) {
if(prost1.hMin == prost2.hMin) {
return prost1.hMax > prost2.hMax;
}
return prost1.hMin < prost2.hMin;
}
return prost1.wMax > prost2.wMax;
}
return prost1.wMin < prost2.wMin;
}
};
const int ROZMIAR = 100100;
int nTest, ile;
Prost prost[ROZMIAR];
void wczytaj() {
for(int i = 0; i < ile; i++) {
cin >> prost[i].wMin >> prost[i].wMax >> prost[i].hMin >> prost[i].hMax;
}
}
Prost wyznaczMin() {
Prost wyn = prost[0];
for(int i = 1; i < ile; i++) {
if(prost[i] < wyn) wyn = prost[i];
}
return wyn;
}
bool czyDziala(Prost obejm) {
for(int i = 0; i < ile; i++) {
if(prost[i].wMin < obejm.wMin || prost[i].wMax > obejm.wMax || prost[i].hMin < obejm.hMin || prost[i].hMax > obejm.hMax) return false;
}
return true;
}
void rozwiaz() {
cin >> ile;
wczytaj();
if(czyDziala(wyznaczMin())) cout << "TAK" << endl;
else cout << "NIE" << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin >> nTest;
for(int i = 0; i < nTest; i++) {
rozwiaz();
}
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<iostream> using namespace std; class Prost { public: int wMin, wMax, hMin, hMax; friend bool operator < (const Prost & prost1, const Prost & prost2) { if(prost1.wMin == prost2.wMin) { if(prost1.wMax == prost2.wMax) { if(prost1.hMin == prost2.hMin) { return prost1.hMax > prost2.hMax; } return prost1.hMin < prost2.hMin; } return prost1.wMax > prost2.wMax; } return prost1.wMin < prost2.wMin; } }; const int ROZMIAR = 100100; int nTest, ile; Prost prost[ROZMIAR]; void wczytaj() { for(int i = 0; i < ile; i++) { cin >> prost[i].wMin >> prost[i].wMax >> prost[i].hMin >> prost[i].hMax; } } Prost wyznaczMin() { Prost wyn = prost[0]; for(int i = 1; i < ile; i++) { if(prost[i] < wyn) wyn = prost[i]; } return wyn; } bool czyDziala(Prost obejm) { for(int i = 0; i < ile; i++) { if(prost[i].wMin < obejm.wMin || prost[i].wMax > obejm.wMax || prost[i].hMin < obejm.hMin || prost[i].hMax > obejm.hMax) return false; } return true; } void rozwiaz() { cin >> ile; wczytaj(); if(czyDziala(wyznaczMin())) cout << "TAK" << endl; else cout << "NIE" << endl; } int main() { ios_base::sync_with_stdio(false); cin >> nTest; for(int i = 0; i < nTest; i++) { rozwiaz(); } return 0; } |
English