Submission #1115724

# Submission time Handle Problem Language Result Execution time Memory
1115724 2024-11-20T21:07:03 Z ahoraSoyPeor Circle Passing (EGOI24_circlepassing) C++14
14 / 100
78 ms 9248 KB
#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

Main.cpp: In function 'int main()':
Main.cpp:39:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf ( "%d%d%d", &N, &M, &Q );
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:42:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         scanf ( "%d", &curr_bff );
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:49:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |         scanf ( "%d%d", &x_i, &y_i );
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Output is correct
2 Correct 4 ms 536 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 9 ms 752 KB Output is correct
6 Correct 6 ms 848 KB Output is correct
7 Correct 5 ms 848 KB Output is correct
8 Correct 6 ms 848 KB Output is correct
9 Correct 6 ms 864 KB Output is correct
10 Correct 6 ms 848 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 592 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 78 ms 9248 KB Output is correct
4 Correct 20 ms 2248 KB Output is correct
5 Incorrect 6 ms 848 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Output is correct
2 Correct 4 ms 536 KB Output is correct
3 Correct 4 ms 592 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 9 ms 752 KB Output is correct
6 Correct 6 ms 848 KB Output is correct
7 Correct 5 ms 848 KB Output is correct
8 Correct 6 ms 848 KB Output is correct
9 Correct 6 ms 864 KB Output is correct
10 Correct 6 ms 848 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Incorrect 1 ms 336 KB Output isn't correct
15 Halted 0 ms 0 KB -