Submission #1555350


Source Code Expand

#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン!!!!
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int h, w, a[100][100], b[100][100], c[100][100], ans;
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			if ((i + j) % 2 == 0)
				b[i][j] += a[i][j];
			else
				c[i][j] += a[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int sum = 0, sum2 = 0;
			if (i != 0)
				sum += b[i - 1][j], sum2 += c[i - 1][j];
			if (j != 0) 
				sum += b[i][j - 1], sum2 += c[i][j - 1];
			if (i != 0 && j != 0)
				sum -= b[i - 1][j - 1], sum2 -= c[i - 1][j - 1];
			b[i][j] += sum, c[i][j] += sum2;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			for (int x = 0; x <= i; x++) {
				for (int y = 0; y <= j; y++) {
					int sum = b[i][j] - (x != 0 ? b[x - 1][j] : 0) - (y != 0 ? b[i][y - 1] : 0) + (x != 0 && y != 0 ? b[x - 1][y - 1] : 0);
					int sum2= c[i][j] - (x != 0 ? c[x - 1][j] : 0) - (y != 0 ? c[i][y - 1] : 0) + (x != 0 && y != 0 ? c[x - 1][y - 1] : 0);
					if (sum == sum2)
						ans = max(ans, (i - x + 1)*(j - y + 1));
				}
			}
		}
	}
	cout << ans << endl;
	getchar(); getchar();
}

Submission Info

Submission Time
Task B - チョコレート
User Thistle
Language C++14 (GCC 5.4.1)
Score 100
Code Size 3177 Byte
Status AC
Exec Time 87 ms
Memory 640 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 85 ms 512 KB
subtask1_10.txt AC 13 ms 384 KB
subtask1_11.txt AC 72 ms 512 KB
subtask1_12.txt AC 72 ms 512 KB
subtask1_13.txt AC 72 ms 512 KB
subtask1_14.txt AC 86 ms 512 KB
subtask1_15.txt AC 87 ms 512 KB
subtask1_16.txt AC 70 ms 640 KB
subtask1_17.txt AC 68 ms 512 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 512 KB
subtask1_20.txt AC 86 ms 512 KB