結果

問題 No.2236 Lights Out On Simple Graph
ユーザー 👑 NachiaNachia
提出日時 2023-03-03 21:48:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,378 bytes
コンパイル時間 1,068 ms
コンパイル使用メモリ 92,600 KB
実行使用メモリ 69,212 KB
最終ジャッジ日時 2023-10-18 01:46:46
合計ジャッジ時間 36,502 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
4,348 KB
testcase_01 AC 148 ms
4,348 KB
testcase_02 AC 175 ms
4,348 KB
testcase_03 AC 694 ms
69,204 KB
testcase_04 WA -
testcase_05 AC 198 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 148 ms
4,348 KB
testcase_09 AC 173 ms
4,348 KB
testcase_10 AC 758 ms
69,204 KB
testcase_11 AC 298 ms
4,348 KB
testcase_12 AC 768 ms
69,204 KB
testcase_13 AC 837 ms
69,204 KB
testcase_14 AC 704 ms
69,204 KB
testcase_15 AC 660 ms
69,140 KB
testcase_16 AC 648 ms
69,204 KB
testcase_17 AC 761 ms
36,372 KB
testcase_18 AC 685 ms
69,140 KB
testcase_19 AC 700 ms
69,140 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 818 ms
69,204 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 776 ms
69,140 KB
testcase_28 AC 686 ms
69,204 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 853 ms
69,140 KB
testcase_36 AC 1,079 ms
69,140 KB
testcase_37 AC 819 ms
69,140 KB
testcase_38 AC 700 ms
19,988 KB
testcase_39 AC 346 ms
4,628 KB
testcase_40 AC 611 ms
36,436 KB
testcase_41 AC 447 ms
20,052 KB
testcase_42 AC 514 ms
36,436 KB
testcase_43 AC 373 ms
11,796 KB
testcase_44 AC 645 ms
36,372 KB
testcase_45 WA -
testcase_46 AC 435 ms
36,436 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 350 ms
20,052 KB
testcase_50 AC 260 ms
4,348 KB
testcase_51 AC 412 ms
19,988 KB
testcase_52 AC 490 ms
11,796 KB
testcase_53 AC 221 ms
4,348 KB
testcase_54 AC 605 ms
36,372 KB
testcase_55 AC 479 ms
11,796 KB
testcase_56 AC 321 ms
7,700 KB
testcase_57 AC 670 ms
11,796 KB
testcase_58 AC 353 ms
7,700 KB
testcase_59 AC 385 ms
7,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
    }
    int 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(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;

0