Submission #234669

#TimeUsernameProblemLanguageResultExecution timeMemory
234669Nodir_BobievXylophone (JOI18_xylophone)C++14
47 / 100
119 ms384 KiB
#include "xylophone.h" void solve(int N) { int idx = 1; for( idx; idx <= N; idx ++ ){ if( query(1, idx) == N-1 ) break; } int ans[N+2] = {}; ans[idx] = N; if( idx != 1 ) ans[idx-1] = N - query(idx-1, idx); if( idx != N ) ans[idx+1] = N - query(idx, idx+1 ); for( int i = idx-2; i >= 1; i -- ){ int val1 = query(i, i+1); int val2 = query(i, i+2); if( ans[i+1] < ans[i+2] ){ if( ans[i+2]-ans[i+1] > val1 and val2 == ans[i+2] - ans[i+1]){ ans[i] = ans[i+1] + val1; } else if( val2 > val1 ){ ans[i] = ans[i+1] - val1; } else{ ans[i] = ans[i+1] + val1; } }else{ if( ans[i+1]-ans[i+2] > val1 and val2 == ans[i+1] - ans[i+2]){ ans[i] = ans[i+1] - val1; } else if( val2 > val1 ){ ans[i] = ans[i+1] + val1; } else{ ans[i] = ans[i+1] - val1; } } } for( int i = idx+2; i <= N; i ++ ){ int val1 = query(i-1, i); int val2 = query(i-2, i); if( ans[i-2] > ans[i-1] ){ if( ans[i-2] - ans[i-1] > val1 and val2 == ans[i-2] - ans[i-1]){ ans[i] = ans[i-1] + val1; } else if( val2 > val1 ){ ans[i] = ans[i-1] - val1; }else{ ans[i] = ans[i-1] + val1; } }else{ if( ans[i-1]-ans[i-2] > val1 and val2 == ans[i-1] - ans[i-2] ){ ans[i] = ans[i-1] - val1; } else if( val2 > val1 ){ ans[i] = ans[i-1] + val1; }else{ ans[i] = ans[i-1] - val1; } } }/* for( int i = 1; i <= N; i ++ ){ printf("%d ", ans[i]); }printf("\n"); */ for( int i = 1; i <= N; i ++ ){ answer(i, ans[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:5:10: warning: statement has no effect [-Wunused-value]
  for( idx; idx <= N; idx ++ ){
          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...