# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
483969 | gg123_pe | 건포도 (IOI09_raisins) | C++14 | 161 ms | 15552 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i = a; i < b; i++)
const int inf = 1e9+10;
int n, m, a[55][55], s[55][55], r[55][55], dp[55][55][55][55];
int cal(int i, int j, int m, int n){
return r[n][j] - r[m-1][j] - r[n][i-1] + r[m-1][i-1];
}
int main(){
scanf("%d %d", &n, &m);
f(i,1,n+1) {
f(j,1,m+1) {
scanf("%d", &a[i][j]);
s[i][j] = s[i][j-1] + a[i][j];
}
}
f(j,1,m+1) f(i,1,n+1) r[i][j] = r[i-1][j] + s[i][j];
f(d1, 0, m){
f(d2, 0, n){
if(d1 == 0 and d2 == 0) continue;
f(i, 1, m-d1+1){
f(x, 1, n-d2+1){
int j = i+d1, y = x+d2, A = cal(i, j, x, y);
dp[i][j][x][y] = inf;
f(k, i, j)
dp[i][j][x][y] = min(dp[i][j][x][y], A + dp[i][k][x][y] + dp[k+1][j][x][y]);
f(k, x, y)
dp[i][j][x][y] = min(dp[i][j][x][y], A + dp[i][j][x][k] + dp[i][j][k+1][y]);
}
}
}
}
printf("%d\n", dp[1][m][1][n]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |