結果

問題 No.971 いたずらっ子
ユーザー cotton_fn_cotton_fn_
提出日時 2020-02-02 01:04:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 1,126 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 122,716 KB
実行使用メモリ 42,496 KB
最終ジャッジ日時 2024-04-25 02:10:21
合計ジャッジ時間 3,251 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
42,496 KB
testcase_01 AC 124 ms
42,368 KB
testcase_02 AC 98 ms
38,528 KB
testcase_03 AC 117 ms
42,368 KB
testcase_04 AC 108 ms
40,448 KB
testcase_05 AC 112 ms
42,496 KB
testcase_06 AC 86 ms
34,432 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 34 ms
17,664 KB
testcase_09 AC 33 ms
17,408 KB
testcase_10 AC 3 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 7 ms
11,520 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 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 <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T> T iabs(const T& x) { return max(x, -x); }

i64 d[2000][2000];
int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i > 0 || j > 0) {
                d[i][j] = 1ll << 60;
            }
            if (i > 0) {
                d[i][j] = d[i - 1][j] + 1;
            }
            if (j > 0) {
                d[i][j] = min(d[i][j], d[i][j - 1] + 1);
            }
            if (a[i][j] == 'k') {
                d[i][j] += i + j;
            }
        }
    }
    cout << d[h - 1][w - 1] << endl;
    return 0;
}
0