結果

問題 No.971 いたずらっ子
ユーザー CleyLCleyL
提出日時 2020-01-17 21:41:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 66,096 KB
実行使用メモリ 23,040 KB
最終ジャッジ日時 2023-08-07 07:51:11
合計ジャッジ時間 3,515 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 203 ms
22,836 KB
testcase_01 AC 200 ms
23,040 KB
testcase_02 AC 151 ms
21,940 KB
testcase_03 AC 197 ms
22,876 KB
testcase_04 AC 184 ms
21,788 KB
testcase_05 AC 191 ms
22,828 KB
testcase_06 AC 148 ms
20,648 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 55 ms
12,716 KB
testcase_09 AC 52 ms
12,556 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 5 ms
17,396 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 3 ms
6,476 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int dp[2000][2000];
int main(){
    int h,w;cin>>h>>w;
    char mp[h][w];
    for(int i = 0; h > i; i++){
        for(int j = 0; w > j; j++){
            cin>>mp[i][j];
        }
    }
    dp[0][0] = 0;
    for(int i = 0; h > i; i++){
        for(int j = 0; w > j; j++){
            if(!(i+j))continue;
            if(!i){
                dp[i][j] = dp[i][j-1]+1;
            }else if(!j){
                dp[i][j] = dp[i-1][j]+1;
            }else{
                dp[i][j] = min(dp[i-1][j],dp[i][j-1])+1;
            }
            if(mp[i][j] == 'k')dp[i][j]+=i+j;
        }
    }
    cout << dp[h-1][w-1] << endl;
}
0