#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MAXN = 1005;
const ll INF = 1e18;
vector<pii> adj[MAXN];
ll dist[MAXN][35];
bool visited[MAXN][35];
int special[MAXN];
double solve(int N, int M, int K, int H, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
for (int i = 0; i < N; i++) {
adj[i].clear();
special[i] = arr[i];
for (int j = 0; j <= K; j++) {
dist[i][j] = INF;
visited[i][j] = false;
}
}
for (int i = 0; i < M; i++) {
adj[x[i]].push_back({y[i], c[i]});
adj[y[i]].push_back({x[i], c[i]});
}
priority_queue<pair<ll, pii>, vector<pair<ll, pii>>, greater<pair<ll, pii>>> pq;
dist[0][0] = 0;
pq.push({0, {0, 0}});
while (!pq.empty()) {
int u = pq.top().second.first;
int k = pq.top().second.second;
pq.pop();
if (visited[u][k]) continue;
visited[u][k] = true;
for (pii p : adj[u]) {
int v = p.first;
int w = p.second;
if (special[v] == 2 && k < K && dist[v][k + 1] > dist[u][k] / 2 + w) {
dist[v][k + 1] = dist[u][k] / 2 + w;
pq.push({dist[v][k + 1], {v, k + 1}});
}
if (special[v] == 0 && dist[v][k] > w) {
dist[v][k] = w;
pq.push({dist[v][k], {v, k}});
}
if (dist[v][k] > dist[u][k] + w) {
dist[v][k] = dist[u][k] + w;
pq.push({dist[v][k], {v, k}});
}
}
}
ll ans = INF;
for (int i = 0; i <= K; i++) {
ans = min(ans, dist[H][i]);
}
return ans == INF ? -1 : ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
856 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
1628 KB |
Correct. |
2 |
Correct |
21 ms |
1928 KB |
Correct. |
3 |
Correct |
19 ms |
1880 KB |
Correct. |
4 |
Correct |
20 ms |
1788 KB |
Correct. |
5 |
Correct |
20 ms |
1880 KB |
Correct. |
6 |
Runtime error |
2 ms |
1372 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
1768 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
18 ms |
6224 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
1768 KB |
Correct. |
2 |
Correct |
19 ms |
1884 KB |
Correct. |
3 |
Correct |
24 ms |
1884 KB |
Correct. |
4 |
Runtime error |
1 ms |
1368 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
1872 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
171 ms |
2332 KB |
Wrong Answer. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1112 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |