結果

問題 No.971 いたずらっ子
ユーザー ngtkanangtkana
提出日時 2020-04-10 21:12:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 200,264 KB
実行使用メモリ 65,920 KB
最終ジャッジ日時 2024-04-25 02:12:43
合計ジャッジ時間 3,915 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
65,664 KB
testcase_01 AC 135 ms
65,792 KB
testcase_02 AC 102 ms
50,176 KB
testcase_03 AC 117 ms
65,920 KB
testcase_04 AC 107 ms
62,208 KB
testcase_05 AC 112 ms
65,920 KB
testcase_06 AC 90 ms
51,712 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 30 ms
19,584 KB
testcase_09 AC 29 ms
19,072 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 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 1 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 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
void cmn(lint&x,lint y){if(x>y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint h,w;std::cin>>h>>w;
    std::vector<std::vector<lint>>g(h,std::vector<lint>(w));
    for(lint i=0;i<h;i++){
    for(lint j=0;j<w;j++){
        char c;std::cin>>c;
        g.at(i).at(j)=c=='k';
    }}
    lint inf=std::numeric_limits<lint>::max();
    std::vector<std::vector<lint>>dp(h,std::vector<lint>(w,inf));
    dp.at(0).at(0)=0;
    for(lint i=0;i<h;i++){
    for(lint j=0;j<w;j++){
        if(g.at(i).at(j))dp.at(i).at(j)+=i+j;
        if(i<h-1)cmn(dp.at(i+1).at(j),dp.at(i).at(j)+1);
        if(j<w-1)cmn(dp.at(i).at(j+1),dp.at(i).at(j)+1);
    }}
    std::cout<<dp.at(h-1).at(w-1)<<'\n';
}
0