Submission #590498

#TimeUsernameProblemLanguageResultExecution timeMemory
590498notaXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int maxN = 5001; int a[maxN]; int chk[maxN]; void solve(int n) { int l = 1, r = n; while(l <= r) { int mid = (l+r)/2; if(query(mid, n) == n-1) l = mid + 1; else r = mid - 1; } answer(r, 1); a[r] = 1; chk[1] = true; for(int i = r - 1; i >= 1; i--) { int que = query(i, i+1); if(a[i+1] - que < 1) { a[i] = a[i+1] + que; answer(i,a[i]); } else if(a[i+1] + que > n) { a[i] = a[i+1] - que; answer(i,a[i]); } else { if(chk[a[i+1]-que]) { a[i] = a[i+1] + que; answer(i, a[i]); } else if(chk[a[i+1] + que]) { a[i] = a[i+1] - que; answer(i,a[i]); } else { int c = a[i+1] - que; int maxx,minn; maxx = max(max(c,a[i+1]),a[i+2]); minn = min(min(c,a[i+1]),a[i+2]); if(query(i,i+2) == maxx - minn) { a[i] = c; answer(i,c); } else { a[i] = a[i+1] + que; answer(i,a[i+1] + que); } } } chk[a[i]] = true; } for(int i = r + 1; i <= n; i++) { int que = query(i-1,i); if(a[i-1] - que < 1) { a[i] = a[i-1] + que; answer(i,a[i]); } else if(a[i-1] + que > n) { a[i] = a[i-1] - que; answer(i,a[i]); } else { if(chk[a[i-1]-que]) { a[i] = a[i-1] + que; answer(i,a[i]); } else if(chk[a[i-1]+que]) { a[i] = a[i-1] - que; answer(i,a[i]); } else { int c = a[i-1] - que; int maxx,minn; maxx = max(max(c,a[i-1]),a[i-2]); minn = min(min(c,a[i-1]),a[i-2]); if(query(i-2,i) == maxx - minn) { a[i] = c; answer(i,c); } else { a[i] = a[i-1] + que; answer(i,a[i-1] + que); } } } chk[a[i]] = true; } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:13:12: error: 'query' was not declared in this scope
   13 |         if(query(mid, n) == n-1)    l = mid + 1;
      |            ^~~~~
xylophone.cpp:16:5: error: 'answer' was not declared in this scope
   16 |     answer(r, 1);
      |     ^~~~~~
xylophone.cpp:21:19: error: 'query' was not declared in this scope; did you mean 'que'?
   21 |         int que = query(i, i+1);
      |                   ^~~~~
      |                   que
xylophone.cpp:66:19: error: 'query' was not declared in this scope; did you mean 'que'?
   66 |         int que = query(i-1,i);
      |                   ^~~~~
      |                   que