Submission #370472

# Submission time Handle Problem Language Result Execution time Memory
370472 2021-02-24T04:02:40 Z casperwang Xoractive (IZhO19_xoractive) C++14
0 / 100
1000 ms 504 KB
#include "interactive.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#define debug(args...) kout("[ " + string(#args) + " ]", args)
void kout() { cerr << endl; }
template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); }
template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; }

vector<int> guess(int n) {
	vector <int> G;

  for (int i = 2; i <= n; i++)
    G.pb(i);
  vector <int> exp = get_pairwise_xor(G);
  G.pb(1);
  vector <int> all = get_pairwise_xor(G);

  vector <int> ans(n);
  set <int> nums;
  vector <int> arr, pos(n);
  ans[0] = ask(1);
  int j = 0;
  for (int i = 0; i < exp.size(); i++, j++)
    while (all[j] != exp[i])
      nums.insert(all[j++] ^ ans[0]);
  while (j < all.size()) nums.insert(all[j++] ^ ans[0]);
  for (int i : nums) arr.pb(i);

  for (int i = 0; (1<<i) < n; i++) {
    G.clear();
    for (int j = 0; j < n; j++)
      if (j & (1<<i)) G.pb(j+1);
    vector <int> res = get_pairwise_xor(G);
    vector <int> tmp, nxt;
    for (int j = 0; j < n; j++) tmp.pb(j);
    while (tmp.size() > G.size()) {
      for (int j : tmp) {
        int cnt = 0;
        for (int k : tmp) {
          int val = arr[j] ^ arr[k];
          if (res[res.size()-1] >= val && *lower_bound(res.begin(), res.end(), val) == val)
            cnt++;
        }
        if (cnt >= G.size()) nxt.pb(j);
      }
      tmp = nxt;
      nxt.clear();
    }
    for (int j : tmp) pos[j] += (1<<i);
  }
  for (int i = 0; i < n; i++)
    ans[pos[i]] = arr[i];
	return ans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int i = 0; i < exp.size(); i++, j++)
      |                   ~~^~~~~~~~~~~~
Xoractive.cpp:27:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   while (j < all.size()) nums.insert(all[j++] ^ ans[0]);
      |          ~~^~~~~~~~~~~~
Xoractive.cpp:45:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         if (cnt >= G.size()) nxt.pb(j);
      |             ~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Execution timed out 3096 ms 364 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 492 KB Output is correct
2 Correct 7 ms 492 KB Output is correct
3 Execution timed out 3095 ms 492 KB Time limit exceeded
4 Halted 0 ms 0 KB -