Submission #604485

#TimeUsernameProblemLanguageResultExecution timeMemory
604485ogibogi2004Finding Routers (IOI20_routers)C++14
96.85 / 100
6 ms700 KiB
#include "routers.h" #include <bits/stdc++.h> using namespace std; map<int,int> found; int use_detector1(int x) { if(found.count(x))return found[x]; auto it=found.lower_bound(x); if(it!=found.end()&&it!=found.begin()) { int t1=(*it).second; it--; int t2=(*it).second; if(t1==t2)return t1; } int t=use_detector(x); found[x]=t; return t; } vector<int> find_routers(int l, int n, int q) { vector<int>r; r.push_back(0); for(int j=1;j<n;j++) { int last=r.back(); int low=(last+2)/2,high=(l-l%2)/2; int mid=(low+high)/2,ans; while(low<=high) { mid=(low+high)/2; if(use_detector1((mid*2+last)/2)==j-1) { ans=mid*2; low=mid+1; } else high=mid-1; } r.push_back(ans); } //for(int i=0;i<r.size();i++)cout<<r[i]<<" "; //cout<<endl; return r; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...