結果

問題 No.866 レベルKの正方形
ユーザー 👑 jupirojupiro
提出日時 2020-02-26 09:50:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,745 ms / 6,000 ms
コード長 1,968 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 117,208 KB
実行使用メモリ 410,624 KB
最終ジャッジ日時 2024-04-21 16:15:55
合計ジャッジ時間 35,512 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2,640 ms
410,624 KB
testcase_09 AC 2,161 ms
410,496 KB
testcase_10 AC 1,887 ms
410,552 KB
testcase_11 AC 2,605 ms
410,348 KB
testcase_12 AC 2,307 ms
410,624 KB
testcase_13 AC 2,745 ms
410,496 KB
testcase_14 AC 2,287 ms
410,468 KB
testcase_15 AC 2,576 ms
410,624 KB
testcase_16 AC 2,493 ms
410,524 KB
testcase_17 AC 2,273 ms
410,496 KB
testcase_18 AC 2,527 ms
410,624 KB
testcase_19 AC 2,736 ms
410,624 KB
testcase_20 AC 2,365 ms
410,624 KB
testcase_21 AC 1,087 ms
410,496 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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