結果

問題 No.971 いたずらっ子
ユーザー merom686merom686
提出日時 2020-01-17 23:06:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 74,780 KB
実行使用メモリ 23,168 KB
最終ジャッジ日時 2024-04-25 02:02:37
合計ジャッジ時間 1,998 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,168 KB
testcase_01 AC 30 ms
23,084 KB
testcase_02 AC 24 ms
23,040 KB
testcase_03 AC 23 ms
22,956 KB
testcase_04 AC 23 ms
22,144 KB
testcase_05 AC 23 ms
23,168 KB
testcase_06 AC 17 ms
20,864 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 11 ms
13,440 KB
testcase_09 AC 10 ms
13,312 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 6 ms
15,488 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

char a[2000][2001];
int d[2000][2000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w;
    cin >> h >> w;

    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int t0 = i > 0 ? d[i - 1][j] : 1 << 30;
            int t1 = j > 0 ? d[i][j - 1] : 1 << 30;
            int t = min(t0, t1) + 1;
            if (a[i][j] == 'k') t += i + j;
            if (i == 0 && j == 0) t = 0;
            d[i][j] = t;
        }
    }

    cout << d[h - 1][w - 1] << endl;

    return 0;
}
0