Submission #562493

#TimeUsernameProblemLanguageResultExecution timeMemory
562493IwanttobreakfreeFinding Routers (IOI20_routers)C++17
98.76 / 100
2 ms636 KiB
#include "routers.h" #include <vector> using namespace std; vector<int> guarda(100001,-1); vector<int> find_routers(int lon, int n, int q) { vector<int> ans(n); vector<int> maxinum(n,1); vector<int> mininum(n,lon); ans[0]=guarda[0]=0; int l=0,r; for(int i=1;i<n;i++){ l=maxinum[i-1]; r=mininum[i]; int sol; while(l<=r){ int mid=(l+r)/2,cerc; if(guarda[mid]==-1)guarda[mid]=use_detector(mid); cerc=guarda[mid]; if(cerc<i){ l=mid+1; sol=mid; } else r=mid-1; if(maxinum[cerc]<mid)maxinum[cerc]=mid; if(mininum[cerc]>mid)mininum[cerc]=mid; } ans[i]=2*sol-ans[i-1]; } return ans; }

Compilation message (stderr)

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:27:10: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |  ans[i]=2*sol-ans[i-1];
      |         ~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...