Submission #1306759

#TimeUsernameProblemLanguageResultExecution timeMemory
1306759Robert_juniorXoractive (IZhO19_xoractive)C++20
100 / 100
4 ms504 KiB
#include "interactive.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
vector<int>get(vector<int>v){
    vector<int>v1 = get_pairwise_xor(v);
    v.pb(1);
    vector<int>v2 = get_pairwise_xor(v);
    map<int, int>mp;
    for(auto it : v2){
        mp[it]++;
    }
    for(auto it : v1){
        mp[it]--;
    }
    vector<int>ans;
    for(auto it : mp){
        if(it.S > 0 && it.F > 0){
            ans.pb(it.F);
        }
    }
    return ans;
}
vector<int>guess(int n) {
	vector<int>ans(n);
	map<int, int>mp;
	for(int i = 0; (1<<i) <= n; i++){
	    vector<int>v;
	    for(int j = 2; j <= n; j++){
	        if((j>>i) & 1) v.pb(j);
	    }
	    vector<int>v1 = get(v);
	    for(auto it : v1){
	        mp[it] += (1<<i);
	    }
	}
	int x = ask(1);
	ans[0] = x;
	for(auto it : mp){
	    ans[it.S - 1] = (it.F ^ x);
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...