結果
| 問題 |
No.866 レベルKの正方形
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2019-08-17 01:01:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,268 ms / 6,000 ms |
| コード長 | 1,418 bytes |
| コンパイル時間 | 1,629 ms |
| コンパイル使用メモリ | 172,428 KB |
| 実行使用メモリ | 425,772 KB |
| 最終ジャッジ日時 | 2024-09-24 07:44:16 |
| 合計ジャッジ時間 | 29,181 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
using lint = long long int;
int dp[2001][2001][27];
int H, W, K;
constexpr int INF = 100000;
int main()
{
cin >> H >> W >> K;
REP(i, H + 1) REP(j, W + 1) REP(d, 27) dp[i][j][d] = INF;
REP(i, H) REP(j, W)
{
char c;
cin >> c;
dp[i][j][c - 'a'] = 1;
}
IREP(i, H) IREP(j, W) REP(d, 26)
{
mmin(dp[i][j][d], min({dp[i + 1][j][d], dp[i][j + 1][d], dp[i + 1][j + 1][d]}) + 1);
}
lint ret = 0;
REP(i, H) REP(j, W)
{
vector<int> v(27);
REP(d, 27) v[d] = dp[i][j][d];
sort(v.begin(), v.end());
int d_max = min(H - i, W - j);
ret += min(v[K] - 1, d_max) - min(v[K - 1] - 1, d_max);
}
cout << ret << endl;
}
hitonanode