結果
問題 |
No.3275 Minesweeper on Graph
|
ユーザー |
![]() |
提出日時 | 2025-09-21 01:11:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 2,000 ms |
コード長 | 778 bytes |
コンパイル時間 | 3,340 ms |
コンパイル使用メモリ | 281,848 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-21 01:11:31 |
合計ジャッジ時間 | 7,172 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; vector<int> a(n); rep(i, n) cin >> a[i]; vector Graph(n, vector<int>()); rep(_, m) { int u, v; cin >> u >> v; --u, --v; Graph[u].push_back(v); Graph[v].push_back(u); } rep(bit, 1 << n) { bool ok = true; rep(i, n) { int cnt = 0; for (int j : Graph[i]) cnt += (bit >> j) & 1; if (cnt != a[i]) ok = false; } if (ok) { cout << "Yes" << '\n'; rep(i, n) cout << ((bit >> i) & 1) << ' '; cout << '\n'; return 0; } } cout << "No" << '\n'; return 0; }