답안 #541913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541913 2022-03-24T19:34:47 Z Alex_tz307 Dijamant (COCI22_dijamant) C++17
70 / 70
77 ms 19964 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 388 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 388 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 37 ms 18484 KB Output is correct
15 Correct 44 ms 19212 KB Output is correct
16 Correct 77 ms 17640 KB Output is correct
17 Correct 39 ms 17484 KB Output is correct
18 Correct 60 ms 19964 KB Output is correct
19 Correct 35 ms 16868 KB Output is correct
20 Correct 40 ms 19912 KB Output is correct
21 Correct 31 ms 16844 KB Output is correct
22 Correct 49 ms 18016 KB Output is correct
23 Correct 47 ms 16988 KB Output is correct
24 Correct 55 ms 18432 KB Output is correct
25 Correct 33 ms 16792 KB Output is correct
26 Correct 41 ms 17384 KB Output is correct