Submission #45163

#TimeUsernameProblemLanguageResultExecution timeMemory
45163ikura355Library (JOI18_library)C++14
0 / 100
98 ms3000 KiB
#include "library.h" #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 + 5; int n; vector<int> way[maxn]; vector<int> ans; int cnt; int ask(int l, int r, int x) { vector<int> vec; for(int i=1;i<=n;i++) { if(i==x || (l<=i && i<=r)) vec.push_back(1); else vec.push_back(0); } return Query(vec); } void addedge(int x, int l, int r) { if(l>r) return ; // printf("ask [%d, %d] : %d = %d\n",l,r,x,ask(l,r,x)); // printf("solve [%d, %d] : %d\n",l,r,solve(l,r)); if(ask(l,r,x)>ask(l,r,0)) return ; if(l==r) { // printf("%d <-> %d\n",l,x); way[x].push_back(l); way[l].push_back(x); cnt++; return ; } int mid = (l+r)/2; addedge(x,l,mid); addedge(x,mid+1,r); } void dfs(int u, int last) { ans.push_back(u); for(auto v : way[u]) { if(v==last) continue; dfs(v, u); } } void Solve(int N) { n = N; for(int i=1;i<=n;i++) way[i].clear(); ans.clear(); for(int x=2;x<=n;x++) addedge(x,1,x-1); assert(cnt<=n-1); for(int x=1;x<=n;x++) { if(way[x].size()==1) { dfs(x, 0); Answer(ans); return ; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...