Submission #3641487


Source Code Expand

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w, b[110][110] = {0}, s[110][110] = {0};

    cin >> h >> w;
    REP(i, h)
    REP(j, w)
    {

        if ((i + j) % 2 == 0)
            cin >> b[i + 1][j + 1];
        else
            cin >> s[i + 1][j + 1];

        if (j > 0)
        {
            b[i + 1][j + 1] += b[i + 1][j];
            s[i + 1][j + 1] += s[i + 1][j];
        }
    }

    FOR(i, 1, h + 1)
    REP(j, w + 1)
    {
        b[i][j] += b[i - 1][j];
        s[i][j] += s[i - 1][j];
    }

    int res = 0;
    REP(i, h)
    REP(j, w)
    {
        for (int k = 0; k <= i; k++)
            for (int l = 0; l <= j; l++)
            {
                int b_ = b[i + 1][j + 1] + b[k][l] - b[i + 1][l] - b[k][j + 1];
                int s_ = s[i + 1][j + 1] + s[k][l] - s[i + 1][l] - s[k][j + 1];

                if (b_ == s_)
                {
                    res = max(res, (i + 1 - k) * (j + 1 - l));
                }
            }
    }

    cout << res << endl;

    return 0;
}

Submission Info

Submission Time
Task B - チョコレート
User Kats
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1708 Byte
Status AC
Exec Time 59 ms
Memory 512 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 2 ms 512 KB
subtask0_sample-02.txt AC 1 ms 384 KB
subtask0_sample-03.txt AC 1 ms 384 KB
subtask0_sample-04.txt AC 1 ms 384 KB
subtask0_sample-05.txt AC 1 ms 384 KB
subtask1_01.txt AC 1 ms 384 KB
subtask1_02.txt AC 1 ms 384 KB
subtask1_03.txt AC 1 ms 384 KB
subtask1_04.txt AC 1 ms 384 KB
subtask1_05.txt AC 1 ms 384 KB
subtask1_06.txt AC 2 ms 384 KB
subtask1_07.txt AC 1 ms 384 KB
subtask1_08.txt AC 1 ms 384 KB
subtask1_09.txt AC 57 ms 384 KB
subtask1_10.txt AC 10 ms 384 KB
subtask1_11.txt AC 47 ms 384 KB
subtask1_12.txt AC 47 ms 384 KB
subtask1_13.txt AC 47 ms 384 KB
subtask1_14.txt AC 58 ms 384 KB
subtask1_15.txt AC 59 ms 384 KB
subtask1_16.txt AC 45 ms 384 KB
subtask1_17.txt AC 46 ms 384 KB
subtask1_18.txt AC 1 ms 384 KB
subtask1_19.txt AC 1 ms 384 KB
subtask1_20.txt AC 54 ms 384 KB