#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)
ll dp[51][51][51][51], a[51][51], ps[51][51];
ll n, m;
ll solve (ll i, ll j, ll k, ll l) {
if (i == j && k == l) return 0;
return dp[i][j][k][l] ? dp[i][j][k][l] : dp[i][j][k][l] = min({i==j?1e9:(solve(i,j-1,k,l)+solve(j,j,k,l)), i==j?1e9:(solve(i+1,j,k,l)+solve(i,i,k,l)), k==l?1e9:(solve(i,j,k+1,l)+solve(i,j,k,k)), k==l?1e9:(solve(i,j,k,l-1)+solve(i,j,l,l))}) + ps[j][l]-ps[j][k-1]-ps[i-1][l]+ps[i-1][k-1];
}
I should quit OI forever () {
Alan fai (true)
cin >> n >> m;
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];
}
}
cout << solve(1, n, 1, m) << "\n";
Sharky orz
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
332 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
716 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
1100 KB |
Output isn't correct |
8 |
Incorrect |
4 ms |
2508 KB |
Output isn't correct |
9 |
Incorrect |
5 ms |
4044 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
4812 KB |
Output isn't correct |
11 |
Incorrect |
6 ms |
3532 KB |
Output isn't correct |
12 |
Incorrect |
14 ms |
8884 KB |
Output isn't correct |
13 |
Incorrect |
23 ms |
11632 KB |
Output isn't correct |
14 |
Incorrect |
7 ms |
4316 KB |
Output isn't correct |
15 |
Incorrect |
26 ms |
13232 KB |
Output isn't correct |
16 |
Incorrect |
7 ms |
6604 KB |
Output isn't correct |
17 |
Incorrect |
16 ms |
11340 KB |
Output isn't correct |
18 |
Incorrect |
50 ms |
23216 KB |
Output isn't correct |
19 |
Incorrect |
69 ms |
24436 KB |
Output isn't correct |
20 |
Incorrect |
76 ms |
26424 KB |
Output isn't correct |