結果
問題 | No.2708 Jewel holder |
ユーザー |
|
提出日時 | 2024-11-01 20:46:52 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,389 bytes |
コンパイル時間 | 3,791 ms |
コンパイル使用メモリ | 320,836 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-01 20:46:57 |
合計ジャッジ時間 | 4,993 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/extc++.h> int main() { using namespace std; unsigned H, W; cin >> H >> W; enum class state { plus, minus, stop }; vector field(H, vector<state>(W)); for (auto &row : field) for (auto &cell : row) { char c; cin >> c; cell = c == 'o' ? state::plus : c == 'x' ? state::minus : state::stop; } unsigned possible_roots{}; for (unsigned i{}; i < (1U << H - 1) << (W - 1); ++i) if (popcount(i) == H - 1) possible_roots += [&]() -> int { unsigned now_jewels{}, x{}, y{}; for (unsigned j{}; j < H + W - 2; ++j) { if (field[x][y] == state::plus) ++now_jewels; if (field[x][y] == state::minus) { if (now_jewels == 0) return 0; --now_jewels; } if (field[x][y] == state::stop) return 0; ++(i >> j & 1 ? x : y); } if (field.back().back() == state::plus) return 1; return now_jewels != 0; }(); cout << possible_roots << '\n'; return 0; }