답안 #133905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133905 2019-07-21T17:27:56 Z duality 도서관 (JOI18_library) C++11
100 / 100
520 ms 456 KB
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
#include "library.h"

void Solve(int N) {
    if (N == 1) {
        vi v;
        v.pb(1);
        Answer(v);
        return;
    }

    int i;
    vi M(N,1);
    for (i = 0; i < N; i++) {
        M[i] = 0;
        if (Query(M) == 1) break;
        else M[i] = 1;
    }
    vi ans,rem;
    ans.pb(i);
    for (i = 0; i < N; i++) {
        if (i != ans.back()) rem.pb(i);
    }
    while (ans.size() < N) {
        int l = 0,r = rem.size()-1;
        while (l < r) {
            int m = (l+r) / 2;
            fill(M.begin(),M.end(),0);
            for (i = l; i <= m; i++) M[rem[i]] = 1;
            int x = Query(M);
            M[ans.back()] = 1;
            if (Query(M) == x) r = m;
            else l = m+1;
        }
        ans.pb(rem[l]);
        rem[l] = rem.back(),rem.pop_back();
    }
    for (i = 0; i < ans.size(); i++) ans[i]++;
    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:31:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (ans.size() < N) {
            ~~~~~~~~~~~^~~
library.cpp:45:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < ans.size(); i++) ans[i]++;
                 ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 316 KB # of queries: 2373
2 Correct 42 ms 376 KB # of queries: 2423
3 Correct 49 ms 248 KB # of queries: 2646
4 Correct 46 ms 376 KB # of queries: 2585
5 Correct 42 ms 376 KB # of queries: 2498
6 Correct 48 ms 376 KB # of queries: 2551
7 Correct 45 ms 248 KB # of queries: 2560
8 Correct 31 ms 308 KB # of queries: 2438
9 Correct 50 ms 376 KB # of queries: 2532
10 Correct 30 ms 248 KB # of queries: 1448
11 Correct 2 ms 248 KB # of queries: 0
12 Correct 2 ms 248 KB # of queries: 1
13 Correct 2 ms 376 KB # of queries: 4
14 Correct 2 ms 380 KB # of queries: 7
15 Correct 3 ms 376 KB # of queries: 77
16 Correct 4 ms 248 KB # of queries: 181
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 316 KB # of queries: 2373
2 Correct 42 ms 376 KB # of queries: 2423
3 Correct 49 ms 248 KB # of queries: 2646
4 Correct 46 ms 376 KB # of queries: 2585
5 Correct 42 ms 376 KB # of queries: 2498
6 Correct 48 ms 376 KB # of queries: 2551
7 Correct 45 ms 248 KB # of queries: 2560
8 Correct 31 ms 308 KB # of queries: 2438
9 Correct 50 ms 376 KB # of queries: 2532
10 Correct 30 ms 248 KB # of queries: 1448
11 Correct 2 ms 248 KB # of queries: 0
12 Correct 2 ms 248 KB # of queries: 1
13 Correct 2 ms 376 KB # of queries: 4
14 Correct 2 ms 380 KB # of queries: 7
15 Correct 3 ms 376 KB # of queries: 77
16 Correct 4 ms 248 KB # of queries: 181
17 Correct 487 ms 452 KB # of queries: 18026
18 Correct 520 ms 408 KB # of queries: 17253
19 Correct 511 ms 376 KB # of queries: 17399
20 Correct 459 ms 248 KB # of queries: 16293
21 Correct 396 ms 456 KB # of queries: 15320
22 Correct 505 ms 316 KB # of queries: 17661
23 Correct 474 ms 380 KB # of queries: 17232
24 Correct 153 ms 324 KB # of queries: 7877
25 Correct 439 ms 380 KB # of queries: 17052
26 Correct 418 ms 388 KB # of queries: 15989
27 Correct 166 ms 248 KB # of queries: 8000
28 Correct 432 ms 456 KB # of queries: 16581
29 Correct 440 ms 248 KB # of queries: 16533
30 Correct 434 ms 376 KB # of queries: 16581