#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
int bel[5000][200];
int rig[5000][200];
int r, c;
void init(int R, int C, int H[5000][200], int V[5000][200]) {
r = R;
c = C;
for(int i = 0; i<r; i++){
for(int j =0 ; j<c; j++){
if(i+1<r){
bel[i][j] = V[i][j];
}
if(j+1<c){
rig[i][j] = H[i][j];
}
}
}
}
void changeH(int P, int Q, int W) {
rig[P][Q] = W;
}
void changeV(int P, int Q, int W) {
bel[P][Q] = W;
}
int escape(int V1, int V2) {
int maxans = r + c;
maxans *= 1000;
vector<pair<int, int> > li[2000];
li[0].push_back(make_pair(0,V1));
bool v[r][c];
int best[r][c];
for(int i = 0; i<r; i++){
for(int j = 0; j<c; j++){
best[i][j] = maxans;
v[i][j] = false;
}
}
for(int zz = 0;; zz++){
int z = zz%2000;
for(int i =0; i<li[z].size(); i++){
int y = li[z][i].first;
int x = li[z][i].second;
if(y==r-1 && x==V2){
return z;
}
if(v[y][x]){
continue;
}
v[y][x] = true;
int ny, nx;
if(x>0){
ny = y;
nx = x-1;
if(!v[ny][nx]){
li[(z+rig[ny][nx])%2000].push_back(make_pair(ny,nx));
}
}
if(x<c-1){
ny = y;
nx = x+1;
if(!v[ny][nx]){
li[(z+rig[y][x])%2000].push_back(make_pair(ny,nx));
}
}
if(y<r-1){
ny = y+1;
nx = x;
if(!v[ny][nx]){
li[(z+bel[y][x])%2000].push_back(make_pair(ny,nx));
}
}
}
li[z].clear();
}
return -1;
}
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;
^~~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:45:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i =0; i<li[z].size(); i++){
~^~~~~~~~~~~~~
wombats.cpp:36:6: warning: variable 'best' set but not used [-Wunused-but-set-variable]
int best[r][c];
^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
114 ms |
8312 KB |
Output is correct |
2 |
Incorrect |
5586 ms |
8508 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
8508 KB |
Output is correct |
2 |
Correct |
3 ms |
8508 KB |
Output is correct |
3 |
Correct |
3 ms |
8508 KB |
Output is correct |
4 |
Correct |
11 ms |
8508 KB |
Output is correct |
5 |
Correct |
10 ms |
8508 KB |
Output is correct |
6 |
Incorrect |
50 ms |
8508 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
131 ms |
8508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10230 ms |
16552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
153 ms |
16552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
119 ms |
16552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |