Submission #807103

#TimeUsernameProblemLanguageResultExecution timeMemory
807103LIFFinding Routers (IOI20_routers)C++14
97.90 / 100
1 ms340 KiB
#include "routers.h" #include<bits/stdc++.h> using namespace std; int pos[300005]; int minn[300005]; bool check(int now,int find) { int idx = use_detector(now); minn[idx] = min(minn[idx],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++)minn[i] = l; for(int i=1;i<n;i++) { int ll = pos[i-1]; int rr = minn[i]; 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; }

Compilation message (stderr)

routers.cpp: In function 'std::vector<int> find_routers(int, int, int)':
routers.cpp:35:28: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |   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...