結果
| 問題 |
No.1900 Don't be Powers of 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-08 22:04:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 66 ms / 2,000 ms |
| コード長 | 825 bytes |
| コンパイル時間 | 3,436 ms |
| コンパイル使用メモリ | 259,264 KB |
| 実行使用メモリ | 35,652 KB |
| 最終ジャッジ日時 | 2024-11-28 12:46:35 |
| 合計ジャッジ時間 | 5,261 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/maxflow>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> A(N);
for (int &a : A)
cin >> a;
atcoder::mf_graph<int> G(N + 2);
vector<bool> dir(N);
for (int i = 0; i < N; i++)
{
if (popcount((unsigned)A[i]) & 1)
dir[i] = 1, G.add_edge(N, i, 1);
else
G.add_edge(i, N + 1, 1);
}
for (int i = 0; i < N; i++)
for (int j = 0; j < i; j++)
{
int k = A[j] ^ A[i];
if (k == (k & (-k)) && k != 0)
{
assert(dir[i] != dir[j]);
if (dir[i])
G.add_edge(i, j, 1);
else
G.add_edge(j, i, 1);
}
}
cout << N - G.flow(N, N + 1) << endl;
}