# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1093702 | kem | Circle Passing (EGOI24_circlepassing) | C++14 | 74 ms | 9816 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
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;
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()) % sz(num), pos2 = (pos1 - 1 + sz(num)) % sz(num);
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;
}
컴파일 시 표준 에러 (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... |