Submission #363136

#TimeUsernameProblemLanguageResultExecution timeMemory
363136Bill_00Xylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; static int A[5000]; void solve(int n) { if(n==2){ answer(i,1); answer(i,n); return; } int a[5005],b[5005],c[5005]; for(int i=1;i<n;i++){ a[i]=query(i,i+1); } int val=query(1,3); if(val==a[1]+a[2]){ b[1]=1; b[2]=1; } else{ b[1]=1; b[2]=-1; } for(int i=2;i<n-1;i++){ int val=query(i,i+2); if(val==a[i]+a[i+1]){ if(b[i]==1) b[i+1]=1; else b[i+1]=-1; } else{ if(b[i]==1) b[i+1]=-1; else b[i+1]=1; } } c[1]=0; for(int i=2;i<=n;i++){ c[i]=c[i-1]+a[i]*b[i]; } pair<int,int>mx={-(n+1),-1},mn={n+1,-1}; for(int i=1;i<=n;i++){ mx=max(mx,{c[i],i}); mn=min(mn,{c[i],i}); } if(mx.second<mn.second){ for(int i=1;i<=n;i++){ c[i]=-c[i]; } } int ihesgegch=1-mn.first; for(int i=1;i<=n;i++){ answer(i,c[i]+ihesgegch); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:8:10: error: 'i' was not declared in this scope
    8 |   answer(i,1);
      |          ^
xylophone.cpp: At global scope:
xylophone.cpp:4:12: warning: 'A' defined but not used [-Wunused-variable]
    4 | static int A[5000];
      |            ^