# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1093698 | 2024-09-27T09:55:37 Z | kem | Circle Passing (EGOI24_circlepassing) | C++14 | 78 ms | 11252 KB |
#include <bits/stdc++.h> using namespace std; #define NAME "name" #define ll long long #define pb push_back #define pii pair<int, int> #define fi first #define se second #define endl "\n" #define sz(v) (int)(v).size() #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() const int LIM = 2e5 + 3; const int INF = 1e9; const int mod = 1e9 + 7; int n, m, q; pii p[LIM]; vector<int> num; int dist(int x, int y) { return min((x - y + (2 * n)) % (2 * n), (y - x + (2 * n)) % (2 * n)); } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (ifstream(NAME ".inp")) { freopen(NAME ".inp", "r", stdin); freopen(NAME ".out", "w", stdout); } cin >> n >> m >> q; memset(p, -1, sizeof(p)); for (int i = 1; i <= m; i++) { int x; cin >> x; num.pb(x); num.pb(x + n); } sort(all(num)); num.erase(unique(all(num)), num.end()); while (q--) { int x, y; cin >> x >> y; int pos1 = lower_bound(all(num), x) - num.begin(), pos2 = (pos1 ? pos1 : sz(num)) - 1; cout << min(dist(x, y), min(dist(x, num[pos1]) + 1 + dist(num[pos1] + n * ((num[pos1] >= n) ? -1 : 1), y), dist(x, num[pos2]) + 1 + dist(num[pos2] + n * ((num[pos2] >= n) ? -1 : 1), y))) << endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2140 KB | Output is correct |
2 | Correct | 4 ms | 2140 KB | Output is correct |
3 | Correct | 4 ms | 2140 KB | Output is correct |
4 | Correct | 1 ms | 1884 KB | Output is correct |
5 | Correct | 4 ms | 2140 KB | Output is correct |
6 | Correct | 5 ms | 2396 KB | Output is correct |
7 | Correct | 6 ms | 2488 KB | Output is correct |
8 | Correct | 6 ms | 2392 KB | Output is correct |
9 | Correct | 6 ms | 2396 KB | Output is correct |
10 | Correct | 5 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 1884 KB | Output is correct |
12 | Correct | 1 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Incorrect | 1 ms | 1884 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Incorrect | 1 ms | 1884 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2304 KB | Output is correct |
2 | Correct | 1 ms | 1880 KB | Output is correct |
3 | Correct | 78 ms | 8908 KB | Output is correct |
4 | Correct | 15 ms | 3804 KB | Output is correct |
5 | Correct | 4 ms | 2396 KB | Output is correct |
6 | Correct | 5 ms | 2396 KB | Output is correct |
7 | Correct | 4 ms | 2396 KB | Output is correct |
8 | Correct | 4 ms | 2396 KB | Output is correct |
9 | Correct | 4 ms | 2392 KB | Output is correct |
10 | Correct | 4 ms | 2392 KB | Output is correct |
11 | Correct | 5 ms | 2396 KB | Output is correct |
12 | Correct | 5 ms | 2396 KB | Output is correct |
13 | Correct | 4 ms | 2396 KB | Output is correct |
14 | Correct | 5 ms | 2396 KB | Output is correct |
15 | Correct | 37 ms | 6088 KB | Output is correct |
16 | Correct | 33 ms | 5988 KB | Output is correct |
17 | Correct | 71 ms | 11252 KB | Output is correct |
18 | Correct | 70 ms | 11056 KB | Output is correct |
19 | Correct | 1 ms | 1880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2140 KB | Output is correct |
2 | Correct | 4 ms | 2140 KB | Output is correct |
3 | Correct | 4 ms | 2140 KB | Output is correct |
4 | Correct | 1 ms | 1884 KB | Output is correct |
5 | Correct | 4 ms | 2140 KB | Output is correct |
6 | Correct | 5 ms | 2396 KB | Output is correct |
7 | Correct | 6 ms | 2488 KB | Output is correct |
8 | Correct | 6 ms | 2392 KB | Output is correct |
9 | Correct | 6 ms | 2396 KB | Output is correct |
10 | Correct | 5 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 1884 KB | Output is correct |
12 | Correct | 1 ms | 1884 KB | Output is correct |
13 | Correct | 1 ms | 1884 KB | Output is correct |
14 | Incorrect | 1 ms | 1884 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |