#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,V1});
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 |
14 ms |
12632 KB |
Output is correct |
3 |
Correct |
1233 ms |
14416 KB |
Output is correct |
4 |
Correct |
13 ms |
12636 KB |
Output is correct |
5 |
Correct |
15 ms |
12632 KB |
Output is correct |
6 |
Correct |
9 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 |
9 ms |
8536 KB |
Output is correct |
2 |
Correct |
10 ms |
8540 KB |
Output is correct |
3 |
Correct |
10 ms |
8540 KB |
Output is correct |
4 |
Correct |
19 ms |
8540 KB |
Output is correct |
5 |
Correct |
13 ms |
8540 KB |
Output is correct |
6 |
Correct |
14 ms |
8540 KB |
Output is correct |
7 |
Correct |
21 ms |
8636 KB |
Output is correct |
8 |
Correct |
19 ms |
8540 KB |
Output is correct |
9 |
Correct |
21 ms |
8540 KB |
Output is correct |
10 |
Correct |
19 ms |
8540 KB |
Output is correct |
11 |
Correct |
4960 ms |
9744 KB |
Output is correct |
12 |
Correct |
20 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
124 ms |
9564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
264 ms |
16984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
112 ms |
9564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
108 ms |
9560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |