///~~~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;
compute_dp();
}
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];
compute_dp();
}
int escape(int p,int q){
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;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
205648 KB |
Output is correct |
2 |
Correct |
35 ms |
205708 KB |
Output is correct |
3 |
Correct |
96 ms |
207376 KB |
Output is correct |
4 |
Correct |
35 ms |
205792 KB |
Output is correct |
5 |
Correct |
34 ms |
205712 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
8540 KB |
Output is correct |
5 |
Correct |
2 ms |
8540 KB |
Output is correct |
6 |
Correct |
2 ms |
8540 KB |
Output is correct |
7 |
Correct |
2 ms |
8540 KB |
Output is correct |
8 |
Correct |
2 ms |
8548 KB |
Output is correct |
9 |
Correct |
2 ms |
8540 KB |
Output is correct |
10 |
Correct |
1 ms |
8684 KB |
Output is correct |
11 |
Correct |
57 ms |
9556 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13415 ms |
10804 KB |
Output is correct |
2 |
Correct |
13170 ms |
10876 KB |
Output is correct |
3 |
Correct |
13518 ms |
10888 KB |
Output is correct |
4 |
Correct |
13109 ms |
10888 KB |
Output is correct |
5 |
Correct |
12743 ms |
11088 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4440 KB |
Output is correct |
9 |
Execution timed out |
20007 ms |
10836 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
175124 KB |
Output is correct |
2 |
Correct |
67 ms |
184152 KB |
Output is correct |
3 |
Correct |
70 ms |
182360 KB |
Output is correct |
4 |
Correct |
95 ms |
192084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12934 ms |
10800 KB |
Output is correct |
2 |
Correct |
12615 ms |
10864 KB |
Output is correct |
3 |
Correct |
13082 ms |
11092 KB |
Output is correct |
4 |
Correct |
13095 ms |
10888 KB |
Output is correct |
5 |
Correct |
12743 ms |
11088 KB |
Output is correct |
6 |
Correct |
72 ms |
191560 KB |
Output is correct |
7 |
Correct |
68 ms |
189524 KB |
Output is correct |
8 |
Correct |
62 ms |
191316 KB |
Output is correct |
9 |
Correct |
95 ms |
191056 KB |
Output is correct |
10 |
Correct |
37 ms |
189016 KB |
Output is correct |
11 |
Correct |
33 ms |
189012 KB |
Output is correct |
12 |
Correct |
85 ms |
191316 KB |
Output is correct |
13 |
Correct |
32 ms |
187288 KB |
Output is correct |
14 |
Correct |
34 ms |
187128 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4540 KB |
Output is correct |
18 |
Correct |
2 ms |
8540 KB |
Output is correct |
19 |
Correct |
1 ms |
8540 KB |
Output is correct |
20 |
Correct |
1 ms |
8636 KB |
Output is correct |
21 |
Correct |
1 ms |
8536 KB |
Output is correct |
22 |
Correct |
1 ms |
8540 KB |
Output is correct |
23 |
Correct |
1 ms |
8540 KB |
Output is correct |
24 |
Correct |
1 ms |
8540 KB |
Output is correct |
25 |
Correct |
57 ms |
10456 KB |
Output is correct |
26 |
Correct |
2 ms |
8536 KB |
Output is correct |
27 |
Execution timed out |
20054 ms |
10876 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13024 ms |
10800 KB |
Output is correct |
2 |
Correct |
12625 ms |
10868 KB |
Output is correct |
3 |
Correct |
13108 ms |
10880 KB |
Output is correct |
4 |
Correct |
13117 ms |
10880 KB |
Output is correct |
5 |
Correct |
12741 ms |
10888 KB |
Output is correct |
6 |
Correct |
69 ms |
207924 KB |
Output is correct |
7 |
Correct |
62 ms |
207960 KB |
Output is correct |
8 |
Correct |
66 ms |
207924 KB |
Output is correct |
9 |
Correct |
96 ms |
209072 KB |
Output is correct |
10 |
Correct |
32 ms |
205648 KB |
Output is correct |
11 |
Correct |
34 ms |
205660 KB |
Output is correct |
12 |
Correct |
87 ms |
207968 KB |
Output is correct |
13 |
Correct |
35 ms |
205648 KB |
Output is correct |
14 |
Correct |
31 ms |
205852 KB |
Output is correct |
15 |
Runtime error |
138 ms |
30824 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |