#include "wombats.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,m,i,j,x[5050][220],y[5050][220],jum,d[2][5050][2],te,b[5050][220];
void upd()
{
ll ii;
d[0][n-1][0]=0;
d[0][n-1][1]=x[n-1][0];
d[1][n-1][1]=0;
d[1][n-1][0]=x[n-1][0];
for(ii=n-2;ii>=0;ii--)
{
d[0][ii][0]=min(d[0][ii+1][0]+y[ii][0],d[0][ii+1][1]+y[ii][1]+x[ii][0]);
d[0][ii][1]=min(d[0][ii+1][1]+y[ii][1],d[0][ii+1][0]+y[ii][0]+x[ii][0]);
d[1][ii][0]=min(d[1][ii+1][0]+y[ii][0],d[1][ii+1][1]+y[ii][1]+x[ii][0]);
d[1][ii][1]=min(d[1][ii+1][1]+y[ii][1],d[1][ii+1][0]+y[ii][0]+x[ii][0]);
}
//for(ii=0;ii<n;ii++)
// cout<<ii<<" "<<d[0][ii][0]<<" "<<d[0][ii][1]<<"\n";
}
void init(int R, int C, int H[5000][200], int V[5000][200])
{
n=R;
m=C;
for(i=0;i<n;i++)
for(j=0;j<(m-1);j++)
x[i][j]=H[i][j];
for(i=0;i<(n-1);i++)
for(j=0;j<m;j++)
y[i][j]=V[i][j];
if(m==2)
{
upd();
}
else
if(m==1)
{
for(i=0;i<(n-1);i++)
jum+=y[i][0];
}
/* ... */
}
void changeH(int P, int Q, int W)
{
if(m==2)
{
x[P][Q]=W;
upd();
}
else
x[P][Q]=W;
/* ... */
}
void changeV(int P, int Q, int W) {
if(m==2)
{
y[P][Q]=W;
upd();
}
else
if(m==1)
{
jum-=y[P][Q];
y[P][Q]=W;
jum+=y[P][Q];
}
else
y[P][Q]=W;
/* ... */
}
int escape(int V1, int V2)
{
if(m==2)
{
return d[V2][0][V1];
}
else
if(m==1)
{
return jum;
}
else
{
priority_queue<pair<ll,pair<ll,ll> > > pq;
pq.push(mp(0,mp(0,V1)));
te++;
while(!pq.empty())
{
ll jar=-pq.top().fi;
ll X=pq.top().se.fi;
ll Y=pq.top().se.se;
pq.pop();
if(b[X][Y]==te)continue;
b[X][Y]=te;
if(X==n-1&&Y==V2)
return jar;
if(Y>0)
if(b[X][Y-1]!=te)
pq.push(mp(-jar-x[X][Y-1],mp(X,Y-1)));
if(Y<(m-1))
if(b[X][Y+1]!=te)
pq.push(mp(-jar-x[X][Y],mp(X,Y+1)));
if(X<(n-1))
if(b[X+1][Y]!=te)
pq.push(mp(-jar-y[X][Y],mp(X+1,Y)));
}
}
}
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:117:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
12928 KB |
Output is correct |
2 |
Correct |
12 ms |
12928 KB |
Output is correct |
3 |
Correct |
73 ms |
14456 KB |
Output is correct |
4 |
Correct |
12 ms |
13004 KB |
Output is correct |
5 |
Correct |
11 ms |
12800 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
17 ms |
512 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
24 ms |
512 KB |
Output is correct |
7 |
Correct |
15 ms |
512 KB |
Output is correct |
8 |
Correct |
19 ms |
500 KB |
Output is correct |
9 |
Correct |
21 ms |
512 KB |
Output is correct |
10 |
Correct |
20 ms |
512 KB |
Output is correct |
11 |
Correct |
9831 ms |
3032 KB |
Output is correct |
12 |
Correct |
23 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
200 ms |
1096 KB |
Output is correct |
2 |
Correct |
147 ms |
1636 KB |
Output is correct |
3 |
Correct |
181 ms |
1152 KB |
Output is correct |
4 |
Correct |
179 ms |
1152 KB |
Output is correct |
5 |
Correct |
180 ms |
1152 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
197 ms |
1280 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
25600 KB |
Output is correct |
2 |
Correct |
60 ms |
25580 KB |
Output is correct |
3 |
Correct |
63 ms |
25464 KB |
Output is correct |
4 |
Correct |
90 ms |
26360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
169 ms |
1024 KB |
Output is correct |
2 |
Correct |
140 ms |
1584 KB |
Output is correct |
3 |
Correct |
174 ms |
1168 KB |
Output is correct |
4 |
Correct |
173 ms |
1152 KB |
Output is correct |
5 |
Correct |
171 ms |
1244 KB |
Output is correct |
6 |
Correct |
57 ms |
25592 KB |
Output is correct |
7 |
Correct |
60 ms |
25848 KB |
Output is correct |
8 |
Correct |
58 ms |
25600 KB |
Output is correct |
9 |
Correct |
91 ms |
26956 KB |
Output is correct |
10 |
Correct |
11 ms |
12800 KB |
Output is correct |
11 |
Correct |
12 ms |
12928 KB |
Output is correct |
12 |
Correct |
71 ms |
15676 KB |
Output is correct |
13 |
Correct |
13 ms |
12928 KB |
Output is correct |
14 |
Correct |
11 ms |
12928 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
16 ms |
512 KB |
Output is correct |
19 |
Correct |
3 ms |
512 KB |
Output is correct |
20 |
Correct |
23 ms |
632 KB |
Output is correct |
21 |
Correct |
16 ms |
632 KB |
Output is correct |
22 |
Correct |
19 ms |
512 KB |
Output is correct |
23 |
Correct |
25 ms |
512 KB |
Output is correct |
24 |
Correct |
20 ms |
512 KB |
Output is correct |
25 |
Correct |
9966 ms |
3112 KB |
Output is correct |
26 |
Correct |
23 ms |
512 KB |
Output is correct |
27 |
Correct |
196 ms |
1272 KB |
Output is correct |
28 |
Execution timed out |
20007 ms |
37756 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
171 ms |
1024 KB |
Output is correct |
2 |
Correct |
139 ms |
1472 KB |
Output is correct |
3 |
Correct |
180 ms |
1168 KB |
Output is correct |
4 |
Correct |
175 ms |
1152 KB |
Output is correct |
5 |
Correct |
177 ms |
1272 KB |
Output is correct |
6 |
Correct |
91 ms |
25592 KB |
Output is correct |
7 |
Correct |
57 ms |
25720 KB |
Output is correct |
8 |
Correct |
60 ms |
25600 KB |
Output is correct |
9 |
Correct |
101 ms |
26916 KB |
Output is correct |
10 |
Correct |
11 ms |
12800 KB |
Output is correct |
11 |
Correct |
12 ms |
12928 KB |
Output is correct |
12 |
Correct |
70 ms |
15580 KB |
Output is correct |
13 |
Correct |
12 ms |
12928 KB |
Output is correct |
14 |
Correct |
11 ms |
12928 KB |
Output is correct |
15 |
Correct |
1425 ms |
44004 KB |
Output is correct |
16 |
Execution timed out |
20084 ms |
41848 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |