#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long
map<pair<pii,pii>, int> cost;
int r, c;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
for(int i = 0; i < R; i++)
{
for(int j = 0; j < C-1; j++){
cost[mp(mp(i,j), mp(i,j+1))] = H[i][j];
}
}
for(int i = 0; i < R-1; i++){
for(int j = 0; j < C; j++){
cost[mp(mp(i,j), mp(i+1, j))] = V[i][j];
}
}
}
void changeH(int P, int Q, int W) {
cost[mp(mp(P,Q), mp(P,Q+1))] = W;
}
void changeV(int P, int Q, int W) {
cost[mp(mp(P,Q), mp(P+1, Q))] = W;
}
int escape(int V1, int V2) {
ll dist[r][c];
for(int i = 0; i < r; i++)
for(int j = 0; j < c; j++)
dist[i][j] = 1e15;
dist[0][V1] = 0;
priority_queue<pair<int, pii> > pq;
pq.push(mp(0, mp(0, V1)));
while(!pq.empty()){
pii at = pq.top().second;
pq.pop();
int x = at.first, y = at.second;
if(y - 1 >= 0 && dist[x][y-1] > dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))]){
dist[x][y-1] = dist[x][y] + cost[mp(mp(x,y-1), mp(x,y))];
pq.push(mp(-dist[x][y-1], mp(x,y-1)));
}
if(y+1 < c && dist[x][y+1] > dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))]){
dist[x][y+1] = dist[x][y] + cost[mp(mp(x,y), mp(x,y+1))];
pq.push(mp(-dist[x][y+1], mp(x,y+1)));
}
if(x + 1 < r && dist[x+1][y] > dist[x][y] + cost[mp(mp(x,y), mp(x+1,y))]){
dist[x+1][y] = dist[x][y] + cost[mp(mp(x,y), mp(x+1, y))];
pq.push(mp(-dist[x+1][y], mp(x+1, y)));
}
}
return dist[r-1][V2];
}
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;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
4436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
3156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
9044 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
3156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
3156 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |