Submission #2908587


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

#define V2(T, x, y) (x, vector<T>(y, 0))
template<typename T> struct Sum2 {
	typedef vector<vector<T>> A;
	A s;
	int X, Y;
	Sum2() { X = Y = -1; }
	Sum2(A & p) { init(p); }
	void init(A & p) {
		X = p.size();
		Y = p[0].size();
		s = A V2(T, X + 1, Y + 1);
		inc1(x, X) { inc1(y, Y) { s[x][y]  = p[x - 1][y - 1]; } }
		inc1(x, X) { inc1(y, Y) { s[x][y] += s[x - 1][y    ]; } }
		inc1(x, X) { inc1(y, Y) { s[x][y] += s[x    ][y - 1]; } }
	}
	T sum(int xl, int xh, int yl, int yh) { // [xl, xh) × [yl, yh)
		assert(inII(xl, 0, X));
		assert(inII(xh, 0, X));
		assert(inII(yl, 0, Y));
		assert(inII(yh, 0, Y));
		assert(xl <= xh);
		assert(yl <= yh);
		return s[xh][yh] - s[xh][yl] - s[xl][yh] + s[xl][yl];
	}
};

// ----

int h, w;
vector<vector<int>> p V2(int, 100, 100);

int main() {
	cin >> h >> w;
	inc(i, h) {
	inc(j, w) {
		cin >> p[i][j];
		p[i][j] *= ((i + j) % 2 == 0 ? +1 : -1);
	}
	}
	
	int ans = 0;
	Sum2<int> s(p);
	incII(ih, 1,  h) {
	incII(il, 0, ih) {
	incII(jh, 1,  w) {
	incII(jl, 0, jh) {
		if(s.sum(il, ih, jl, jh) == 0) { setmax(ans, (ih - il) * (jh - jl)); }
	}
	}
	}
	}
	
	cout << ans << endl;
	
	return 0;
}

Submission Info

Submission Time
Task B - チョコレート
User FF256grhy
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2752 Byte
Status AC
Exec Time 78 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 384 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 76 ms 384 KB
subtask1_10.txt AC 13 ms 384 KB
subtask1_11.txt AC 62 ms 384 KB
subtask1_12.txt AC 62 ms 384 KB
subtask1_13.txt AC 62 ms 384 KB
subtask1_14.txt AC 77 ms 384 KB
subtask1_15.txt AC 78 ms 384 KB
subtask1_16.txt AC 60 ms 384 KB
subtask1_17.txt AC 62 ms 384 KB
subtask1_18.txt AC 1 ms 384 KB
subtask1_19.txt AC 1 ms 384 KB
subtask1_20.txt AC 63 ms 384 KB