#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
const int N = 50001;
#define M
const bool de = 0;
int n,w,t;
bool nie;
pair <int,int> tab [N]; //pozycja/wysokość
//~ pair <int, int > pos [N];
inline void in(){
scanf ( "%d",&t );
for ( int i = 0; i < t; i++ ){
int a,b,c,d;
nie = false;
scanf ( "%d%d", &n,&w );
for ( int j = 0; j < n; j++ ){
scanf ( "%d%d%d%d",&a,&b,&c,&d );
tab[j].first =min (a,c);
tab[j].second=max(b,d)-min(b,d);
if ( de == 1 )
printf ( " tab[j].first = %d tab[j].s = %d \n",tab[j].first,tab[j].second );
}
for ( int j = 0; j < n; j++ ){
scanf ( "%d%d%d%d",&a,&b,&c,&d );
int pom = min (a,c);
int wysokosc = max(b,d)-min(b,d);
for ( int k = 0; k < n; k++){
if ( k != j && tab[k].first >= min ( tab[j].first , pom) && tab[k].first <= max ( tab[j].first , pom) ){
if ( de )
printf ( " tab [k] = %d , tab[j] = %d , pom = %d \n ",tab[k].first,tab[j].first,pom );
if (w < wysokosc+tab[k].second)
nie = true;
}
}
}
if ( nie == false )
printf ( "TAK\n" );
else
printf ( "NIE\n" );
}
}
int main(){
in();
}
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 | #include <iostream> #include <cstdio> #include <vector> #include <utility> #include <algorithm> using namespace std; const int N = 50001; #define M const bool de = 0; int n,w,t; bool nie; pair <int,int> tab [N]; //pozycja/wysokość //~ pair <int, int > pos [N]; inline void in(){ scanf ( "%d",&t ); for ( int i = 0; i < t; i++ ){ int a,b,c,d; nie = false; scanf ( "%d%d", &n,&w ); for ( int j = 0; j < n; j++ ){ scanf ( "%d%d%d%d",&a,&b,&c,&d ); tab[j].first =min (a,c); tab[j].second=max(b,d)-min(b,d); if ( de == 1 ) printf ( " tab[j].first = %d tab[j].s = %d \n",tab[j].first,tab[j].second ); } for ( int j = 0; j < n; j++ ){ scanf ( "%d%d%d%d",&a,&b,&c,&d ); int pom = min (a,c); int wysokosc = max(b,d)-min(b,d); for ( int k = 0; k < n; k++){ if ( k != j && tab[k].first >= min ( tab[j].first , pom) && tab[k].first <= max ( tab[j].first , pom) ){ if ( de ) printf ( " tab [k] = %d , tab[j] = %d , pom = %d \n ",tab[k].first,tab[j].first,pom ); if (w < wysokosc+tab[k].second) nie = true; } } } if ( nie == false ) printf ( "TAK\n" ); else printf ( "NIE\n" ); } } int main(){ in(); } |
English