Submission #4545793


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0;(i)<(int)(n);(i)++)

using ll = long long;

int N;
ll K, a[100010];

string tobs(ll x) {
  string res;
  REP(i,60) {
    if (x & (1LL << i)) res += '1';
    else res += '0';
  }
  reverse(res.begin(), res.end());
  return res;
}

int main() {
  cin >> N >> K;
  REP(i,N) scanf("%lld", &a[i]);

  int cnt[60];
  REP(i,60) cnt[i] = 0;
  REP(i,N) {
    string bs = tobs(a[i]);
    REP(j,bs.length()) if (bs[j] == '1') cnt[j]++;
  }

  ll k = 0;
  REP(i,60) {
    int digit = 60 - i - 1;
    // cout << cnt[i] << ' ' << (1LL<<digit) << endl;
    if (cnt[i] <= N / 2 && (1LL<<digit) + k <= K) {
      k += (1LL<<digit);
    }
  }

  ll res = 0LL;
  REP(i,N) res += (k ^ a[i]);
  cout << res << endl;

  return 0;
}

Submission Info

Submission Time
Task D - XXOR
User jyane
Language C++14 (GCC 5.4.1)
Score 400
Code Size 836 Byte
Status AC
Exec Time 106 ms
Memory 1024 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:24:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   REP(i,N) scanf("%lld", &a[i]);
                                ^

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 25
AC × 3
Set Name Test Cases
All 0_normal_1, 0_normal_2, 0_normal_3, 0_normal_4, 0_normal_5, 0_normal_6, 0_normal_7, 0_normal_8, 0_normal_9, 1_max_1, 1_max_2, 1_max_3, 1_max_4, 1_max_5, 1_max_6, 1_max_7, 1_max_8, 2_beki_1, 2_beki_2, 3_hand_1, 3_hand_2, 3_hand_3, sample_01, sample_02, sample_03
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
0_normal_1 AC 65 ms 768 KiB
0_normal_2 AC 10 ms 256 KiB
0_normal_3 AC 81 ms 768 KiB
0_normal_4 AC 44 ms 512 KiB
0_normal_5 AC 58 ms 640 KiB
0_normal_6 AC 82 ms 896 KiB
0_normal_7 AC 86 ms 896 KiB
0_normal_8 AC 84 ms 896 KiB
0_normal_9 AC 54 ms 640 KiB
1_max_1 AC 106 ms 1024 KiB
1_max_2 AC 106 ms 1024 KiB
1_max_3 AC 105 ms 1024 KiB
1_max_4 AC 106 ms 1024 KiB
1_max_5 AC 105 ms 1024 KiB
1_max_6 AC 105 ms 1024 KiB
1_max_7 AC 106 ms 1024 KiB
1_max_8 AC 106 ms 1024 KiB
2_beki_1 AC 87 ms 896 KiB
2_beki_2 AC 81 ms 896 KiB
3_hand_1 AC 76 ms 1024 KiB
3_hand_2 AC 74 ms 1024 KiB
3_hand_3 AC 83 ms 1024 KiB
sample_01 AC 2 ms 256 KiB
sample_02 AC 2 ms 256 KiB
sample_03 AC 1 ms 256 KiB