#include <bits/stdc++.h>
#include "xylophone.h"
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define pb push_back
#define pu push
#define ins insert
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ff(x,a,b,c) for (auto x=a;x<=b;x+=c)
#define fd(x,a,b,c) for (auto x=a;x>=b;x-=c)
#define int ll
using namespace std;
const int N = 1e4+5;
const int mod = 1e9+7;
int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;}
int a[N];
int check[N];
int ans[N];
void solve(int n)
{
a[2] = query(1,2); check[2] = 0;
for (int i=3;i<=n;i++)
{
int x = query(i-1,i),y = query(i-2,i);
a[i] = x;
if (a[i-1]+a[i]==y) check[i] = check[i-1];
else check[i] = 1-check[i-1];
}
for (int i=1;i<=n;i++) ans[i] = ans[i-1]+a[i]*(1-check[i]*2);
int mx = LLONG_MIN,mn = LLONG_MAX,idx1,idx2;
for (int i=1;i<=n;i++)
{
if (mx<ans[i]) mx = ans[i],idx1 = i;
if (mn>ans[i]) mn = ans[i],idx2 = i;
}
int tmp = mn;
if (idx1<idx2)
{
for (int i=1;i<=n;i++) ans[i] = ans[i-1]+a[i]*(check[i]*2-1);
tmp = -mx;
}
for (int i=1;i<=n;i++) answer(i,ans[i]-tmp+1);
}
Compilation message
xylophone.cpp: In function 'void solve(long long int)':
xylophone.cpp:43:2: warning: 'idx2' may be used uninitialized in this function [-Wmaybe-uninitialized]
43 | if (idx1<idx2)
| ^~
xylophone.cpp:43:2: warning: 'idx1' may be used uninitialized in this function [-Wmaybe-uninitialized]
/usr/bin/ld: /tmp/ccvKHhlN.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status