답안 #995067

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995067 2024-06-08T11:51:34 Z Bula 도서관 (JOI18_library) C++17
19 / 100
245 ms 432 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;
//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);
//}
void Solve(int n){
    if(n == 1){
        vector<int> z = {1};
        Answer(z); return;
    }
    vector<int> p(n, 1), b(n, 1);
    int cur = 1;
    for(int i = 1; i <= n; i++){
        p[i - 1] = 0;
        if(Query(p) == 1){
            cur = i; break;
        }
        p[i - 1] = 1;
    }
    vector<int> ans = {cur};
    for(int i = 1; i < n; i++){
        int l = 1, r = n;
        while(l < r){
            int m = (l + r) / 2; for(int j = 0; j < n; j++) p[j] = 0;
            for(int j = 0; j < m; j++){
                p[j] = min(1, b[j]);
            } 
            p[cur - 1] = 1;
            int k = -1;
            if(accumulate(p.begin(), p.end(), 0)) k = Query(p);
            int t = -1; p[cur - 1] = 0;
            if(accumulate(p.begin(), p.end(), 0)) t = Query(p);
            if(k == t) r = m;
            else l = m + 1;
        }
        ans.push_back(l); b[cur - 1] = 0; cur = l;
    }
    //for(auto x : ans) cout << x << " ";
    //cout << endl;
    Answer(ans);
}

//int main()
//{
//	judge.init();
//	Solve(judge.N);
//	judge.end();
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 344 KB # of queries: 2928
2 Correct 19 ms 344 KB # of queries: 2963
3 Correct 24 ms 340 KB # of queries: 3205
4 Correct 27 ms 344 KB # of queries: 3151
5 Correct 29 ms 344 KB # of queries: 3058
6 Correct 20 ms 344 KB # of queries: 3113
7 Correct 17 ms 344 KB # of queries: 3120
8 Correct 25 ms 344 KB # of queries: 2961
9 Correct 24 ms 344 KB # of queries: 3096
10 Correct 10 ms 432 KB # of queries: 1816
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 7
14 Correct 0 ms 344 KB # of queries: 10
15 Correct 1 ms 344 KB # of queries: 106
16 Correct 2 ms 344 KB # of queries: 249
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 344 KB # of queries: 2928
2 Correct 19 ms 344 KB # of queries: 2963
3 Correct 24 ms 340 KB # of queries: 3205
4 Correct 27 ms 344 KB # of queries: 3151
5 Correct 29 ms 344 KB # of queries: 3058
6 Correct 20 ms 344 KB # of queries: 3113
7 Correct 17 ms 344 KB # of queries: 3120
8 Correct 25 ms 344 KB # of queries: 2961
9 Correct 24 ms 344 KB # of queries: 3096
10 Correct 10 ms 432 KB # of queries: 1816
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 2
13 Correct 0 ms 344 KB # of queries: 7
14 Correct 0 ms 344 KB # of queries: 10
15 Correct 1 ms 344 KB # of queries: 106
16 Correct 2 ms 344 KB # of queries: 249
17 Runtime error 245 ms 420 KB Execution killed with signal 13
18 Halted 0 ms 0 KB -