제출 #581841

#제출 시각아이디문제언어결과실행 시간메모리
581841YaserFaisalXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; void solve(int n) { int ans[5001] , pre_query[5001][5001] , found[100001] ; int one = 1 ; // searching for the one while ( true ) { pre_query[one+1][n] = query(one+1,n) ; if ( q[one+1][n] != n-1 ) break ; one++ ; } ans[one] = 1 ; found[1] = 1 ; //================================== for ( int i = one+1 ; i <= n ; i++ ) { int x , y ; x = pre_query[i-1][i] = query(i-1,i) ; if ( ans[i-1]+x > n || found[ans[i-1]+x] == 1 ) ans[i] = ans[i-1]-x ; else if ( ans[i-1]-x <= 1 || found[ans[i-1]-x] == 1 ) ans[i] = ans[i-1]+x ; else { y = pre_query[i-2][i] = query(i-2,i) ; if ( ans[i-1] > ans[i-2] ) { if ( y == pre_query[i-2][i-1] || y == x ) ans[i] = ans[i-1]-x ; else ans[i] = ans[i-1]+x ; } else { if ( y == pre_query[i-2][i-1] || y == x ) ans[i] = ans[i-1]+x ; else ans[i] = ans[i-1]-x ; } } } //======================== for ( int i = one-1 ; i >= 1 ; i-- ) { int x , y ; x = pre_query[i][i+1] = query(i,i+1) ; if ( ans[i+1]+x > n || found[ans[i+1]+x] == 1 ) ans[i] = ans[i+1]-x ; else if ( ans[i+1]-x <= 1 || found[ans[i+1]-x] == 1 ) ans[i] = ans[i+1]+x ; else { y = pre_query[i][i+2] = query(i,i+2) ; if ( ans[i+1] > ans[i+2] ) { if ( y == pre_query[i+1][i+2] || y == x ) ans[i] = ans[i+1]-x ; else ans[i] = ans[i+1]+x ; } else { if ( y == pre_query[i+1][i+2] || y == x ) ans[i] = ans[i+1]+x ; else ans[i] = ans[i+1]-x ; } } } //======================== for ( int i = 1 ; i <= n ; i++ ) answer(i,ans[i]) ; } //query(s,t) , return abs(A[s]-A[t]) // answer(i,a) , A[i] = a

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:15:14: error: 'q' was not declared in this scope
   15 |         if ( q[one+1][n] != n-1 ) break ;
      |              ^
xylophone.cpp: At global scope:
xylophone.cpp:5:12: warning: 'A' defined but not used [-Wunused-variable]
    5 | static int A[5000];
      |            ^