Submission #939673

#TimeUsernameProblemLanguageResultExecution timeMemory
939673AndreyLibrary (JOI18_library)C++14
100 / 100
295 ms700 KiB
#include <cstdio> #include <vector> #include "library.h" #include<bits/stdc++.h> using namespace std; void Solve(int n) { if(n == 1) { Answer({1}); return; } else if(n == 2) { Answer({1,2}); return; } vector<int> bruh(n,1); vector<int> ans(n); vector<int> yeah(n+1,1); int p = -1; for(int i = 0; i < n; i++) { bruh[i] = 0; if(Query(bruh) == 1) { ans[0] = i+1; p = i+1; yeah[i+1] = 0; break; } bruh[i] = 1; } for(int i = 1; i < n; i++) { vector<int> wut(0); for(int j = 1; j <= n; j++) { if(yeah[j]) { wut.push_back(j); } } int l = 0,r = wut.size()-1; while(l < r) { for(int j = 0; j < n; j++) { bruh[j] = 0; } int mid = (l+r)/2; for(int j = 0; j <= mid; j++) { bruh[wut[j]-1] = 1; } int c = Query(bruh); bruh[p-1] = 1; if(Query(bruh) == c) { r = mid; } else { l = mid+1; } } p = wut[l]; yeah[p] = 0; ans[i] = p; } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...