Submission #867354

#TimeUsernameProblemLanguageResultExecution timeMemory
867354lalig777Finding Routers (IOI20_routers)C++14
0 / 100
1 ms348 KiB
#include "routers.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> find_routers(int l, int n, int q){ vector<int>ans(n); vector<int>before(n, -1); ans[0]=0; if (l%2!=0) l--; vector<pair<int,int>>memoria(n, make_pair(0, 1e9)); for (int i=1; i<n; i++){ int right=min(l-2*(n-i-1), 2*memoria[i].second-ans[i-1]-2); int left=max(ans[i-1]+2, 2*memoria[i-1].first-ans[i-1]); int m; bool tipo=false; while (left!=right){ m=(right-left)/2+left; if (m%2!=0) m++; if (left+2==right){ int m3=(left-ans[i-1])/2+ans[i-1]; if (m3%2==0) m3+=2; else m3++; if (use_detector(m3)==i) right-=2; else left+=2; } else if (tipo==false){ if (use_detector(m)==i+1){ memoria[i+1].second=min(memoria[i+1].second, m); right=m-2; }else{ memoria[i].first=max(memoria[i].first, m); tipo=true; } }else{ int m2=(right-m)/2+m; if (m2%2!=0) m2++; if (use_detector(m2)==i+1){ memoria[i+1].second=min(memoria[i+1].second, m2); right=m-2; tipo=false; }else{ memoria[i].first=max(memoria[i].first, m2); left=m; } } }ans[i]=left; }return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...