Submission #351100

#TimeUsernameProblemLanguageResultExecution timeMemory
351100kshitij_sodaniXoractive (IZhO19_xoractive)C++14
100 / 100
7 ms512 KiB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
#define endl '\n'
#define cc get_pairwise_xor 


#include "interactive.h"
using namespace std;
int it[101];

vector<int> proc(vector<int> aa,vector<int> bb){
	int ind=0;
	int ind2=0;
	vector<int> mm;

	while(ind<aa.size() or ind2<bb.size()){
		if(ind2==bb.size()){
			mm.pb(aa[ind]);
			ind++;
		}
		else{
			if(aa[ind]==bb[ind2]){
				ind++;
				ind2++;
				continue;
			}
			mm.pb(aa[ind]);
			ind++;
		}
	}
	return mm;
}
/*vector<int> cur[101];
void solve(vector<pair<int,int>> pp){
	if(pp.size()==0){
		return ;
	}
	vector<int> ss;
	for(auto j:pp){
		for(int k=j.a;k<=(j.a+j.b)/2;k++){
			ss.pb(k);
		}
	}
	vector<int> ee=cc(ss);
	ss.pb(1);
	vector<int> ff=cc(ss);
	vector<int> fin=proc(ff,ee);
	map<int,int> xx;
	for(auto j:fin){
		if(j!=0){
			xx[j^it[0]]++;
		}
	}
	vector<pair<int,int>> ne;
	for(auto j:pp){
		vector<int> a1;
		vector<int> a2;
		for(auto k:cur[j.a]){
			if(xx.find(k)!=xx.end()){
				a1.pb(k);
			}
			else{
				a2.pb(k);
			}
		}
		cur[j.a]=a1;
		cur[((j.a+j.b)/2)+1]=a2;
		int mid=(j.a+j.b)/2;
		if(mid>j.a){
			ne.pb({j.a,mid});
		}
		if(mid+1<j.b){
			ne.pb({mid+1,j.b});
		}
	}
	solve(ne);
}*/
map<int,int> ac[101];
vector<int> guess(int n) {
	it[0]=ask(1);
	vector<int> ss;
		for(int k=2;k<=n;k++){
			ss.pb(k);
		}
	set<int> cot;
	for(int i=0;i<7;i++){
		vector<int> ss;
		for(int k=2;k<=n;k++){
			if(k&(1<<i)){
				ss.pb(k);
				//cout<<k<<",";
			}
		}
		//cout<<endl;

			map<int,int> xx;
		if(ss.size()>0){

		
		vector<int> ee=cc(ss);
		ss.pb(1);
		vector<int> ff=cc(ss);
		vector<int> fin=proc(ff,ee);
	
		for(auto j:fin){
			if(j!=0){
				xx[j^it[0]]++;
				cot.insert(j^it[0]);
			}
		}
	}
		ac[i]=xx;
	}

	for(int i=2;i<=n;i++){
		for(auto j:cot){
			int st=1;
			for(int k=0;k<7;k++){
				if((i&(1<<k)) and ac[k].find(j)!=ac[k].end()){

				}
				else if((i&(1<<k))==0 and ac[k].find(j)==ac[k].end()){

				}
				else{
					st=0;
				}
			}
			if(st==1){
				it[i]=j;
			}
		}
	}
	/*vector<int> ee=cc(ss);
	ss.pb(1);
	vector<int> ff=cc(ss);
	vector<int> fin=proc(ff,ee);
	map<int,int> xx;
	for(auto j:fin){
		if(j!=0){
			xx[j^it[0]]++;
		}
	}
	for(auto j:xx){
		cur[2].pb(j.a);
	}


	solve({{2,n}});*/
	vector<int> ans;
	ans.pb(it[0]);
	for(int i=2;i<=n;i++){
		ans.pb(it[i]);
	}







	return ans;
}

Compilation message (stderr)

Xoractive.cpp: In function 'std::vector<int> proc(std::vector<int>, std::vector<int>)':
Xoractive.cpp:22:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  while(ind<aa.size() or ind2<bb.size()){
      |        ~~~^~~~~~~~~~
Xoractive.cpp:22:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  while(ind<aa.size() or ind2<bb.size()){
      |                         ~~~~^~~~~~~~~~
Xoractive.cpp:23:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if(ind2==bb.size()){
      |      ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...