Submission #909917

#TimeUsernameProblemLanguageResultExecution timeMemory
909917PlayVoltzCoreputer (IOI23_coreputer)C++17
100 / 100
1 ms596 KiB
#include "coreputer.h" #include <bits/stdc++.h> using namespace std; #define pb push_back vector<int> malfunctioning_cores(int n){ int c1=0, c2=0; vector<int> c(n, 0), vect; int low=-1, high=n, end; while (low+1<high){ int mid=(low+high)/2; vect.clear(); for (int i=0; i<=mid; ++i)vect.pb(i); int res=run_diagnostic(vect); if (res>=0)high=mid, end=res; else low=mid; } c[high]=1; if (high==n-1)return c; ++c1; for (int i=0; i<high; ++i){ vect.clear(); for (int j=0; j<=high; ++j)if (i!=j)vect.pb(j); if (run_diagnostic(vect)<0)c[i]=1, ++c1; } if (end){ for (int i=high+1; i<n-1; ++i){ vect.clear(); for (int j=high; j<n; ++j)if (i!=j)vect.pb(j); if (run_diagnostic(vect)<0)c[i]=1, ++c2; } if (c1>c2+1)c[n-1]=1; } else{ for (int i=high+1; i<n-1; ++i){ vect.clear(); for (int j=high+1; j<n; ++j)if (i!=j)vect.pb(j); if (run_diagnostic(vect)<0)c[i]=1, ++c2; } if (c1>c2)c[n-1]=1; } return c; }

Compilation message (stderr)

coreputer.cpp: In function 'std::vector<int> malfunctioning_cores(int)':
coreputer.cpp:27:2: warning: 'end' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |  if (end){
      |  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...