Submission #998943

#TimeUsernameProblemLanguageResultExecution timeMemory
99894312345678Coreputer (IOI23_coreputer)C++17
100 / 100
1 ms596 KiB
#include "coreputer.h" #include <bits/stdc++.h> using namespace std; std::vector<int> malfunctioning_cores(int N) { int l=0, r=N-1, cnt=0, cnt2=0; vector<int> res(N), v(N); while (l<r) { int md=(l+r)/2; vector<int> qrs; for (int i=0; i<=md; i++) qrs.push_back(i); if ((v[md]=run_diagnostic(qrs))>=0) r=md; else l=md+1; } if (l==N-1) v[l]=1; res[l]=1; if (l<N-1-l) { for (int i=0; i<l; i++) { vector<int> qrs; for (int j=0; j<=l; j++) if (j!=i) qrs.push_back(j); if (run_diagnostic(qrs)>=0) res[i]=0; else cnt++, res[i]=1; } cnt+=(v[l]==0); for (int i=l+1; i<N-1; i++) { vector<int> qrs; for (int j=0; j<l; j++) qrs.push_back(j); qrs.push_back(i); if (run_diagnostic(qrs)>=0) res[i]=1, cnt2++; else res[i]=0; } res[N-1]=cnt2!=cnt; } else { for (int i=l+1; i<N; i++) { vector<int> qrs; for (int j=0; j<l; j++) qrs.push_back(j); qrs.push_back(i); if (run_diagnostic(qrs)>=0) res[i]=1, cnt2++; else res[i]=0; } cnt2+=(v[l]!=0); cnt=1; for (int i=0; i<l-1; i++) { vector<int> qrs; for (int j=0; j<=l; j++) if (j!=i) qrs.push_back(j); if (run_diagnostic(qrs)>=0) res[i]=0; else cnt++, res[i]=1; } //cout<<"debug "<<cnt2<<' '<<cnt<<'\n'; res[l-1]=(cnt2!=cnt); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...