結果

問題 No.971 いたずらっ子
ユーザー chocoruskchocorusk
提出日時 2020-01-17 21:31:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 1,036 ms
コンパイル使用メモリ 111,476 KB
実行使用メモリ 27,008 KB
最終ジャッジ日時 2024-04-25 01:55:42
合計ジャッジ時間 3,111 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
26,944 KB
testcase_01 AC 115 ms
27,008 KB
testcase_02 AC 85 ms
23,040 KB
testcase_03 AC 103 ms
26,880 KB
testcase_04 AC 98 ms
25,704 KB
testcase_05 AC 102 ms
26,916 KB
testcase_06 AC 77 ms
20,864 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 31 ms
13,696 KB
testcase_09 AC 30 ms
13,568 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 2 ms
5,376 KB
testcase_14 AC 6 ms
11,520 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
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int h, w;
	cin>>h>>w;
	string a[2020];
	for(int i=0; i<h; i++){
		cin>>a[i];
	}
	int dp[2020][2020];
	dp[0][0]=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(i==0 && j==0) continue;
			dp[i][j]=1e9;
			if(i) dp[i][j]=min(dp[i][j], dp[i-1][j]+1);
			if(j) dp[i][j]=min(dp[i][j], dp[i][j-1]+1);
			if(a[i][j]=='k') dp[i][j]+=i+j;
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}
0