Submission #227441

#TimeUsernameProblemLanguageResultExecution timeMemory
227441muhammad_hokimiyonXylophone (JOI18_xylophone)C++14
47 / 100
125 ms436 KiB
#include "xylophone.h" #include <bits/stdc++.h> const int N = 5e3 + 7; int b[N]; int get( int x , int y , int x1 , int y1 ) { if( x1 > y1 ){ if( y == x1 - y1 )return x1 - x; if( x == y )return x1 - x; return x1 + x; }else{ if( y == x + y1 - x1 )return x1 - x; if( y == y1 - x1 )return x1 + x; return x1 + x; } } void solve(int N) { int i = 1 , j = N; for( ; i + 1 <= j - 1; i++,j-- ){ if( query( i + 1 , j - 1 ) != N - 1 ){ while( query( i + 1 , j ) == N - 1 )i += 1; while( query( i , j - 1 ) == N - 1 )j -= 1; break; } } b[i] = 1; b[j] = N; if( i != 1 )b[i - 1] = query( i - 1 , i ) + 1; if( i + 1 < j )b[i + 1] = query( i , i + 1 ) + 1; if( j - 1 > i + 1 )b[j - 1] = N - query( j - 1 , j ); if( j != N )b[j + 1] = N - query( j , j + 1 ); for( int h = i - 2; h >= 1; h-- ){ int x = query( h , h + 1 ); int y = query( h , h + 2 ); b[h] = get( x , y , b[h + 1] , b[h + 2] ); } for( int h = i + 2; h <= j - 2; h++ ){ int x = query( h - 1 , h ); int y = query( h - 2 , h ); b[h] = get( x , y , b[h - 1] , b[h - 2] ); } for( int h = j + 2; h <= N; h++ ){ int x = query( h - 1 , h ); int y = query( h - 2 , h ); b[h] = get( x , y , b[h - 1] , b[h - 2] ); } for( int h = 1; h <= N; h++ ){ answer( h , b[h] ); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...