Submission #995972

#TimeUsernameProblemLanguageResultExecution timeMemory
995972ThanhsXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
// #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <xylophone.h> using namespace std; #define int long long #define pb push_back // #define endl '\n' #define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define setmin(x,y) x=min((x),(y)) #define setmax(x,y) x=max((x),(y)) #define fi first #define se second mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count()); int rand(int l,int r){return l+((hdp()%(r-l+1))+r-l+1)%(r-l+1);} const int N = 1e4+5; const int mod = 998244353; const int SQ = 450; const int inf = 1e9+1; int ans[N],n; bool b[N]; bool check(int x) { if(x<0||x>n) return 0; return !b[x]; } void solve(int _n) { n=_n; int l=1,r=n-1; while(l<r-1) { int m=l+r>>1; if(query(1,m)!=n-1) r=m; else l=m; } ans[l]=1; b[1]=1; if(l-1) { ans[l-1]=ans[l]+query(l-1,l); b[ans[l-1]]=1; } if(l+1<=n) { ans[l+1]=ans[l]+query(l,l+1); b[ans[l+1]]=1; } for(int i=l-2;i>=1;i--) { int t=query(i,i+1); if(!check(ans[i+1]+t)) ans[i]=ans[i+1]-t; else if(!check(ans[i+1]-t)) ans[i]=ans[i+1]+t; if(!ans[i]) { int tt=query(i,i+2); if(tt==abs(ans[i+2]-ans[i+1])) { if(ans[i+2]>ans[i+1]) ans[i]=ans[i+1]+t; else ans[i]=ans[i+1]-t; } else if(tt==t) { if(ans[i+2]>ans[i+1]) ans[i]=ans[i+1]+t; else ans[i]=ans[i+1]-t; } else { if(ans[i+2]>ans[i+1]) ans[i]=ans[i+1]-t; else ans[i]=ans[i+1]+t; } } b[ans[i]]=1; } for(int i=1;i<=n;i++) answer(i,ans[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(long long int)':
xylophone.cpp:39:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   39 |         int m=l+r>>1;
      |               ~^~
/usr/bin/ld: /tmp/ccb6RBhU.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status