제출 #402244

#제출 시각아이디문제언어결과실행 시간메모리
402244victoriadFinding Routers (IOI20_routers)C++14
100 / 100
3 ms672 KiB
#include "routers.h" using namespace std; std::vector<int> find_routers(int l, int n, int q) { std::vector<int> ans(n); vector<int>s(l+1,-1); ans[0]=0; s[0]=0; if(l%2==1)l--; for(int i=1;i<n;i++){ int low=1,hi=l,r; while(low<=hi){ int mid=(low+hi)/2; if(s[mid]==-1){ s[mid]=use_detector(mid); } if(s[mid]>=i){ hi=mid-1; r=mid; } else{ low=mid +1; } } ans[i]=2*r-2-ans[i-1]; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:25:17: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |       ans[i]=2*r-2-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...