#include <queue>
#include <stack>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int MAX = 1010;
typedef struct COOR{
int lx,ly,rx,ry;
bool dir; // dir标记方向,true为南北,false为东西
}COOR;
COOR c[MAX];
int map[MAX][MAX];
int dis(int x1,int y1,int x2,int y2)
{
return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}
int conDifDir(int i,int k) // 判断是否相连或者交叉
{
if( c[k].lx >= c[i].lx && c[k].lx <= c[i].rx && c[i].ly >= c[k].ly && c[i].ly <= c[k].ry )
return 1;
return 0;
}
int conSamDir(int i,int k)
{
if( c[i].dir == true )
{
if( c[i].ly != c[k].ly )
return 0;
if( c[i].rx >= c[k].lx && c[i].lx <= c[k].rx )
return 1;
}
if( c[i].dir == false )
{
if( c[i].lx != c[k].lx )
return 0;
if( c[i].ly <= c[k].ry && c[i].ry >= c[k].ly )
return 1;
}
}
int minSamDis(int i,int k)
{
if( c[i].dir == true )
{
if( c[i].lx <= c[k].rx && c[i].lx >= c[k].lx || c[i].rx >= c[k].lx && c[i].rx <= c[k].rx )
return abs( c[i].ly - c[k].ly );
return INT_MAX;
}
if( c[i].dir == false )
{
// cout << i << ' ' << k << endl;cout << c[i].lx << ' ' << c[i].rx << ' '<< c[k].lx << ' ' << c[k].rx << endl;
if( c[i].ly <= c[k].ry && c[i].ly >= c[k].ly || c[i].ry >= c[k].ly && c[i].ry <= c[k].ry )
return abs( c[i].lx - c[k].lx );
#include <stack>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int MAX = 1010;
typedef struct COOR{
int lx,ly,rx,ry;
bool dir; // dir标记方向,true为南北,false为东西
}COOR;
COOR c[MAX];
int map[MAX][MAX];
int dis(int x1,int y1,int x2,int y2)
{
return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}
int conDifDir(int i,int k) // 判断是否相连或者交叉
{
if( c[k].lx >= c[i].lx && c[k].lx <= c[i].rx && c[i].ly >= c[k].ly && c[i].ly <= c[k].ry )
return 1;
return 0;
}
int conSamDir(int i,int k)
{
if( c[i].dir == true )
{
if( c[i].ly != c[k].ly )
return 0;
if( c[i].rx >= c[k].lx && c[i].lx <= c[k].rx )
return 1;
}
if( c[i].dir == false )
{
if( c[i].lx != c[k].lx )
return 0;
if( c[i].ly <= c[k].ry && c[i].ry >= c[k].ly )
return 1;
}
}
int minSamDis(int i,int k)
{
if( c[i].dir == true )
{
if( c[i].lx <= c[k].rx && c[i].lx >= c[k].lx || c[i].rx >= c[k].lx && c[i].rx <= c[k].rx )
return abs( c[i].ly - c[k].ly );
return INT_MAX;
}
if( c[i].dir == false )
{
// cout << i << ' ' << k << endl;cout << c[i].lx << ' ' << c[i].rx << ' '<< c[k].lx << ' ' << c[k].rx << endl;
if( c[i].ly <= c[k].ry && c[i].ly >= c[k].ly || c[i].ry >= c[k].ly && c[i].ry <= c[k].ry )
return abs( c[i].lx - c[k].lx );