제출 #1020941

#제출 시각아이디문제언어결과실행 시간메모리
1020941vako_p도서관 (JOI18_library)C++14
0 / 100
32 ms596 KiB
#include <cstdio> #include <vector> #include "library.h" #define pb push_back #define ll int using namespace std; ll n; vector<ll> v,v1,ans; bool ok(ll mid, ll idx){ for(int i = 0; i < n; i++) v[i] = 0; for(int i = 0; i <= mid; i++) v[v1[i] - 1] = 1; ll x = Query(v); v[ans[idx] - 1] = 1; x -= Query(v); return (!x); } void Solve(int N){ n = N; v.assign(n, 0LL); ans.assign(n, 0LL); for(int i = 1; i <= n; i++) v1.pb(i); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ v[j] = (j != i); } ll x = Query(v); if(x == 1){ ans[0] = i + 1; v1.erase(v1.begin() + i); break; } } for(int i = 1; i < n; i++){ ll l = -1, r = v1.size() - 1; while(r > l + 1){ ll mid = l + (r - l) / 2; if(ok(mid, i - 1)) r = mid; else l = mid; } ans[i] = v1[r]; v1.erase(v1.begin() + r); } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...