Submission #376621

#TimeUsernameProblemLanguageResultExecution timeMemory
376621MatheusLealVXoractive (IZhO19_xoractive)C++17
100 / 100
7 ms512 KiB
#include "interactive.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(x) begin(x), end(x)
using namespace std;

vector<int> guess(int n) {
	vector <int> ans (n);
	map<int, int> pos;
	ans[0] = ask(1);
	pos[ans[0]]=1;
	for(int i = 0; i < 7; i++){
		map<int, int> cont;
		vector<int> A, B = {1};
		for(int j = 2; j <= n; j++){
			if(j&(1<<i)){
				A.pb(j);
				B.pb(j);
			}
		}
		if(A.empty()) continue;
		auto ans_A = get_pairwise_xor(A);
		auto ans_B = get_pairwise_xor(B);
		sort(all(ans_A));
		sort(all(ans_B));
		for(auto x: ans_B){
			int cnt_A = upper_bound(all(ans_A), x) - lower_bound(all(ans_A), x);
			int cnt_B = upper_bound(all(ans_B), x) - lower_bound(all(ans_B), x);
			if(cnt_B > cnt_A and x != ans[1]){
				pos[x^ans[0]] |= (1<<i);
			}
		}
	}
	for(auto x: pos) ans[x.s-1] = x.f;
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...