結果

問題 No.971 いたずらっ子
ユーザー CleyLCleyL
提出日時 2020-01-17 21:41:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 659 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 65,012 KB
実行使用メモリ 23,168 KB
最終ジャッジ日時 2024-04-25 01:57:16
合計ジャッジ時間 3,631 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 218 ms
23,040 KB
testcase_01 AC 217 ms
23,040 KB
testcase_02 AC 170 ms
22,016 KB
testcase_03 AC 210 ms
23,168 KB
testcase_04 AC 212 ms
22,144 KB
testcase_05 AC 214 ms
23,040 KB
testcase_06 AC 158 ms
20,224 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 60 ms
12,672 KB
testcase_09 AC 57 ms
12,288 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 1 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
11,520 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 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 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>
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