Submission #3981606


Source Code Expand

#include <string>
#include <vector>
#include <iostream>
using namespace std;
long long solve(vector<string> S) {
	int H = S.size(), W = S[0].size();
	long long ans = 0;
	for (int i = 0; i <= H + W - 2; ++i) {
		for (int j = i + 2; j <= H + W - 2; j += 2) {
			int B = (j - i) / 2;
			for (int k = 0; k < H - B; ++k) {
				if (i - k >= W || i - k - B < 0 || S[k][i - k] == '.' || S[k + B][i - k - B] == '.') continue;
				for (int l = k + B; l <= k + 2 * B && l < H; ++l) {
					ans += (0 <= j - l && j - l < W && S[l][j - l] == '#' ? 1 : 0) * 2;
				}
				ans -= (0 <= j - (k + B) && j - (k + B) < W && S[k + B][j - (k + B)] == '#' ? 1 : 0);
				ans -= (k + 2 * B < H && 0 <= j - (k + 2 * B) && j - (k + 2 * B) < W && S[k + 2 * B][j - (k + 2 * B)] == '#' ? 1 : 0);
			}
		}
	}
	return ans;
}
vector<string> rotate(vector<string> S) {
	int H = S.size(), W = S[0].size();
	vector<string> ans(W, string(H, '?'));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ans[j][H - i - 1] = S[i][j];
		}
	}
	return ans;
}
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int i = 0; i < H; ++i) {
		cin >> S[i];
	}
	long long ans = 0;
	for (int i = 0; i < 4; ++i) {
		ans += solve(S);
		S = rotate(S);
	}
	cout << ans / 2 << endl;
	return 0;
}

Submission Info

Submission Time
Task E - Equilateral
User square1001
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1312 Byte
Status TLE
Exec Time 2103 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 32
TLE × 8
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 996 ms 640 KB
02.txt AC 977 ms 640 KB
03.txt AC 979 ms 640 KB
04.txt AC 1003 ms 640 KB
05.txt AC 983 ms 640 KB
06.txt AC 997 ms 640 KB
07.txt AC 975 ms 640 KB
08.txt AC 995 ms 640 KB
09.txt AC 176 ms 640 KB
10.txt AC 170 ms 640 KB
11.txt AC 169 ms 640 KB
12.txt AC 173 ms 640 KB
13.txt AC 173 ms 640 KB
14.txt AC 172 ms 640 KB
15.txt TLE 2103 ms 640 KB
16.txt TLE 2103 ms 640 KB
17.txt TLE 2103 ms 640 KB
18.txt TLE 2103 ms 640 KB
19.txt TLE 2103 ms 640 KB
20.txt TLE 2103 ms 512 KB
21.txt TLE 2103 ms 640 KB
22.txt TLE 2103 ms 640 KB
23.txt AC 99 ms 512 KB
24.txt AC 102 ms 640 KB
25.txt AC 1498 ms 640 KB
26.txt AC 1481 ms 640 KB
27.txt AC 12 ms 256 KB
28.txt AC 12 ms 256 KB
29.txt AC 12 ms 256 KB
30.txt AC 12 ms 256 KB
31.txt AC 12 ms 256 KB
32.txt AC 12 ms 256 KB
33.txt AC 12 ms 256 KB
34.txt AC 12 ms 256 KB
35.txt AC 1 ms 256 KB
36.txt AC 1 ms 256 KB
37.txt AC 1 ms 256 KB
38.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB