답안 #1119113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1119113 2024-11-26T16:06:11 Z thangdz2k7 도서관 (JOI18_library) C++17
0 / 100
58 ms 504 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};
    for (int loops = 1; loops < n; ++ loops){
        int l = 1, r = a.size() - 1, g = 0;
        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:45:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |             int mid = l + r >> 1;
      |                       ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 504 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 58 ms 504 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -