結果

問題 No.971 いたずらっ子
ユーザー kotamanegikotamanegi
提出日時 2020-01-17 21:34:46
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,063 bytes
コンパイル時間 2,496 ms
コンパイル使用メモリ 134,192 KB
実行使用メモリ 51,032 KB
最終ジャッジ日時 2023-08-07 07:50:17
合計ジャッジ時間 3,848 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
50,900 KB
testcase_01 AC 37 ms
50,992 KB
testcase_02 AC 31 ms
49,848 KB
testcase_03 AC 29 ms
51,032 KB
testcase_04 AC 28 ms
47,872 KB
testcase_05 AC 29 ms
50,280 KB
testcase_06 AC 23 ms
44,808 KB
testcase_07 AC 2 ms
6,000 KB
testcase_08 AC 12 ms
26,968 KB
testcase_09 AC 11 ms
26,512 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 11 ms
48,924 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 3 ms
9,880 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:18: warning: '#pragma comment linker' ignored [-Wignored-pragmas]
#pragma comment (linker, "/STACK:256000000")
                 ^
1 warning generated.

ソースコード

diff #

#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}
#define int ll
int dist[3000][3000];
void solve() {
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		REP(q, w) {
			dist[i][q] = 1e18;
		}
	}
	dist[0][0] = 0;
	REP(i, h) {
		string s;
		cin >> s;
		REP(q, s.length()) {
			int cost = 1;
			if (s[q] == 'k') {
				cost += llabs(i + q);
			}
			if (i != 0) {
				dist[i][q] = min(dist[i - 1][q] + cost, dist[i][q]);
			}
			if (q != 0) {
				dist[i][q] = min(dist[i][q - 1] + cost, dist[i][q]);
			}
		}
	}
	cout << dist[h - 1][w - 1] << endl;
}

#undef int

int main() {
	init();
	solve();
}
0