답안 #1119302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1119302 2024-11-26T18:32:43 Z thangdz2k7 도서관 (JOI18_library) C++17
100 / 100
493 ms 592 KB
// author : thembululquaUwU
// 3.9.2024
 
#include <bits/stdc++.h>
#include "library.h"
#define pb push_back
#define fi first
#define se second
#define endl '\n'
 
using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
 
const int MaxN = 2e5;
const int mod = 1e9 + 7;
 
void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}
 
void Solve(int n){
    vector <int> a(n);
    iota(a.begin(), a.end(), 0);
 
    auto del = [&](int x) -> void {
        a.erase(a.begin() + x);
    };
 
    vector <int> qr(n, 1);
    int st = 0;
    for (int i = 1; i < n; ++ i){
        qr[i] = 0;
        if (Query(qr) == 1){
            st = i;
            break;
        }
        qr[i] = 1;
    }
 
    vector <int> ans = {st};
    del(st);
    for (int loops = 1; loops < n; ++ loops){
        int l = 0, g = a.size() - 1, r = g - 1;
        while (l <= r){
            int mid = l + r >> 1;
            qr.assign(n, 0);
            for (int i = 0; i <= mid; ++ i) qr[a[i]] = 1;
            int res = Query(qr);
            qr[ans.back()] = 1;
            if (res == Query(qr)) g = mid, r = mid - 1;
            else l = mid + 1;
        }
        ans.push_back(a[g]);
        del(g);
    }
 
    for (int &f : ans) f ++;
    Answer(ans);
}
 
//void solve(){
//
//}
//
//int main(){
//    if (fopen("Library.inp", "r")){
//        freopen("Library.inp", "r", stdin);
//        freopen("Library.out", "w", stdout);
//    }
//    ios_base::sync_with_stdio(0);
//    cin.tie(0); cout.tie(0);
//
//    int t = 1; // cin >> t;
//    while (t --) solve();
//    return 0;
//}

Compilation message

library.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
library.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
library.cpp:20:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
library.cpp:20:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
library.cpp: In function 'void Solve(int)':
library.cpp:46:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |             int mid = l + r >> 1;
      |                       ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 436 KB # of queries: 2374
2 Correct 44 ms 336 KB # of queries: 2408
3 Correct 58 ms 336 KB # of queries: 2647
4 Correct 58 ms 336 KB # of queries: 2594
5 Correct 62 ms 592 KB # of queries: 2507
6 Correct 59 ms 592 KB # of queries: 2550
7 Correct 44 ms 336 KB # of queries: 2543
8 Correct 53 ms 440 KB # of queries: 2419
9 Correct 55 ms 444 KB # of queries: 2545
10 Correct 31 ms 436 KB # of queries: 1473
11 Correct 1 ms 336 KB # of queries: 0
12 Correct 1 ms 336 KB # of queries: 1
13 Correct 1 ms 336 KB # of queries: 3
14 Correct 2 ms 336 KB # of queries: 9
15 Correct 3 ms 336 KB # of queries: 81
16 Correct 5 ms 336 KB # of queries: 182
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 436 KB # of queries: 2374
2 Correct 44 ms 336 KB # of queries: 2408
3 Correct 58 ms 336 KB # of queries: 2647
4 Correct 58 ms 336 KB # of queries: 2594
5 Correct 62 ms 592 KB # of queries: 2507
6 Correct 59 ms 592 KB # of queries: 2550
7 Correct 44 ms 336 KB # of queries: 2543
8 Correct 53 ms 440 KB # of queries: 2419
9 Correct 55 ms 444 KB # of queries: 2545
10 Correct 31 ms 436 KB # of queries: 1473
11 Correct 1 ms 336 KB # of queries: 0
12 Correct 1 ms 336 KB # of queries: 1
13 Correct 1 ms 336 KB # of queries: 3
14 Correct 2 ms 336 KB # of queries: 9
15 Correct 3 ms 336 KB # of queries: 81
16 Correct 5 ms 336 KB # of queries: 182
17 Correct 429 ms 436 KB # of queries: 17981
18 Correct 413 ms 436 KB # of queries: 17292
19 Correct 439 ms 440 KB # of queries: 17466
20 Correct 407 ms 440 KB # of queries: 16324
21 Correct 370 ms 444 KB # of queries: 15323
22 Correct 469 ms 440 KB # of queries: 17668
23 Correct 435 ms 440 KB # of queries: 17223
24 Correct 187 ms 436 KB # of queries: 7914
25 Correct 404 ms 444 KB # of queries: 17135
26 Correct 382 ms 440 KB # of queries: 15962
27 Correct 174 ms 428 KB # of queries: 8039
28 Correct 449 ms 436 KB # of queries: 18933
29 Correct 469 ms 440 KB # of queries: 18912
30 Correct 493 ms 436 KB # of queries: 18933