#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
// int a[N], L[N], R[N];
int par[N];
// int get(int l, int r) {
// int gcd = 0;
// for (int i = l; i <= r; ++i) gcd = __gcd(gcd, a[i]);
// return gcd;
// }
// int query(int a, int b, int c, int d) {
// return get(a, b) == get(c, d);
// }
int solve(int n, int* L, int* R) {
memset(par, -1, sizeof par);
L[0] = R[0] = -1;
for (int i = 1; i < n; ++i) {
int cur = i - 1;
L[i] = R[i] = -1;
while (1) {
if (query(cur, i, i, i)) {
if (par[cur] == -1) {
par[cur] = i, L[i] = cur; break;
}
else cur = par[cur];
}
else {
if (R[cur] == -1) R[cur] = i, par[i] = cur;
else par[R[cur]] = i, par[i] = cur, L[i] = R[cur], R[cur] = i;
break;
}
}
}
}
// int main() {
// int n; cin >> n;
// for (int i = 0; i < n; ++i) cin >> a[i];
// solve(n, L, R);
// for (int i = 0; i < n; ++i) cout << L[i] << ' '; cout << '\n';
// for (int i = 0; i < n; ++i) cout << R[i] << ' '; cout << '\n';
// }
Compilation message
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:27:8: error: 'query' was not declared in this scope
if (query(cur, i, i, i)) {
^~~~~
popa.cpp:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^