제출 #227445

#제출 시각아이디문제언어결과실행 시간메모리
227445muhammad_hokimiyonXylophone (JOI18_xylophone)C++14
47 / 100
103 ms512 KiB
#include "xylophone.h" #include <bits/stdc++.h> const int NN = 5e3 + 7; int b[NN]; 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; int l = i , r = n; while( l < r ){ int m = (l + r) / 2; if( query( m + 1 , n ) != n - 1 )r = m; else l = m + 1; } i = l; b[i] = 1; if( i != 1 )b[i - 1] = query( i - 1 , i ) + 1; b[i + 1] = query( i , i + 1 ) + 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 <= 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] ); } }

컴파일 시 표준 에러 (stderr) 메시지

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:23:17: warning: unused variable 'j' [-Wunused-variable]
     int i = 1 , j = n;
                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...