結果
| 問題 | No.184 たのしい排他的論理和(HARD) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-01 22:45:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,136 bytes |
| 記録 | |
| コンパイル時間 | 1,838 ms |
| コンパイル使用メモリ | 202,104 KB |
| 最終ジャッジ日時 | 2025-01-19 09:03:01 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 WA * 5 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
vector<int> g[61 + 100000];
int match[61 + 100000];
bool used[61 + 100000];
void add_edge(int u, int v) {
g[u].push_back(61 + v);
g[61 + v].push_back(u);
}
bool dfs(int v) {
used[v] = true;
for (int i = 0; i < g[v].size(); i++) {
int u = g[v][i];
int w = match[u];
if (w < 0 || !used[w] && dfs(w)) {
match[v] = u;
match[u] = v;
return true;
}
}
return false;
}
int bipartite_matching() {
int ret = 0;
memset(match, -1, sizeof(match));
for (int v = 0; v <= 60; v++) {
if (match[v] < 0) {
memset(used, 0, sizeof(used));
if (dfs(v)) {
++ret;
}
}
}
return ret;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a.begin(), a.end());
a.erase(unique(a.begin(), a.end()), a.end());
for (int i = 0; i < a.size(); i++) {
for (int j = 0; j <= 60; j++) {
if (a[i] & 1LL << j)
add_edge(j, i);
}
}
cout << (1LL<<bipartite_matching()) << endl;
return 0;
}