fork(3) download
  1. const int sz = 20000;
  2. struct query {
  3. int s, e, k, m, res;
  4. } qu[105];
  5. int qn, cnt[105];
  6. const int mod = 1000000007;
  7. inline bool cmp(query q1, query q2) {
  8. return q1.m < q2.m;
  9. }
  10. class LimitedMemorySeries1 {
  11. public:
  12. void upd(int X) {
  13. int lo = 0, hi = qn - 1, md, F = qn;
  14. while (lo <= hi) {
  15. md = (lo + hi) / 2;
  16. if (qu[md].m < X) lo = md + 1;
  17. else {
  18. F = min(F, md);
  19. hi = md - 1;
  20. }
  21. }
  22. cnt[F]++;
  23. }
  24. long long getSum(int n, int x0, int a, int b, vector <int> q) {
  25. sort(q.begin(), q.end());
  26. qn = q.size();
  27. for (int i = 0; i < qn; i++) qu[i] = { 0, mod - 1, q[i], 0, mod - 1 };
  28. long long res = 0;
  29. for (int K = 0; K < 32; K++) {
  30. for (int i = 0; i < qn; i++) qu[i].m = (qu[i].s + qu[i].e) / 2;
  31. sort(qu, qu + qn, cmp);
  32. for (int i = 0; i < qn; i++) cnt[i] = 0;
  33. int qi = 0;
  34. long long X;
  35. X = x0;
  36. upd(X);
  37. for (int i = 1; i < n; i++) {
  38. X = (X*a + b) % mod;
  39. upd(X);
  40. }
  41. for (int i = 1; i < qn; i++) cnt[i] += cnt[i - 1];
  42. for (int i = 0; i < qn; i++) {
  43. if (cnt[i] > qu[i].k) qu[i].e = qu[i].m - 1, qu[i].res = min(qu[i].res, qu[i].m);
  44. else qu[i].s = qu[i].m + 1;
  45. }
  46. }
  47. for (int i = 0; i < qn; i++) res += qu[i].res;
  48. return res;
  49. }
  50. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:24:48: error: 'vector' has not been declared
  long long getSum(int n, int x0, int a, int b, vector <int> q) {
                                                ^
prog.cpp:24:55: error: expected ',' or '...' before '<' token
  long long getSum(int n, int x0, int a, int b, vector <int> q) {
                                                       ^
prog.cpp: In member function 'void LimitedMemorySeries1::upd(int)':
prog.cpp:18:18: error: 'min' was not declared in this scope
     F = min(F, md);
                  ^
prog.cpp: In member function 'long long int LimitedMemorySeries1::getSum(int, int, int, int, int)':
prog.cpp:25:8: error: 'q' was not declared in this scope
   sort(q.begin(), q.end());
        ^
prog.cpp:25:26: error: 'sort' was not declared in this scope
   sort(q.begin(), q.end());
                          ^
prog.cpp:27:38: error: no match for 'operator=' (operand types are 'query' and '<brace-enclosed initializer list>')
   for (int i = 0; i < qn; i++) qu[i] = { 0, mod - 1, q[i], 0, mod - 1 };
                                      ^
prog.cpp:2:8: note: candidate: query& query::operator=(const query&)
 struct query {
        ^
prog.cpp:2:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const query&'
prog.cpp:2:8: note: candidate: query& query::operator=(query&&)
prog.cpp:2:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'query&&'
prog.cpp:43:84: error: 'min' was not declared in this scope
     if (cnt[i] > qu[i].k) qu[i].e = qu[i].m - 1, qu[i].res = min(qu[i].res, qu[i].m);
                                                                                    ^
stdout
Standard output is empty