| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355484 | mxhrvs | Circle Passing (EGOI24_circlepassing) | C++20 | 60 ms | 8660 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m, q;
ll dist(ll x, ll y) {
ll d = abs(x - y);
return min(d, 2 * n - d);
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> n >> m >> q;
vector<ll> s;
for(int i = 0; i < m; i++){
ll k; cin >> k;
s.push_back(k);
s.push_back(k + n);
}
sort(s.begin(), s.end());
while(q--){
ll x, y;
cin >> x >> y;
ll ans = dist(x, y);
auto it = lower_bound(s.begin(), s.end(), x);
vector<ll> v;
if (it != s.end()) v.push_back(*it);
if (it != s.begin()) v.push_back(*prev(it));
else v.push_back(s.back());
for (ll x1 : v) {
ll y1 = (x1 < n) ? (x1 + n) : (x1 - n);
ll mn = dist(x, x1) + 1 + dist(y1, y);
ans = min(ans, mn);
}
cout << ans << "\n";
}
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
