結果
問題 |
No.2708 Jewel holder
|
ユーザー |
|
提出日時 | 2024-11-01 20:49:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 1,806 bytes |
コンパイル時間 | 3,261 ms |
コンパイル使用メモリ | 153,836 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-01 20:49:56 |
合計ジャッジ時間 | 4,150 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <math.h> #include <queue> #include <numeric> #include <map> #include <atcoder/all> using namespace atcoder; using namespace std; using ll = long long; #define Sort(a) sort((a).begin(), (a).end()) #define Rev(a) reverse((a).begin(), (a).end()) #define cfs(a) cout << fixed << setprecision(a) int main() { ll H, W; cin >> H >> W; vector<string> A(H); for (int i = 0; i < H; i++) { cin >> A[i]; } ll all = (H - 1) + (W - 1); ll ans = 0; for (ll i = 0; i < pow(2, all); i++) { bool ok = true; ll have = 1; ll now_h = 0; ll now_w = 0; ll div = 1; ll rem = i; for (ll j = 0; j < all; j++) { rem /= div; if (rem % 2 == 0) { now_h++; if (now_h >= H) { ok = false; } } else { now_w++; if (now_w >= W) { ok = false; } } div *= 2; rem = i; if (!ok) { break; } if (A[now_h][now_w] == '#') { ok = false; break; } if (A[now_h][now_w] == 'o') { have++; } if (A[now_h][now_w] == 'x') { have--; if (have < 0) { ok = false; break; } } } if (ok) { ans++; } } cout << ans << endl; }