結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー kk
提出日時 2021-03-01 22:44:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,109 bytes
コンパイル時間 4,098 ms
コンパイル使用メモリ 201,304 KB
実行使用メモリ 36,472 KB
最終ジャッジ日時 2024-04-14 03:55:28
合計ジャッジ時間 6,241 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 4 ms
6,944 KB
testcase_02 AC 5 ms
6,940 KB
testcase_03 AC 5 ms
6,940 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 98 ms
28,288 KB
testcase_09 AC 22 ms
10,864 KB
testcase_10 AC 75 ms
22,752 KB
testcase_11 AC 54 ms
18,888 KB
testcase_12 AC 114 ms
31,484 KB
testcase_13 AC 121 ms
33,216 KB
testcase_14 AC 70 ms
21,956 KB
testcase_15 AC 132 ms
35,452 KB
testcase_16 AC 109 ms
30,584 KB
testcase_17 AC 117 ms
32,832 KB
testcase_18 AC 5 ms
6,940 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 11 ms
6,944 KB
testcase_21 AC 134 ms
36,220 KB
testcase_22 AC 135 ms
36,472 KB
testcase_23 AC 4 ms
6,944 KB
testcase_24 AC 4 ms
6,944 KB
testcase_25 AC 4 ms
6,944 KB
testcase_26 AC 5 ms
6,940 KB
testcase_27 AC 5 ms
6,940 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 133 ms
35,704 KB
testcase_34 AC 130 ms
35,324 KB
testcase_35 AC 133 ms
36,004 KB
testcase_36 AC 133 ms
35,712 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];


  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