Submission #1115724

#TimeUsernameProblemLanguageResultExecution timeMemory
1115724ahoraSoyPeorCircle Passing (EGOI24_circlepassing)C++14
14 / 100
78 ms9248 KiB
#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)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...