#include "wombats.h"
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
using namespace std;
vector<vector<int>> h , v;
int r , c;
int xx[3] = {1 , 0 , 0};
int yy[3] = {0 , -1 , 1};
void init(int R, int C, int H[5000][200], int V[5000][200]) {
r = R;
c = C;
h.assign(R , vector<int>(C));
v = h;
for(int i = 0 ; i < R ; i++)
{
for(int j = 0; j < C - 1 ; j++)
{
h[i][j] = H[i][j];
}
}
for(int i = 0 ; i < R-1 ; i++)
{
for(int j = 0; j < C ; j++)
{
v[i][j] = V[i][j];
}
}
}
void changeH(int P, int Q, int W) {
h[P][Q] = W;
}
void changeV(int P, int Q, int W) {
v[P][Q] = W;
}
int escape(int V1, int V2) {
priority_queue<pair<int ,pair<int ,int>> ,vector<pair<int ,pair<int,int>>>, greater<pair<int ,pair<int, int>>>> pq;
pq.push({0 , {0 , V1}});
vector<bitset<200>> vis(r);
while(!pq.empty())
{
auto [d , p] = pq.top();
auto [i , j] = p;
pq.pop();
vis[i][j] = 1;
if(i == r - 1 && j == V2)
{
return d;
}
for(int k = 0 ; k < 3 ; k++)
{
int ni = i + xx[k] , nj = j + yy[k];
if(ni >= 0 && nj >= 0 && ni < r && nj < c)
{
int cost = 0;
if(xx[k] == 1)
cost = v[i][j];
if(yy[k] == 1)
cost = h[i][j];
if(yy[k] == -1)
cost = h[i][j - 1];
if(!vis[ni][nj])
{
pq.push({cost + d , {ni , nj}});
}
}
}
}
}
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;
| ^~~
wombats.cpp: In function 'int escape(int, int)':
wombats.cpp:40:117: warning: control reaches end of non-void function [-Wreturn-type]
40 | priority_queue<pair<int ,pair<int ,int>> ,vector<pair<int ,pair<int,int>>>, greater<pair<int ,pair<int, int>>>> pq;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
5048 KB |
Output is correct |
2 |
Correct |
34 ms |
5048 KB |
Output is correct |
3 |
Correct |
12730 ms |
7636 KB |
Output is correct |
4 |
Correct |
34 ms |
5048 KB |
Output is correct |
5 |
Correct |
35 ms |
5052 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
66 ms |
536 KB |
Output is correct |
5 |
Runtime error |
2752 ms |
262144 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
453 ms |
848 KB |
Output is correct |
2 |
Correct |
151 ms |
1272 KB |
Output is correct |
3 |
Correct |
445 ms |
820 KB |
Output is correct |
4 |
Correct |
353 ms |
604 KB |
Output is correct |
5 |
Correct |
350 ms |
600 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1677 ms |
3628 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11760 ms |
9164 KB |
Output is correct |
2 |
Execution timed out |
20039 ms |
11572 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
480 ms |
600 KB |
Output is correct |
2 |
Correct |
144 ms |
1268 KB |
Output is correct |
3 |
Correct |
420 ms |
816 KB |
Output is correct |
4 |
Correct |
352 ms |
600 KB |
Output is correct |
5 |
Correct |
357 ms |
796 KB |
Output is correct |
6 |
Correct |
11678 ms |
9168 KB |
Output is correct |
7 |
Execution timed out |
20039 ms |
11564 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
455 ms |
856 KB |
Output is correct |
2 |
Correct |
146 ms |
1268 KB |
Output is correct |
3 |
Correct |
433 ms |
600 KB |
Output is correct |
4 |
Correct |
363 ms |
812 KB |
Output is correct |
5 |
Correct |
352 ms |
600 KB |
Output is correct |
6 |
Correct |
11674 ms |
9168 KB |
Output is correct |
7 |
Execution timed out |
20031 ms |
11524 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |