結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー kk
提出日時 2021-03-01 22:02:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 994 bytes
コンパイル時間 2,836 ms
コンパイル使用メモリ 197,176 KB
実行使用メモリ 36,088 KB
最終ジャッジ日時 2024-04-14 03:53:59
合計ジャッジ時間 7,612 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,812 KB
testcase_01 AC 5 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 5 ms
6,940 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 100 ms
28,028 KB
testcase_09 AC 24 ms
11,116 KB
testcase_10 AC 75 ms
22,720 KB
testcase_11 AC 57 ms
18,888 KB
testcase_12 AC 114 ms
31,100 KB
testcase_13 AC 123 ms
32,824 KB
testcase_14 AC 71 ms
21,760 KB
testcase_15 AC 130 ms
34,836 KB
testcase_16 AC 110 ms
30,404 KB
testcase_17 AC 121 ms
32,324 KB
testcase_18 AC 5 ms
6,940 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 22 ms
10,000 KB
testcase_21 AC 137 ms
35,712 KB
testcase_22 AC 136 ms
36,088 KB
testcase_23 AC 5 ms
6,940 KB
testcase_24 AC 4 ms
6,940 KB
testcase_25 AC 4 ms
6,944 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 5 ms
6,944 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 131 ms
35,392 KB
testcase_34 AC 130 ms
34,688 KB
testcase_35 AC 134 ms
35,708 KB
testcase_36 AC 134 ms
35,456 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