답안 #570343

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570343 2022-05-29T09:03:00 Z Spade1 도서관 (JOI18_library) C++14
100 / 100
488 ms 356 KB
#include<bits/stdc++.h>
#include "library.h"
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;

bool mark[1010];

void Solve(int N) {
    vector<int> ans;
    ans.pb(1);
    vector<int> rmn;
    for (int i = 2; i <= N; ++i) rmn.pb(i);

    while (true) {
        int l = 0, r = rmn.size();
        while (l < r) {
            vector<int> tst(N, 0);
            int mid = (l+r)/2;
            for (int i = 0; i <= mid; ++i) {
                tst[rmn[i]-1] = 1;
            }
            int tmp = Query(tst);
            tst[ans.back()-1] = 1;
            if (Query(tst) > tmp) l = mid+1;
            else r = mid;
        }
        if (l == rmn.size()) break;
        else {
            ans.pb(rmn[l]);
            rmn.erase(rmn.begin()+l);
        }
    }

    reverse(ans.begin(), ans.end());

    while (true) {
        int l = 0, r = rmn.size();
        while (l < r) {
            vector<int> tst(N, 0);
            int mid = (l+r)/2;
            for (int i = 0; i <= mid; ++i) {
                tst[rmn[i]-1] = 1;
            }
            int tmp = Query(tst);
            tst[ans.back()-1] = 1;
            if (Query(tst) > tmp) l = mid+1;
            else r = mid;
        }
        if (l == rmn.size()) break;
        else {
            ans.pb(rmn[l]);
            rmn.erase(rmn.begin()+l);
        }
    }

    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (l == rmn.size()) break;
      |             ~~^~~~~~~~~~~~~
library.cpp:56:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         if (l == rmn.size()) break;
      |             ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 208 KB # of queries: 2422
2 Correct 35 ms 208 KB # of queries: 2398
3 Correct 44 ms 208 KB # of queries: 2528
4 Correct 36 ms 208 KB # of queries: 2538
5 Correct 35 ms 208 KB # of queries: 2546
6 Correct 41 ms 208 KB # of queries: 2542
7 Correct 25 ms 296 KB # of queries: 2558
8 Correct 37 ms 288 KB # of queries: 2412
9 Correct 39 ms 208 KB # of queries: 2518
10 Correct 19 ms 208 KB # of queries: 1476
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 2
13 Correct 1 ms 208 KB # of queries: 8
14 Correct 1 ms 208 KB # of queries: 10
15 Correct 1 ms 208 KB # of queries: 84
16 Correct 4 ms 356 KB # of queries: 196
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 208 KB # of queries: 2422
2 Correct 35 ms 208 KB # of queries: 2398
3 Correct 44 ms 208 KB # of queries: 2528
4 Correct 36 ms 208 KB # of queries: 2538
5 Correct 35 ms 208 KB # of queries: 2546
6 Correct 41 ms 208 KB # of queries: 2542
7 Correct 25 ms 296 KB # of queries: 2558
8 Correct 37 ms 288 KB # of queries: 2412
9 Correct 39 ms 208 KB # of queries: 2518
10 Correct 19 ms 208 KB # of queries: 1476
11 Correct 0 ms 208 KB # of queries: 0
12 Correct 1 ms 208 KB # of queries: 2
13 Correct 1 ms 208 KB # of queries: 8
14 Correct 1 ms 208 KB # of queries: 10
15 Correct 1 ms 208 KB # of queries: 84
16 Correct 4 ms 356 KB # of queries: 196
17 Correct 419 ms 296 KB # of queries: 17258
18 Correct 445 ms 292 KB # of queries: 16950
19 Correct 465 ms 296 KB # of queries: 17228
20 Correct 416 ms 292 KB # of queries: 16012
21 Correct 363 ms 288 KB # of queries: 15076
22 Correct 453 ms 296 KB # of queries: 17220
23 Correct 407 ms 288 KB # of queries: 17194
24 Correct 163 ms 288 KB # of queries: 7826
25 Correct 449 ms 292 KB # of queries: 16766
26 Correct 431 ms 288 KB # of queries: 15694
27 Correct 162 ms 208 KB # of queries: 7782
28 Correct 460 ms 288 KB # of queries: 17954
29 Correct 443 ms 328 KB # of queries: 17934
30 Correct 488 ms 296 KB # of queries: 17954