結果
| 問題 |
No.866 レベルKの正方形
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-31 02:53:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,618 bytes |
| コンパイル時間 | 1,079 ms |
| コンパイル使用メモリ | 116,852 KB |
| 実行使用メモリ | 415,440 KB |
| 最終ジャッジ日時 | 2024-09-16 08:28:46 |
| 合計ジャッジ時間 | 40,206 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 3 |
ソースコード
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long MAX = 5100000;
const long long INF = 1LL << 60;
//const long long mod = 1000000007LL;
//const long long mod = 998244353LL;
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
int dp[2007][2007][26];
string vs[2007];
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll H, W, K; cin >> H >> W >> K;
for (ll i = 0; i < H; i++) {
cin >> vs[i];
}
for (ll i = 0; i <= H; i++)for (ll j = 0; j <= W; j++)for (ll k = 0; k < 26; k++) dp[i][j][k] = (1 << 30);
for (ll k = 0; k < 26; k++) {
for (ll i = H - 1; i >= 0; i--) {
for (ll j = W - 1; j >= 0; j--) {
int f = min(H - i, W - j);
if (vs[i][j] - 'a' == k) dp[i][j][k] = 1;
else dp[i][j][k] = min({ f,dp[i + 1][j][k],dp[i][j + 1][k],dp[i + 1][j + 1][k] }) + 1;
}
}
}
ll res = 0;
for (ll i = 0; i < H; i++) {
for (ll j = 0; j < W; j++) {
sort(dp[i][j], dp[i][j] + 26);
res += dp[i][j][K] - dp[i][j][K - 1];
}
}
cout << res << endl;
return 0;
}