제출 #806712

#제출 시각아이디문제언어결과실행 시간메모리
806712LIFFinding Routers (IOI20_routers)C++14
39 / 100
1 ms256 KiB
#include "routers.h" #include<bits/stdc++.h> using namespace std; int pos[300005]; bool check(int now,int find) { int idx = use_detector(now); if(idx >= find)return true; else return false; } std::vector<int> find_routers(int l, int n, int q) { /*std::vector<int> ans; for (int i = 0; i < n; i++) { ans.push_back(0); }*/ pos[0] = 0; for(int i=1;i<n;i++) { int ll = pos[i]; int rr = l - (i-1) * 2; int ans; while(ll <= rr) { int mid = (ll+rr)>>1; if(check(mid,i) == true) { ans = mid; rr = mid - 1; } else ll = mid + 1; } pos[i] = pos[i-1] + (ans - 1 - pos[i-1]) * 2; } vector<int> temp; for(int i=0;i<n;i++)temp.push_back(pos[i]); return temp; }

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

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