답안 #268655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
268655 2020-08-16T16:17:38 Z DavidDamian 도서관 (JOI18_library) C++11
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
//#include "library.h"
using namespace std;
set<int> S; //Set with non fixed numbers
vector<int> Q;
vector<int> Q2;
vector<int> disc;
bool inRange(int L,int R)
{
    for(int i=L;i<=R;i++){
        Q[i-1]=1;
        if(disc[i-1]==0) Q2[i-1]=1;
    }
    int A=Query(Q);
    int B=Query(Q2);
    for(int i=L;i<=R;i++){
        Q2[i-1]=0;
        if(!disc[i-1]) Q[i-1]=0;
    }
    return A==B;
}
int binarySearch(int N)
{
    int L=1;
    int R=N;
    int x;
    while(L<R){
        int mid=(L+R)/2;
        auto it=S.lower_bound(L);
        int minimum=(*it);
        if(minimum<=mid && inRange(L,mid))
            R=mid;
        else
            L=mid+1;
    }
    if(L==R) x=L;
    return x;
}
void Solve(int N)
{
	vector<int> ANS(N);
	if(N==1){
        ANS[0]=1;
        Answer(ANS);
        return;
	}
	Q.resize(N);
	Q2.resize(N);
	disc.resize(N);
	for(int i=1;i<=N;i++){
        S.insert(i);
        Q[i-1]=1;
	}
	for(int i=1;i<=N;i++){
        Q[i-1]=0;
        if(Query(Q)==1){
            ANS[0]=i;
            S.erase(i);
            disc[i-1]=1;
            break;
        }
        Q[i-1]=1;
	}
	for(int i=1;i<=N;i++){
        Q[i-1]=0;
	}
	Q[ ANS[0]-1 ]=1;
	int i=1;
	while(S.size()){
        int nxt=binarySearch(N);
        ANS[i++]=nxt;
        S.erase(nxt);
        disc[nxt-1]=1;
        Q[nxt-1]=1;
	}
	Answer(ANS);
}

Compilation message

library.cpp: In function 'bool inRange(int, int)':
library.cpp:14:11: error: 'Query' was not declared in this scope
   14 |     int A=Query(Q);
      |           ^~~~~
library.cpp: In function 'void Solve(int)':
library.cpp:44:9: error: 'Answer' was not declared in this scope
   44 |         Answer(ANS);
      |         ^~~~~~
library.cpp:56:12: error: 'Query' was not declared in this scope
   56 |         if(Query(Q)==1){
      |            ^~~~~
library.cpp:76:2: error: 'Answer' was not declared in this scope
   76 |  Answer(ANS);
      |  ^~~~~~