Submission #870529

#TimeUsernameProblemLanguageResultExecution timeMemory
870529KiaRezXoractive (IZhO19_xoractive)C++17
94 / 100
4 ms832 KiB
/*
    IN THE NAME OF GOD
*/
#include <bits/stdc++.h>
#include "interactive.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;

#define F                                      first
#define S                                      second
#define Mp                                     make_pair
#define pb                                     push_back
#define pf                                     push_front
#define size(x)                                ((ll)x.size())
#define all(x)                                 (x).begin(),(x).end()
#define kill(x)		                           cout << x << '\n', exit(0);
#define fuck(x)                                cout << "(" << #x << " , " << x << ")" << endl
#define endl                                   '\n'

vector<int> guess(int n) {
	vector<int> ans;
	ans.pb(ask(1));
	for(int i=0; i<n-1; i++) ans.pb(0);

	vector<int> vec[n+1];
	map<int, int> mp[10], mp2[10];
	set<int> st;

	for(int b=0; b<7; b++) {
		for(int i=2; i<=n; i++) {
			if((i&(1<<b)) > 0) {
				vec[b].pb(i);
			}
		}
		vector<int> tmp[2];
		for(auto it : vec[b]) {
			tmp[0].pb(it); tmp[1].pb(it);
		}
		tmp[1].pb(1);

		tmp[0] = get_pairwise_xor(tmp[0]);
		tmp[1] = get_pairwise_xor(tmp[1]);
		for(auto it : tmp[1]) {
			mp[b][it] ++;
		}
		for(auto it : tmp[0]) {
			mp[b][it] --;
		}
		mp[b][0]--;
		for(auto it : mp[b]) {
			if(it.S == 2) {
				mp2[b][it.F^ans[0]] ++;
				st.insert(it.F^ans[0]);
			}
		}
	}

	for(auto it : st) {
		int x = 0;
		for(int b=0; b<7; b++) {
			if(mp2[b][it] == 1) {
				x += (1<<b);
			}
		}
		ans[x - 1] = it;
	}

	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...