結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2024-07-13 18:34:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 817 bytes |
| コンパイル時間 | 2,022 ms |
| コンパイル使用メモリ | 175,528 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-13 18:34:53 |
| 合計ジャッジ時間 | 3,248 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
int main() {
int H, W;
cin >> H >> W;
vector<string> s(H);
rep(i, H) cin >> s[i];
int ans = 0;
using P = pair<int, int>;
queue<P> q;
q.push(P(0, 1));
while(q.size()) {
int t, c;
tie(t, c) = q.front();
q.pop();
int y = t / W;
int x = t % W;
if(y == H - 1 && x == W - 1) ans++;
if(y + 1 < H) {
t = (y + 1) * W + x;
if(s[y + 1][x] == 'o') {
q.push(P(t, c + 1));
}
else if(s[y + 1][x] == 'x') {
if(c > 0) {
q.push(P(t, c - 1));
}
}
}
if(x + 1 < W) {
t = y * W + x + 1;
if(s[y][x + 1] == 'o') {
q.push(P(t, c + 1));
}
else if(s[y][x + 1] == 'x') {
if(c > 0) {
q.push(P(t, c - 1));
}
}
}
}
cout << ans << endl;
}
forest3