답안 #867587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867587 2023-10-28T20:08:23 Z Bula 건포도 (IOI09_raisins) C++14
10 / 100
5000 ms 35420 KB
#include <bits/stdc++.h>
using namespace std;
int n, m, x[55][55], dp[55][55][55][55], pref[55][55];

int rec(int a, int b, int A, int B){
    if(a == A && b == B){
        return 0;
    }
    int sum = pref[A][B] + pref[a - 1][b - 1] - pref[a - 1][B] - pref[A][b - 1];
    for(int i = a; i < A; i++){
        dp[a][b][A][B] = sum + rec(a, b, i, B) + rec(i + 1, b, A, B);
    }
    for(int i = b; i < B; i++){
        dp[a][b][A][B] = sum + rec(a, b, A, i) + rec(a, i + 1, A, B);
    }
    return dp[a][b][A][B];
}


main(){
    cin >> n >> m;
    for(int i = 1; i <= 50; i++){
        for(int j = 1; j <= 50; j++){
            for(int k = 1; k <= 50; k++){
                for(int l = 1; l <= 50; l++){
                    dp[i][j][k][l] = INT_MAX;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> x[i][j];
            dp[i][j][i][j] = 0; 
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            pref[i][j] = x[i][j] + pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1];
        }
    }

    cout << rec(1, 1, n, m) << endl;
}

Compilation message

raisins.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 35420 KB Output is correct
2 Correct 6 ms 35164 KB Output is correct
3 Incorrect 6 ms 35164 KB Output isn't correct
4 Incorrect 6 ms 35164 KB Output isn't correct
5 Incorrect 41 ms 35308 KB Output isn't correct
6 Execution timed out 5089 ms 35160 KB Time limit exceeded
7 Execution timed out 5037 ms 35164 KB Time limit exceeded
8 Execution timed out 5050 ms 35164 KB Time limit exceeded
9 Execution timed out 5052 ms 35416 KB Time limit exceeded
10 Execution timed out 5095 ms 35160 KB Time limit exceeded
11 Execution timed out 5023 ms 35160 KB Time limit exceeded
12 Execution timed out 5064 ms 35164 KB Time limit exceeded
13 Execution timed out 5046 ms 35164 KB Time limit exceeded
14 Execution timed out 5056 ms 35164 KB Time limit exceeded
15 Execution timed out 5042 ms 35160 KB Time limit exceeded
16 Execution timed out 5046 ms 35160 KB Time limit exceeded
17 Execution timed out 5050 ms 35164 KB Time limit exceeded
18 Execution timed out 5062 ms 35164 KB Time limit exceeded
19 Execution timed out 5009 ms 35160 KB Time limit exceeded
20 Execution timed out 5033 ms 35164 KB Time limit exceeded