#include <cstdio>
#include <algorithm>
using namespace std;
struct Car{
int x1;
int y1;
int x2;
int y2;
Car(){};
Car(int a, int b, int c, int d)
:x1(a), y1(b), x2(c), y2(d)
{}
};
Car tab[500005];
Car tab2[500005];
bool sortuj(Car x, Car y){
if(x.x1 > y.x1)return false;
return true;
}
int main(){
int T;
scanf("%d", &T);
for(int t = 1; t <= T; t++){
int n, w;
scanf("%d%d", &n, &w);
for(int y = 0; y < n; y++){
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
tab[y]=Car(x1, y1, x2, y2);
}
for(int y = 0; y < n; y++){
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
tab2[y]=Car(x1, y1, x2, y2);
}
//sort(tab, tab + n, sortuj);
//sort(tab2, tab2 + n, sortuj);
bool tak=true;
for(int i = 0; i < n; i++){
for(int j = 0; j < i; j++){
if(tab[j].x1 < tab[i].x1){
if(tab2[j].x2 > tab2[i].x2){
if(w < tab[i].y2-tab[i].y1 + tab[j].y2 - tab[j].y1){
tak=false;
break;
}
}
}
}
if(!tak)break;
}
if(tak)printf("TAK\n");
else printf("NIE\n");
}
}
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 <algorithm> using namespace std; struct Car{ int x1; int y1; int x2; int y2; Car(){}; Car(int a, int b, int c, int d) :x1(a), y1(b), x2(c), y2(d) {} }; Car tab[500005]; Car tab2[500005]; bool sortuj(Car x, Car y){ if(x.x1 > y.x1)return false; return true; } int main(){ int T; scanf("%d", &T); for(int t = 1; t <= T; t++){ int n, w; scanf("%d%d", &n, &w); for(int y = 0; y < n; y++){ int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); tab[y]=Car(x1, y1, x2, y2); } for(int y = 0; y < n; y++){ int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); tab2[y]=Car(x1, y1, x2, y2); } //sort(tab, tab + n, sortuj); //sort(tab2, tab2 + n, sortuj); bool tak=true; for(int i = 0; i < n; i++){ for(int j = 0; j < i; j++){ if(tab[j].x1 < tab[i].x1){ if(tab2[j].x2 > tab2[i].x2){ if(w < tab[i].y2-tab[i].y1 + tab[j].y2 - tab[j].y1){ tak=false; break; } } } } if(!tak)break; } if(tak)printf("TAK\n"); else printf("NIE\n"); } } |
English