Submission #225318

# Submission time Handle Problem Language Result Execution time Memory
225318 2020-04-20T09:15:35 Z kshitij_sodani Library (JOI18_library) C++17
0 / 100
773 ms 632 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(aa[l]==0){
			ll=-1;
			return ;
		}

	/*	if(ind==l){
			ll=-1;
			while(true){
				continue;
			}
		}
		else{*/
			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){
				aa[l]=0;
				ll=l;
			}
			else{
				ll=-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){
				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;
	aa[0]=0;
	int cco=0;

	while(le and cco<2*n){
		cco+=1;
		int y=x;
		ll=-2;

		solve(x,0,n-1);

		if(ll!=-1){
			le-=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[x]=0;
		aa[y]=0;
	}
	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(5);


	return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 38 ms 256 KB # of queries: 2939
2 Correct 63 ms 256 KB # of queries: 2901
3 Correct 64 ms 384 KB # of queries: 3084
4 Correct 49 ms 256 KB # of queries: 3038
5 Correct 50 ms 256 KB # of queries: 3062
6 Correct 55 ms 256 KB # of queries: 3074
7 Correct 64 ms 384 KB # of queries: 3025
8 Correct 60 ms 256 KB # of queries: 2936
9 Correct 63 ms 256 KB # of queries: 3079
10 Incorrect 55 ms 384 KB Wrong Answer [5]
11 Correct 5 ms 384 KB # of queries: 0
12 Correct 5 ms 256 KB # of queries: 1
13 Correct 4 ms 256 KB # of queries: 5
14 Correct 5 ms 256 KB # of queries: 9
15 Correct 6 ms 384 KB # of queries: 104
16 Correct 10 ms 384 KB # of queries: 252
# Verdict Execution time Memory Grader output
1 Correct 38 ms 256 KB # of queries: 2939
2 Correct 63 ms 256 KB # of queries: 2901
3 Correct 64 ms 384 KB # of queries: 3084
4 Correct 49 ms 256 KB # of queries: 3038
5 Correct 50 ms 256 KB # of queries: 3062
6 Correct 55 ms 256 KB # of queries: 3074
7 Correct 64 ms 384 KB # of queries: 3025
8 Correct 60 ms 256 KB # of queries: 2936
9 Correct 63 ms 256 KB # of queries: 3079
10 Incorrect 55 ms 384 KB Wrong Answer [5]
11 Correct 5 ms 384 KB # of queries: 0
12 Correct 5 ms 256 KB # of queries: 1
13 Correct 4 ms 256 KB # of queries: 5
14 Correct 5 ms 256 KB # of queries: 9
15 Correct 6 ms 384 KB # of queries: 104
16 Correct 10 ms 384 KB # of queries: 252
17 Runtime error 715 ms 500 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Correct 518 ms 376 KB # of queries: 19485
19 Correct 536 ms 508 KB # of queries: 19763
20 Correct 523 ms 504 KB # of queries: 18573
21 Runtime error 641 ms 500 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 713 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Correct 599 ms 480 KB # of queries: 19748
24 Runtime error 392 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 773 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 702 ms 608 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Correct 218 ms 376 KB # of queries: 9064
28 Correct 318 ms 388 KB # of queries: 11067
29 Correct 293 ms 372 KB # of queries: 11060
30 Correct 271 ms 412 KB # of queries: 11067