This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 3e2;
vector<pair<int, int>> g[MAXN];
#define MP make_pair
int N, M;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
N = R, M = C;
for (int i = 0; i < N; i++){
for (int j = 0; j < M - 1; j++){
g[i * M + j].emplace_back(i * M + j + 1, H[i][j]);
g[i * M + j + 1].emplace_back(i * M + j, H[i][j]);
}
}
for (int i = 0; i < N - 1; i++){
for (int j = 0; j < M; j++){
g[i * M + j].emplace_back((i + 1) * M + j, V[i][j]);
}
}
}
void changeH(int P, int Q, int W) {
int x = P * M + Q, y = x + 1;
for (auto &now : g[x]){
if (now.first == y){
now.second = W;
break;
}
}
for (auto &now : g[y]){
if (now.first == x){
now.second = W;
break;
}
}
}
void changeV(int P, int Q, int W) {
int x = P * M + Q, y = x + M;
for (auto &now : g[x]){
if (now.first == y){
now.second = W;
break;
}
}
}
int escape(int V1, int V2) {
priority_queue<pair<int, int>> pq;
pq.push(MP(0, V1));
vector<int> d(N * M, 2e9 + 5);
vector<bool> processed(N * M, false);
d[V1] = 0;
while (!pq.empty()){
int x = pq.top().second; pq.pop();
if (processed[x]) continue;
processed[x] = true;
for (auto edge : g[x]){
int y = edge.first, w = edge.second;
if (d[y] > d[x] + w){
d[y] = d[x] + w;
pq.push(MP(-d[y], y));
}
}
}
return d[(N - 1) * M + V2];
}
Compilation message (stderr)
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
15 | int res;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |