답안 #286996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286996 2020-08-31T08:45:21 Z mosiashvililuka 도서관 (JOI18_library) C++14
0 / 100
47 ms 512 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);
		exit(0);
	}
	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 41 ms 384 KB # of queries: 2562
2 Correct 30 ms 384 KB # of queries: 2543
3 Correct 42 ms 384 KB # of queries: 2684
4 Correct 42 ms 384 KB # of queries: 2684
5 Correct 41 ms 384 KB # of queries: 2698
6 Correct 42 ms 512 KB # of queries: 2684
7 Correct 41 ms 384 KB # of queries: 2672
8 Correct 27 ms 388 KB # of queries: 2547
9 Correct 47 ms 384 KB # of queries: 2667
10 Correct 17 ms 380 KB # of queries: 1575
11 Incorrect 0 ms 256 KB Unexpected end of file - token expected
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 384 KB # of queries: 2562
2 Correct 30 ms 384 KB # of queries: 2543
3 Correct 42 ms 384 KB # of queries: 2684
4 Correct 42 ms 384 KB # of queries: 2684
5 Correct 41 ms 384 KB # of queries: 2698
6 Correct 42 ms 512 KB # of queries: 2684
7 Correct 41 ms 384 KB # of queries: 2672
8 Correct 27 ms 388 KB # of queries: 2547
9 Correct 47 ms 384 KB # of queries: 2667
10 Correct 17 ms 380 KB # of queries: 1575
11 Incorrect 0 ms 256 KB Unexpected end of file - token expected
12 Halted 0 ms 0 KB -