結果

問題 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,345 ms
コンパイル使用メモリ 204,040 KB
実行使用メモリ 36,340 KB
最終ジャッジ日時 2024-04-14 03:56:21
合計ジャッジ時間 6,307 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 4 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 101 ms
27,916 KB
testcase_09 AC 23 ms
10,880 KB
testcase_10 AC 73 ms
22,740 KB
testcase_11 AC 54 ms
18,632 KB
testcase_12 AC 115 ms
31,484 KB
testcase_13 AC 122 ms
33,144 KB
testcase_14 AC 70 ms
21,888 KB
testcase_15 AC 132 ms
35,452 KB
testcase_16 AC 113 ms
30,848 KB
testcase_17 AC 119 ms
32,580 KB
testcase_18 AC 5 ms
6,944 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 13 ms
6,940 KB
testcase_21 AC 136 ms
36,340 KB
testcase_22 AC 136 ms
36,288 KB
testcase_23 AC 4 ms
6,944 KB
testcase_24 AC 4 ms
6,940 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 4 ms
6,940 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 131 ms
35,196 KB
testcase_35 AC 135 ms
36,220 KB
testcase_36 AC 133 ms
35,968 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