結果

問題 No.1900 Don't be Powers of 2
ユーザー rin204
提出日時 2022-04-08 22:47:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 654 bytes
コンパイル時間 2,482 ms
コンパイル使用メモリ 205,776 KB
最終ジャッジ日時 2025-01-28 16:31:57
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/maxflow>
using namespace std;
using namespace atcoder;

int main(void){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    mf_graph<int> g(n + 2);
    int s = n, t = n + 1;
    for(int i = 0; i < n; i++){
        if(__builtin_popcount(A[i]) % 2 == 0){
            g.add_edge(s, i, 1);
            for(int j = 0; j < i; j++){
                if(__builtin_popcount(A[j]) % 2 == 1){
                    g.add_edge(i, j, 1);
                }
            }
        }
        else{
            g.add_edge(i, t, 1);
        }
    }
    cout << n - g.flow(s, t) << "\n";

}
0