题目地址:http://poj.org/problem?id=1729
本来想用string保存路程 后来发现太慢了
优先队列要以一条路中最近的距离排序
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstring>
using namespace std;
const int maxn=30+5;
const double INF=999999999;
char G[maxn][maxn];
int vis[maxn][maxn][maxn][maxn];
int n;
struct Point{
int x,y;
Point(int x=0,int y=0):x(x),y(y){}
bool operator == (const Point& p){
return x==p.x&&y==p.y;
}
bool operator != (const Point& p){
return !(*this==p);
}
};
int inline Dist(Point a,Point b){
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
struct Node{
Point Jack,Jill; int dist,pre,id; //dist 保存此路中相聚最近的距离
int d1,d2;
Node(Point a=Point(0,0),Point b=Poi