답안 #286999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286999 2020-08-31T08:49:54 Z mosiashvililuka 도서관 (JOI18_library) C++14
100 / 100
401 ms 540 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;
void bewdva(vector <int> q){
	for(int h=0; h<q.size(); h++) cout<<q[h]<<" ";
	cout<<endl;
	//exit(0);
}
int a,b,c,d,e,i,j,ii,jj,zx,xc,p[1009],fx[1009];
void rec(vector <int> q){
	//cout<<p[i]<<"     ";
	//bewdva(q);
	if(q.size()==1){
		p[i+1]=q[0];
		return;
	}
	vector <int> w;
	while(w.size()<q.size()){
		w.push_back(q[q.size()-1]);
		q.pop_back();
	}
	vector <int> v;
	for(j=1; j<=a; j++) v.push_back(0);
	v[p[i]-1]=1;
	for(j=0; j<q.size(); j++){
		v[q[j]-1]=1;
	}
	//bewdva(v);
	int qw=Query(v);
	v[p[i]-1]=0;
	//bewdva(v);
	int we=Query(v);
	if(qw==we){
		rec(q);
	}else{
		rec(w);
	}
}
void Solve(int N){
	a=N;
	vector <int> v,vv;
	if(a<=2){
		for(i=1; i<=a; i++) vv.push_back(i);
		Answer(vv);
	}else{
	for(i=1; i<=a; i++) v.push_back(1);
	for(i=1; i<=a; i++){
		v[i-1]=0;
		c=Query(v);
		if(c==1){
			if(zx==0){
				zx=i;
			}else{
				xc=i;
			}
		}
		v[i-1]=1;
	}
	p[1]=zx;p[a]=xc;
	fx[zx]=1;fx[xc]=1;
	for(i=1; i<a-1; i++){
		v.clear();
		for(j=1; j<=a; j++) if(fx[j]==0) v.push_back(j);
		rec(v);
		fx[p[i+1]]=1;
	}
	/*cout<<"#23";
	exit(0);*/
	for(i=1; i<=a; i++){
		if(fx[i]==0){
			p[a-1]=i;
			break;
		}
	}
	v.clear();
	for(i=1; i<=a; i++) v.push_back(p[i]);
	//bewdva(v);
	Answer(v);
    }
}

Compilation message

library.cpp: In function 'void bewdva(std::vector<int>)':
library.cpp:5:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |  for(int h=0; h<q.size(); h++) cout<<q[h]<<" ";
      |               ~^~~~~~~~~
library.cpp: In function 'void rec(std::vector<int>)':
library.cpp:25:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(j=0; j<q.size(); j++){
      |           ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 384 KB # of queries: 2562
2 Correct 39 ms 384 KB # of queries: 2543
3 Correct 40 ms 384 KB # of queries: 2684
4 Correct 41 ms 384 KB # of queries: 2684
5 Correct 44 ms 384 KB # of queries: 2698
6 Correct 40 ms 384 KB # of queries: 2684
7 Correct 36 ms 384 KB # of queries: 2672
8 Correct 28 ms 376 KB # of queries: 2547
9 Correct 41 ms 384 KB # of queries: 2667
10 Correct 30 ms 384 KB # of queries: 1575
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 0
13 Correct 0 ms 384 KB # of queries: 3
14 Correct 1 ms 256 KB # of queries: 6
15 Correct 1 ms 256 KB # of queries: 83
16 Correct 3 ms 540 KB # of queries: 197
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 384 KB # of queries: 2562
2 Correct 39 ms 384 KB # of queries: 2543
3 Correct 40 ms 384 KB # of queries: 2684
4 Correct 41 ms 384 KB # of queries: 2684
5 Correct 44 ms 384 KB # of queries: 2698
6 Correct 40 ms 384 KB # of queries: 2684
7 Correct 36 ms 384 KB # of queries: 2672
8 Correct 28 ms 376 KB # of queries: 2547
9 Correct 41 ms 384 KB # of queries: 2667
10 Correct 30 ms 384 KB # of queries: 1575
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 0
13 Correct 0 ms 384 KB # of queries: 3
14 Correct 1 ms 256 KB # of queries: 6
15 Correct 1 ms 256 KB # of queries: 83
16 Correct 3 ms 540 KB # of queries: 197
17 Correct 353 ms 376 KB # of queries: 18128
18 Correct 371 ms 504 KB # of queries: 17957
19 Correct 386 ms 504 KB # of queries: 18146
20 Correct 320 ms 372 KB # of queries: 16908
21 Correct 345 ms 376 KB # of queries: 15925
22 Correct 383 ms 376 KB # of queries: 18108
23 Correct 393 ms 504 KB # of queries: 18131
24 Correct 104 ms 372 KB # of queries: 8279
25 Correct 401 ms 376 KB # of queries: 17723
26 Correct 312 ms 508 KB # of queries: 16523
27 Correct 168 ms 376 KB # of queries: 8245
28 Correct 358 ms 504 KB # of queries: 16938
29 Correct 374 ms 504 KB # of queries: 16919
30 Correct 354 ms 504 KB # of queries: 16938