Submission #1192796


Source Code Expand

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int h, w;
int c[105][105];

int main(int argc, char const *argv[]) {
	cin >> h >> w;
	FOR(i, h) {
		FOR(j, w) {
			cin >> c[i][j];
			if ((i+j)%2) c[i][j] *= -1;
		}
	}
	// FOR(i, h) {
	// 	FOR(j, w) cout << c[i][j] << " ";
	// 	cout << endl;
	// }
	FOR(i, h) {
		for (int j = 1; j < w; j++) {
			c[i][j] += c[i][j-1];
		}
	}
	// FOR(i, h) {
	// 	FOR(j, w) cout << c[i][j] << " ";
	// 	cout << endl;
	// }
	FOR(j, w) {
		for (int i = 1; i < h; i++) {
			c[i][j] += c[i-1][j];
		}
	}

	int ans = 0;
	FOR(i1, h) {
		FOR(j1, w) {
			for (int i2 = i1; i2 < h; i2++) {
				for (int j2 = j1; j2 < w; j2++) {
					if (i1 && j1) {
						if (c[i2][j2]-c[i2][j1-1]-c[i1-1][j2]+c[i1-1][j1-1] == 0) ans = max(ans, (i2-i1+1)*(j2-j1+1));
					}
					else if (i1) {
						if (c[i2][j2]-c[i1-1][j2] == 0) ans = max(ans, (i2-i1+1)*(j2-j1+1));
					}
					else if (j1) {
						if (c[i2][j2]-c[i2][j1-1] == 0) ans = max(ans, (i2-i1+1)*(j2-j1+1));
					}
					else if (!c[i2][j2]) ans = max(ans, (i2+1)*(j2+1));
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task B - チョコレート
User moguta
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1379 Byte
Status AC
Exec Time 74 ms
Memory 256 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 71 ms 256 KB
subtask1_10.txt AC 12 ms 256 KB
subtask1_11.txt AC 54 ms 256 KB
subtask1_12.txt AC 54 ms 256 KB
subtask1_13.txt AC 54 ms 256 KB
subtask1_14.txt AC 73 ms 256 KB
subtask1_15.txt AC 74 ms 256 KB
subtask1_16.txt AC 52 ms 256 KB
subtask1_17.txt AC 59 ms 256 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 256 KB
subtask1_20.txt AC 53 ms 256 KB