結果
問題 | No.971 いたずらっ子 |
ユーザー | merom686 |
提出日時 | 2020-01-17 23:06:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 767 bytes |
コンパイル時間 | 831 ms |
コンパイル使用メモリ | 74,188 KB |
実行使用メモリ | 23,040 KB |
最終ジャッジ日時 | 2024-11-07 11:32:23 |
合計ジャッジ時間 | 2,282 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; char a[2000][2001]; int d[2000][2000]; int main() { ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; for (int i = 0; i < h; i++) { cin >> a[i]; } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { int t0 = i > 0 ? d[i - 1][j] : 1 << 30; int t1 = j > 0 ? d[i][j - 1] : 1 << 30; int t = min(t0, t1) + 1; if (a[i][j] == 'k') t += i + j; if (i == 0 && j == 0) t = 0; d[i][j] = t; } } cout << d[h - 1][w - 1] << endl; return 0; }