Submission #260346

# Submission time Handle Problem Language Result Execution time Memory
260346 2020-08-10T06:17:50 Z 문홍윤(#5075) Library (JOI18_library) C++17
100 / 100
559 ms 508 KB
#include "library.h"
#include <bits/stdc++.h>
#define eb emplace_back
using namespace std;

int n;
vector<int> ret, qu;

int get_side(){
    for(int i=0; i<n; i++)qu[i]=1;
    for(int i=0; i<n; i++){
        qu[i]=0;
        int tmp=Query(qu);
        if(tmp==1)return i;
        qu[i]=1;
    }
}

int ch[1010];
vector<int> vc;
vector<int> did;

int get_dnc(int s, int e){
    if(s==e)return vc[s];
    int mid=(s+e)/2;
    for(int i=s; i<=mid; i++)qu[vc[i]]=1;
    int tmp1=Query(qu);
    for(auto i:did)qu[i]=1;
    int tmp2=Query(qu);
    for(auto i:did)qu[i]=0;
    for(int i=s; i<=mid; i++)qu[vc[i]]=0;
    if(tmp1==tmp2)return get_dnc(s, mid);
    return get_dnc(mid+1, e);
}

int get_nxt(){
    vc.clear();
    for(int i=0; i<n; i++){
        if(!ch[i])vc.eb(i);
    }
    return get_dnc(0, vc.size()-1);
}

void Solve(int N){
    n=N;
    ret.resize(n);
    qu.resize(n);
    if(n==1){
        ret[0]=1;
        Answer(ret);
        return;
    }
	int rt=get_side();
	for(int i=0; i<n; i++)qu[i]=0;
	ret[0]=rt+1;
	ch[rt]=1;
	did.eb(rt);
	for(int i=1; i<n; i++){
        int tmp=get_nxt();
        ret[i]=tmp+1;
        ch[tmp]=1;
        did.eb(tmp);
	}
	Answer(ret);
}

Compilation message

library.cpp: In function 'int get_side()':
library.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 35 ms 256 KB # of queries: 2387
2 Correct 50 ms 256 KB # of queries: 2433
3 Correct 47 ms 256 KB # of queries: 2638
4 Correct 40 ms 256 KB # of queries: 2593
5 Correct 61 ms 256 KB # of queries: 2504
6 Correct 29 ms 384 KB # of queries: 2553
7 Correct 54 ms 256 KB # of queries: 2568
8 Correct 43 ms 384 KB # of queries: 2402
9 Correct 51 ms 256 KB # of queries: 2512
10 Correct 29 ms 256 KB # of queries: 1478
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 1 ms 256 KB # of queries: 1
13 Correct 0 ms 256 KB # of queries: 4
14 Correct 1 ms 256 KB # of queries: 7
15 Correct 1 ms 256 KB # of queries: 73
16 Correct 3 ms 256 KB # of queries: 187
# Verdict Execution time Memory Grader output
1 Correct 35 ms 256 KB # of queries: 2387
2 Correct 50 ms 256 KB # of queries: 2433
3 Correct 47 ms 256 KB # of queries: 2638
4 Correct 40 ms 256 KB # of queries: 2593
5 Correct 61 ms 256 KB # of queries: 2504
6 Correct 29 ms 384 KB # of queries: 2553
7 Correct 54 ms 256 KB # of queries: 2568
8 Correct 43 ms 384 KB # of queries: 2402
9 Correct 51 ms 256 KB # of queries: 2512
10 Correct 29 ms 256 KB # of queries: 1478
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 1 ms 256 KB # of queries: 1
13 Correct 0 ms 256 KB # of queries: 4
14 Correct 1 ms 256 KB # of queries: 7
15 Correct 1 ms 256 KB # of queries: 73
16 Correct 3 ms 256 KB # of queries: 187
17 Correct 534 ms 384 KB # of queries: 18008
18 Correct 450 ms 392 KB # of queries: 17231
19 Correct 527 ms 504 KB # of queries: 17451
20 Correct 487 ms 384 KB # of queries: 16277
21 Correct 455 ms 384 KB # of queries: 15362
22 Correct 494 ms 384 KB # of queries: 17617
23 Correct 508 ms 508 KB # of queries: 17170
24 Correct 186 ms 384 KB # of queries: 7885
25 Correct 517 ms 504 KB # of queries: 17118
26 Correct 422 ms 504 KB # of queries: 15989
27 Correct 165 ms 384 KB # of queries: 7994
28 Correct 463 ms 508 KB # of queries: 17935
29 Correct 487 ms 504 KB # of queries: 17915
30 Correct 559 ms 504 KB # of queries: 17935