結果

問題 No.866 レベルKの正方形
ユーザー 0w10w1
提出日時 2019-08-23 18:56:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 778 bytes
コンパイル時間 5,929 ms
コンパイル使用メモリ 204,520 KB
実行使用メモリ 61,600 KB
最終ジャッジ日時 2024-04-21 15:51:15
合計ジャッジ時間 10,894 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);

  int H, W, K;
  cin >> H >> W >> K;

  vector<string> G(H);
  for (int i = 0; i < H; ++i) {
    cin >> G[i];
  }

  int ans = 0;
  vector<vector<vector<int>>> dp(2, vector<vector<int>>(H, vector<int>(W)));
  for (int l = 1; l <= min(H, W); ++l) {
    for (int i = 0; i + l <= H; ++i) {
      for (int j = 0; j + l <= W; ++j) {
        dp[l & 1][i][j] = 1 << G[i][j] - 'a';
        if (1 < l) {
          dp[l & 1][i][j] |= 1 << G[i + l - 1][j + l - 1] - 'a';
          dp[l & 1][i][j] |= dp[~l & 1][i + 1][j];
          dp[l & 1][i][j] |= dp[~l & 1][i][j + 1];
        }
        ans += __builtin_popcount(dp[l & 1][i][j]) == K;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
0