Submission #96927

# Submission time Handle Problem Language Result Execution time Memory
96927 2019-02-12T19:06:33 Z dalgerok Library (JOI18_library) C++14
100 / 100
496 ms 448 KB
#include "library.h"
#include<bits/stdc++.h>
using namespace std;



int ask(vector < int > &V){
    return Query(V);
}

int n;

int Find(int n){
    if(n == 1){
        return 0;
    }
    vector < int > a(n);
    for(int i = 0; i < n; i++){
        a[i] = 1;
    }
    for(int i = 0; i < n; i++){
        a[i] = 0;
        if(ask(a) == 1){
            return i;
        }
        a[i] = 1;
    }
    return 0;
}

vector < int > a, b;
vector < bool > used;

int Find_next(int l, int r, vector < int > &vec){
    if(l == r){
        return vec[l];
    }
    int mid = (r + l) >> 1;
    for(int i = 0; i <= mid; i++){
        a[vec[i]] = b[vec[i]] = true;
    }
    int x = ask(a), y = ask(b);
    for(int i = 0; i <= mid; i++){
        a[vec[i]] = b[vec[i]] = false;
    }
    if(x == y){
        return Find_next(l, mid, vec);
    }
    else{
        return Find_next(mid + 1, r, vec);
    }
}
void Solve(int N){
    n = N;
    a.resize(n, 0);
    b.resize(n, 0);
    used.resize(n, false);
    vector < int > ans(n);
    int pos = Find(n);
    a[pos] = 1;
    ans[0] = pos + 1;
    used[pos] = true;
    for(int i = 1; i < n; i++){
        vector < int > vec;
        for(int j = 0; j < n; j++){
            if(!used[j]){
                vec.push_back(j);
            }
        }
        int nxt = Find_next(0, (int)vec.size() - 1, vec);
        ans[i] = nxt + 1;
        used[nxt] = true;
        a[nxt] = 1;
    }
    Answer(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 37 ms 256 KB # of queries: 2387
2 Correct 49 ms 256 KB # of queries: 2433
3 Correct 37 ms 384 KB # of queries: 2638
4 Correct 47 ms 256 KB # of queries: 2593
5 Correct 60 ms 384 KB # of queries: 2504
6 Correct 35 ms 256 KB # of queries: 2553
7 Correct 34 ms 384 KB # of queries: 2568
8 Correct 39 ms 256 KB # of queries: 2402
9 Correct 32 ms 384 KB # of queries: 2512
10 Correct 22 ms 256 KB # of queries: 1478
11 Correct 2 ms 256 KB # of queries: 0
12 Correct 2 ms 256 KB # of queries: 1
13 Correct 2 ms 256 KB # of queries: 4
14 Correct 3 ms 384 KB # of queries: 7
15 Correct 3 ms 384 KB # of queries: 73
16 Correct 5 ms 256 KB # of queries: 187
# Verdict Execution time Memory Grader output
1 Correct 37 ms 256 KB # of queries: 2387
2 Correct 49 ms 256 KB # of queries: 2433
3 Correct 37 ms 384 KB # of queries: 2638
4 Correct 47 ms 256 KB # of queries: 2593
5 Correct 60 ms 384 KB # of queries: 2504
6 Correct 35 ms 256 KB # of queries: 2553
7 Correct 34 ms 384 KB # of queries: 2568
8 Correct 39 ms 256 KB # of queries: 2402
9 Correct 32 ms 384 KB # of queries: 2512
10 Correct 22 ms 256 KB # of queries: 1478
11 Correct 2 ms 256 KB # of queries: 0
12 Correct 2 ms 256 KB # of queries: 1
13 Correct 2 ms 256 KB # of queries: 4
14 Correct 3 ms 384 KB # of queries: 7
15 Correct 3 ms 384 KB # of queries: 73
16 Correct 5 ms 256 KB # of queries: 187
17 Correct 420 ms 384 KB # of queries: 18008
18 Correct 383 ms 256 KB # of queries: 17231
19 Correct 393 ms 384 KB # of queries: 17451
20 Correct 362 ms 304 KB # of queries: 16277
21 Correct 354 ms 332 KB # of queries: 15362
22 Correct 412 ms 256 KB # of queries: 17617
23 Correct 373 ms 376 KB # of queries: 17170
24 Correct 132 ms 384 KB # of queries: 7885
25 Correct 496 ms 256 KB # of queries: 17118
26 Correct 406 ms 384 KB # of queries: 15989
27 Correct 184 ms 256 KB # of queries: 7994
28 Correct 413 ms 256 KB # of queries: 17935
29 Correct 482 ms 256 KB # of queries: 17915
30 Correct 446 ms 448 KB # of queries: 17935