답안 #786063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
786063 2023-07-18T01:28:34 Z winter0101 도서관 (JOI18_library) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
/*namespace {
struct Judge
{
	int N;
	int A[1002];
	int pos[1002];
	bool f[1002];
	int query_c;
	bool answered;
	void init()
	{
		query_c=0;
		int ret=scanf("%d",&N); ret++;
		answered=false;
		for(int i=0;i<N;i++)ret=scanf("%d",&A[i]),pos[A[i]]=i;
	}
	int query(const vector<int>& M)
	{
		if(query_c==20000)
		{
			puts("Wrong Answer [3]");
			exit(0);
		}
		if(int(M.size())!=N)
		{
			puts("Wrong Answer [1]");
			exit(0);
		}
		bool all_zero=true;
		for(int i=0;i<N;i++)
		{
			if(M[i]!=0&&M[i]!=1)
			{
				puts("Wrong Answer [2]");
				exit(0);
			}
			if(M[i]==1)all_zero=false;
		}
		if(all_zero)
		{
			puts("Wrong Answer [2]");
			exit(0);
		}
		memset(f,0,sizeof(f));
		for(int i=0;i<N;i++)if(M[i])f[pos[i+1]]=true;
		bool las=false;
		int r=0;
		for(int i=0;i<N;i++)
		{
			if(las==false&&f[i]==true)r++;
			las=f[i];
		}
		query_c++;
		return r;
	}
	void answer(const vector<int>& res)
	{
		bool f1=true,f2=true;
		if(int(res.size())!=N)
		{
			puts("Wrong Answer [4]");
			exit(0);
		}
		if(answered)
		{
			puts("Wrong Answer [7]");
			exit(0);
		}
		answered=true;
		memset(f,0,sizeof(f));
		for(int i=0;i<N;i++)
		{
			if(res[i]<=0||res[i]>N)
			{
				puts("Wrong Answer [5]");
				exit(0);
			}
			if(f[res[i]])
			{
				puts("Wrong Answer [6]");
				exit(0);
			}
			f[res[i]]=true;
		}
		for(int i=0;i<N;i++)
		{
			f1&=A[i]==res[i];
			f2&=A[i]==res[N-i-1];
		}
		if(!f1&&!f2)
		{
			puts("Wrong Answer [8]");
			exit(0);
		}
	}
	void end()
	{
		if(!answered)puts("Wrong Answer [7]");
		else printf("Accepted : %d\n",query_c);
	}
}judge;
}

int Query(const vector<int>& M)
{
	return judge.query(M);
}
void Answer(const vector<int>& res)
{
	judge.answer(res);
}*/
bool use[1009];
void Solve(int n){
vector<vector<int>>gr;
//cout<<Query({1,1,1,1,0})<<'\n';
gr.pb({1});
for1(i,2,5){
vector<int>t;
for1(j,1,i)t.pb(j);
vector<int>t1;
for1(j,1,n)use[j]=0;
for (auto v:t){
    use[v]=1;
}
for1(j,1,n){
t1.pb(use[j]);
}
int nans=Query(t1);
//cout<<i<<" "<<nans<<'\n';
if (nans==sz(gr)+1){
    gr.pb({i});
    continue;
}
else if (nans==sz(gr)){
    int l=0,r=sz(gr)-1,ans=r;
    //cerr<<l<<" "<<r<<'\n';
    while (l<=r){
        int mid=(l+r)/2;
        vector<int>tt;
        for1(j,0,mid){
        for(auto v:gr[j]){
            tt.pb(v);
        }
        }
        //cerr<<mid<<'\n';
        tt.pb(i);
        for1(j,1,n)use[j]=0;
        for (auto v:tt){
            use[v]=1;
        }
        vector<int>tt1;
        for1(j,1,n)tt1.pb(use[j]);
        int val=Query(tt1);
        if (val==mid+1){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    gr[ans].pb(i);
    //cerr<<ans<<'\n';
    continue;
}
else{
    int l=0,r=sz(gr)-1,ans=r;
    while (l<=r){
        int mid=(l+r)/2;
        vector<int>tt;
        for1(j,0,mid){
        for(auto v:gr[j]){
            tt.pb(v);
        }
        }
        tt.pb(i);
        vector<int>tt1;
        for1(j,1,n)use[j]=0;
        for (auto v:tt){
            use[v]=1;
        }
        for1(j,1,n)tt1.pb(use[j]);
        int val=Query(tt1);
        if (val<=mid+1){
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    //cerr<<ans<<'\n';
    l=ans+1,r=sz(gr)-1;
    int ano=r;
    while (l<=r){
        int mid=(l+r)/2;
        vector<int>tt;
        for1(j,0,mid){
        if (j==ans)continue;
        for(auto v:gr[j]){
            tt.pb(v);
        }
        }
        tt.pb(i);
        vector<int>tt1;
        for1(j,1,n)use[j]=0;
        for(auto v:tt){
            use[v]=1;
        }
        for1(j,1,n){
        tt1.pb(use[j]);
        }
        int val=Query(tt1);
        if (val<=mid+1){
            ano=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    vector<vector<int>>newgr;
    for1(j,0,sz(gr)-1){
        if (j==ano){
          newgr[ans].pb(i);
          for (auto v:gr[j]){
            newgr[ans].pb(v);
          }
        }
        else {
          newgr.pb(gr[j]);
        }
    }
    gr.swap(newgr);
    continue;
}
}
//cout<<sz(gr)<<'\n';
/*for (auto v:gr){
    for(auto u:v){
        cout<<u<<" ";
    }
    cout<<'\n';
}*/
Answer(gr[0]);
}
/*signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("temp.INP","r",stdin);
    //freopen(".OUT","w",stdout);
    judge.init();
	Solve(judge.N);
	judge.end();

}*/

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:145:10: error: 'Query' was not declared in this scope
  145 | int nans=Query(t1);
      |          ^~~~~
library.cpp:256:1: error: 'Answer' was not declared in this scope
  256 | Answer(gr[0]);
      | ^~~~~~