Submission #1162701

#TimeUsernameProblemLanguageResultExecution timeMemory
1162701Hamed_GhaffariLibrary (JOI18_library)C++20
100 / 100
129 ms432 KiB
#include <cstdio> #include <vector> #include "library.h" #include<bits/stdc++.h> using namespace std; int edge(vector<int> vec) { int ans=0; for(int i : vec) ans += i; return ans - Query(vec); } void Solve(int n) { if(n==1) { vector<int> res = {1}; Answer(res); return; } vector<int> vec(n, 1); for(int v=0; v<n; v++) { vec[v] = 0; if(edge(vec)==n-2) { vector<int> res = {v}; vector<int> mark(n, 0); mark[v] = 1; for(int t=0; t<n-2; t++) { vector<int> out; for(int u=0; u<n; u++) if(!mark[u]) out.push_back(u); int l=0, r=out.size(), mid; while(r-l>1) { fill(vec.begin(), vec.end(), 0); mid = (l+r)>>1; for(int i=l; i<mid; i++) vec[out[i]] = 1; int e = - res.size() + 1 - edge(vec); for(int i : res) vec[i] = 1; e += edge(vec); (e ? r : l) = mid; } res.push_back(out[l]); mark[out[l]] = 1; } for(int i=0; i<n; i++) if(!mark[i]) res.push_back(i); for(int &i : res) i++; Answer(res); return; } vec[v] = 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...