Submission #330804

#TimeUsernameProblemLanguageResultExecution timeMemory
330804FidiskXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define oo 1e9 #define fi first #define se second #define sp(iiii) setprecision(iiii) #define IO ios_base::sync_with_stdio(false); cin.tie(0) #define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa)) #define cntbit(xxxx) __builtin_popcount(xxxx) #define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1) typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pair<int,int>,int> piii; typedef pair<long long,long long> pll; typedef pair<pair<long long,long long>,long long> plll; const ll mod=1e9+7; bool ok[5009]; int a[5009],type[5009],ans[5009],last,i,j,n,b[5009]; bool check(int x,int t) { last=1; ms(ok,false); ans[1]=x; ok[x]=true; if (t==1) { for (int ii=1;ii<=n;ii++) { if (type[ii]==1) { if (last==1) { ans[ii]=ans[ii-1]+a[ii-1]; } else { ans[ii]=ans[ii-1]-a[ii-1]; } } else { if (last==1) { ans[ii]=ans[ii-1]-a[ii-1]; } else { ans[ii]=ans[ii-1]+a[ii-1]; } } if (!ok[ans[ii]]) { ok[ans[ii]]=true; } else { return false; } } } else { last=0; for (int ii=1;ii<=n;ii++) { if (type[ii]==1) { if (last==1) { ans[ii]=ans[ii-1]+a[ii-1]; } else { ans[ii]=ans[ii-1]-a[ii-1]; } } else { if (last==1) { ans[ii]=ans[ii-1]-a[ii-1]; } else { ans[ii]=ans[ii-1]+a[ii-1]; } } if (!ok[ans[ii]]&&ans[ii]>=1&&ans[ii]<=n) { ok[ans[ii]]=true; } else { return false; } } } return true; } void solve(int n) { if (n==2) { answer(1,1); answer(2,2); return; } for (i=1;i<n;i++) { a[i]=query(i,i+1); } for (i=1;i<n-1;i++) { b[i]=query(i,i+2); } for (i=1;i<=n-2;i++) { if (a[i]==b[i]||a[i+1]==b[i]) { type[i+1]=1; } else { type[i+1]=0; } } for (i=1;i<=n;i++) { if (check(i,1)) { for (j=1;j<=n;j++) { answer(i,a[i]); } } if (check(i,0)) { for (j=1;j<=n;j++) { answer(i,a[i]); } } } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:89:9: error: 'answer' was not declared in this scope
   89 |         answer(1,1);
      |         ^~~~~~
xylophone.cpp:94:14: error: 'query' was not declared in this scope
   94 |         a[i]=query(i,i+1);
      |              ^~~~~
xylophone.cpp:97:14: error: 'query' was not declared in this scope
   97 |         b[i]=query(i,i+2);
      |              ^~~~~
xylophone.cpp:110:17: error: 'answer' was not declared in this scope
  110 |                 answer(i,a[i]);
      |                 ^~~~~~
xylophone.cpp:115:17: error: 'answer' was not declared in this scope
  115 |                 answer(i,a[i]);
      |                 ^~~~~~