Submission #991176

#TimeUsernameProblemLanguageResultExecution timeMemory
991176tch1cherinXoractive (IZhO19_xoractive)C++17
100 / 100
4 ms596 KiB
#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> guess(int n) {
  vector<int> a(n);
  a[0] = ask(1);
  map<int, int> pos;
  for (int bit = 0; bit < 7; bit++) {
    vector<int> ind;
    for (int i = 1; i < n; i++) {
      if ((i >> bit) & 1) {
        ind.push_back(1 + i);
      }
    }
    if (ind.empty()) {
      continue;
    }
    vector<int> ind_1 = ind;
    ind_1.push_back(1);
    vector<int> vals = get_pairwise_xor(ind);
    vector<int> vals_1 = get_pairwise_xor(ind_1);
    map<int, int> cnt;
    for (int value : vals_1) {
      cnt[value]++;
    }
    for (int value : vals) {
      cnt[value]--;
    }
    cnt[0]--;
    for (auto [key, value] : cnt) {
      if (value > 0) {
        pos[key ^ a[0]] |= 1 << bit;
      }
    }
  }
  for (auto [key, value] : pos) {
    a[value] = key;
  }
  return a;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...