結果

問題 No.971 いたずらっ子
ユーザー merom686merom686
提出日時 2020-01-17 23:06:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 73,552 KB
実行使用メモリ 23,156 KB
最終ジャッジ日時 2023-08-07 07:56:20
合計ジャッジ時間 2,116 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,156 KB
testcase_01 AC 30 ms
22,856 KB
testcase_02 AC 24 ms
22,848 KB
testcase_03 AC 22 ms
22,964 KB
testcase_04 AC 21 ms
22,848 KB
testcase_05 AC 20 ms
22,972 KB
testcase_06 AC 17 ms
22,692 KB
testcase_07 AC 3 ms
6,140 KB
testcase_08 AC 9 ms
15,668 KB
testcase_09 AC 9 ms
15,588 KB
testcase_10 AC 2 ms
5,496 KB
testcase_11 AC 2 ms
5,460 KB
testcase_12 AC 2 ms
5,380 KB
testcase_13 AC 2 ms
5,468 KB
testcase_14 AC 6 ms
21,852 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
8,452 KB
testcase_17 AC 2 ms
5,428 KB
testcase_18 AC 2 ms
5,448 KB
testcase_19 AC 2 ms
5,568 KB
testcase_20 AC 2 ms
5,568 KB
testcase_21 AC 2 ms
5,740 KB
testcase_22 AC 2 ms
5,428 KB
testcase_23 AC 2 ms
5,368 KB
testcase_24 AC 2 ms
5,396 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