제출 #502264

#제출 시각아이디문제언어결과실행 시간메모리
502264vrohakXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int N) { int A[N]; A[0] = 0; int D[N - 1]; int T[N - 2]; for(int i = 1; i < N; i++) { D[i - 1] = query(i, i + 1); } for(int i = 2; i < N; i++) { T[i - 2] = query(i - 1, i + 1); } A[1] = D[0]; bool up = true; for(int i = 2; i < N; i++) { if(D[i - 2] + D[i - 1] != T[i - 2]) { up = !up; } A[i] = A[i - 1] + D[i - 1] * ((int)up * 2 - 1); } int rj1[N+1], rj2[N+1]; int mx = 0, mn = 0; int idx1 = 0, idx2 = 0; for(int i = 1; i < N; i++) { mn = min(mn, A[i]); } mn = (-1)*mn+1; for(int i=0;i<N;i++){ rj1[i] = A[i]+mn; rj2[i] = -A[i]; } mn=0; for(int i = 1; i < N; i++) { mn = min(mn, rj2[i]); } mn = (-1)*mn+1; for(int i=0;i<N;i++) rj2[i]+=mn; for(int i=0;i<N;i++){ if(rj1[i] == 1) idx1 = i; if(rj1[i] == n) idx2 = i; } if(idx1 < idx2) { for(int i = 0; i < N; i++) { answer(i + 1, rj1[i]); } } else { for(int i = 0; i < N; i++) { answer(i + 1, rj2[i]); } } return; }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:42:20: error: 'n' was not declared in this scope
   42 |       if(rj1[i] == n) idx2 = i;
      |                    ^
xylophone.cpp:24:6: warning: unused variable 'mx' [-Wunused-variable]
   24 |  int mx = 0, mn = 0;
      |      ^~