Submission #851098

#TimeUsernameProblemLanguageResultExecution timeMemory
851098ttamxCoreputer (IOI23_coreputer)C++17
100 / 100
1 ms756 KiB
#include "coreputer.h" #include<bits/stdc++.h> using namespace std; vector<int> malfunctioning_cores(int N){ int l=0,r=N-1; vector<int> ans(N,-1); int cnt=0; bool even=false; while(l<r){ int m=(l+r)/2; vector<int> res; for(int i=0;i<=m;i++)res.emplace_back(i); int tmp=run_diagnostic(res); even|=tmp==0; if(tmp==-1)l=m+1; else r=m; } ans[l]=1; cnt++; for(int i=0;i<l&&cnt<N-1;i++){ vector<int> res; for(int j=0;j<=l;j++)if(j!=i)res.emplace_back(j); ans[i]=run_diagnostic(res)==-1; cnt++; } for(int i=l+1;i<N&&cnt<N-1;i++){ vector<int> res; for(int j=0;j<l;j++)res.emplace_back(j); if(even)res.emplace_back(l); res.emplace_back(i); ans[i]=run_diagnostic(res)==1; cnt++; } int suml=0,sumr=0; for(int i=0;i<l;i++)suml+=ans[i]==-1?0:ans[i]; for(int i=l+1;i<N;i++)sumr+=ans[i]==-1?0:ans[i]; if(even)suml++; for(int i=0;i<N;i++)if(ans[i]==-1)ans[i]=abs(suml-sumr); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...