結果

問題 No.866 レベルKの正方形
ユーザー 👑 hitonanodehitonanode
提出日時 2019-08-17 01:01:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,335 ms / 6,000 ms
コード長 1,418 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 173,456 KB
実行使用メモリ 425,920 KB
最終ジャッジ日時 2023-10-24 16:28:25
合計ジャッジ時間 30,446 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,688 KB
testcase_01 AC 2 ms
5,688 KB
testcase_02 AC 2 ms
5,688 KB
testcase_03 AC 2 ms
5,688 KB
testcase_04 AC 2 ms
5,688 KB
testcase_05 AC 3 ms
5,688 KB
testcase_06 AC 2 ms
5,688 KB
testcase_07 AC 2 ms
5,688 KB
testcase_08 AC 2,233 ms
425,880 KB
testcase_09 AC 1,893 ms
425,920 KB
testcase_10 AC 1,685 ms
425,920 KB
testcase_11 AC 2,293 ms
425,920 KB
testcase_12 AC 1,834 ms
425,920 KB
testcase_13 AC 2,193 ms
425,920 KB
testcase_14 AC 1,897 ms
425,920 KB
testcase_15 AC 1,934 ms
425,920 KB
testcase_16 AC 2,042 ms
425,920 KB
testcase_17 AC 1,955 ms
425,920 KB
testcase_18 AC 2,036 ms
425,920 KB
testcase_19 AC 2,335 ms
425,920 KB
testcase_20 AC 2,058 ms
425,920 KB
testcase_21 AC 912 ms
425,920 KB
testcase_22 AC 2 ms
5,684 KB
testcase_23 AC 2 ms
5,684 KB
testcase_24 AC 3 ms
7,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0