結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-22 18:23:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 786 bytes |
| コンパイル時間 | 908 ms |
| コンパイル使用メモリ | 72,204 KB |
| 最終ジャッジ日時 | 2025-02-18 22:06:23 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
using namespace std;
int main() {
int H, W, ans = 0;
cin >> H >> W;
vector<string> G(H);
for (int i = 0; i < H; i++) {
cin >> G[i];
}
int dx[] = {1, 0};
int dy[] = {0, 1};
int N = H + W - 2;
for (int bit = 0; bit < (1 << N); bit++) {
int x = 0, y = 0, now = 1;
bool ok = true;
for (int i = 0; i < N; i++) {
int a = x + dx[(bit >> i) & 1];
int b = y + dy[(bit >> i) & 1];
if (a < 0 || b < 0 || a >= H || b >= W || G[a][b] == '#') {
ok = false;
break;
}
now += (G[a][b] == 'o' ? 1 : -1);
if (now < 0) {
ok = false;
break;
}
x = a;
y = b;
}
if (ok) ans++;
}
cout << ans << endl;
}