# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058094 | kachim2 | Circle Passing (EGOI24_circlepassing) | C++17 | 316 ms | 52692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main(){
int64_t n, m, q, pbm;
cin >> n >> m >> q;
set<int64_t> v;
auto pos = [n](int64_t x){
return ((x)+2*n)%(2*n);
};
for(int64_t i = 0; i < m; i++){
int64_t x;
cin >> x;
int64_t y = pos(x+n);
v.insert(x);
v.insert(y);
pbm = x;
}
auto dist = [n, &pos](int64_t x, int64_t y){
return min(pos(pos(x)-pos(y)), pos(pos(y)-pos(x)));
};
while(q--){
int64_t x, y;
cin >> x >> y;
int64_t bd = dist(x, y);
auto it1 = v.lower_bound(x);
if(it1==v.end()){
it1=v.begin();
}
auto it2 = v.upper_bound(x);
if(it2==v.begin())
it2=v.end();
it2--;
bd = min(dist(x, *it1)+dist(*it1+n, y)+1, bd);
bd = min(dist(x, *it2)+dist(*it2+n, y)+1, bd);
cout << bd << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |