結果

問題 No.971 いたずらっ子
ユーザー otamay6otamay6
提出日時 2020-01-19 10:57:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 1,560 ms
コンパイル使用メモリ 169,084 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-04-25 02:08:59
合計ジャッジ時間 3,330 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
26,496 KB
testcase_01 AC 103 ms
26,624 KB
testcase_02 AC 76 ms
18,944 KB
testcase_03 AC 91 ms
26,752 KB
testcase_04 AC 87 ms
25,216 KB
testcase_05 AC 92 ms
26,624 KB
testcase_06 AC 69 ms
18,816 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 26 ms
9,344 KB
testcase_09 AC 24 ms
9,344 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
 
int main(){
    int H,W;cin>>H>>W;
    vector<string> s(H);
    REP(i,H) cin>>s[i];
    const int inf=1e9;
    vector<vector<int>> dp(H,vector<int>(W,inf));
    dp[0][0]=0;
    REP(i,H) REP(j,W){
        int pl=1;
        if(s[i][j]!='.') pl+=i+j;
        if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+pl);
        if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+pl);
    }
    cout<<dp[H-1][W-1]<<endl;
}
0