Submission #225282

# Submission time Handle Problem Language Result Execution time Memory
225282 2020-04-20T07:30:33 Z kshitij_sodani Library (JOI18_library) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <bits/stdc++.h>
#include "library.h"
using namespace std;

#define pb push_back
typedef long long llo;
#define a first
#define b second
int n;
vector<int> aa;
vector<int> bb;
/*void Answer(vector<int> cc){
	for(auto j:cc){
		cout<<j<<" ";
	}
	cout<<endl;
}
int Query(vector<int> cc){
	for(auto j:cc){
		cout<<j<<" ";
	}
	cout<<endl;
	int xx;
	cin>>xx;
	return xx;
}*/
int ll;
void solve(int ind,int l,int r){
	//cout<<l<<" "<<r<<endl;
	if(l==r){
	/*	if(l==n-1 and aa[n-1]==0){
			ll=-1;
		}
		else{
			ll=l;
		}*/
		for(int i=0;i<n;i++){
			if((ind==i or i==l)){

				bb[i]=1;
			}
			else{
				bb[i]=0;
			}
		}
		int yy=Query(bb);
		if(yy==1){
			//ll=l;
			ll=l;
		}
		else{
			ll=-1;
		//	return -1;
		}
	}
	else{
		int mid=(l+r)/2;
		int co=0;
		for(int i=0;i<n;i++){
			bb[i]=0;
		}
		for(int i=l;i<=mid;i++){
			if(aa[i]==2 and i!=ind){
				bb[i]=1;
				co+=1;
			}
		}
		if(co==0){
			solve(ind,mid+1,r);
		}
		else{
			bb[ind]=1;
			int yy=Query(bb);
			bb[ind]=0;
			int zz=Query(bb);
			if(yy==zz){
				solve(ind,l,mid);
			}
			else{
				solve(ind,mid+1,r);
			}
		}

	}
}
void Solve(int nn){
	n=nn;
	for(int i=0;i<n;i++){
		aa.pb(2);
		bb.pb(0);
	}
	int x=0;
	deque<int> ans;
	ans.push_back(0);
	int st=0;
	int kk=0;
	int le=n-1;
	for(le){
		int y=x;
		ll=-2;
		solve(x,0,n-1);
		if(ll!=-1){
			ll-=1;
		}
		x=ll;
		if(x==-1){
			x=0;
			st=1;
			kk+=1;
		}
		else{
			if(st==0){
				ans.push_back(x);
			}
			else{
				ans.push_front(x);
			}
		}
		aa[y]=0;
	}
	/*if(kk>1){
		while(true){
			continue;
		}
	}*/
	vector<int> fin;
	for(int i=0;i<n;i++){
		int x=ans.front();
		ans.pop_front();
		fin.pb(x+1);
	}
	Answer(fin);
}
/*int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	Solve(4);


	return 0;
}*/

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:99:8: error: expected ';' before ')' token
  for(le){
        ^
library.cpp:121:2: warning: statement has no effect [-Wunused-value]
  }
  ^
library.cpp:127:14: error: expected primary-expression before 'fin'
  vector<int> fin;
              ^~~
library.cpp:127:14: error: expected ';' before 'fin'
library.cpp:127:14: error: 'fin' was not declared in this scope
library.cpp:127:14: note: suggested alternative: 'sin'
  vector<int> fin;
              ^~~
              sin
library.cpp:127:17: error: expected ')' before ';' token
  vector<int> fin;
                 ^
library.cpp:131:3: error: 'fin' was not declared in this scope
   fin.pb(x+1);
   ^~~
library.cpp:131:3: note: suggested alternative: 'sin'
   fin.pb(x+1);
   ^~~
   sin
library.cpp:133:9: error: 'fin' was not declared in this scope
  Answer(fin);
         ^~~
library.cpp:133:9: note: suggested alternative: 'sin'
  Answer(fin);
         ^~~
         sin
library.cpp:93:6: warning: unused variable 'x' [-Wunused-variable]
  int x=0;
      ^
library.cpp:96:6: warning: unused variable 'st' [-Wunused-variable]
  int st=0;
      ^~
library.cpp:97:6: warning: unused variable 'kk' [-Wunused-variable]
  int kk=0;
      ^~