Submission #887404

#TimeUsernameProblemLanguageResultExecution timeMemory
887404jay_jayjayCoreputer (IOI23_coreputer)C++17
100 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; int run_diagnostic(vector<int> T); // begin my code // vector<int> U {0,0,0,1,0,0,1,0,1,0,1}; // int run_diagnostic(vector<int> T) { // int s=0; // for(auto x:T)s+=U[x]; // int cnt=0;for(auto x:U)cnt+=x; // int o = cnt-s; // return (s>o) - (o>s); // } // end my code vector<int> malfunctioning_cores(int N) { vector<int> res(N); int l=0, r=N-1; // find the first i such that run[0...i] is >= while(l<r) { int m = l+(r-l)/2; vector<int> t; for(int i=0;i<=m;i++)t.push_back(i); if((res[m]=run_diagnostic(t))>=0) r=m; else l=m+1; } vector<int> on(N); on[l] = 1; if(l == N-1) return on; for(int i=0;i<l;i++) { // try this one vector<int> t; for(int j=0;j<=l;j++) if(i!=j) t.push_back(j); if(run_diagnostic(t)<0) on[i]=1; } for(int i=l+1;i<N-1;i++) { vector<int> t; for(int j=0;j<l;j++) t.push_back(j); t.push_back(i); if(run_diagnostic(t)>=0) on[i]=1; } if(res[l] == 0) { int ls=0,rs=0; for(int i=0;i<=l;i++)ls+=on[i]; for(int i=l+1;i<N;i++)rs+=on[i]; if(ls>rs) on[N-1]=1; } else { int ls=0,rs=0; for(int i=0;i<l;i++)ls+=on[i]; for(int i=l+1;i<N;i++)rs+=on[i]; if(ls>rs) on[N-1]=1; } return on; } // int main() { // auto v=malfunctioning_cores(U.size()); // for(auto x:v)cout<<x<<endl; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...