0%

 The Doors

思路讲解

image

可以用dij做。搜索做不太了。

先建边,然后再跑dij,会快一些。

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
auto check=[&](Line a){
int idx=lower_bound(all(A),Line(a.a,Point(INF,INF)))-A.begin();
bool ok=true;
FOR(i,idx,SZ(A)-1){
Line t=A[i];
if(sgn(t.a.x()-a.b.x())>=0) break;
if(isseginterline(t, a)){
ok=false;
break;
}
}
return ok;
};
vb vis(node.size()+5);
vector<vector<pair<ld,int> > > g(SZ(node)+5);
priority_queue<DIS> pq;
pq.EM(0,0);
FOR(i,0,SZ(node)-1){
FOR(j,i+1,SZ(node)-1){
if(node[i].x()==node[j].x()){
continue;
}
Point a=node[i],b=node[j];
if(check(Line(a,b))){
g[i].emplace_back(abs(a-b),j);
}
}
}

AC代码

https://vjudge.net/solution/63271204

心路历程(WA,TLE,MLE……)