Submission #1058700

#TimeUsernameProblemLanguageResultExecution timeMemory
1058700Szymon_PilipczukCircle Passing (EGOI24_circlepassing)C++17
0 / 100
112 ms4236 KiB
#include <iostream> #include <vector> using namespace std; vector<int> bf; int n,m; int bin_search(int c) { int l = 0; int r = m-1; int mid; while(r>l+1) { mid = (r+l)/2; if(bf[mid]>c) { r = mid; } else { l = mid; } } return l; } int main() { int q; cin>>n>>m>>q; int cu; for(int i = 0;i<m;i++) { cin>>cu; bf.push_back(cu); } int x,y; for(int i = 0;i<q;i++) { cin>>x>>y; if(x<y) { cu = y; y= x; x = cu; } int ans = min(x-y,y-x+2*n); if(x>=n && y>=n) { x-=n; y-=n; } int f = bin_search(y); int s = f+1; if(s == m) { s = 0; } if(bf[f]>y) { f =m-1; } ans = min(ans,1+max(y-bf[f],bf[f]-y)+max(x-(bf[f]+n),(bf[f]+n)-x)); ans = min(ans,1+max(y-bf[s],bf[s]-y)+max(x-(bf[s]+n),(bf[s]+n)-x)); cout<<ans<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...