Submission #541913

#TimeUsernameProblemLanguageResultExecution timeMemory
541913Alex_tz307Dijamant (COCI22_dijamant)C++17
70 / 70
77 ms19964 KiB
#include <bits/stdc++.h> using namespace std; void testCase() { int n, m; cin >> n >> m; vector<string> a(n + 1); vector<vector<int>> sum(n + 1, vector<int>(m + 1)); for (int i = 1; i <= n; ++i) { a[i].resize(m); cin >> a[i]; a[i] = '$' + a[i]; for (int j = 1; j <= m; ++j) { sum[i][j] = sum[i][j - 1] + (a[i][j] == '#'); } } auto checkDown = [&](int lin, int l, int r) -> bool { while (l <= r) { if (a[lin][l] != '#' || a[lin][r] != '#' || (l < r && sum[lin][r - 1] - sum[lin][l])) { return false; } lin += 1; l += 1; r -= 1; } return true; }; int ans = 0; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (a[i][j] == '#') { int lin = i + 1, l = j - 1, r = j + 1; while (lin + (lin - i) <= n && l > 0 && r <= m) { if (a[lin][l] != '#' || a[lin][r] != '#' || sum[lin][r - 1] - sum[lin][l]) { break; } ans += checkDown(lin + 1, l + 1, r - 1); lin += 1; l -= 1; r += 1; } } } } cout << ans << '\n'; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int tests = 1; for (int tc = 0; tc < tests; ++tc) { testCase(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...