Submission #45180

#TimeUsernameProblemLanguageResultExecution timeMemory
45180ikura355Library (JOI18_library)C++14
100 / 100
499 ms716 KiB
#include "library.h" #include<bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; int n; int vis[maxn]; vector<int> vec, ans; int link(int st) { vector<int> a; vis[st] = 1; for(int i=1;i<=n;i++) if(!vis[i]) a.push_back(i); int l = 0, r = a.size()-1; while(l<r) { //ask int mid = (l+r)/2; for(int i=l;i<=mid;i++) vec[a[i]-1] = 1; int bef = Query(vec); vec[st-1] = 1; int aft = Query(vec); //reset for(int i=l;i<=mid;i++) vec[a[i]-1] = 0; vec[st-1] = 0; //divide if(bef==aft) r = mid; else l = mid+1; } // printf("%d -> %d\n",st,a[l]); return a[l]; } void Solve(int N) { n = N; if(n==1) return Answer({1}); vec.clear(); ans.clear(); memset(vis,0,sizeof(vis)); //1000 int st = -1; for(int i=0;i<n;i++) vec.push_back(0); for(int x=1;x<=n;x++) { for(int i=1;i<=n;i++) vec[i-1] = (x!=i); if(Query(vec)==1) st = x; } ans.push_back(st); //1000 * 10 for(int i=0;i<n;i++) vec[i] = 0; for(int i=1;i<n;i++) ans.push_back(link(ans[i-1])); Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...