Submission #1092138

#TimeUsernameProblemLanguageResultExecution timeMemory
1092138juicyXoractive (IZhO19_xoractive)C++17
100 / 100
4 ms596 KiB
#include "interactive.h"

#include <bits/stdc++.h>

using namespace std;

void sub(vector<int> &a, vector<int> b) {
  for (int x : b) {
    a.erase(find(a.begin(), a.end(), x));
  }
}

vector<int> qry(vector<int> cnd) {
  vector<int> a = cnd;
  a.push_back(1);
  a = get_pairwise_xor(a);
  sub(a, get_pairwise_xor(cnd));
  a.erase(find(a.begin(), a.end(), 0));
  vector<int> nw;
  for (int i = 0; i < a.size(); i += 2) {
    nw.push_back(a[i]);
  }
  a.swap(nw);
  return a;
}

vector<int> guess(int n) {
  vector<int> a(n);
  a[0] = ask(1);
  int lg = __lg(n);
  vector<vector<int>> s(lg + 1);
  map<int, int> mp;
  for (int j = 0; j <= lg; ++j) {
    vector<int> cnd;
    for (int i = 2; i <= n; ++i) {
      if (i >> j & 1) {
        cnd.push_back(i);
      }
    } 
    s[j] = qry(cnd);
    for (int x : s[j]) {
      mp[x ^ a[0]] |= 1 << j;
    }
  }
  for (auto [x, i] : mp) {
    a[i - 1] = x;
  }
  return a;
}

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> qry(std::vector<int>)':
Xoractive.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int i = 0; i < a.size(); i += 2) {
      |                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...