Submission #284238

#TimeUsernameProblemLanguageResultExecution timeMemory
284238YJUXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; const ll MOD=1e9+7; const ll MOD2=998244353; const ll N=2e5+5; const ld pi=3.14159265359; const ll INF=(1LL<<60); #define SQ(i) ((i)*(i)) #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(_a) (ll)_a.size() ll vis[N],ans[N],low=0; void solve(ll n){ for(ll i=18;i>=0;i--){ if(low+(1LL<<i)>=n)continue; if(query(low+(1LL<<i),n)==n-1){ low+=(1LL<<i); } } vis[ans[low]=1]=1; for(ll i=low;i<n;i++){ ll d=query(i,i+1); if(ans[i]+d>n||vis[ans[i]+d]){ans[i+1]=ans[i]-d;vis[ans[i+1]]=1;continue;} if(ans[i]-d<1||vis[ans[i]-d]){ans[i+1]=ans[i]+d;vis[ans[i+1]]=1;continue;} ll D=query(i-1,i+1); if(D==d+abs(ans[i]-ans[i-1])){ ans[i+1]=(ans[i]>ans[i-1]?ans[i]+d:ans[i]-d); vis[ans[i+1]]=1;continue; }else{ ans[i+1]=(ans[i]>ans[i-1]?ans[i]-d:ans[i]+d); vis[ans[i+1]]=1;continue; } } for(ll i=low;i>1;i--){ ll d=query(i,i-1); if(ans[i]+d>n||vis[ans[i]+d]){ans[i-1]=ans[i]-d;vis[ans[i-1]]=1;continue;} if(ans[i]-d<1||vis[ans[i]-d]){ans[i-1]=ans[i]+d;vis[ans[i-1]]=1;continue;} ll D=query(i-1,i+1); if(D==d+abs(ans[i]-ans[i+1])){ ans[i-1]=(ans[i]>ans[i+1]?ans[i]+d:ans[i]-d); vis[ans[i-1]]=1;continue; }else{ ans[i-1]=(ans[i]>ans[i+1]?ans[i]-d:ans[i]+d); vis[ans[i-1]]=1;continue; } } REP1(i,n)answer(i,ans[i]); return; }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(ll)':
xylophone.cpp:28:6: error: 'query' was not declared in this scope
   28 |   if(query(low+(1LL<<i),n)==n-1){
      |      ^~~~~
xylophone.cpp:34:8: error: 'query' was not declared in this scope
   34 |   ll d=query(i,i+1);
      |        ^~~~~
xylophone.cpp:47:8: error: 'query' was not declared in this scope
   47 |   ll d=query(i,i-1);
      |        ^~~~~
xylophone.cpp:59:11: error: 'answer' was not declared in this scope
   59 |  REP1(i,n)answer(i,ans[i]);
      |           ^~~~~~