#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
ll INF=1e18+1;
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
//DFS from start
vector<pii> a(N);
REP(i,0,M){
a[x[i]].PB({y[i],i});
a[y[i]].PB({x[i],i});
}
priority_queue<int> pq;
vi b(N,0);
pq.push(0);
while(!pq.empty()){
int k1=pq.top();
pq.pop();
b[k1]=1;
if(k1==H)continue;
for(auto u:a[k1]){
if(b[u.F]==1)continue;
pq.push(u.F);
}
}
if(b[H]==0)return -1;
double ans=0;bool flag=0;
//Djikistra from end
priority_queue<pair<int,double>,vector<pair<int,double>>,greater<pair<int,double>>> pq2;
vector<double> d(N,INF);
d[H]=0.0;
vi val(N,1);
K*=2;
for(auto u:a[H]){
d[u.F]=(double)c[u.S];
pq2.push({d[u.F],u.F});
val[u.F]=min(K,val[H]*arr[u.F]);
}
while(!pq2.empty()){
//distance
double p=pq2.top().F;
//vertice
int q=pq2.top().S;
pq2.pop();
if(d[q]<p)continue;
if(arr[q]==0||q==0){
if(b[q]==1){
ans=d[q];
//cout<<"a";
flag=1;
break;
}
else{
continue;
}
}
for(auto u:a[q]){
if(d[u.F]<=d[q]+(double)c[u.S]/val[q])continue;
d[u.F]=d[q]+(double)c[u.S]/val[q];
pq2.push({d[u.F],u.F});
val[u.F]=min(K,val[q]*arr[u.F]);
}
}
if(flag)return ans;
else return d[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
600 KB |
Correct. |
2 |
Correct |
14 ms |
860 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
568 KB |
Correct. |
2 |
Correct |
20 ms |
604 KB |
Correct. |
3 |
Correct |
20 ms |
596 KB |
Correct. |
4 |
Correct |
20 ms |
348 KB |
Correct. |
5 |
Correct |
20 ms |
576 KB |
Correct. |
6 |
Correct |
16 ms |
1440 KB |
Correct. |
7 |
Correct |
20 ms |
1436 KB |
Correct. |
8 |
Correct |
9 ms |
2692 KB |
Correct. |
9 |
Correct |
20 ms |
348 KB |
Correct. |
10 |
Correct |
20 ms |
348 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
572 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
6232 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3020 ms |
66908 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3013 ms |
132960 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3019 ms |
263760 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3054 ms |
264616 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |