fork download
  1. #include <bits/stdc++.h>
  2. #include "findposition.h"
  3. using namespace std;
  4.  
  5. const int MAXN = 8e4;
  6.  
  7. int n, k;
  8. int t[4 * MAXN];
  9.  
  10. void build(int v, int tl, int tr)
  11. {
  12. if (tl == tr) {
  13. t[v] = tl;
  14. }
  15. else {
  16. int tm = (tl + tr) / 2;
  17. build(v * 2, tl, tm);
  18. build(v * 2 + 1, tm + 1, tr);
  19. t[v] = (IsLess(t[v * 2] + 1, t[v * 2 + 1] + 1) ? t[v * 2] : t[v * 2 + 1]);
  20. }
  21. }
  22.  
  23. void update(int v, int tl, int tr, int pos)
  24. {
  25. if (tl == tr) {
  26. t[v] = -1;
  27. }
  28. else {
  29. int tm = (tl + tr) / 2;
  30. if (pos <= tm)
  31. update(v * 2, tl, tm, pos);
  32. else
  33. update(v * 2 + 1, tm + 1, tr, pos);
  34. if (t[v * 2] == -1 && t[v * 2 + 1] == -1)
  35. t[v] = -1;
  36. else if (t[v * 2] == -1)
  37. t[v] = t[v * 2 + 1];
  38. else if (t[v * 2 + 1] == -1)
  39. t[v] = t[v * 2];
  40. else
  41. t[v] = (IsLess(t[v * 2] + 1, t[v * 2 + 1] + 1) ? t[v * 2] : t[v * 2 + 1]);
  42. }
  43. }
  44.  
  45. int main()
  46. {
  47. Init(n, k);
  48. build(1, 0, n - 1);
  49. for (int i = 0; i < k - 1; i++) {
  50. update(1, 0, n - 1, t[1]);
  51. }
  52. Finish(t[1] + 1);
  53. return 0;
  54. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:26: fatal error: findposition.h: No such file or directory
 #include "findposition.h"
                          ^
compilation terminated.
stdout
Standard output is empty