結果

問題 No.971 いたずらっ子
ユーザー kotatsugamekotatsugame
提出日時 2020-01-17 22:39:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 68,320 KB
実行使用メモリ 42,624 KB
最終ジャッジ日時 2024-04-25 02:02:18
合計ジャッジ時間 2,450 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
42,368 KB
testcase_01 AC 126 ms
42,624 KB
testcase_02 AC 96 ms
38,528 KB
testcase_03 AC 108 ms
42,496 KB
testcase_04 AC 98 ms
40,448 KB
testcase_05 AC 104 ms
42,496 KB
testcase_06 AC 81 ms
34,688 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 33 ms
17,792 KB
testcase_09 AC 32 ms
17,408 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 7 ms
11,648 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 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
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int H,W;
string s[2000];
long dp[2000][2000];
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)
	{
		cin>>s[i];
		for(int j=0;j<W;j++)dp[i][j]=1e18;
	}
	dp[0][0]=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		if(i+1<H)
		{
			long nxt=dp[i][j]+1;
			if(s[i+1][j]=='k')nxt+=i+1+j;
			dp[i+1][j]=min(dp[i+1][j],nxt);
		}
		if(j+1<W)
		{
			long nxt=dp[i][j]+1;
			if(s[i][j+1]=='k')nxt+=i+j+1;
			dp[i][j+1]=min(dp[i][j+1],nxt);
		}
	}
	cout<<dp[H-1][W-1]<<endl;
}
0