제출 #122019

#제출 시각아이디문제언어결과실행 시간메모리
122019eriksuenderhaufXylophone (JOI18_xylophone)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; const int MAXN = 1e4 + 5; int qry[MAXN][2]; int a[MAXN]; set<int> tmp; bool finish = 0; void detect_pitch(int n) { int mi = 0, fl = 0; for (int i = 0; i < n; i++) mi = min(mi, a[i]); for (int i = 0; i < n; i++) { a[i] -= mi; if (a[i] == n - 1 && !fl) return; if (a[i] == 0) fl = 1; } for (int i = 0; i < n; i++) answer(i, a[i]); finish = 1; } void solve(int n) { for (int i = 0; i + 1 < n; i++) qry[i][0] = ask(i, i + 1); for (int i = 0; i + 2 < n; i++) qry[i][1] = ask(i, i + 2); a[1] = qry[0][0]; tmp.insert(0); tmp.insert(a[1]); for (int i = 2; i < n; i++) { if (qry[i - 2][0] == qry[i - 2][1]) { int fl = 1; if (a[i - 1] > a[i - 2]) fl = -1; a[i] = a[i - 1] + fl * qry[i - 1][0]; } else if (qry[i - 2][0] + qry[i - 1][0] == qry[i - 2][1]) { int fl = 1; if (a[i - 1] < a[i - 2]) fl = -1; a[i] = a[i - 1] + fl * qry[i - 1][0]; } else { int fl = 1; if (a[i - 1] > a[i - 2]) fl = -1; a[i] = a[i - 1] + fl * qry[i - 1][0]; } tmp.insert(a[i]); } if ((int)tmp.size() == n) detect_pitch(n); if (finish) return; for (int i = 0; i < n; i++) a[i] = 0; tmp.clear(); a[1] = -qry[0][0]; tmp.insert(0); tmp.insert(a[1]); for (int i = 2; i < n; i++) { if (qry[i - 2][0] == qry[i - 2][1]) { int fl = 1; if (a[i - 1] > a[i - 2]) fl = -1; a[i] = a[i - 1] + fl * qry[i - 1][0]; } else if (qry[i - 2][0] + qry[i - 1][0] == qry[i - 2][1]) { int fl = 1; if (a[i - 1] < a[i - 2]) fl = -1; a[i] = a[i - 1] + fl * qry[i - 1][0]; } else { int fl = 1; if (a[i - 1] > a[i - 2]) fl = -1; a[i] = a[i - 1] + fl * qry[i - 1][0]; } tmp.insert(a[i]); } if ((int)tmp.size() == n) detect_pitch(n); }

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

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:28:21: error: 'ask' was not declared in this scope
         qry[i][0] = ask(i, i + 1);
                     ^~~
xylophone.cpp:30:21: error: 'ask' was not declared in this scope
         qry[i][1] = ask(i, i + 2);
                     ^~~