제출 #400987

#제출 시각아이디문제언어결과실행 시간메모리
400987jairRSFinding Routers (IOI20_routers)C++17
94.99 / 100
2 ms628 KiB
#include "routers.h" #define pb push_back using namespace std; std::vector<int> find_routers(int l, int n, int q) { vector<int> ans = {0}; vector<int> lastSeen(n + 1, l); vector<int> memo(l + 1, -1); lastSeen[0] = 0; int lastRouterIndex = 0; for (int toFind = 1; toFind <= n - 1; toFind++) { int lo = lastRouterIndex + 2, hi = lastSeen[toFind + 1]; while(lo <= hi){ int mid = (lo + hi)/2; int detected = (memo[mid] != -1 ? memo[mid] : use_detector(mid)); memo[mid] = detected; if(detected >= toFind) hi = mid - 1; else lo = mid + 1; lastSeen[detected] = min(lastSeen[detected], mid); } int nextRouter = lastRouterIndex + (lo - 1 - lastRouterIndex)*2; ans.pb(nextRouter); lastRouterIndex = nextRouter; } 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...