#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define REP(a,b,c) for(int a=b;a<c;a++)
#define F first
#define S second
#define PB push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
int inf=1000000010;
vii a(5000,vi(200,0)),b(5000,vi(200,0));
int n,m;
vi dist;
vector<vector<pi>> arr;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
n=R;
m=C;
REP(i,0,5000)REP(j,0,200)a[i][j]=H[i][j];
REP(i,0,5000)REP(j,0,200)b[i][j]=V[i][j];
a.resize(n*m+2);
REP(i,0,n*m){
if(i%m!=0)arr[i].PB({i+1,b[i/m][i%m]});
if(i+m<n*m+1)arr[i].PB({i+m,a[i/m][i%m]});
if(i%m!=1)arr[i].PB({i-1,a[(i-1)/m][(i-1)%m]});
}
}
void changeH(int P, int Q, int W) {
/* ... */
}
void changeV(int P, int Q, int W) {
b[P][Q]=W;
}
int escape(int V1, int V2) {
if(m==1){
int ans=0;
REP(i,0,n)REP(j,0,m)ans+=b[i][j];
return ans;
}
dist.clear();
dist.resize(n*m+2,inf);
dist[V1]=0;
priority_queue<pi,vector<pi>,greater<pi>> pq;
pq.push({0,0});
while(!pq.empty()){
int x=pq.top().F;
int y=pq.top().S;
pq.pop();
if(x!=dist[y])continue;
for(auto u:arr[y])if(dist[u.F]>x+u.S){
dist[u.F]=x+u.S;
pq.push({dist[u.F],u.F});
}
}
return dist[(n-1)*m+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 |
Runtime error |
33 ms |
25432 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
14 ms |
16988 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
18128 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
24 ms |
33588 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
20 ms |
18008 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
16 ms |
18024 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |