結果
問題 |
No.2236 Lights Out On Simple Graph
|
ユーザー |
![]() |
提出日時 | 2023-03-02 13:35:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 930 bytes |
コンパイル時間 | 1,099 ms |
コンパイル使用メモリ | 109,788 KB |
最終ジャッジ日時 | 2025-02-11 01:07:50 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 52 TLE * 5 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; int main(){ ll N, M, m, a, b, vtx, ans=1e9, c=0, mx; cin >> N >> M; m = M; vector<pair<ll, ll>> e(M); for (int i=0; i<M; i++){ cin >> a >> b; a--; b--; e[i] = {a, b}; } for (int i=0; i<N; i++){ cin >> a; c |= a*(1LL<<i); } mx = 1<<M; for (int i=0; i<mx; i++){ vtx = 0; for (int j=0; j<m; j++){ if (i & (1<<j)){ tie(a, b) = e[j]; vtx ^= (1LL<<a); vtx ^= (1LL<<b); } } if (c ^ vtx == 0) ans = min(ans, (ll)__builtin_popcount(i)); } if (ans == 1e9) ans = -1; cout << ans << endl; return 0; }