fork download
  1. #include <bits/stdc++.h>
  2. #include "minerals.h"
  3.  
  4. using namespace std;
  5.  
  6. bool query(int x) {
  7. static int last = 0;
  8. int cur = Query(x);
  9. bool ans = cur != last;
  10. last = cur;
  11. return ans;
  12. }
  13.  
  14. void solve(vector<int> l, vector<int> r, bool fill) {
  15. int n = (int) l.size(), m = ceil(n * 0.36);
  16. if (fill) {
  17. m = n - m;
  18. }
  19. if (n == 1) {
  20. Answer(l[0], r[0]);
  21. return;
  22. }
  23. if (fill) {
  24. for (int i = n - 1; i >= m; --i) {
  25. query(l[i]);
  26. }
  27. } else {
  28. for (int i = 0; i < m; ++i) {
  29. query(l[i]);
  30. }
  31. }
  32. vector<int> left, right;
  33. random_shuffle(r.begin(), r.end());
  34. for (auto i : r) {
  35. if ((int) left.size() == m) {
  36. right.push_back(i);
  37. } else if ((int) right.size() == n - m) {
  38. left.push_back(i);
  39. } else if (query(i)) {
  40. right.push_back(i);
  41. } else {
  42. left.push_back(i);
  43. }
  44. }
  45. solve(vector<int>(l.begin(), l.begin() + m), left, true);
  46. solve(vector<int>(l.begin() + m, l.end()), right, false);
  47. }
  48.  
  49. void Solve(int n) {
  50. vector<int> l, r;
  51. for (int i = 1; i <= n * 2; ++i) {
  52. if (query(i) == 1) {
  53. l.push_back(i);
  54. } else {
  55. r.push_back(i);
  56. }
  57. }
  58. solve(l, r, true);
  59. }
  60.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:22: fatal error: minerals.h: No such file or directory
 #include "minerals.h"
                      ^
compilation terminated.
stdout
Standard output is empty