답안 #267045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
267045 2020-08-15T18:09:56 Z Toirov_Sadi 도서관 (JOI18_library) C++17
100 / 100
389 ms 504 KB
#include<bits/stdc++.h>
#include "library.h"

using namespace std;

void Solve(int n){
    if(n == 1){
        Answer(vector<int> (1, 1));
        return;
    }
    vector<int> res;
    vector<int> q(n, 1);
    vector<int> t(n);
    iota(t.begin(), t.end(), 1);
    for(int i = 1; i <= n; i ++){
        q[i - 1] = 0;
        if(Query(q) == 1){
            res.push_back(i);
            t.erase(t.begin() + i - 1);
            q[i - 1] = 1;
            break;
        }
        q[i - 1] = 1;
    }

    q = vector<int>(n, 0);
    while((int)res.size() < n){
        int l = 0, r = (int)t.size() - 1;
        while(l < r){
            int m = (l + r) / 2;
            for(int i = l; i <= m; i ++) q[t[i] - 1] = 1;
            int res1 = Query(q);
            q[res.back() - 1] = 1;
            int res2 = Query(q);
            q[res.back() - 1] = 0;
            for(int i = l; i <= m; i ++) q[t[i] - 1] = 0;
            if(res1 == res2) r = m;
            else l = m + 1;
        }
        res.push_back(t[l]);
        t.erase(t.begin() + l);
    }
    Answer(res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 372 KB # of queries: 2387
2 Correct 34 ms 256 KB # of queries: 2433
3 Correct 46 ms 256 KB # of queries: 2638
4 Correct 38 ms 256 KB # of queries: 2593
5 Correct 36 ms 256 KB # of queries: 2504
6 Correct 41 ms 256 KB # of queries: 2553
7 Correct 26 ms 380 KB # of queries: 2568
8 Correct 27 ms 256 KB # of queries: 2402
9 Correct 34 ms 256 KB # of queries: 2512
10 Correct 17 ms 368 KB # of queries: 1478
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 1
13 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 372 KB # of queries: 2387
2 Correct 34 ms 256 KB # of queries: 2433
3 Correct 46 ms 256 KB # of queries: 2638
4 Correct 38 ms 256 KB # of queries: 2593
5 Correct 36 ms 256 KB # of queries: 2504
6 Correct 41 ms 256 KB # of queries: 2553
7 Correct 26 ms 380 KB # of queries: 2568
8 Correct 27 ms 256 KB # of queries: 2402
9 Correct 34 ms 256 KB # of queries: 2512
10 Correct 17 ms 368 KB # of queries: 1478
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 1
13 Correct 1 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 272 ms 380 KB # of queries: 18008
18 Correct 285 ms 504 KB # of queries: 17231
19 Correct 291 ms 376 KB # of queries: 17451
20 Correct 264 ms 504 KB # of queries: 16277
21 Correct 248 ms 384 KB # of queries: 15362
22 Correct 294 ms 376 KB # of queries: 17617
23 Correct 284 ms 384 KB # of queries: 17170
24 Correct 115 ms 376 KB # of queries: 7885
25 Correct 303 ms 484 KB # of queries: 17118
26 Correct 286 ms 504 KB # of queries: 15989
27 Correct 106 ms 256 KB # of queries: 7994
28 Correct 283 ms 384 KB # of queries: 17935
29 Correct 295 ms 504 KB # of queries: 17915
30 Correct 389 ms 504 KB # of queries: 17935