Submission #631835

#TimeUsernameProblemLanguageResultExecution timeMemory
631835gromperenXoractive (IZhO19_xoractive)C++14
100 / 100
6 ms484 KiB
#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;

// find bit by bit location of each value x
vector<int> guess(int n) {
	vector <int> ans(n);
	ans[0] = ask(1);
	map<int,int> loc;
	for (int i =0; i <7; ++i) { // 2^7 > 100
		vector<int> cur;
		for (int j = 2; j <=n; ++j) if ((j >> i) & 1) cur.push_back(j);
		if (cur.empty())continue;
		vector<int> a1 = get_pairwise_xor(cur);
		cur.push_back(1);
		vector<int> a2 = get_pairwise_xor(cur);
		map<int,int> cnt;
		for (auto x : a1) cnt[x]++;
		for (auto x : a2) {
			cnt[x]--;
			if (x != 0 && cnt[x] == -1) loc[x^ans[0]] |= (1<<i);
		}
	}
	for (auto i : loc) {
		ans[i.second-1] = i.first;
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...