///~~~LOTA~~~///
#include "wombats.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define N 10000000
int n,m;
int x[5000][100];
int y[5000][100];
int dp[5000][100][100];
void compute_dp(){
for(int i=0;i<m;i++)
for(int j=0;j<m;j++)
dp[n-1][i][j]=abs(x[n-1][i]-x[n-1][j]);
for(int i=n-2;i>=0;i--){
for(int j=0;j<m;j++){
for(int k=0;k<m;k++){
dp[i][j][k]=1e9;
for(int l=0;l<m;l++)
dp[i][j][k]=min(dp[i][j][k],
dp[i+1][l][k]+abs(x[i][j]-x[i][l])+y[i][l]);
}
}
}
}
void init(int R, int C, int H[5000][200], int V[5000][200]){
n=R; m=C;
for(int i=0;i<n;i++)
for(int j=0;j<m-1;j++)
x[i][j+1]=x[i][j]+H[i][j];
for(int i=0;i<n-1;i++)
for(int j=0;j<m;j++)
y[i][j]=V[i][j];
compute_dp();
}
void changeV(int p,int q,int w){
y[p][q]=w;
}
void changeH(int p,int q,int w){
for(int i=m-1;i>0;i--)
x[p][i]-=x[p][i-1];
x[p][q+1]=w;
for(int i=0;i<m-1;i++)
x[p][i+1]+=x[p][i];
}
int escape(int p,int q){
if(max(n,m)>20) compute_dp();
return dp[0][p][q];
}
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 |
33 ms |
205660 KB |
Output is correct |
2 |
Correct |
32 ms |
205660 KB |
Output is correct |
3 |
Correct |
4758 ms |
207560 KB |
Output is correct |
4 |
Correct |
36 ms |
205652 KB |
Output is correct |
5 |
Correct |
36 ms |
205660 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4700 KB |
Output is correct |
4 |
Correct |
2 ms |
8536 KB |
Output is correct |
5 |
Correct |
1 ms |
8540 KB |
Output is correct |
6 |
Correct |
1 ms |
8540 KB |
Output is correct |
7 |
Correct |
1 ms |
8540 KB |
Output is correct |
8 |
Correct |
1 ms |
8604 KB |
Output is correct |
9 |
Correct |
2 ms |
8540 KB |
Output is correct |
10 |
Correct |
2 ms |
8540 KB |
Output is correct |
11 |
Correct |
55 ms |
9464 KB |
Output is correct |
12 |
Correct |
2 ms |
8536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12967 ms |
10808 KB |
Output is correct |
2 |
Correct |
12650 ms |
10812 KB |
Output is correct |
3 |
Correct |
13121 ms |
10804 KB |
Output is correct |
4 |
Correct |
13082 ms |
10836 KB |
Output is correct |
5 |
Correct |
12750 ms |
10808 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
13101 ms |
11056 KB |
Output is correct |
10 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
207680 KB |
Output is correct |
2 |
Correct |
101 ms |
207708 KB |
Output is correct |
3 |
Correct |
108 ms |
207852 KB |
Output is correct |
4 |
Correct |
8417 ms |
208932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12991 ms |
10804 KB |
Output is correct |
2 |
Correct |
12783 ms |
10812 KB |
Output is correct |
3 |
Correct |
13269 ms |
10808 KB |
Output is correct |
4 |
Correct |
13225 ms |
10800 KB |
Output is correct |
5 |
Correct |
12870 ms |
10804 KB |
Output is correct |
6 |
Correct |
110 ms |
207708 KB |
Output is correct |
7 |
Correct |
108 ms |
207716 KB |
Output is correct |
8 |
Correct |
96 ms |
207852 KB |
Output is correct |
9 |
Correct |
7864 ms |
209012 KB |
Output is correct |
10 |
Correct |
32 ms |
205660 KB |
Output is correct |
11 |
Correct |
32 ms |
205624 KB |
Output is correct |
12 |
Correct |
4858 ms |
207436 KB |
Output is correct |
13 |
Correct |
33 ms |
205648 KB |
Output is correct |
14 |
Correct |
34 ms |
205656 KB |
Output is correct |
15 |
Correct |
1 ms |
4440 KB |
Output is correct |
16 |
Correct |
1 ms |
4440 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
8540 KB |
Output is correct |
19 |
Correct |
2 ms |
8540 KB |
Output is correct |
20 |
Correct |
2 ms |
8540 KB |
Output is correct |
21 |
Correct |
2 ms |
8540 KB |
Output is correct |
22 |
Correct |
2 ms |
8540 KB |
Output is correct |
23 |
Correct |
2 ms |
8540 KB |
Output is correct |
24 |
Correct |
1 ms |
8676 KB |
Output is correct |
25 |
Correct |
55 ms |
9588 KB |
Output is correct |
26 |
Correct |
2 ms |
8540 KB |
Output is correct |
27 |
Correct |
13143 ms |
10808 KB |
Output is correct |
28 |
Execution timed out |
20012 ms |
209892 KB |
Time limit exceeded |
29 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13126 ms |
10576 KB |
Output is correct |
2 |
Correct |
12811 ms |
10804 KB |
Output is correct |
3 |
Correct |
13615 ms |
10796 KB |
Output is correct |
4 |
Correct |
13224 ms |
10800 KB |
Output is correct |
5 |
Correct |
12826 ms |
10808 KB |
Output is correct |
6 |
Correct |
111 ms |
207848 KB |
Output is correct |
7 |
Correct |
99 ms |
207696 KB |
Output is correct |
8 |
Correct |
102 ms |
207696 KB |
Output is correct |
9 |
Correct |
8534 ms |
208648 KB |
Output is correct |
10 |
Correct |
42 ms |
205664 KB |
Output is correct |
11 |
Correct |
33 ms |
205660 KB |
Output is correct |
12 |
Correct |
5910 ms |
207544 KB |
Output is correct |
13 |
Correct |
33 ms |
205660 KB |
Output is correct |
14 |
Correct |
33 ms |
205620 KB |
Output is correct |
15 |
Runtime error |
141 ms |
31232 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |