Submission #496608

#TimeUsernameProblemLanguageResultExecution timeMemory
496608ignaciocantaXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void solve(int n) { int low = 1, high = n; while(high - low > 1){ int mid = low + (high - low) / 2; if(query(1, mid) == n - 1) high = mid; else low = mid; } int posN = high; low = 1, high = n; while(high - low > 1){ int mid = low + (high - low) / 2; if(query(mid, n) == n - 1) low = mid; else high = mid; } vector<set<int>> cands(n+1); vector<bool> seen(n+1, 0), use(n+1, 0); cands[posN].insert(n); cands[low].insert(1); int tot = 0; while(tot < n){ int todo = -1; for(int i = 1; i <= n; ++i){ if(int(cands[i].size()) == 1 && !use[i]){ todo = *cands[i].begin(); use[i] = 1; //cout << "En " << i << " va " << todo << "\n"; answer(i, *cands[i].begin()); seen[todo] = 1; ++tot; if(i + 1 <= n && !use[i+1]){ int r1 = query(i, i+1); if(todo + r1 <= n && !seen[todo+r1]){ cands[i+1].insert(todo+r1); } if(todo - r1 >= 1 && !seen[todo-r1]){ cands[i+1].insert(todo-r1); } } if(i - 1 >= 1 && !use[i-1]){ int r1 = query(i-1, i); if(todo + r1 <= n && !seen[todo+r1]){ cands[i-1].insert(todo+r1); } if(todo - r1 >= 1 && !seen[todo-r1]){ cands[i-1].insert(todo-r1); } } break; } } for(int i = 1; i <= n; ++i){ if(cands[i].count(todo)){ cands[i].erase(todo); } } } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:8:6: error: 'query' was not declared in this scope
    8 |   if(query(1, mid) == n - 1) high = mid;
      |      ^~~~~
xylophone.cpp:15:6: error: 'query' was not declared in this scope
   15 |   if(query(mid, n) == n - 1) low = mid;
      |      ^~~~~
xylophone.cpp:30:5: error: 'answer' was not declared in this scope
   30 |     answer(i, *cands[i].begin());
      |     ^~~~~~
xylophone.cpp:34:15: error: 'query' was not declared in this scope
   34 |      int r1 = query(i, i+1);
      |               ^~~~~
xylophone.cpp:43:15: error: 'query' was not declared in this scope
   43 |      int r1 = query(i-1, i);
      |               ^~~~~