結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-31 13:42:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 837 bytes |
| コンパイル時間 | 1,905 ms |
| コンパイル使用メモリ | 194,104 KB |
| 最終ジャッジ日時 | 2025-02-20 16:28:33 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int h, w;
cin >> h >> w;
char a[h][w];
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
cin >> a[i][j];
}
}
int ans = 0;
for (int i = 0; i < 1 << (h + w - 2); i++) {
int x = 0, y = 0;
int p = 1;
for (int j = 0; j < h + w - 2; j++) {
if (i & (1 << j)) {
x++;
} else {
y++;
}
if (x >= h || y >= w) {
p = -999;
break;
}
if (a[x][y] == '#') {
p = -999;
break;
}
if (a[x][y] == 'o') {
p++;
}
if (a[x][y] == 'x') {
p--;
if (p == -1) {
p = -999;
break;
}
}
}
if (p >= 0) {
ans++;
}
}
cout << ans << endl;
return 0;
}