#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
struct edge
{
int x,y;
long long dist;
edge(){};
edge(int xi, int yi, long long di)
{
x = xi;
y = yi;
dist = di;
}
bool operator<(const edge&ed) const
{
return dist>ed.dist;
}
};
int r,c;
int h[5000][200],v[5000][200];
unsigned int d[5000][200],inf = -1;
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)
{
memset(d,-1,sizeof(d));
priority_queue<edge>q;
d[0][V1] = 0;
q.push({0,V1,0});
edge e,nb;
while(!q.empty())
{
e = q.top();
q.pop();
if(e.dist<=d[e.x][e.y])
{
///LEFT
nb = {0,0,inf};
if(e.y>0) nb = {e.x,e.y-1,h[e.x][e.y-1]};
if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y])
{
nb.dist += e.dist;
d[nb.x][nb.y] = nb.dist;
q.push(nb);
}
///RIGHT
nb = {0,0,inf};
if(e.y<c-1) nb = {e.x,e.y+1,h[e.x][e.y]};
if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y])
{
nb.dist += e.dist;
d[nb.x][nb.y] = nb.dist;
q.push(nb);
}
///DOWN
nb = {0,0,inf};
if(e.x<r-1) nb = {e.x+1,e.y,v[e.x][e.y]};
if(nb.dist!=inf&&e.dist+nb.dist<d[nb.x][nb.y])
{
nb.dist += e.dist;
d[nb.x][nb.y] = nb.dist;
q.push(nb);
}
}
}
int pom = d[r-1][V2];
return pom;
}
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-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];
}
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;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
14936 KB |
Output is correct |
2 |
Correct |
81 ms |
14936 KB |
Output is correct |
3 |
Execution timed out |
20013 ms |
16580 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
36 ms |
10732 KB |
Output is correct |
5 |
Correct |
34 ms |
10588 KB |
Output is correct |
6 |
Correct |
30 ms |
10584 KB |
Output is correct |
7 |
Correct |
38 ms |
10588 KB |
Output is correct |
8 |
Correct |
39 ms |
10704 KB |
Output is correct |
9 |
Correct |
37 ms |
10708 KB |
Output is correct |
10 |
Correct |
37 ms |
10584 KB |
Output is correct |
11 |
Correct |
17336 ms |
12716 KB |
Output is correct |
12 |
Correct |
39 ms |
10588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
10868 KB |
Output is correct |
2 |
Correct |
135 ms |
11208 KB |
Output is correct |
3 |
Correct |
86 ms |
10844 KB |
Output is correct |
4 |
Correct |
91 ms |
10756 KB |
Output is correct |
5 |
Correct |
89 ms |
10856 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6488 KB |
Output is correct |
9 |
Correct |
126 ms |
10916 KB |
Output is correct |
10 |
Correct |
2 ms |
10584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
397 ms |
20060 KB |
Output is correct |
2 |
Correct |
878 ms |
20056 KB |
Output is correct |
3 |
Correct |
371 ms |
20060 KB |
Output is correct |
4 |
Execution timed out |
20007 ms |
21008 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
10848 KB |
Output is correct |
2 |
Correct |
125 ms |
11068 KB |
Output is correct |
3 |
Correct |
86 ms |
10844 KB |
Output is correct |
4 |
Correct |
86 ms |
10856 KB |
Output is correct |
5 |
Correct |
84 ms |
10848 KB |
Output is correct |
6 |
Correct |
393 ms |
20056 KB |
Output is correct |
7 |
Correct |
873 ms |
20060 KB |
Output is correct |
8 |
Correct |
368 ms |
20060 KB |
Output is correct |
9 |
Execution timed out |
20065 ms |
21028 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
10852 KB |
Output is correct |
2 |
Correct |
118 ms |
11072 KB |
Output is correct |
3 |
Correct |
93 ms |
10844 KB |
Output is correct |
4 |
Correct |
87 ms |
10840 KB |
Output is correct |
5 |
Correct |
85 ms |
10840 KB |
Output is correct |
6 |
Correct |
388 ms |
20060 KB |
Output is correct |
7 |
Correct |
874 ms |
20076 KB |
Output is correct |
8 |
Correct |
394 ms |
20060 KB |
Output is correct |
9 |
Execution timed out |
20070 ms |
20680 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |