답안 #914387

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914387 2024-01-21T21:01:47 Z amirhoseinfar1385 도서관 (JOI18_library) C++17
100 / 100
192 ms 1908 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()==0){
		return 0;
	}
	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;
	if(n==1){
		Answer({1});
		return ;		
	}
	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 20 ms 1504 KB # of queries: 2375
2 Correct 17 ms 1208 KB # of queries: 2409
3 Correct 24 ms 952 KB # of queries: 2648
4 Correct 18 ms 1480 KB # of queries: 2595
5 Correct 18 ms 980 KB # of queries: 2508
6 Correct 21 ms 1232 KB # of queries: 2551
7 Correct 19 ms 1508 KB # of queries: 2544
8 Correct 22 ms 728 KB # of queries: 2420
9 Correct 20 ms 1252 KB # of queries: 2546
10 Correct 9 ms 948 KB # of queries: 1474
11 Correct 1 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 1
13 Correct 0 ms 344 KB # of queries: 4
14 Correct 1 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 77
16 Correct 2 ms 544 KB # of queries: 183
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1504 KB # of queries: 2375
2 Correct 17 ms 1208 KB # of queries: 2409
3 Correct 24 ms 952 KB # of queries: 2648
4 Correct 18 ms 1480 KB # of queries: 2595
5 Correct 18 ms 980 KB # of queries: 2508
6 Correct 21 ms 1232 KB # of queries: 2551
7 Correct 19 ms 1508 KB # of queries: 2544
8 Correct 22 ms 728 KB # of queries: 2420
9 Correct 20 ms 1252 KB # of queries: 2546
10 Correct 9 ms 948 KB # of queries: 1474
11 Correct 1 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 1
13 Correct 0 ms 344 KB # of queries: 4
14 Correct 1 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 77
16 Correct 2 ms 544 KB # of queries: 183
17 Correct 189 ms 1824 KB # of queries: 17982
18 Correct 164 ms 1484 KB # of queries: 17293
19 Correct 174 ms 1312 KB # of queries: 17467
20 Correct 172 ms 1416 KB # of queries: 16325
21 Correct 176 ms 1908 KB # of queries: 15324
22 Correct 172 ms 1572 KB # of queries: 17669
23 Correct 192 ms 1396 KB # of queries: 17224
24 Correct 67 ms 1468 KB # of queries: 7915
25 Correct 175 ms 1272 KB # of queries: 17136
26 Correct 161 ms 1840 KB # of queries: 15963
27 Correct 75 ms 704 KB # of queries: 8040
28 Correct 170 ms 1276 KB # of queries: 15957
29 Correct 161 ms 1632 KB # of queries: 15939
30 Correct 166 ms 1232 KB # of queries: 15957