# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115724 | ahoraSoyPeor | Circle Passing (EGOI24_circlepassing) | C++14 | 78 ms | 9248 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;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef pair <int,int> pii;
int N, M, Q;
vector <int> bff;
int dist ( int a, int b ) {
return min ( abs(b-a), 2*N-abs(b-a) );
}
bool check_bff ( int a, int b ) {
auto pnt_a = lower_bound ( bff.begin(), bff.end(), a ),
pnt_b = upper_bound ( bff.begin(), bff.end(), b );
if ( a <= b )
return pnt_b - pnt_a > 0;
return pnt_a != bff.end() or pnt_b != bff.begin();
}
int get_ans ( int x_i, int y_i ) {
int d_x = dist ( x_i, y_i ), bff_x = (x_i+N)%(2*N);
int res = d_x;
if ( check_bff ( y_i, bff_x ) )
res = min ( res, dist ( y_i, bff_x ) + 1 );
return res;
}
int main () {
#ifndef LOCAL
#endif
scanf ( "%d%d%d", &N, &M, &Q );
while ( M-- ) {
int curr_bff;
scanf ( "%d", &curr_bff );
bff.pb ( curr_bff ), bff.pb ( curr_bff + N );
}
sort ( bff.begin(), bff.end() );
while ( Q-- ) {
int x_i, y_i;
scanf ( "%d%d", &x_i, &y_i );
printf ( "%d\n", get_ans ( x_i, y_i ) );
}
return 0;
}
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... |