結果

問題 No.971 いたずらっ子
ユーザー tarattata1tarattata1
提出日時 2020-01-17 23:49:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,245 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 77,344 KB
実行使用メモリ 38,316 KB
最終ジャッジ日時 2023-08-07 07:58:29
合計ジャッジ時間 2,343 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
38,276 KB
testcase_01 AC 74 ms
38,308 KB
testcase_02 AC 59 ms
38,316 KB
testcase_03 AC 49 ms
38,292 KB
testcase_04 AC 46 ms
38,136 KB
testcase_05 AC 46 ms
38,292 KB
testcase_06 AC 36 ms
35,836 KB
testcase_07 AC 3 ms
5,724 KB
testcase_08 AC 16 ms
23,000 KB
testcase_09 AC 15 ms
22,936 KB
testcase_10 AC 2 ms
5,300 KB
testcase_11 AC 2 ms
5,020 KB
testcase_12 AC 2 ms
5,060 KB
testcase_13 AC 2 ms
4,988 KB
testcase_14 AC 9 ms
36,820 KB
testcase_15 AC 2 ms
5,064 KB
testcase_16 AC 3 ms
9,648 KB
testcase_17 AC 2 ms
5,084 KB
testcase_18 AC 1 ms
5,072 KB
testcase_19 AC 1 ms
5,060 KB
testcase_20 AC 1 ms
5,024 KB
testcase_21 AC 2 ms
5,136 KB
testcase_22 AC 2 ms
5,112 KB
testcase_23 AC 2 ms
4,968 KB
testcase_24 AC 2 ms
5,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;

char str[2005][2005];

int dx[2]={1,0};
int dy[2]={0,1};
ll dp[2005][2005];
int main(int argc, char* argv[])
{
    int h,w;
    scanf("%d%d", &h, &w);
    int i,j,k;
    for(i=0; i<h; i++) {
        scanf("%s", str[i]);
    }
    for(i=0; i<=h; i++) {
        for(j=0; j<=w; j++) {
            dp[i][j]=LINF;
        }
    }
    dp[0][0]=0;
    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            for(k=0; k<2; k++) {
                int i2=i+dx[k], j2=j+dy[k];
                if(i2>=h || j2>=w) continue;
                int add=(str[i2][j2]=='k'? i2+j2+1: 1);
                dp[i2][j2]=MIN(dp[i2][j2],dp[i][j]+add);
            }
        }
    }
    printf("%lld\n", dp[h-1][w-1]);

    return 0;
}
0