結果

問題 No.866 レベルKの正方形
ユーザー 👑 jupirojupiro
提出日時 2020-02-26 09:49:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,371 ms / 6,000 ms
コード長 2,022 bytes
コンパイル時間 1,743 ms
コンパイル使用メモリ 128,460 KB
実行使用メモリ 410,528 KB
最終ジャッジ日時 2024-04-27 03:05:39
合計ジャッジ時間 30,056 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
56,708 KB
testcase_01 AC 13 ms
56,716 KB
testcase_02 AC 13 ms
56,716 KB
testcase_03 AC 13 ms
56,668 KB
testcase_04 AC 13 ms
54,792 KB
testcase_05 AC 12 ms
54,668 KB
testcase_06 AC 13 ms
56,708 KB
testcase_07 AC 12 ms
54,792 KB
testcase_08 AC 2,371 ms
410,468 KB
testcase_09 AC 1,774 ms
410,496 KB
testcase_10 AC 1,534 ms
410,500 KB
testcase_11 AC 2,112 ms
410,428 KB
testcase_12 AC 1,677 ms
410,416 KB
testcase_13 AC 2,159 ms
410,520 KB
testcase_14 AC 1,805 ms
410,436 KB
testcase_15 AC 1,993 ms
410,396 KB
testcase_16 AC 1,981 ms
410,528 KB
testcase_17 AC 1,797 ms
410,512 KB
testcase_18 AC 2,014 ms
410,424 KB
testcase_19 AC 2,178 ms
410,488 KB
testcase_20 AC 1,856 ms
410,372 KB
testcase_21 AC 700 ms
410,420 KB
testcase_22 AC 13 ms
54,764 KB
testcase_23 AC 12 ms
54,636 KB
testcase_24 AC 13 ms
58,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#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関連注意!!!!!!!!!!!!
	*/
}
0