#include <iostream>
using namespace std;
int main()
{
int ilosc,ofert,min1,max1,min2,max2;
int n1,n2,n3,n4;
bool czy_jest;
cin>> ilosc;
while(ilosc>0)
{
cin>> ofert;
cin>> min1 >> max1 >> min2 >> max2; // pierwsza oferta
czy_jest=1;
for(int i=0;i<ofert-1;i++)
{
cin >> n1 >> n2 >> n3 >> n4;
if(n1<=min1 && n2>=max1 && n3<=min2 && n4>=max2) // jeżeli czyjaś oferta pokrywa pozostałe, to spoko.
{
min1=n1;
max1=n2;
min2=n3;
max2=n4;
czy_jest=1;
}
else
{
if(n2>max1)
{
czy_jest=0;
max1=n2;
}
if(n1<min1)
{
min1=n1;
czy_jest=0;
}
if(n4>max2)
{
czy_jest=0;
max2=n4;
}
if(n3<min2)
{
min2=n3;
czy_jest=0;
}
}
}
if(czy_jest) cout<< "TAK" <<endl;
else cout << "NIE" <<endl;
ilosc--;
}
}
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 | #include <iostream> using namespace std; int main() { int ilosc,ofert,min1,max1,min2,max2; int n1,n2,n3,n4; bool czy_jest; cin>> ilosc; while(ilosc>0) { cin>> ofert; cin>> min1 >> max1 >> min2 >> max2; // pierwsza oferta czy_jest=1; for(int i=0;i<ofert-1;i++) { cin >> n1 >> n2 >> n3 >> n4; if(n1<=min1 && n2>=max1 && n3<=min2 && n4>=max2) // jeżeli czyjaś oferta pokrywa pozostałe, to spoko. { min1=n1; max1=n2; min2=n3; max2=n4; czy_jest=1; } else { if(n2>max1) { czy_jest=0; max1=n2; } if(n1<min1) { min1=n1; czy_jest=0; } if(n4>max2) { czy_jest=0; max2=n4; } if(n3<min2) { min2=n3; czy_jest=0; } } } if(czy_jest) cout<< "TAK" <<endl; else cout << "NIE" <<endl; ilosc--; } } |
English