Submission #1132274

#TimeUsernameProblemLanguageResultExecution timeMemory
1132274MuhammetXoractive (IZhO19_xoractive)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "interactive.h"
#include "grader.cpp"

using namespace std;

#define SZ(s) (int)s.size()
#define ff first
#define ss second

map <int,int> vis, vis1, mp;

vector<int> guess(int n) {
	vector <int> v, v1, v2;
	int x = (ask(1));
	mp[1] = x;
	vector <vector <int>> vc, vc1;
	vector <pair<int,int>> ve, ve1;
	vc.push_back({0});
	ve.push_back({2,n});
	int cnt = -1;
	while(SZ(vc) > 0) {
		v.clear(), v1.clear(), v2.clear();
		cnt++;
		for(int i = 0; i < SZ(vc); i++){
			int l = ve[i].ff, r = ve[i].ss;
			for(int j = l; j <= ((l + r) / 2); j++){
				v.push_back(j);
			}
		}
		if(SZ(v) == 0) break;
		v.push_back(1);
		v1 = get_pairwise_xor(v);
		v.pop_back();
		v2 = get_pairwise_xor(v);
		vis.clear(), vis1.clear();
		vis[0]++;
		for(auto i : v2) {
			vis[i]++;
		}
		vector <int> v3;
		for(auto i : v1) {
			if(vis[i]) vis[i]--;
			else {
				if(vis1[i^x] == 0){
					vis1[i^x] = true;
					v3.push_back(i^x);
				}
			}
		}
		// if(!cnt){
		// 	vc[0] = v3;
		// 	ve[0] = {2,n};
		// 	continue;
		// }
		int ind = 0;
		for(int i = 0; i < SZ(vc); i++){
			vector <int> vec;
			int l = ve[i].ff, r = ve[i].ss;
			if(SZ(vc[i]) == 1) {
				ind = i;
				for(auto j : v3){
					if(vis1[j] == true) vec.push_back(j);
				}
				if(SZ(vec) == 1) mp[l] = vec[0];
				else vc1.push_back(vec), ve1.push_back({l,(l+r)/2});
				if((r-l+1) - SZ(vec) == 1) continue;
				else vc1.push_back({0}), ve1.push_back({(l+r)/2+1,r});
				continue;
			}
			for(auto j : vc[i]){
				if(vis1.find(j) != vis1.end()) vec.push_back(j);
			}
			if(SZ(vec) == 1) mp[l] = vec[0];
			else vc1.push_back(vec), ve1.push_back({l,(l+r)/2});
			vec.clear();
			for(auto j : vc[i]){
				if(vis1.find(j) == vis1.end()) vec.push_back(j);
			}
			if(SZ(vec) == 1) mp[r] = vec[0];
			else vc1.push_back(vec), ve1.push_back({(l+r)/2+1,r});
			for(auto j : vc[i]){
				if(vis1.find(j) != vis1.end()) vis1[j] = false;
			}
			vec.clear();
		}
		vc = vc1;
		vc1.clear();
		ve = ve1;
		ve1.clear();
	}
	vector <int> ans;
	for(int i = 1; i <= n; i++){
		ans.push_back(mp[i]);
	}
	ans[n-1] = ask(n);
	return ans;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccvdIX3y.o: in function `query()':
grader.cpp:(.text+0x460): multiple definition of `query()'; /tmp/cc4GboqL.o:Xoractive.cpp:(.text+0x960): first defined here
/usr/bin/ld: /tmp/ccvdIX3y.o: in function `ask(int)':
grader.cpp:(.text+0x490): multiple definition of `ask(int)'; /tmp/cc4GboqL.o:Xoractive.cpp:(.text+0x990): first defined here
/usr/bin/ld: /tmp/ccvdIX3y.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc4GboqL.o:Xoractive.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccvdIX3y.o: in function `get_pairwise_xor(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x4f0): multiple definition of `get_pairwise_xor(std::vector<int, std::allocator<int> >)'; /tmp/cc4GboqL.o:Xoractive.cpp:(.text+0x9f0): first defined here
collect2: error: ld returned 1 exit status