我草这是什么神仙算法??
搜题解全是二分图,,,还什么最小权。。。题目里根本没说要求路径和最小啊。。这也不好证明路径和最小时就满足条件啊。。。不太明白正确性。。。
还不如随机冒泡靠谱(((((
#include <cstdio>
#include <cmath>
#include <algorithm>
#define pii pair<int,int>
using namespace std;
typedef double db;
const db eps=1e-6;
const db pi=acos(-1);
int sign(db k){
if (k>eps) return 1; else if (k<-eps) return -1; return 0;
}
int cmp(db k1,db k2){return sign(k1-k2);}
int inmid(db k1,db k2,db k3){return sign(k1-k3)*sign(k2-k3)<=0;}// k3 在 [k1,k2] 内
struct point{
db x,y;
point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
point operator * (db k1) const{return (point){x*k1,y*k1};}
point operator / (db k1) const{return (point){x/k1,y/k1};}
int operator == (const point &k1) const{return cmp(x,k1.x)==0&&cmp(y,k1.y)==0;}
// 逆时针旋转
point turn(db k1){return (point){x*cos(k1)-y*sin(k1),x*sin(k1)+y*cos(k1)};}
point turn90(){return (point){-y,x};}
bool operator < (const point k1) const{
int a=cmp(x,k1.x);
if (a==-1) return 1; else if (a==1) return 0; else return cmp(y,k1.y)==-1;
}
db abs(){return sqrt(x*x+y*y);}
db abs2(){return x*x+y*y;}
db dis(point k1){return ((*this)-k1).abs();}
point unit(){db w=abs(); return (point){x/w,y/w};}
void scan(){double k1,k2; scanf("%lf%lf",&k1,&k2); x=k1; y=k2;}
void print(){printf("%.11lf %.11lf\n",x,y);}
db getw(){return atan2(y,x);}
point getdel(){if (sign(x)==-1||(sign(x)==0&&sign(y)==-1)) return (*this)*(-1); else return (*this);}
int getP() const{return sign(y)==1||(sign(y)==0&&sign(x)==-1);}
};
db cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}
int intersect(db l1,db r1,db l2,db r2){
if (l1>r1) swap(l1,r1); if (l2>r2) swap(l2,r2); return cmp(r1,l2)!=-1&&cmp(r2,l1)!=-1;
}
int checkSS(point k1,point k2,point k3,point k4){
return intersect(k1.x,k2.x,k3.x,k4.x)&&intersect(k1.y,k2.y,k3.y,k4.y)&&
sign(cross(k3-k1,k4-k1))*sign(cross(k3-k2,k4-k2))<=0&&
sign(cross(k1-k3,k2-k3))*sign(cross(k1-k4,k2-k4))<=0;
}
int n;point a[105],b[105];
int p[105];
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
p[i]=i;
scanf("%lf%lf",&a[i].x,&a[i].y);
}
for(int i=1;i<=n;i++){
scanf("%lf%lf",&b[i].x,&b[i].y);
}
random_shuffle(p+1,p+1+n);
while (1) {
bool f=0;
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (checkSS(a[i], b[p[i]], a[j], b[p[j]])) {
swap(p[i], p[j]);
f=1;
}
}
}
if(!f)break;
}
for (int i = 1; i <= n; i++)printf("%d ", p[i]);
}