結果
問題 | No.866 レベルKの正方形 |
ユーザー | leaf_1415 |
提出日時 | 2019-08-22 04:26:59 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 4,956 ms / 6,000 ms |
コード長 | 1,192 bytes |
コンパイル時間 | 714 ms |
コンパイル使用メモリ | 63,200 KB |
実行使用メモリ | 432,996 KB |
最終ジャッジ日時 | 2024-04-19 09:43:40 |
合計ジャッジ時間 | 36,905 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
9,568 KB |
testcase_01 | AC | 3 ms
9,564 KB |
testcase_02 | AC | 2 ms
9,564 KB |
testcase_03 | AC | 3 ms
9,564 KB |
testcase_04 | AC | 3 ms
9,564 KB |
testcase_05 | AC | 3 ms
9,568 KB |
testcase_06 | AC | 3 ms
9,568 KB |
testcase_07 | AC | 3 ms
9,568 KB |
testcase_08 | AC | 4,947 ms
432,612 KB |
testcase_09 | AC | 4,331 ms
431,844 KB |
testcase_10 | AC | 4,355 ms
431,208 KB |
testcase_11 | AC | 4,854 ms
431,588 KB |
testcase_12 | AC | 4,556 ms
431,716 KB |
testcase_13 | AC | 4,888 ms
431,464 KB |
testcase_14 | AC | 4,785 ms
431,204 KB |
testcase_15 | AC | 4,956 ms
431,464 KB |
testcase_16 | AC | 4,776 ms
431,076 KB |
testcase_17 | AC | 4,559 ms
432,484 KB |
testcase_18 | AC | 4,606 ms
432,484 KB |
testcase_19 | AC | 4,785 ms
432,996 KB |
testcase_20 | AC | 4,592 ms
432,228 KB |
testcase_21 | AC | 3,307 ms
431,584 KB |
testcase_22 | AC | 3 ms
7,648 KB |
testcase_23 | AC | 3 ms
9,568 KB |
testcase_24 | AC | 3 ms
11,492 KB |
ソースコード
#include <iostream> #include <stdio.h> #include <algorithm> #include <vector> #define llint long long #define inf 1000000000 using namespace std; int h, w, k; int sum[2005][2005]; char c[2005][2005]; int dp[2005][2005]; int vec[2005][2005][26]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> h >> w >> k; for(int y = 1; y <= h; y++){ for(int x = 1; x <= w; x++){ cin >> c[x][y]; } } for(int x = 1; x <= w+1; x++) dp[x][h+1] = inf; for(int y = 1; y <= h+1; y++) dp[w+1][y] = inf; for(int i = 0; i < 26; i++){ for(int y = h; y >= 1; y--){ for(int x = w; x >= 1; x--){ if(c[x][y] == i+'a') dp[x][y] = 0; else{ dp[x][y] = dp[x+1][y]; if(dp[x][y] > dp[x][y+1]) dp[x][y] = dp[x][y+1]; if(dp[x][y] > dp[x+1][y+1]) dp[x][y] = dp[x+1][y+1]; dp[x][y]++; } vec[x][y][i] = dp[x][y]; } } } llint ans = 0; for(int x = 1; x <= w; x++){ for(int y = 1; y <= h; y++){ sort(vec[x][y], vec[x][y]+26); if(vec[x][y][k-1] > min(w-x, h-y)) continue; if(k >= 26 || vec[x][y][k] > min(w-x, h-y)) ans += min(w-x, h-y)+1; else ans += vec[x][y][k]; ans -= vec[x][y][k-1]; } } cout << ans << endl; return 0; }