結果
| 問題 | No.2236 Lights Out On Simple Graph | 
| コンテスト | |
| ユーザー |  Nachia | 
| 提出日時 | 2023-03-03 21:43:09 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,383 bytes | 
| コンパイル時間 | 806 ms | 
| コンパイル使用メモリ | 87,512 KB | 
| 最終ジャッジ日時 | 2025-02-11 02:11:26 | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 39 WA * 18 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <atcoder/modint>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;
i64 GCD(i64 a, i64 b){ return b ? GCD(b,a%b) : a; }
using Modint = atcoder::static_modint<998244353>;
int main(){
    int N, M; cin >> N >> M;
    map<i64, int> Q0;
    vector<i64> E(40, 0);
    rep(i,M){
        int u, v; cin >> u >> v; u--; v--;
        E[i] = (1ll << u) | (1ll << v);
    }
    i64 C = 0;
    rep(i,N){ int a; cin >> a; C |= (i64)a << i; }
    rep(i,1<<20){
        i64 q = 0;
        rep(j,20) if(i&(1<<j)) q ^= E[j];
        int f = __builtin_popcount(i);
        auto I = Q0.find(q);
        if(I == Q0.end()) I = Q0.emplace(q, 1001001).first;
        I->second = min(I->second, f);
    }
    i64 ans = 1001001;
    rep(i,1<<20){
        int q = 0;
        rep(j,20) if(i&(1<<j)) q ^= E[20+j];
        auto I = Q0.find(C ^ q);
        if(I != Q0.end()) ans = min<i64>(ans, __builtin_popcount(i) + I->second);
    }
    if(ans >= 10000) ans = -1;
    cout << ans << endl;
    return 0;
}
struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
            
            
            
        