結果
| 問題 |
No.971 いたずらっ子
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-03 21:40:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,250 bytes |
| コンパイル時間 | 1,806 ms |
| コンパイル使用メモリ | 178,208 KB |
| 実行使用メモリ | 23,424 KB |
| 最終ジャッジ日時 | 2024-11-25 22:44:41 |
| 合計ジャッジ時間 | 3,603 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | AC * 7 WA * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)
using ll = long long;
using ld = long double;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(0);
int h, w;
cin >> h >> w;
int dx[2] = {0, 1};
int dy[2] = {1, 0};
vector<string> s(h);
vector<vector<int> > dist(h, vector<int>(w, Inf));
rep (i, h) cin >> s[i];
queue<pair<int, int> > q;
q.push({0, 0});
dist[0][0] = 0;
while (!q.empty()) {
int x, y;
x = q.front().first, y = q.front().second;
q.pop();
rep (i, 2) {
int nx, ny;
nx = x + dx[i];
ny = y + dy[i];
if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
if (dist[nx][ny] != Inf) continue;
int tmp = dist[x][y] + 1;
if (s[nx][ny] == 'k') tmp += x + y;
if (tmp >= dist[nx][ny]) continue;
dist[nx][ny] = tmp;
q.push({nx, ny});
}
}
cout << dist[h - 1][w - 1] << endl;
return 0;
}