1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (int i=0, ___=(n); i<___; ++i)
#define FOR(i, a, b) for (int i=(a), ___=(b); i<=___; ++i)
#define FORD(i, a, b) for (int i=(a), ___=(b); i>=___; --i)


#include "message.h"
#include "dzialka.h"


int main() {
	if (MyNodeId() != 0) return 0;

	int x = GetFieldHeight();
	int y = GetFieldWidth();

	vector<vector<long long> > v(x+1, vector<long long>(y+1, 0));
	REP(i, x) REP(j, y) v[i+1][j+1] = 1 - IsUsableCell(i, j) - v[i][j] + v[i][j+1] + v[i+1][j];

	long long res = 0;

//	REP(i, x+1) {
//		REP(j, y+1) cout << v[i][j] << " ";
//		cout << "\n";
//	}

	REP(i, x) REP(j, y) FOR(ii, i, x-1) FOR(jj, j, y-1) {
		if (v[ii+1][jj+1] + v[i][j] == v[i][jj+1] + v[ii+1][j])
			++res;
	}

	cout << res << "\n";

	return 0;
}