제출 #483969

#제출 시각아이디문제언어결과실행 시간메모리
483969gg123_pe건포도 (IOI09_raisins)C++14
100 / 100
161 ms15552 KiB
#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) 메시지

raisins.cpp: In function 'int main()':
raisins.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
raisins.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf("%d", &a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...