Submission #1440840


Source Code Expand

#include <bits/stdc++.h>
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> choco(h, vector<int>(w));
    repeat(i, h) {
        repeat(j, w) {
            cin >> choco[i][j];
            if( (i+j) % 2 ) choco[i][j] = -choco[i][j];
        }
    }
    
    vector<vector<int>> cumul(h+1, vector<int>(w+1, 0));
    repeat_from_to(i, 1, h) {
        repeat_from_to(j, 1, w) {
            cumul[i][j] = cumul[i-1][j] + cumul[i][j-1] - cumul[i-1][j-1] + choco[i-1][j-1];
        }
    }
   
    /*
    repeat_from(i, 0, h) {
        repeat_from(j, 0, w) {
            cout << choco[i][j] << " ";
        }
        cout << endl;
    }
    
    repeat_from_to(i, 0, h) {
        repeat_from_to(j, 0, w) {
            cout << cumul[i][j] << " ";
        }
        cout << endl;
    }
    */
    
    int ans = 0;
    repeat_from_to(i, 0, h-1) {
        repeat_from_to(j, 0, w-1) {
            repeat_from_to(k, i+1, h) {
                repeat_from_to(l, j+1, w) {
                    if(cumul[k][l] - cumul[k][j] - cumul[i][l] + cumul[i][j] == 0) ans = max(ans, (k-i)*(l-j));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
                
}

Submission Info

Submission Time
Task B - チョコレート
User maphylageo
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1790 Byte
Status AC
Exec Time 45 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 5
AC × 25
Set Name Test Cases
Sample subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask0_sample-04.txt, subtask0_sample-05.txt
All subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask0_sample-04.txt, subtask0_sample-05.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Case Name Status Exec Time Memory
subtask0_sample-01.txt AC 1 ms 256 KB
subtask0_sample-02.txt AC 1 ms 256 KB
subtask0_sample-03.txt AC 1 ms 256 KB
subtask0_sample-04.txt AC 1 ms 256 KB
subtask0_sample-05.txt AC 1 ms 256 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 1 ms 256 KB
subtask1_06.txt AC 2 ms 256 KB
subtask1_07.txt AC 1 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB
subtask1_09.txt AC 43 ms 384 KB
subtask1_10.txt AC 8 ms 256 KB
subtask1_11.txt AC 32 ms 384 KB
subtask1_12.txt AC 32 ms 384 KB
subtask1_13.txt AC 32 ms 384 KB
subtask1_14.txt AC 44 ms 384 KB
subtask1_15.txt AC 45 ms 384 KB
subtask1_16.txt AC 31 ms 384 KB
subtask1_17.txt AC 35 ms 384 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 256 KB
subtask1_20.txt AC 36 ms 384 KB