#include "cyberland.h"
#include <bits/stdc++.h>
using namespace std;
struct tpos{
int node;
double cnt;
};
bool operator < (const tpos &a, const tpos &b){
return a.cnt>b.cnt;
}
struct ari{
int node;
double cnt;
};
vector<vector<ari>> adj;
int state[100000];
priority_queue<tpos> q;
int n, m, k, fin;
double memo[100000];
double ans;
void dfs(){
tpos t;
while(!q.empty()){
t=q.top(); q.pop();
if(memo[t.node]!=-1 && memo[t.node]<=t.cnt)
continue;
memo[t.node]=t.cnt;
if(t.node==fin)
continue;
for(auto h: adj[t.node]){
if(state[t.node]==0)
q.push({h.node, h.cnt});
else
q.push({h.node, t.cnt+h.cnt});
}
}
}
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) {
n=N; m=M; k=K; fin=H;
adj.clear();
adj.resize(n);
ans=-1;
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]});
}
for(int i=0; i<n; i++){
state[i]=arr[i];
memo[i]=-1;
}
for(auto h: adj[0]){
q.push({h.node, h.cnt});
}
memo[0]=0;
dfs();
return memo[fin];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
604 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
604 KB |
Correct. |
2 |
Correct |
25 ms |
604 KB |
Correct. |
3 |
Correct |
24 ms |
604 KB |
Correct. |
4 |
Correct |
31 ms |
604 KB |
Correct. |
5 |
Correct |
30 ms |
620 KB |
Correct. |
6 |
Correct |
21 ms |
1708 KB |
Correct. |
7 |
Correct |
34 ms |
1624 KB |
Correct. |
8 |
Correct |
12 ms |
2968 KB |
Correct. |
9 |
Correct |
22 ms |
516 KB |
Correct. |
10 |
Correct |
22 ms |
344 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
29 ms |
624 KB |
Correct. |
2 |
Correct |
31 ms |
604 KB |
Correct. |
3 |
Correct |
26 ms |
604 KB |
Correct. |
4 |
Correct |
25 ms |
348 KB |
Correct. |
5 |
Correct |
25 ms |
348 KB |
Correct. |
6 |
Correct |
6 ms |
1372 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
7004 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
652 KB |
Correct. |
2 |
Correct |
30 ms |
604 KB |
Correct. |
3 |
Correct |
29 ms |
680 KB |
Correct. |
4 |
Correct |
24 ms |
1956 KB |
Correct. |
5 |
Correct |
22 ms |
348 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
604 KB |
Correct. |
2 |
Correct |
28 ms |
632 KB |
Correct. |
3 |
Correct |
34 ms |
9612 KB |
Correct. |
4 |
Correct |
18 ms |
1592 KB |
Correct. |
5 |
Correct |
28 ms |
756 KB |
Correct. |
6 |
Correct |
26 ms |
604 KB |
Correct. |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
604 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
600 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |