結果

問題 No.866 レベルKの正方形
ユーザー 0w10w1
提出日時 2019-08-23 18:54:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 849 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 209,428 KB
実行使用メモリ 813,696 KB
最終ジャッジ日時 2024-04-21 15:50:45
合計ジャッジ時間 5,610 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 MLE -
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<set<char>>>> dp(2, vector<vector<set<char>>>(H, vector<set<char>>(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].clear();
        dp[l & 1][i][j].insert(G[i][j]);
        if (1 < l) {
          dp[l & 1][i][j].insert(G[i + l - 1][j + l - 1]);
          for (char c : dp[~l & 1][i + 1][j]) dp[l & 1][i][j].insert(c);
          for (char c : dp[~l & 1][i][j + 1]) dp[l & 1][i][j].insert(c);
        }
        ans += dp[l & 1][i][j].size() == K;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
0