結果
問題 | No.1900 Don't be Powers of 2 |
ユーザー |
![]() |
提出日時 | 2022-04-08 23:01:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 1,396 bytes |
コンパイル時間 | 2,443 ms |
コンパイル使用メモリ | 226,224 KB |
最終ジャッジ日時 | 2025-01-28 16:41:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include<bits/stdc++.h>namespace {#pragma GCC diagnostic push#pragma GCC diagnostic ignored "-Wunused-function"#include<atcoder/all>#pragma GCC diagnostic popusing namespace std;using namespace atcoder;#define rep(i,n) for(int i = 0; i < (int)(n); i++)#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)#define all(x) begin(x), end(x)#define rall(x) rbegin(x), rend(x)template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }using ll = long long;using P = pair<int,int>;using VI = vector<int>;using VVI = vector<VI>;using VL = vector<ll>;using VVL = vector<VL>;} int main() {ios::sync_with_stdio(false);cin.tie(0);int n;cin >> n;VI a0, a1;rep(i, n) {int x;cin >> x;if (__builtin_parity(x)) a1.emplace_back(x);else a0.emplace_back(x);}int s0 = a0.size(), s1 = a1.size();int src = s0 + s1, snk = src + 1;mf_graph<int> g(snk + 1);rep(i, s0) g.add_edge(src, i, 1);rep(j, s1) g.add_edge(s0 + j, snk, 1);rep(i, s0) rep(j, s1) {int x = a0[i] ^ a1[j];if (x == (x & -x)) g.add_edge(i, s0 + j, 1);}g.flow(src, snk);auto cut = g.min_cut(src);int ans = 0;rep(i, s0) if (cut[i]) ans++;rep(j, s1) if (!cut[s0 + j]) ans++;cout << ans << '\n';}