# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058088 | kachim2 | Circle Passing (EGOI24_circlepassing) | C++17 | 210 ms | 33316 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(){
int n, m, q, pbm;
cin >> n >> m >> q;
set<int> v;
auto pos = [n](int x){
return ((x)+2*n)%(2*n);
};
for(int i = 0; i < m; i++){
int x;
cin >> x;
int y = pos(x+n);
v.insert(x);
v.insert(y);
pbm = x;
}
auto dist = [n, &pos](int x, int y){
return min(pos(pos(x)-pos(y)), pos(pos(y)-pos(x)));
};
while(q--){
int x, y;
cin >> x >> y;
int 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... |