結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,484 KB
testcase_01 AC 5 ms
6,436 KB
testcase_02 AC 5 ms
6,480 KB
testcase_03 AC 5 ms
6,496 KB
testcase_04 AC 6 ms
6,416 KB
testcase_05 AC 6 ms
6,484 KB
testcase_06 AC 5 ms
6,632 KB
testcase_07 AC 5 ms
6,480 KB
testcase_08 AC 95 ms
27,960 KB
testcase_09 AC 23 ms
11,000 KB
testcase_10 AC 70 ms
22,444 KB
testcase_11 AC 57 ms
18,792 KB
testcase_12 AC 108 ms
30,992 KB
testcase_13 AC 116 ms
32,508 KB
testcase_14 AC 69 ms
21,668 KB
testcase_15 AC 124 ms
34,584 KB
testcase_16 AC 109 ms
30,212 KB
testcase_17 AC 113 ms
32,092 KB
testcase_18 AC 5 ms
6,440 KB
testcase_19 AC 5 ms
6,420 KB
testcase_20 AC 22 ms
9,720 KB
testcase_21 AC 129 ms
35,488 KB
testcase_22 AC 129 ms
35,864 KB
testcase_23 AC 6 ms
6,444 KB
testcase_24 AC 6 ms
6,528 KB
testcase_25 AC 6 ms
6,432 KB
testcase_26 AC 5 ms
6,480 KB
testcase_27 AC 6 ms
6,448 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 126 ms
35,076 KB
testcase_34 AC 124 ms
34,820 KB
testcase_35 AC 129 ms
35,468 KB
testcase_36 AC 127 ms
35,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector<int> g[61+100000];
int match[61+100000];
int 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;
  
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    for (int j = 0; j <= 60; j++) {
      if (a & 1LL<<j)
        add_edge(j, i);
    }
  }

  cout << (1LL<<bipartite_matching()) << endl;
  
  return 0;
}
0