제출 #502263

#제출 시각아이디문제언어결과실행 시간메모리
502263vrohakXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include "xylophone.h" 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:22:13: error: 'n' was not declared in this scope
   22 |     int rj1[n+1], rj2[n+1];
      |             ^
xylophone.cpp:26:8: error: 'min' was not declared in this scope; did you mean 'mn'?
   26 |   mn = min(mn, A[i]);
      |        ^~~
      |        mn
xylophone.cpp:30:7: error: 'rj1' was not declared in this scope
   30 |       rj1[i] = A[i]+mn;
      |       ^~~
xylophone.cpp:31:7: error: 'rj2' was not declared in this scope
   31 |       rj2[i] = -A[i];
      |       ^~~
xylophone.cpp:35:16: error: 'rj2' was not declared in this scope
   35 |   mn = min(mn, rj2[i]);
      |                ^~~
xylophone.cpp:35:8: error: 'min' was not declared in this scope; did you mean 'mn'?
   35 |   mn = min(mn, rj2[i]);
      |        ^~~
      |        mn
xylophone.cpp:38:25: error: 'rj2' was not declared in this scope
   38 |    for(int i=0;i<N;i++) rj2[i]+=mn;
      |                         ^~~
xylophone.cpp:40:10: error: 'rj1' was not declared in this scope
   40 |       if(rj1[i] == 1) idx1 = i;
      |          ^~~
xylophone.cpp:41:10: error: 'rj1' was not declared in this scope
   41 |       if(rj1[i] == n) idx2 = i;
      |          ^~~
xylophone.cpp:45:18: error: 'rj1' was not declared in this scope
   45 |    answer(i + 1, rj1[i]);
      |                  ^~~
xylophone.cpp:49:18: error: 'rj2' was not declared in this scope
   49 |    answer(i + 1, rj2[i]);
      |                  ^~~
xylophone.cpp:23:6: warning: unused variable 'mx' [-Wunused-variable]
   23 |  int mx = 0, mn = 0;
      |      ^~