답안 #914383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914383 2024-01-21T20:28:50 Z amirhoseinfar1385 도서관 (JOI18_library) C++17
0 / 100
23 ms 1524 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
const int maxn=1000+10;
int vis[maxn],n;
vector<int>ers;

int findsar(){
	for(int i=0;i<n;i++){
		ers.clear();
		ers.resize(n,1);
		ers[i]=0;
		int r=Query(ers);
		if(r==1){
			return i;
		}
	}
	return 0;
}

int findbad(vector<int>r,vector<int>s){
//	cout<<"wtf: "<<(int)r.size()<<" "<<s.size()<<endl;
	if((int)s.size()==1){
		return s[0];
	}
	int m=(int)s.size();
	m>>=1;
	ers.clear();
	ers.resize(n);
	for(auto x:r){
		ers[x]=1;
	}
	for(int i=0;i<m;i++){
		ers[s[i]]=1;
	}
	int resr=Query(ers);
	ers.clear();
	ers.resize(n);
	for(int i=0;i<m;i++){
		ers[s[i]]=1;
	}
	int resrr=Query(ers);
	if(resrr==resr){
		vector<int>fake;
		for(int i=0;i<m;i++){
			fake.push_back(s[i]);
		}
		return findbad(r,fake);
	}
	vector<int>fake;
	for(int i=m;i<(int)s.size();i++){
		fake.push_back(s[i]);
	}
	return findbad(r,fake);
}

void Solve(int N)
{
	n=N;
	int av=findsar();
	vector<int>res={av};
	vis[av]=1;
	//cout<<av<<endl;
	for(int i=0;i<N-1;i++){
		vector<int>all;
		for(int j=0;j<n;j++){
			if(vis[j]==0){
				all.push_back(j);
			}
		}
		res.push_back(findbad(res,all));
		vis[res.back()]=1;
	}
	for(int i=0;i<n;i++){
		res[i]++;
	}
	Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 948 KB # of queries: 2375
2 Correct 18 ms 1200 KB # of queries: 2409
3 Correct 20 ms 1464 KB # of queries: 2648
4 Correct 19 ms 1524 KB # of queries: 2595
5 Correct 19 ms 1496 KB # of queries: 2508
6 Correct 18 ms 1504 KB # of queries: 2551
7 Correct 23 ms 1208 KB # of queries: 2544
8 Correct 20 ms 1456 KB # of queries: 2420
9 Correct 18 ms 1464 KB # of queries: 2546
10 Correct 11 ms 1212 KB # of queries: 1474
11 Runtime error 1 ms 440 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 948 KB # of queries: 2375
2 Correct 18 ms 1200 KB # of queries: 2409
3 Correct 20 ms 1464 KB # of queries: 2648
4 Correct 19 ms 1524 KB # of queries: 2595
5 Correct 19 ms 1496 KB # of queries: 2508
6 Correct 18 ms 1504 KB # of queries: 2551
7 Correct 23 ms 1208 KB # of queries: 2544
8 Correct 20 ms 1456 KB # of queries: 2420
9 Correct 18 ms 1464 KB # of queries: 2546
10 Correct 11 ms 1212 KB # of queries: 1474
11 Runtime error 1 ms 440 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -