Submission #1092418

#TimeUsernameProblemLanguageResultExecution timeMemory
1092418LuvidiCoreputer (IOI23_coreputer)C++17
100 / 100
1 ms344 KiB
#include "coreputer.h" #include <bits/stdc++.h> using namespace std; std::vector<int> malfunctioning_cores(int n) { int idx,s=1; int l=0,r=n-1; while(l<r){ int m=(l+r)/2; vector<int> v; for(int i=0;i<=m;i++)v.push_back(i); int x=run_diagnostic(v); if(x==-1)l=m+1; else{ r=m; s=x; } } idx=l; vector<int> ans(n); if(s){ int x; if(idx==n-1)x=0; else x=n-1; vector<int> v; for(int i=0;i<idx;i++)v.push_back(i); ans[idx]=1; for(int i=idx+1;i<n;i++)if(i!=x){ v.push_back(i); ans[i]=run_diagnostic(v)==1; v.pop_back(); } v.clear(); for(int i=idx+1;i<n;i++)v.push_back(i); for(int i=0;i<idx;i++)if(i!=x){ v.push_back(i); ans[i]=run_diagnostic(v)==1; v.pop_back(); } ans[x]=1; for(int i=0;i<n;i++)if(i!=x)ans[x]^=ans[i]; }else{ vector<int> v; for(int i=0;i<=idx;i++)v.push_back(i); ans[idx]=1; for(int i=idx+1;i<n-1;i++){ v.push_back(i); ans[i]=run_diagnostic(v)==1; v.pop_back(); } v.clear(); for(int i=idx+1;i<n;i++)v.push_back(i); for(int i=0;i<idx;i++){ v.push_back(i); ans[i]=run_diagnostic(v)==1; v.pop_back(); } for(int i=0;i<n-1;i++)ans[n-1]^=ans[i]; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...