結果
| 問題 |
No.866 レベルKの正方形
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-26 09:50:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,610 ms / 6,000 ms |
| コード長 | 1,968 bytes |
| コンパイル時間 | 1,137 ms |
| コンパイル使用メモリ | 118,936 KB |
| 実行使用メモリ | 410,496 KB |
| 最終ジャッジ日時 | 2024-10-13 15:12:27 |
| 合計ジャッジ時間 | 33,465 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#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 int inf = 1 << 28;
//const long long mod = 1000000007LL;
const long long mod = 998244353LL;
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
int dp[26][2002][2002];
int len[27];
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
int H, W, K; cin >> H >> W >> K;
for (int k = 0; k < 26; k++)for (int i = 0; i <= H; i++) for (int j = 0; j <= W; j++) dp[k][i][j] = min(H - i + 1, W - j + 1);
for (int i = 0; i < H; i++) {
string s; cin >> s;
for (ll j = 0; j < W; j++) {
dp[s[j] - 'a'][i][j] = 1;
}
}
for (int k = 0; k < 26; k++) {
for (int i = H - 1; i >= 0; i--) {
for (int j = W - 1; j >= 0; j--) {
chmin(dp[k][i][j], dp[k][i + 1][j] + 1);
chmin(dp[k][i][j], dp[k][i][j + 1] + 1);
chmin(dp[k][i][j], dp[k][i + 1][j + 1] + 1);
}
}
}
ll res = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
for (int k = 0; k < 26; k++) {
len[k] = dp[k][i][j];
}
sort(len, len + 26);
len[26] = min(H - i + 1, W - j + 1);
//cout << i << " " << j << " " << len[K] << " " << len[K - 1] << endl;
res += len[K] - len[K - 1];
}
}
cout << res << "\n";
return 0;
/*
おまじないを使ったらscanfとprintf関連注意!!!!!!!!!!!!
*/
}