結果
| 問題 |
No.866 レベルKの正方形
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-23 18:56:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 778 bytes |
| コンパイル時間 | 2,147 ms |
| コンパイル使用メモリ | 202,440 KB |
| 最終ジャッジ日時 | 2025-01-07 14:45:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 TLE * 14 |
ソースコード
#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;
}