Submission #1554685


Source Code Expand

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void ioup() { cin.tie(0); ios::sync_with_stdio(false); }

int a[101][101], b[101][101];

int main() {
	int h, w, c;
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> c;
			if ((i + j) % 2 == 0)
				a[i][j] = c;
			else
				b[i][j] = c;
			a[i][j] += a[i][j - 1];
			b[i][j] += b[i][j - 1];
		}
	}

	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			a[i][j] += a[i - 1][j];
			b[i][j] += b[i - 1][j];
		}
	}

	int ans = 0;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			for (int y = i; y <= h; ++y) {
				for (int x = j; x <= w; ++x) {
					int sa = a[y][x] - a[y][j - 1] - a[i - 1][x] + a[i - 1][j - 1];
					int sb = b[y][x] - b[y][j - 1] - b[i - 1][x] + b[i - 1][j - 1];
					if (sa == sb)
						ans = max(ans, (y - i + 1) * (x - j + 1));
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Submission Info

Submission Time
Task B - チョコレート
User temple
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2151 Byte
Status AC
Exec Time 69 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 67 ms 384 KB
subtask1_10.txt AC 11 ms 256 KB
subtask1_11.txt AC 55 ms 384 KB
subtask1_12.txt AC 55 ms 384 KB
subtask1_13.txt AC 55 ms 384 KB
subtask1_14.txt AC 68 ms 384 KB
subtask1_15.txt AC 69 ms 384 KB
subtask1_16.txt AC 53 ms 384 KB
subtask1_17.txt AC 54 ms 256 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 384 KB
subtask1_20.txt AC 64 ms 384 KB