#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
int ar[MAXN];
void detect_pitch(int n) {
memset(ar, -1, sizeof ar);
ar[0] = 0;
ar[1] = ask(0, 1);
for (int i = 1; i + 1 < n; i++) {
int a = ar[i], b = ar[i - 1];
int one = ask(i, i + 1);
int two = ask(i - 1, i + 1);
if (a < b) {
if (a - one + two == b)
ar[i + 1] = a - one;
else
ar[i + 1] = a + one;
} else {
if (a + one - two == b)
ar[i + 1] = a + one;
else
ar[i + 1] = a - one;
}
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (abs(ar[i] - ar[j]) != n - 1)
continue;
int add = 0 - min(ar[i], ar[j]);
for (int k = 0; k < n; k++) {
ar[k] += add;
}
if (ar[i] > ar[j]) {
for (int k = 0; k < n; k++) {
ar[k] = n - 1 - ar[k];
}
}
}
}
for (int i = 0; i < n; i++) {
answer(i, ar[i]);
}
}
Compilation message
xylophone.cpp: In function 'void detect_pitch(int)':
xylophone.cpp:14:10: error: 'ask' was not declared in this scope
ar[1] = ask(0, 1);
^~~