結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー kk
提出日時 2021-03-01 22:45:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,136 bytes
コンパイル時間 2,925 ms
コンパイル使用メモリ 207,044 KB
実行使用メモリ 36,212 KB
最終ジャッジ日時 2023-07-26 13:56:15
合計ジャッジ時間 7,905 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,392 KB
testcase_01 AC 4 ms
6,268 KB
testcase_02 AC 4 ms
6,212 KB
testcase_03 AC 5 ms
6,188 KB
testcase_04 AC 4 ms
6,132 KB
testcase_05 AC 4 ms
6,136 KB
testcase_06 AC 4 ms
6,132 KB
testcase_07 AC 5 ms
6,272 KB
testcase_08 AC 98 ms
27,640 KB
testcase_09 AC 23 ms
10,724 KB
testcase_10 AC 72 ms
22,524 KB
testcase_11 AC 53 ms
18,532 KB
testcase_12 AC 113 ms
31,152 KB
testcase_13 AC 120 ms
32,976 KB
testcase_14 AC 69 ms
21,724 KB
testcase_15 AC 128 ms
35,356 KB
testcase_16 AC 109 ms
30,740 KB
testcase_17 AC 117 ms
32,300 KB
testcase_18 AC 4 ms
6,200 KB
testcase_19 AC 4 ms
6,188 KB
testcase_20 AC 12 ms
6,668 KB
testcase_21 AC 132 ms
36,024 KB
testcase_22 AC 134 ms
36,148 KB
testcase_23 AC 4 ms
6,176 KB
testcase_24 AC 4 ms
6,240 KB
testcase_25 AC 4 ms
6,252 KB
testcase_26 AC 4 ms
6,160 KB
testcase_27 AC 4 ms
6,232 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 130 ms
35,460 KB
testcase_34 AC 128 ms
35,092 KB
testcase_35 AC 132 ms
36,212 KB
testcase_36 AC 131 ms
35,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0