// 2007アジア地区予選E : Geometric Map #include #include #include #include #include #include using namespace std; typedef complex P; struct L { P p, q; L(P p, P q) : p(p), q(q) {} }; class Node { public: int p, q; double cost; Node(int p, int q, double cost) : p(p), q(q), cost(cost) {} bool operator < (const Node &nd) const { return cost > nd.cost; } }; typedef vector< vector > graph; const double EPS = 1e-6; bool comp(const P &a, const P &b) { return make_pair(a.real(), a.imag()) < make_pair(b.real(), b.imag()); } double dot(P a, P b) { return real(conj(a)*b); } double cross(P a, P b) { return imag(conj(a)*b); } bool spIntersect(L l, P p){ return abs(abs(l.p-p)+abs(p-l.q)-abs(l.p-l.q)) < EPS; } bool checkSign(L l, const vector &sign){ for(int i=0;i -EPS) return false; swap(sg.p, sg.q); } } return true; } graph makeGraph(vector

&pt, const vector &road, const vector &sign){ for(int i=0;i > vp; for(int j=0;j &vp){ int n = g.size(); vector cost(n, 1e12); cost[s] = 0.0; vector prev(n, -1); priority_queue qu; qu.push(Node(-1, s, 0.0)); while(!qu.empty()){ Node nd = qu.top(); qu.pop(); int pos = nd.q; if(prev[pos] != nd.p) continue; if(pos == t){ vector path; for(int p=t;p!=-1;p=prev[p]) path.push_back(p); reverse(path.begin(), path.end()); for(int i=0;i> n, n){ int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; P start = P(x1, y1), goal = P(x2, y2); vector vl, road, sign; for(int i=0;i> x1 >> y1 >> x2 >> y2; vl.push_back(L(P(x1,y1), P(x2,y2))); } for(int i=0;i vp; graph g = makeGraph(vp, road, sign); int sidx, gidx; for(int i=0;i