結果
| 問題 |
No.971 いたずらっ子
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-01-18 19:42:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 1,128 bytes |
| コンパイル時間 | 1,063 ms |
| コンパイル使用メモリ | 93,556 KB |
| 実行使用メモリ | 23,296 KB |
| 最終ジャッジ日時 | 2024-11-07 11:38:49 |
| 合計ジャッジ時間 | 2,643 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 971.cc: No.971 いたずらっ子 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_H = 2000;
const int MAX_W = 2000;
const int INF = 1 << 30;
/* typedef */
/* global variables */
char fs[MAX_H][MAX_W + 4];
int ds[MAX_H][MAX_W];
/* subroutines */
inline void setmin(int &a, int b) { if (a > b) a = b; }
/* main */
int main() {
int h, w;
scanf("%d%d", &h, &w);
for (int y = 0; y < h; y++) {
scanf("%s", fs[y]);
fill(ds[y], ds[y] + w, INF);
}
ds[0][0] = 0;
for (int y = 0; y < h; y++)
for (int x = 0; x < w; x++) {
int vd = ds[y][x] + 1;
if (fs[y][x] == 'k') vd += y + x;
if (y + 1 < h) setmin(ds[y + 1][x], vd);
if (x + 1 < w) setmin(ds[y][x + 1], vd);
}
printf("%d\n", ds[h - 1][w - 1]);
return 0;
}
tnakao0123