답안 #531386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531386 2022-02-28T14:54:45 Z Alan 건포도 (IOI09_raisins) C++17
100 / 100
670 ms 30012 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)

ll dp[51][51][51][51], a[51][51], ps[51][51];
bool calc[51][51][51][51];
ll n, m;

ll solve (ll i, ll j, ll k, ll l) {
	if (i == j || k == l) return 0;
	if (calc[i][j][k][l]) return dp[i][j][k][l];
	calc[i][j][k][l] = true;
	dp[i][j][k][l] = 1e18;
	for (int mid = i+1; mid <= j; mid++) dp[i][j][k][l] = min(dp[i][j][k][l], solve(i,mid,k,l) + solve(mid,j,k,l));
	for (int mid = k+1; mid <= l; mid++) dp[i][j][k][l] = min(dp[i][j][k][l], solve(i,j,k,mid) + solve(i,j,mid,l));
	return dp[i][j][k][l] = dp[i][j][k][l] + ps[j][l]-ps[i][l]-ps[j][k]+ps[i][k];
}

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];
			dp[i-1][i][j-1][j] = 0;
			calc[i-1][i][j-1][j] = true;
			ps[i][j] = a[i][j] + ps[i][j-1] + ps[i-1][j] - ps[i-1][j-1];
		}
	}
	cout << solve(0, n, 0, m) << "\n";

	Sharky orz
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 844 KB Output is correct
7 Correct 2 ms 1484 KB Output is correct
8 Correct 13 ms 3020 KB Output is correct
9 Correct 15 ms 4932 KB Output is correct
10 Correct 22 ms 5712 KB Output is correct
11 Correct 17 ms 4116 KB Output is correct
12 Correct 62 ms 10356 KB Output is correct
13 Correct 110 ms 13296 KB Output is correct
14 Correct 28 ms 4928 KB Output is correct
15 Correct 148 ms 15024 KB Output is correct
16 Correct 15 ms 8628 KB Output is correct
17 Correct 54 ms 13628 KB Output is correct
18 Correct 360 ms 26192 KB Output is correct
19 Correct 567 ms 27576 KB Output is correct
20 Correct 670 ms 30012 KB Output is correct