Submission #133691

#TimeUsernameProblemLanguageResultExecution timeMemory
133691dooweyLibrary (JOI18_library)C++14
19 / 100
644 ms504 KiB
#include <bits/stdc++.h> #include "library.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair int query(vector<int> t){ bool yes = false; for(auto p : t) yes |= (p > 0); if(!yes) return 0; return Query(t); } void Solve(int n){ if(n==1){ Answer({1}); return; } if(n == 2){ Answer({1,2}); return; } vector<int> p(n); vector<int> answ; for(int i = 0 ; i < n; i ++ ) p[i] = 1; int las; for(int i = 0 ; i < n; i ++ ){ p[i]=0; if(query(p) == 1){ answ.push_back(i); break; } p[i]=1; } int lf, rf, md; int cur, nx; for(int i = 1 ; i < n; i ++ ){ las = answ.back(); lf = 0; rf = n-1; while(lf < rf){ md = (lf + rf) / 2; for(int t = 0 ;t < n; t ++ ) p[t] = 0; for(int t = 0 ; t <= md; t ++ ) p[t] = 1; for(auto v : answ) p[v] = 0; cur = query(p); p[las] = 1; nx = query(p); if(cur == nx){ rf = md; } else{ lf = md + 1; } } answ.push_back(rf); } for(int i = 0 ; i < n ; i ++ ) answ[i] ++ ; Answer(answ); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...