답안 #225280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225280 2020-04-20T07:28:12 Z kshitij_sodani 도서관 (JOI18_library) C++17
0 / 100
552 ms 504 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(ll==n-1 and aa[n-1]==2){
			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;
	for(int i=0;i<n;i++){
		int y=x;
		if(i==n-1 and st==0){
			break;
		}
		ll=-2;
		solve(x,0,n-1);
		if(ll==-2){
			while(true){
				continue;
			}
		}
		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;
}*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 384 KB Wrong Answer [6]
2 Incorrect 57 ms 256 KB Wrong Answer [6]
3 Incorrect 64 ms 384 KB Wrong Answer [6]
4 Incorrect 59 ms 384 KB Wrong Answer [6]
5 Incorrect 46 ms 256 KB Wrong Answer [8]
6 Incorrect 41 ms 288 KB Wrong Answer [6]
7 Incorrect 35 ms 256 KB Wrong Answer [6]
8 Incorrect 48 ms 256 KB Wrong Answer [6]
9 Incorrect 47 ms 256 KB Wrong Answer [6]
10 Incorrect 37 ms 256 KB Wrong Answer [6]
11 Correct 5 ms 256 KB # of queries: 0
12 Correct 4 ms 256 KB # of queries: 0
13 Incorrect 4 ms 256 KB Wrong Answer [8]
14 Correct 5 ms 384 KB # of queries: 6
15 Correct 6 ms 256 KB # of queries: 90
16 Incorrect 7 ms 256 KB Wrong Answer [6]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 384 KB Wrong Answer [6]
2 Incorrect 57 ms 256 KB Wrong Answer [6]
3 Incorrect 64 ms 384 KB Wrong Answer [6]
4 Incorrect 59 ms 384 KB Wrong Answer [6]
5 Incorrect 46 ms 256 KB Wrong Answer [8]
6 Incorrect 41 ms 288 KB Wrong Answer [6]
7 Incorrect 35 ms 256 KB Wrong Answer [6]
8 Incorrect 48 ms 256 KB Wrong Answer [6]
9 Incorrect 47 ms 256 KB Wrong Answer [6]
10 Incorrect 37 ms 256 KB Wrong Answer [6]
11 Correct 5 ms 256 KB # of queries: 0
12 Correct 4 ms 256 KB # of queries: 0
13 Incorrect 4 ms 256 KB Wrong Answer [8]
14 Correct 5 ms 384 KB # of queries: 6
15 Correct 6 ms 256 KB # of queries: 90
16 Incorrect 7 ms 256 KB Wrong Answer [6]
17 Incorrect 487 ms 504 KB Wrong Answer [6]
18 Incorrect 552 ms 384 KB Wrong Answer [6]
19 Incorrect 478 ms 504 KB Wrong Answer [6]
20 Incorrect 419 ms 384 KB Wrong Answer [6]
21 Incorrect 368 ms 384 KB Wrong Answer [6]
22 Incorrect 476 ms 380 KB Wrong Answer [6]
23 Incorrect 544 ms 404 KB Wrong Answer [6]
24 Incorrect 162 ms 384 KB Wrong Answer [6]
25 Incorrect 379 ms 384 KB Wrong Answer [6]
26 Incorrect 506 ms 376 KB Wrong Answer [6]
27 Incorrect 159 ms 504 KB Wrong Answer [6]
28 Correct 281 ms 380 KB # of queries: 10068
29 Correct 357 ms 504 KB # of queries: 10062
30 Correct 260 ms 504 KB # of queries: 10068