Submission #763302

#TimeUsernameProblemLanguageResultExecution timeMemory
763302vjudge1Xylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5003; int ans[N]; vector <int> w; void solve(int n){ w.push_back(1); w.push_back(n+1); int l = 1, r = n; while(l < r){ int mid = (l+r)/2; int x = query(1, mid); if (x == (n-1)){ r = mid; } else { l = mid+1; } } ans[l] = n; w.push_back(l); l = 1, r = n; while(l < r){ int mid = (l+r)/2; int x = query(mid, n); if (x == (n-1)){ l = mid; } else { r = mid-1; } } ans[l] = 1; w.push_back(l); for (int k = n-1; k > 1; k--){ sort(w.begin(), w.end()); int reset = 0; int l = 1, r = n; for (int i = 0; i < (int)w.size() - 1; i++){ if (reset){ break; } l = w[i], r = w[i+1] - 1; while(l < r){ int mid = (l+r)/2; int x = query(w[i], mid); if (x == abs(ans[w[i]] - k)){ r = mid; reset = 1; } else { l = mid+1; } } } ans[l] = k; w.push_back(l); } for (int i = 1; i <= n; i++){ answer(i, ans[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:15:17: error: 'query' was not declared in this scope
   15 |         int x = query(1, mid);
      |                 ^~~~~
xylophone.cpp:27:17: error: 'query' was not declared in this scope
   27 |         int x = query(mid, n);
      |                 ^~~~~
xylophone.cpp:47:25: error: 'query' was not declared in this scope
   47 |                 int x = query(w[i], mid);
      |                         ^~~~~
xylophone.cpp:60:9: error: 'answer' was not declared in this scope
   60 |         answer(i, ans[i]);
      |         ^~~~~~