#include <bits/stdc++.h>
#ifndef ARTHUR_LOCAL
#include "wombats.h"
#endif
using namespace std;
const int INF = 1000000000;
int r=-1;
int c=-1;
int H[5000][200];
int V[5000][200];
int dis[401][401];
void init(int r_raw, int c_raw, int H_raw[5000][200], int V_raw[5000][200])
{
r=r_raw;
c=c_raw;
for(int i=0; i<5000; i++)
{
for(int j=0; j<200; j++)
{
H[i][j]=H_raw[i][j];
V[i][j]=V_raw[i][j];
}
}
for(int i=0; i<=400; i++)
{
for(int j=0; j<=400; j++)
{
dis[i][j]=INF;
}
}
// pre-calculate all the answers
// Floyd-Warshall on a directed graph
for(int i=0; i<=400; i++)
{
int row=int(i/c);
int col=i%c;
if(row>=r) break;
// << "RC: " << row << " " << col << endl;
if(row < r-1)
{
dis[i][i+c] = V[row][col];
// cout << i << " " << i+c << " " << V[row][col] << " V" << endl;
}
if(col < c-1)
{
dis[i][i+1] = H[row][col];
dis[i+1][i] = H[row][col];
// cout << i << " " << i+1 << " " << H[row][col] << " H" << endl;
}
}
for(int i=0; i<=400; i++)
{
for(int j=0; j<=400; j++)
{
for(int k=0; k<=400; k++)
{
if(max({i,j,k}) < r*c) dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j]);
}
}
}
}
void changeH(int p, int q, int w)
{
return;
}
void changeV(int p, int q, int w)
{
return;
}
int escape(int v1, int v2)
{
return dis[v1][(r-1)*c + v2];
}
Compilation message
grader.c: In function 'int main()':
grader.c:15:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
int res;
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
223 ms |
12732 KB |
Output is correct |
2 |
Incorrect |
227 ms |
12792 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
110 ms |
8952 KB |
Output is correct |
2 |
Correct |
107 ms |
8824 KB |
Output is correct |
3 |
Correct |
107 ms |
8952 KB |
Output is correct |
4 |
Incorrect |
226 ms |
8824 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
220 ms |
8952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
228 ms |
16632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
235 ms |
8984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
221 ms |
8984 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |