답안 #1018063

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018063 2024-07-09T13:36:56 Z davit_tsibadze 도서관 (JOI18_library) C++17
0 / 100
22 ms 344 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>

const ll inf = 1e18;
// #define int long long
int d;
vector <int> ans, m, a;

bool isgood(int mid){
    for (int i = 0; i < (int)m.size(); i++)
        m[i] = 0;
    for (int i = 0; i <= mid; i++)
        m[a[i] - 1] = 1;
    int x = Query(m);
    m[ans.back() - 1] = 1;
    return (x == Query(m));
}
void Solve(int N){
    bool used[N + 1] = {};
    while((int)m.size() < N)m.pb(1);
    if (N == 1){
        ans.pb(1);
        Answer(ans);
        return;
    }
    for (int i = 1; i <= N; i++){
        m[i - 1] = 0;
        if (Query(m) == 1){d = i; break;}
        m[i] = 1;
    }
    ans.pb(d); used[d] = true;
    for (int i = 1; i <= N; i++) if (!used[i])a.pb(i); 
    while(a.size()){
        int l = 0, r = a.size() - 1, mid, answ = a.size() - 1;
        while(l <= r){
            mid = (l + r) / 2;
            if (isgood(mid)) {
                answ = mid;
                r = mid - 1;
            }
            else l = mid + 1;
        }
        ans.pb(a[answ]); used[a[answ]] = true; a.clear();
        for (int i = 1; i <= N; i++) if (!used[i])a.pb(i);
    }
    Answer(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 344 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 344 KB Wrong Answer [8]
2 Halted 0 ms 0 KB -