#include "cyberland.h"
#include <vector>
#include <queue>
#include <functional>
using namespace std;
struct edge{
int v;
double cost;
bool operator<(const edge &tmp)const{
return cost>tmp.cost;
}
};
const int MAXK=100;
const double INF=1e15;
vector<edge> Adj[100000];
bool Ikeru[100000];
double Dist[100000];
priority_queue<edge> PQ;
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){
for (int i=0; i<N; i++)
Adj[i].clear();
fill(Ikeru,Ikeru+N,false);
fill(Dist,Dist+N,INF);
while (!PQ.empty())
PQ.pop();
for (int i=0; i<M; i++){
Adj[x[i]].push_back({y[i],(double)c[i]});
Adj[y[i]].push_back({x[i],(double)c[i]});
}
function<void(int)> dfs=[&](int v){
Ikeru[v]=true;
if (v==H)
return;
for (edge i:Adj[v]){
if (!Ikeru[i.v])
dfs(i.v);
}
};
dfs(0);
if (!Ikeru[H])
return -1;
K=min(K,MAXK)+1;
for (int i=0; i<N; i++){
if (Ikeru[i]&&!arr[i]){
Dist[i]=0;
PQ.push({i,0});
}
}
Dist[0]=0;
PQ.push({0,0});
while (K--){
while (!PQ.empty()){
edge cur=PQ.top();
PQ.pop();
if (Dist[cur.v]<cur.cost||cur.v==H)
continue;
for (edge i:Adj[cur.v]){
if (Dist[i.v]>cur.cost+i.cost){
Dist[i.v]=cur.cost+i.cost;
PQ.push({i.v,Dist[i.v]});
}
}
}
for (int i=0; i<N; i++){
if (Ikeru[i]&&arr[i]==2){
Dist[i]/=2;
PQ.push({i,Dist[i]});
}
}
}
return Dist[H];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
3932 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
4280 KB |
Correct. |
2 |
Correct |
23 ms |
4456 KB |
Correct. |
3 |
Correct |
21 ms |
4440 KB |
Correct. |
4 |
Correct |
23 ms |
4280 KB |
Correct. |
5 |
Correct |
22 ms |
4444 KB |
Correct. |
6 |
Correct |
20 ms |
5212 KB |
Correct. |
7 |
Correct |
25 ms |
5192 KB |
Correct. |
8 |
Correct |
11 ms |
5724 KB |
Correct. |
9 |
Correct |
21 ms |
4188 KB |
Correct. |
10 |
Correct |
21 ms |
4188 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
4188 KB |
Correct. |
2 |
Correct |
22 ms |
4440 KB |
Correct. |
3 |
Correct |
21 ms |
4440 KB |
Correct. |
4 |
Correct |
23 ms |
4184 KB |
Correct. |
5 |
Correct |
23 ms |
4188 KB |
Correct. |
6 |
Correct |
5 ms |
4440 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
47 ms |
10464 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
4444 KB |
Correct. |
2 |
Correct |
21 ms |
4444 KB |
Correct. |
3 |
Correct |
20 ms |
4444 KB |
Correct. |
4 |
Correct |
21 ms |
5724 KB |
Correct. |
5 |
Correct |
18 ms |
4188 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
4952 KB |
Correct. |
2 |
Correct |
18 ms |
4444 KB |
Correct. |
3 |
Correct |
36 ms |
11380 KB |
Correct. |
4 |
Correct |
14 ms |
5212 KB |
Correct. |
5 |
Correct |
20 ms |
4188 KB |
Correct. |
6 |
Correct |
19 ms |
4444 KB |
Correct. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
4392 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
4496 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |