# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
358276 |
2021-01-25T09:29:42 Z |
tengiz05 |
Wombats (IOI13_wombats) |
C++17 |
|
1093 ms |
16236 KB |
#include "wombats.h"
#ifndef EVAL
#include "grader.c"
#endif
#include <bits/stdc++.h>
using namespace std;
int n, m;
int h[5000][200], v[5000][200];
int dp[200][200];
int old[200][200];
void recalc(){
for(int start = 0; start < m; start++){
int carry = 0;
for(int i=start;i<m;i++){
old[start][i] = carry;
carry += h[0][i];
}carry = 0;
for(int i=start-1;i>=0;i--){
carry += h[0][i];
old[start][i] = carry;
}
for(int row=1;row<n;row++){
for(int i=0;i<m;i++){
dp[start][i] = old[start][i] + v[row-1][i];
}for(int i=0;i<m;i++){
if(i != 0)dp[start][i] = min(dp[start][i], old[start][i-1] + h[row-1][i-1]);
if(i+1< m)dp[start][i] = min(dp[start][i], old[start][i+1] + h[row-1][i]);
}swap(dp[start],old[start]);
}swap(dp[start],old[start]);
}
//~ cout << "______________________________\n";
//~ cout << "what my dp looks like\n";
//~ for(int i=0;i<m;i++){
//~ for(int j=0;j<m;j++){
//~ cout << dp[i][j] << ' ';
//~ }cout << '\n';
//~ }cout << "______________________________\n\n";
}
void init(int R, int C, int H[5000][200], int V[5000][200]){
n = R, m = C;
for(int i=0;i<5000;i++){
for(int j=0;j<200;j++){
h[i][j] = H[i][j];
v[i][j] = V[i][j];
}
}
recalc();
}
void changeH(int P, int Q, int W){
h[P][Q] = W;
recalc();
return;
}
void changeV(int P, int Q, int W){
v[P][W] = W;
recalc();
return;
}
int escape(int V1, int V2){
return dp[V1][V2];
}
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 |
559 ms |
12140 KB |
Output is correct |
2 |
Incorrect |
545 ms |
12140 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8172 KB |
Output is correct |
2 |
Correct |
9 ms |
8172 KB |
Output is correct |
3 |
Correct |
7 ms |
8172 KB |
Output is correct |
4 |
Incorrect |
8 ms |
8172 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
528 ms |
8428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1093 ms |
16236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
547 ms |
8556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
552 ms |
8556 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |