#include "cyberland.h"
#include<bits/stdc++.h>
using namespace std;
using db=double;
using pii=pair<int,int>;
#define eb emplace_back
#define f first
#define s second
const db eps=1e-8;
using A=pair<int,db>;
using B=pair<A,int>;
vector<pii> adj[100005];
A d[100005];
priority_queue<B,vector<B>,greater<B>> pq;
double solve(int N, int M, int K, int H, std::vector<int> U, std::vector<int> V, std::vector<int> W, std::vector<int> arr) {
for(int i=0;i<M;++i) adj[U[i]].eb(V[i],W[i]), adj[V[i]].eb(U[i],W[i]);
function<void(db)> dijk=[&](db lim){
while(!pq.empty()){
auto [w,u]=pq.top(); pq.pop();
for(auto &[v,vw]:adj[u]){
A w2={w.f,w.s+vw};
if(w2.s>lim&&arr[v]==2) ++w2.f, w2.s/=2;
if(d[v]>w2){
d[v]=w2;
pq.emplace(w2,v);
}
}
}
};
db l=0,r=1e14;
while(r-l>eps){
db mid=(l+r)/2;
pq.emplace(A(0,0),0);
d[0]=A(0,0);
for(int i=1;i<N;++i){
if(arr[i]==0) pq.emplace(A(0,0),i), d[i]=A(0,0);
else d[i]=A(1e9,0);
}
dijk(mid);
if(d[H].f>K) l=mid;
else r=mid;
}
pq.emplace(A(0,0),0);
d[0]=A(0,0);
for(int i=1;i<N;++i){
if(arr[i]==0) pq.emplace(A(0,0),i), d[i]=A(0,0);
else d[i]=A(1e9,0);
}
dijk(l);
return d[H].s;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3032 ms |
4508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3039 ms |
5568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2914 ms |
5600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
825 ms |
8784 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3071 ms |
5432 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2781 ms |
5704 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3060 ms |
5268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3021 ms |
5492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |