답안 #939673

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939673 2024-03-06T16:31:31 Z Andrey 도서관 (JOI18_library) C++14
100 / 100
295 ms 700 KB
#include <cstdio>
#include <vector>
#include "library.h"
#include<bits/stdc++.h>
using namespace std;

void Solve(int n) {
    if(n == 1) {
        Answer({1});
        return;
    }
    else if(n == 2) {
        Answer({1,2});
        return;
    }
    vector<int> bruh(n,1);
    vector<int> ans(n);
    vector<int> yeah(n+1,1);
    int p = -1;
    for(int i = 0; i < n; i++) {
        bruh[i] = 0;
        if(Query(bruh) == 1) {
            ans[0] = i+1;
            p = i+1;
            yeah[i+1] = 0;
            break;
        }
        bruh[i] = 1;
    }
    for(int i = 1; i < n; i++) {
        vector<int> wut(0);
        for(int j = 1; j <= n; j++) {
            if(yeah[j]) {
                wut.push_back(j);
            }
        }
        int l = 0,r = wut.size()-1;
        while(l < r) {
            for(int j = 0; j < n; j++) {
                bruh[j] = 0;
            }
            int mid = (l+r)/2;
            for(int j = 0; j <= mid; j++) {
                bruh[wut[j]-1] = 1;
            }
            int c = Query(bruh);
            bruh[p-1] = 1;
            if(Query(bruh) == c) {
                r = mid;
            }
            else {
                l = mid+1;
            }
        }
        p = wut[l];
        yeah[p] = 0;
        ans[i] = p;
    }
    Answer(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 344 KB # of queries: 2387
2 Correct 22 ms 344 KB # of queries: 2433
3 Correct 30 ms 344 KB # of queries: 2638
4 Correct 19 ms 344 KB # of queries: 2593
5 Correct 19 ms 344 KB # of queries: 2504
6 Correct 23 ms 344 KB # of queries: 2553
7 Correct 24 ms 344 KB # of queries: 2568
8 Correct 18 ms 344 KB # of queries: 2402
9 Correct 19 ms 340 KB # of queries: 2512
10 Correct 10 ms 436 KB # of queries: 1478
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 0
13 Correct 0 ms 344 KB # of queries: 4
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 73
16 Correct 1 ms 344 KB # of queries: 187
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 344 KB # of queries: 2387
2 Correct 22 ms 344 KB # of queries: 2433
3 Correct 30 ms 344 KB # of queries: 2638
4 Correct 19 ms 344 KB # of queries: 2593
5 Correct 19 ms 344 KB # of queries: 2504
6 Correct 23 ms 344 KB # of queries: 2553
7 Correct 24 ms 344 KB # of queries: 2568
8 Correct 18 ms 344 KB # of queries: 2402
9 Correct 19 ms 340 KB # of queries: 2512
10 Correct 10 ms 436 KB # of queries: 1478
11 Correct 0 ms 344 KB # of queries: 0
12 Correct 0 ms 344 KB # of queries: 0
13 Correct 0 ms 344 KB # of queries: 4
14 Correct 0 ms 344 KB # of queries: 7
15 Correct 1 ms 344 KB # of queries: 73
16 Correct 1 ms 344 KB # of queries: 187
17 Correct 251 ms 444 KB # of queries: 18008
18 Correct 237 ms 440 KB # of queries: 17231
19 Correct 260 ms 444 KB # of queries: 17451
20 Correct 238 ms 452 KB # of queries: 16277
21 Correct 206 ms 448 KB # of queries: 15362
22 Correct 269 ms 444 KB # of queries: 17617
23 Correct 261 ms 444 KB # of queries: 17170
24 Correct 84 ms 440 KB # of queries: 7885
25 Correct 257 ms 700 KB # of queries: 17118
26 Correct 222 ms 452 KB # of queries: 15989
27 Correct 100 ms 596 KB # of queries: 7994
28 Correct 261 ms 448 KB # of queries: 17935
29 Correct 291 ms 448 KB # of queries: 17915
30 Correct 295 ms 448 KB # of queries: 17935