Submission #96927

#TimeUsernameProblemLanguageResultExecution timeMemory
96927dalgerokLibrary (JOI18_library)C++14
100 / 100
496 ms448 KiB
#include "library.h" #include<bits/stdc++.h> using namespace std; int ask(vector < int > &V){ return Query(V); } int n; int Find(int n){ if(n == 1){ return 0; } vector < int > a(n); for(int i = 0; i < n; i++){ a[i] = 1; } for(int i = 0; i < n; i++){ a[i] = 0; if(ask(a) == 1){ return i; } a[i] = 1; } return 0; } vector < int > a, b; vector < bool > used; int Find_next(int l, int r, vector < int > &vec){ if(l == r){ return vec[l]; } int mid = (r + l) >> 1; for(int i = 0; i <= mid; i++){ a[vec[i]] = b[vec[i]] = true; } int x = ask(a), y = ask(b); for(int i = 0; i <= mid; i++){ a[vec[i]] = b[vec[i]] = false; } if(x == y){ return Find_next(l, mid, vec); } else{ return Find_next(mid + 1, r, vec); } } void Solve(int N){ n = N; a.resize(n, 0); b.resize(n, 0); used.resize(n, false); vector < int > ans(n); int pos = Find(n); a[pos] = 1; ans[0] = pos + 1; used[pos] = true; for(int i = 1; i < n; i++){ vector < int > vec; for(int j = 0; j < n; j++){ if(!used[j]){ vec.push_back(j); } } int nxt = Find_next(0, (int)vec.size() - 1, vec); ans[i] = nxt + 1; used[nxt] = true; a[nxt] = 1; } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...