제출 #478982

#제출 시각아이디문제언어결과실행 시간메모리
478982ponytailXylophone (JOI18_xylophone)C++17
컴파일 에러
0 ms0 KiB
//SUBMIT #include <bits/stdc++.h> #include "xylophone.h" using namespace std; static int A[N_MAX]; void solve(int N) { int value = query(1, N); int P[N+1]; int delta[N+1]; int one[N+1], two[N+1]; for(int i = 1; i < N; i++) { one[i] = query(i, i+1); } for(int i=1; i<N-1; i++) { two[i] = query(i, i+2); } if(one[1] + one[2] == two[1]) delta[1] = one[1], delta[2] = one[2]; else delta[1] = one[1], delta[2] = -one[2]; for(int i=3; i<N; i++) { if(one[i-1] + one[i] == two[i-1]) delta[i] = (delta[i-1] > 0 ? 1 : -1) * one[i]; else delta[i] = (delta[i-1] > 0 ? -1 : 1) * one[i]; } int mini, maxi, cur; mini = 1e9, maxi = -1e9, cur = 0; for(int i=1; i<N; i++) { cur += delta[i]; mini = min(mini, cur); maxi = max(maxi, cur); } cur = 0; int pos[N+1]; for(int i=2; i<=N; i++) { cur += delta[i-1]; P[i] = cur - mini + 1; pos[P[i]] = i; } P[1] = -mini + 1; if(pos[1] > pos[N]) { for(int i=1; i<N; i++) delta[i] *= -1; mini = 1e9, maxi = -1e9, cur = 0; for(int i=1; i<N; i++) { cur += delta[i]; mini = min(mini, cur); maxi = max(maxi, cur); } cur = 0; for(int i=2; i<=N; i++) { cur += delta[i-1]; P[i] = cur - mini + 1; } P[1] = -mini + 1; } for(int i=1; i<=N; i++) { answer(i, P[i]); } } //END SUBMIT

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

xylophone.cpp:9:14: error: 'N_MAX' was not declared in this scope; did you mean 'NL_NMAX'?
    9 | static int A[N_MAX];
      |              ^~~~~
      |              NL_NMAX
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:13:6: warning: unused variable 'value' [-Wunused-variable]
   13 |  int value = query(1, N);
      |      ^~~~~