#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];
arr.resize(n*m+2);
REP(i,0,n*m){
if((i+1)%m!=0)arr[i].PB({i+1,a[i/m][i%m]});
if(i+m<n*m+1)arr[i].PB({i+m,b[i/m][i%m]});
if(i%m!=0)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 |
Correct |
14 ms |
12636 KB |
Output is correct |
2 |
Correct |
16 ms |
12632 KB |
Output is correct |
3 |
Correct |
1235 ms |
15532 KB |
Output is correct |
4 |
Correct |
14 ms |
12632 KB |
Output is correct |
5 |
Correct |
15 ms |
12768 KB |
Output is correct |
6 |
Correct |
10 ms |
8540 KB |
Output is correct |
7 |
Correct |
9 ms |
8540 KB |
Output is correct |
8 |
Correct |
10 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
8540 KB |
Output is correct |
2 |
Correct |
9 ms |
8536 KB |
Output is correct |
3 |
Correct |
9 ms |
8668 KB |
Output is correct |
4 |
Incorrect |
10 ms |
8536 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
9560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
151 ms |
17136 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
9560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
9564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |