結果
| 問題 |
No.971 いたずらっ子
|
| ユーザー |
|
| 提出日時 | 2020-02-15 15:55:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 151 ms / 2,000 ms |
| コード長 | 1,234 bytes |
| コンパイル時間 | 1,506 ms |
| コンパイル使用メモリ | 120,524 KB |
| 実行使用メモリ | 26,624 KB |
| 最終ジャッジ日時 | 2024-11-07 11:41:36 |
| 合計ジャッジ時間 | 3,973 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;
const int INF = INT_MAX / 2;
int main()
{
int h, w;
cin >> h >> w;
vector<string> s(h);
for(int y=0; y<h; ++y)
cin >> s[y];
vector<vector<int> > dp(h, vector<int>(w, INF));
dp[0][0] = 0;
for(int y=0; y<h; ++y){
for(int x=0; x<w; ++x){
for(int i=0; i<2; ++i){
int y2 = y + i;
int x2 = x + (i ^ 1);
if(y2 >= h || x2 >= w)
continue;
if(s[y2][x2] == 'k')
dp[y2][x2] = min(dp[y2][x2], dp[y][x] + y + x + 2);
else
dp[y2][x2] = min(dp[y2][x2], dp[y][x] + 1);
}
}
}
cout << dp[h-1][w-1] << endl;
return 0;
}