제출 #502954

#제출 시각아이디문제언어결과실행 시간메모리
502954MardukXylophone (JOI18_xylophone)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = (1e3+7); bool arr[MAXN]; int memo_d[MAXN], memo_t[MAXN]; int sol[MAXN]; int D(int x){ if(memo_d[x]) return memo_d[x]; return memo_d[x] = query(x, x+1); } int T(int x){ if(memo_t[x]) return memo_t[x]; return memo_t[x] = query(x, x+2); } void solve(int N){ arr[2] = true; for(int i = 1;i<=N-2;i++){ if(D(i)+D(i+1) == T(i)) arr[i+2] = true; else arr[i+2] = false; } for(int i = 0;i<2;i++){ int MIN = MAXN; for(int i = 2;i<=N;i++){ sol[i] = sol[i-1] + (arr[i]%2-(arr[i]+1)%2)*D(i-1); MIN = min(MIN,sol[i]); arr[i]*=-1; } bool found = 0; for(int i = 1;i<=N;i++){ if(sol[i]+(1-MIN) == 1) break; if(sol[i]+(1-MIN) == N) {found = 1; break;} } if(!found){ for(int i = 1;i<=N;i++) answer(i,sol[i]+(1-MIN)); return; } } }

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

xylophone.cpp: In function 'int D(int)':
xylophone.cpp:12:24: error: 'query' was not declared in this scope
   12 |     return memo_d[x] = query(x, x+1);
      |                        ^~~~~
xylophone.cpp: In function 'int T(int)':
xylophone.cpp:17:24: error: 'query' was not declared in this scope
   17 |     return memo_t[x] = query(x, x+2);
      |                        ^~~~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:34:19: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
   34 |             arr[i]*=-1;
      |             ~~~~~~^~~~
xylophone.cpp:44:37: error: 'answer' was not declared in this scope
   44 |             for(int i = 1;i<=N;i++) answer(i,sol[i]+(1-MIN));
      |                                     ^~~~~~