# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
531309 |
2022-02-28T11:29:23 Z |
Alan |
Raisins (IOI09_raisins) |
C++17 |
|
1 ms |
332 KB |
#include <bits/stdc++.h>
#define I using
#define WA using namespace std;
#define on using ll = long long;
#define Test(x) int AlanIQ = -(x);
#define should ld =
#define quit long double;
#define OI int
#define forever main
#define Alan cin.tie(0);
#define fai(x) ios::ios_base::sync_with_stdio(!x);
#define Sharky return
#define orz 0;
WA on Test (109)
int dp[51][51][2], a[51][51], ps[51][51];
bool calc[51][51][2];
int n, m;
int solve (int i, int j, bool mode) {
if (i == j) return 0;
if (calc[i][j][mode]) return dp[i][j][mode];
calc[i][j][mode] = true;
dp[i][j][mode] = min(dp[i][j][mode], min(solve(i, j-1, mode), solve(i+1, j, mode)) + (mode ? ps[j][m]-ps[i-1][m] : ps[n][j]-ps[n][i-1]));
return dp[i][j][mode];
}
I should quit OI forever () {
Alan fai (true)
cin >> n >> m;
for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) for (int k = 0; k < 2; k++) dp[i][j][k] = 1e9;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
ps[i][j] = a[i][j] + ps[i][j-1] + ps[i-1][j] - ps[i-1][j-1];
}
}
int ans = solve(1, m, 0);
cout << ans + solve(1, n, 1) << "\n";
Sharky orz
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
10 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
16 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
17 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
19 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
20 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |