#include <bits/stdc++.h>
using namespace std;
#include "wombats.h"
const int M = 5000;
const int N = 200;
int R, C;
// tuple<from, to, weight>
vector<tuple<int, int, int>> edges;
const int MAX = 1000'000;
vector<vector<pair<int, int>>> adj(MAX, vector<pair<int, int>>());
void init(int _R, int _C, int H[5000][200], int V[5000][200]) {
R = _R;
C = _C;
// for (int i = 0; i < R; i++)
// for (int j = 0; j < C - 1; j++)
// H[i][j] = _H[i][j], sum += H[i][j];
// for (int i = 0; i < R - 1; i++)
// for (int j = 0; j < C; j++)
// V[i][j] = _V[i][j], sum += V[i][j];
for (int i = 0; i < R; i++)
for (int j = 0; j < C - 1; j++)
// edges.push_back({i * 5000 + j, i * 5000 + (j + 1), H[i][j]}),
{
int a = i * 5000 + j;
int b = i * 5000 + (j + 1);
adj[a].push_back({b, H[i][j]});
adj[b].push_back({a, H[i][j]});
}
for (int i = 0; i < R - 1; i++)
for (int j = 0; j < C; j++)
// edges.push_back({i * 5000 + j, (i + 1) * 5000 + j, V[i][j]});
{
int a = i * 5000 + j;
int b = (i + 1) * 5000 + j;
adj[a].push_back({b, V[i][j]});
adj[b].push_back({a, V[i][j]});
}
}
void changeH(int P, int Q, int W) {
}
void changeV(int P, int Q, int W) {
}
int escape(int V1, int V2) {
int a = 0 * 5000 + V1;
int b = (R - 1) * 5000 + V2;
vector<int> dist(MAX, INT_MAX);
dist[a] = 0;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
pq.push({0, a});
while (!pq.empty()) {
auto [d, u] = pq.top();
pq.pop();
if (d > dist[u])
continue;
for (auto [v, w] : adj[u]) {
if (dist[u] + w < dist[v]) {
dist[v] = dist[u] + w;
pq.push({dist[v], v});
}
}
}
return dist[b];
}
Compilation message
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
15 | int res;
| ^~~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:65:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
65 | auto [d, u] = pq.top();
| ^
wombats.cpp:71:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
71 | for (auto [v, w] : adj[u]) {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
55892 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
27740 KB |
Output is correct |
2 |
Correct |
18 ms |
27740 KB |
Output is correct |
3 |
Correct |
20 ms |
27740 KB |
Output is correct |
4 |
Correct |
184 ms |
27896 KB |
Output is correct |
5 |
Correct |
163 ms |
27744 KB |
Output is correct |
6 |
Correct |
191 ms |
27928 KB |
Output is correct |
7 |
Correct |
192 ms |
27924 KB |
Output is correct |
8 |
Incorrect |
163 ms |
27924 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
157 ms |
28508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
38 ms |
64064 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
182 ms |
28504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
162 ms |
28508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |