結果
| 問題 | 
                            No.1900 Don't be Powers of 2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-02-16 00:04:30 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 83 ms / 2,000 ms | 
| コード長 | 808 bytes | 
| コンパイル時間 | 4,839 ms | 
| コンパイル使用メモリ | 256,656 KB | 
| 最終ジャッジ日時 | 2025-01-27 23:17:48 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 42 | 
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)
int main(void)
{
    int N;
    cin>> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    vector<int> odd;
    vector<int> even;
    rep(i, N){
        if(__builtin_popcount(a[i]) % 2) odd.push_back(a[i]);
        else even.push_back(a[i]);
    }
    int n = size(odd);
    int m = size(even);
    mf_graph<int> G(N + 2);
    rep(i, n) G.add_edge(0, i + 1, 1);
    rep(i, m) G.add_edge(n + i + 1, N + 1, 1);
    rep(i, n){
        rep(j, m){
            if(__builtin_popcount(odd[i] ^ even[j]) == 1) G.add_edge(i + 1, n + j + 1, 1);
        }
    }
    cout << N - G.flow(0, N + 1) << endl;
    return 0;
}