QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#210372#7449. rgxsxrsNero80 3499ms58340kbC++2010.1kb2023-10-11 12:23:002023-10-11 12:23:00

Judging History

你现在查看的是最新测评结果

  • [2023-10-11 12:23:00]
  • 评测
  • 测评结果:80
  • 用时:3499ms
  • 内存:58340kb
  • [2023-10-11 12:23:00]
  • 提交

answer

#include <bits/stdc++.h>
#ifdef ALGO
#include "magica.hpp"
#else
#define DUMP(...)
#define CHECK(...) (__VA_ARGS__)
#endif

namespace {

using LL = long long;
const int INF = 0x3f3f3f3f;

using ValueType = int;

struct Summary {
  LL sum = 0;
  int cnt = 0;
  ValueType vmin = INF;
  ValueType vmax = 0;

  void reset(ValueType value) {
    sum = vmin = vmax = value;
    cnt = 1;
  }

  Summary& append(ValueType value) {
    sum += value;
    ++cnt;
    vmin = std::min(vmin, value);
    vmax = std::max(vmax, value);
    return *this;
  }

  Summary& apply(ValueType added) {
    if (cnt != 0 && added) {
      sum += LL(cnt) * added;
      vmin += added;
      vmax += added;
    }
    return *this;
  }
};

Summary& operator+=(Summary& lhs, const Summary& rhs) {
  lhs.sum += rhs.sum;
  lhs.cnt += rhs.cnt;
  lhs.vmin = std::min(lhs.vmin, rhs.vmin);
  lhs.vmax = std::max(lhs.vmax, rhs.vmax);
  return lhs;
}

Summary operator+(Summary lhs, const Summary& rhs) {
  lhs += rhs;
  return lhs;
}

inline int get_highest_bit(unsigned x) {
  return 31 - __builtin_clz(x);
}

struct CompressedTrie {
  CompressedTrie* ch[2] = {};
  unsigned bits : 27, height : 5;

  Summary summary;
  ValueType lazy_tag = 0;

  void apply(ValueType tag) {
    summary.apply(tag);
    lazy_tag += tag;
  }

  void down() {
    if (lazy_tag == 0) return;
    if (ch[0]) ch[0]->apply(lazy_tag);
    if (ch[1]) ch[1]->apply(lazy_tag);
    lazy_tag = 0;
  }
};

template<typename T>
class MemoryPool {
 public:
  T* allocate() {
    if (__builtin_expect(pool_.empty(), false)) {
      T* arr = new T[kReAllocSize];
      for (int i = 0; i < kReAllocSize; ++i) {
        pool_.emplace_back(arr + i);
      }
    }

    T* ret = pool_.back(); pool_.pop_back();
    return new(ret) T{};
  }

  void free(T* ptr) {
    pool_.emplace_back(ptr);
  }

 private:
  static constexpr int kReAllocSize = 1024;

  std::vector<T*> pool_;
};

MemoryPool<CompressedTrie> pool;

void insert(CompressedTrie*& trie, unsigned bits, ValueType value) {
  if (trie == nullptr) {
    trie = pool.allocate();
    trie->bits = bits;
    trie->height = 0;
    trie->summary.reset(value);
  } else if ((trie->bits ^ bits) >> trie->height) {
    int new_height = get_highest_bit(trie->bits ^ bits) + 1;
    CompressedTrie* new_trie = pool.allocate();
    new_trie->bits = trie->bits;
    new_trie->height = new_height;
    new_trie->ch[trie->bits >> (new_height - 1) & 1] = trie;
    trie = new_trie;
    insert(trie->ch[bits >> (new_height - 1) & 1], bits, value);
    // trie->summary = trie->ch[0]->summary + trie->ch[1]->summary;
    trie->summary.sum = trie->ch[0]->summary.sum + trie->ch[1]->summary.sum;
    trie->summary.cnt = trie->ch[0]->summary.cnt + trie->ch[1]->summary.cnt;
    trie->summary.vmin = std::min(trie->ch[0]->summary.vmin, trie->ch[1]->summary.vmin);
    trie->summary.vmax = std::max(trie->ch[0]->summary.vmax, trie->ch[1]->summary.vmax);
  } else if (trie->height == 0) {
    trie->summary.append(value);
  } else {
    trie->down();
    insert(trie->ch[bits >> (trie->height - 1) & 1], bits, value);
    // trie->summary = trie->ch[0]->summary + trie->ch[1]->summary;
    trie->summary.sum = trie->ch[0]->summary.sum + trie->ch[1]->summary.sum;
    trie->summary.cnt = trie->ch[0]->summary.cnt + trie->ch[1]->summary.cnt;
    trie->summary.vmin = std::min(trie->ch[0]->summary.vmin, trie->ch[1]->summary.vmin);
    trie->summary.vmax = std::max(trie->ch[0]->summary.vmax, trie->ch[1]->summary.vmax);
  }
}

template<typename OnPopOut>
void subtract(CompressedTrie*& trie, int L, int R, ValueType delta, ValueType lower_bound, OnPopOut&& on_pop_out) {
  if (trie == nullptr) {
    return;
  }
  if (trie->summary.vmax + delta <= 0) {
    return;
  }
  int l = trie->bits >> trie->height << trie->height;
  int r = l + (1 << trie->height) - 1;
  if (r < L || R < l) {
    return;
  }
  if (L <= l && r <= R && trie->summary.vmin + delta >= lower_bound) {
    trie->apply(delta);
  } else if (trie->height == 0) {
    on_pop_out(trie->bits, trie->summary.vmin + delta);
    pool.free(trie);
    trie = nullptr;
  } else {
    trie->down();
    subtract(trie->ch[0], L, R, delta, lower_bound, std::forward<OnPopOut>(on_pop_out));
    subtract(trie->ch[1], L, R, delta, lower_bound, std::forward<OnPopOut>(on_pop_out));
    if (trie->ch[0] != nullptr && trie->ch[1] != nullptr) {
      // trie->summary = trie->ch[0]->summary + trie->ch[1]->summary;
      trie->summary.sum = trie->ch[0]->summary.sum + trie->ch[1]->summary.sum;
      trie->summary.cnt = trie->ch[0]->summary.cnt + trie->ch[1]->summary.cnt;
      trie->summary.vmin = std::min(trie->ch[0]->summary.vmin, trie->ch[1]->summary.vmin);
      trie->summary.vmax = std::max(trie->ch[0]->summary.vmax, trie->ch[1]->summary.vmax);
    } else if (trie->ch[0] != nullptr || trie->ch[1] != nullptr) {
      CompressedTrie* tmp = trie->ch[trie->ch[0] == nullptr];
      pool.free(trie);
      trie = tmp;
    } else {
      pool.free(trie);
      trie = nullptr;
    }
  }
}

template<typename Handler>
void query(CompressedTrie* trie, int L, int R, Handler&& handler) {
  if (trie == nullptr) {
    return;
  }
  int l = trie->bits >> trie->height << trie->height;
  int r = l + (1 << trie->height) - 1;
  if (r < L || R < l) {
    return;
  }
  if (L <= l && r <= R) {
    handler(trie->summary);
    return;
  }
  trie->down();
  query(trie->ch[0], L, R, std::forward<Handler>(handler));
  query(trie->ch[1], L, R, std::forward<Handler>(handler));
}

struct IO {
  IO(FILE *in = stdin) : in(in) {}

  IO& operator >> (int& x) {
    x = next_int();
    return *this;
  }

  int next_char() {
    if (position == length) {
      position = 0, length = fread(buffer, 1, LENGTH, in);
    }
    if (position == length) {
      eof = true;
      return -1;
    }
    return buffer[position++];
  }

  int next_uint() {
    int c = next_char(), x = 0;
    while (c <= 32) {
      c = next_char();
    }
    for (; '0' <= c && c <= '9'; c = next_char()) {
      x = x * 10 + c - '0';
    }
    return x;
  }

  int next_int() {
    int s = 1, c = next_char(), x = 0;
    while (c <= 32) {
      c = next_char();
    }
    if (c == '-') {
      s = -1, c = next_char();
    }
    for (; '0' <= c && c <= '9'; c = next_char()) {
      x = x * 10 + c - '0';
    }
    return x * s;
  }

  void next_string(char *s) {
    int c = next_char();
    while (c <= 32) {
      c = next_char();
    }
    for (; c > 32; c = next_char()) {
      *s++ = c;
    }
    *s = 0;
  }

private:
  static const int LENGTH = 1 << 16;

  char buffer[LENGTH];
  int position = 0, length = 0;
  bool eof = false;
  FILE *in;
};

struct FastOut {
  static const int BUFSIZE = 4096;

  FastOut& operator << (int64_t x) {
    print(x);
    return *this;
  }

  FastOut& operator << (const char *s) {
    puts(s);
    return *this;
  }

  void putchar(char c) {
    buf[len++] = c;
    if (len == BUFSIZE) {
      fwrite(buf, 1, BUFSIZE, stdout);
      len = 0;
    }
  }

  void puts(const char *s) {
    while (*s) {
      putchar(*(s++));
    }
  }

  void print(int64_t n) {
    static char bufn[32];
    bool negative = false;
    if (n < 0) {
      n = -n;
      negative = true;
    }
    int top = 32;
    while (n >= 10) {
      bufn[--top] = '0' + n % 10;
      n /= 10;
    }
    bufn[--top] = '0' + n;
    if (negative) {
      bufn[--top] = '-';
    }
    for (; top < 32; ++top) {
      putchar(bufn[top]);
    }
  }

  void println(int64_t n) {
    print(n);
    putchar('\n');
  }

  ~FastOut() {
    if (len) {
      fwrite(buf, 1, len, stdout);
    }
    fflush(stdout);
  }

  char buf[BUFSIZE];
  int len = 0;
};

constexpr int B = 8;

inline uint8_t get_block_id(ValueType value) {
  // return (31 ^ __builtin_clz(value)) >> 3;
  // return (value >> 24) ? 3 : (value >> 16) ? 2 : (value >> 8) ? 1 : 0;
  return (value > 16777215.5) + (value > 65535.5) + (value > 255.5);
  // return uint8_t(bool(value / 16777216)) + bool(value / 65536) + bool(value / 256);
  // return uint8_t(bool(value >> 24)) + bool(value >> 16) + bool(value >> 8);
  // return ((value >> 24) > 0) + ((value >> 16) > 0) + ((value >> 8) > 0);
  // return 3 ^ (__builtin_clz(value) >> 3);
  // int b = -1;
  // for (; value; value /= B, ++b);
  // return b;
}

struct Solver {

  template<typename Reader, typename Writer>
  void solve(Reader&& reader, Writer&& writer) {
    int n, m;
    reader >> n >> m;
    std::vector<ValueType> bounds{1};
    while (bounds.back() * 1LL * B < INF) {
      bounds.emplace_back(bounds.back() * B);
    }
    std::vector<CompressedTrie*> tries(bounds.size(), nullptr);
    for (int i = 0; i < n; ++i) {
      int x;
      reader >> x;
      int b = get_block_id(x);
      assert(b >= 0 && b < bounds.size());
      insert(tries[b], i, x);
    }
    int last_ans = 0;
    while (m--) {
      int op, l, r;
      reader >> op >> l >> r;
      l ^= last_ans;
      r ^= last_ans;
      --l;
      --r;
      assert(0 <= l && l < n);
      assert(0 <= r && r < n);
      if (op == 1) {
        int x;
        reader >> x;
        x ^= last_ans;
        assert(1 <= x && x <= 1e9);
        for (int i = 0; i < tries.size(); ++i) {
          subtract(tries[i], l, r, -x, bounds[i], [&tries, &i](unsigned bits, ValueType value) {
            int j = get_block_id(value);
            assert(j >= 0 && j < i);
            insert(tries[j], bits, value);
          });
        }
      } else {
        Summary result{};
        for (CompressedTrie* trie : tries) {
          query(trie, l, r, [&result](const Summary& summary) {
            result += summary;
          });
        }
        writer << result.sum << " " << result.vmin << " " << result.vmax << "\n";
        last_ans = result.sum & ((1 << 20) - 1);
      }
    }
  }
};

}  // namespace

int main() {
  // std::ios::sync_with_stdio(false);
  // std::cin.tie(nullptr);
  // std::istream& reader = std::cin;
  IO reader;
  FastOut writer;

  Solver().solve(reader, writer);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 1ms
memory: 3608kb

input:

1000 1000
935816535 513713699 701239859 881761843 312245068 749043434 112422339 4851733 369182510 741607986 336173081 76013815 91837056 23042507 28754006 935721035 332487169 739344582 280604892 549629633 428486579 693745524 772744523 736620619 596867287 553364838 842666116 620926490 350404590 972861...

output:

265016378473 746807 999055631
666065535 666065535 666065535
271006237166 746807 999055631
244146031651 726339 992039812
15823858743 7712227 991422034
1807891893 93288403 840436769
17240518274 746807 968670509
110636754727 726339 817084515
57343541330 746807 806807028
41246731402 746807 770270334
588...

result:

ok 1575 numbers

Subtask #2:

score: 20
Accepted

Test #2:

score: 20
Accepted
time: 137ms
memory: 25452kb

input:

200000 200000
10 7 6 1 5 5 10 1 9 4 7 1 5 4 8 9 5 7 10 2 10 3 3 5 5 2 1 4 10 5 7 2 6 1 3 1 6 4 7 5 3 1 3 2 9 5 4 10 8 3 10 4 4 8 5 4 6 10 4 10 9 6 7 4 6 7 7 6 2 6 6 10 10 6 8 8 9 4 6 3 3 9 8 1 8 5 8 2 7 3 1 10 5 10 1 5 8 5 6 6 7 9 7 3 5 8 4 4 3 2 9 3 10 2 5 4 2 2 6 3 3 5 8 4 2 1 2 9 2 3 6 3 8 9 4 10...

output:

8548 1 10
358083 1 10
371696 1 10
367527 1 10
31930 1 10
41965 1 5
4288 1 10
52736 1 9
311942 1 10
168381 1 10
136991 1 7
52274 1 9
35176 1 5
114387 1 10
4104 1 10
74578 1 6
188927 1 10
425739 1 10
46796 1 6
109184 1 6
47640 1 6
115544 1 6
123196 1 6
118225 1 6
160295 1 5
43007 1 10
10471 1 7
80111 ...

result:

ok 303618 numbers

Test #3:

score: 0
Accepted
time: 152ms
memory: 25412kb

input:

200000 200000
10 9 3 10 4 4 2 5 9 2 8 8 8 9 6 6 2 1 2 9 10 3 2 6 6 7 1 10 9 8 7 10 6 10 2 5 3 5 7 1 1 9 2 3 4 4 7 5 5 9 1 10 9 8 9 7 10 10 5 7 7 4 10 3 9 5 7 5 4 7 3 8 3 1 10 4 7 5 8 1 4 7 1 9 5 4 8 8 1 9 10 3 8 6 5 2 7 7 3 10 5 7 10 6 10 2 8 3 7 7 6 4 1 3 3 9 6 3 1 1 5 9 4 6 5 4 6 5 8 4 5 5 1 5 10 ...

output:

120436 1 10
27918 1 6
11888 1 10
48329 1 6
43608 1 6
151778 1 10
46169 1 6
46361 1 10
483850 1 10
124481 1 10
526839 1 10
119733 1 5
154279 1 10
7638 1 6
3630 1 5
54630 1 5
250280 1 10
123344 1 10
145094 1 6
130966 1 6
34776 1 10
26218 1 3
185021 1 9
28302 1 5
2697 1 10
135625 1 6
67958 1 4
164444 1...

result:

ok 303477 numbers

Test #4:

score: 0
Accepted
time: 88ms
memory: 25456kb

input:

199998 199995
10 4 6 4 4 4 3 5 2 9 5 2 10 9 8 6 7 5 1 6 5 3 7 10 8 5 6 9 2 5 3 8 6 9 5 2 7 2 10 6 1 7 6 3 4 3 9 5 2 4 8 9 1 8 7 4 6 1 10 3 8 7 2 7 1 1 8 3 1 3 2 2 2 3 5 10 5 7 6 10 10 1 8 1 9 7 7 10 3 7 8 6 10 7 6 3 3 10 1 4 2 2 7 9 5 3 1 6 10 10 3 2 10 3 1 6 4 1 3 6 7 2 10 9 8 1 5 1 1 8 6 3 4 3 4 9...

output:

1100462 1 10
1100462 1 10
681018 1 7
681018 1 7
340625 1 4
340629 1 4
340635 1 4
340636 1 4
280123 1 3
280128 1 3
280125 1 3
280127 1 3
280131 1 3
280127 1 3
280134 1 3
280131 1 3
240083 1 2
240082 1 2
240095 1 5
240085 1 2
240090 1 2
240085 1 2
240081 1 2
240085 1 2
240087 1 2
240082 1 2
240082 1 2...

result:

ok 303447 numbers

Subtask #3:

score: 20
Accepted

Test #5:

score: 20
Accepted
time: 243ms
memory: 25460kb

input:

200000 200000
615 736 846 534 658 429 631 720 898 583 797 295 303 336 449 358 57 338 954 414 330 212 171 200 403 553 308 20 805 249 767 291 545 196 324 928 439 197 20 601 737 748 817 858 816 130 403 858 813 936 771 242 833 863 978 260 357 856 954 89 673 733 364 473 903 445 823 894 49 747 382 56 309 ...

output:

4143168 1 1000
8707838 1 1000
47796901 1 1000
55161188 1 1000
17880698 1 1000
9738037 1 888
11217598 1 939
2273447 1 939
12642515 1 888
12437017 1 999
15429733 1 888
29802638 1 939
200711 2 887
51511251 1 1000
9402071 1 888
25821404 1 939
19529749 1 923
6444888 1 930
10956864 1 564
1514736 1 408
881...

result:

ok 303498 numbers

Test #6:

score: 0
Accepted
time: 246ms
memory: 25448kb

input:

200000 200000
125 824 862 182 678 103 976 229 994 666 261 737 199 82 516 546 993 137 824 978 152 110 658 490 260 884 466 658 80 203 193 443 19 931 960 23 631 599 241 535 772 487 972 459 325 180 450 245 625 743 373 110 795 745 877 694 50 259 939 542 544 831 881 600 77 748 527 805 36 348 118 781 452 9...

output:

50865154 1 1000
24220463 1 919
1989344 1 919
3666274 1 697
8844621 1 910
17319620 1 919
13277574 1 760
13369358 1 617
11322496 1 617
5979926 1 755
528498 1 351
3799125 1 351
9939407 1 351
12522427 1 1000
1849238 1 351
938420 1 339
16252281 1 1000
1216964 1 238
40887 1 342
1201726 1 712
3143310 1 351...

result:

ok 303603 numbers

Test #7:

score: 0
Accepted
time: 81ms
memory: 25484kb

input:

199997 199998
3 10 7 6 7 1 7 3 7 2 1 3 5 6 9 6 10 5 9 8 6 3 5 8 1 1 8 1 10 3 9 9 10 6 7 4 5 1 1 9 10 10 6 10 8 3 7 8 4 10 10 4 10 5 4 7 6 3 5 8 8 6 8 9 5 8 6 7 5 7 1 3 7 7 10 6 7 6 10 9 5 4 5 3 6 10 4 3 2 10 8 3 7 10 1 8 9 6 4 7 1 6 8 9 10 7 5 3 2 8 9 4 5 2 8 10 5 1 9 4 8 3 10 5 3 2 1 6 9 8 5 4 2 4 ...

output:

1103927 1 10
199995 1 2
199989 1 1
199995 1 2
199992 1 2
199997 1 2
199997 1 2
199988 1 1
199987 1 1
199992 1 1
199994 1 1
199987 1 1
199988 1 1
199989 1 1
199991 1 1
199994 1 1
199988 1 1
199992 1 1
199990 1 1
199992 1 1
199991 1 1
199998 1 3
199990 1 1
199991 1 1
199987 1 1
199998 1 3
199991 1 1
1...

result:

ok 303471 numbers

Subtask #4:

score: 20
Accepted

Test #8:

score: 20
Accepted
time: 396ms
memory: 25480kb

input:

200000 200000
78066 141247 11068 105207 26127 179253 104948 145839 150954 60877 67556 61673 69638 150806 127596 162902 125410 38242 97645 20582 193537 139906 114184 129867 126626 85640 91551 19445 134855 85251 22162 3798 122992 38278 131907 96159 153440 94561 185234 15296 76886 108452 70560 77355 14...

output:

9335629761 8 199997
291062233 15 145210
2757513812 2 114001
457932161 15 145210
2988949571 2 104377
2096022866 2 145091
51774664 57 104218
1802593096 2 101531
838652514 1 91888
2086037512 5 199981
1740038288 2 113977
2833816579 1 101510
1643368391 2 132714
1457965364 2 101524
868906251 2 101524
8249...

result:

ok 303507 numbers

Test #9:

score: 0
Accepted
time: 378ms
memory: 25484kb

input:

200000 200000
58317 79021 111303 154733 179567 182629 28968 33314 26824 125092 137496 124768 21399 111741 66359 31703 141726 116799 156902 28665 149214 66685 131783 19127 38615 4167 165498 40897 131724 96109 70688 194505 116284 197762 197275 125439 199849 166102 198410 81173 189204 163194 89937 6629...

output:

10985120427 2 200000
14253061393 1 200000
14076919529 1 200000
155392718 18 199663
3863170615 1 199996
434379913 1 195113
4794602467 1 130342
546767600 22 130346
1870193310 1 199971
179334704 16 195113
8677927116 1 130348
106148166 2 130332
960648401 1 117463
2257713113 1 130348
7347437398 1 199939
...

result:

ok 303558 numbers

Test #10:

score: 0
Accepted
time: 239ms
memory: 25448kb

input:

200000 200000
100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 ...

output:

9999999999 1 100000
9999999999 1 100000
9999600003 1 99996
9998600013 1 99986
9998600013 1 99986
9998600013 1 99986
9998600013 1 99986
9998600013 1 99986
9998600013 1 99986
9998600013 1 99986
9998400015 1 99984
9998200017 1 99982
9997800021 1 99978
9997400025 1 99974
9997000029 1 99970
9997000029 1 ...

result:

ok 300624 numbers

Test #11:

score: 0
Accepted
time: 50ms
memory: 25416kb

input:

200000 200000
100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000...

output:

19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 100000 100000
19999800000 10...

result:

ok 300624 numbers

Subtask #5:

score: 0
Time Limit Exceeded

Test #12:

score: 20
Accepted
time: 1838ms
memory: 58240kb

input:

500000 500000
56 22353719 15918 54 13 1 389 7 809 2204 75911688 4218278 36 7205 93542078 506 4761175 102646343 48 65900 10 228 2 292994 26348644 6 19339 148 704 232124395 19307 52070 8964343 7430314 42755 115 869 32485365 252183868 481162087 852632 38758 2945883 279412 15012 82 33076951 1537 6954898...

output:

106593480756 1 984003850
3657321749885 1 772605710
4340368607039 1 997617313
2024546424119 1 999735807
1053708059297 1 999735807
1594458070417 1 999904830
3990648241119 1 772605710
2714488265571 1 999735807
384978298678 1 772605710
1159542455950 1 999273673
3500807088693 1 967123827
5113110257086 1 ...

result:

ok 741759 numbers

Test #13:

score: 0
Accepted
time: 3499ms
memory: 58340kb

input:

500000 500000
719948 153 112344106 7040 61985682 1 4356 19222 34672195 143174 78 125 40 3164569 5392 441953981 421249543 12617 3266128 328415 53035 94 9 1346009 225 15 59366 45339 5849 2398 27 156152 2638 4843 26647250 11247481 329 214049 894418 3236 208 1 484 238 8994209 369935 86558 40 221409788 1...

output:

5285629884440 1 999595241
1354254428547 1 998815652
6209523108119 1 999667867
2643824165208 1 999237892
325473150578 1 998669925
1404935498427 1 999492008
4164725213474 1 999492008
10565537848386 1 999667866
5605651848441 1 999667866
596109764947 1 999382953
8182967158272 1 999667866
23983679113 1 9...

result:

ok 749955 numbers

Test #14:

score: 0
Accepted
time: 1135ms
memory: 58280kb

input:

500000 500000
1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 ...

output:

8026000008025 1 1000000000
27600989649626 1 999999624
8238996338525 1 999999624
81362960647319 1 999999687
6026997731789 1 1000000000
78299915801111 1 999999132
12387975001016 1 999997981
32302970208351 1 1000000000
40351942833256 1 999999132
128012549695034 1 1000000000
40700911063983 1 999998877
5...

result:

ok 758784 numbers

Test #15:

score: 0
Accepted
time: 2061ms
memory: 58172kb

input:

500000 500000
1073407 283193 20385 5011866 2 115524490 2697 9 16 129664216 8848 105017 2875465 265260 9094846 2 14 31117 3 252 240087622 259 282 26043524 2821157 1840 15 886794143 335431476 2 102453 118282 368335348 1015112 47696 3744460 101333101 856 41641 18669 246439 204 106974535 1091958 683 511...

output:

4742168057689 1 691487645

result:

ok 3 number(s): "4742168057689 1 691487645"

Test #16:

score: 0
Accepted
time: 1801ms
memory: 58228kb

input:

499993 499947
13414 23 32141 104807103 1174 495217 44780963 1300464 19 6203 971535498 782408085 49963750 381 230040650 54452 410395414 51005 43 878213 503990390 42198918 14766 925276 1357043 1444680 390091 492648 168613 27 858072 429791 80038 53142 111502 129082975 1 47442077 359562738 13824753 1532...

output:

2453076569360 1 999240106
14472971286976 1 999984216
1219095316005 1 999513073
3487338535438 1 999982855
8411392124584 1 999620485
6744171119065 1 999813722
3353888410654 1 999712807
3361207525003 1 999620485
12416955594065 1 999813722
11469791076989 1 999813722
7401080028481 1 999812483
24726061606...

result:

ok 742260 numbers

Test #17:

score: 0
Accepted
time: 410ms
memory: 58272kb

input:

500000 500000
1581 895 46203 49 129606351 2 31495192 213963419 1291 4536 362 4058 15414 1440 184847279 237 277321048 905050338 952286 369044346 8068 53 747186357 34 2960 132 388315 13 231 1 51242 141068292 40073573 155291367 162969 39548 461826822 419 106617135 1 83667 1931884 20276468 16 209363 417...

output:

17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
17498248305875 1 999969822
174...

result:

ok 1499997 numbers

Test #18:

score: 0
Accepted
time: 1810ms
memory: 58220kb

input:

499926 499930
22937262 1613 906389 566 932238802 13950 14189125 3047588 15 423235434 7313 56975057 7087213 10 35661699 6598 244 196464021 408789794 9 10474413 1251 1019428 17350047 5 851592 2462 2 2166042 36762719 5360640 14857807 10447890 155682563 12461137 6429 25101566 869501 80281 59015909 20 33...

output:

1758069221739 1 999476727
8175967307588 1 999862940
6132878512178 1 999951781
4521065687476 1 999862940
159378017701 1 992737998
8648463605465 1 999862940
288142899618 1 996062426
2717594258415 1 999135330
10228430093991 1 999862699
268775935507 1 999038080
6546651272480 1 999862699
2165382278738 1 ...

result:

ok 741552 numbers

Test #19:

score: 0
Accepted
time: 1770ms
memory: 58284kb

input:

499975 499948
4268 4 3628 29677261 54 198 15028150 3834289 11468351 609241 65358445 1749982 26241 1441 133510652 1477700 9359775 7 136042 235 33450656 43383666 1179100 10380 923456394 5 106270 204908 1 878777 1 4675 21629 37046 2597 243 8678080 4588828 1550 28277393 406287122 19 36 123 1860 19556841...

output:

17367588833012 1 999917498
17367652224951 1 999917498
11637809535582 1 684383667
11569383346014 1 684007335
11543614547228 1 683877294
11543614547228 1 683877294
7119081091781 1 460391025
7119081091781 1 460391025
7119087875366 1 460390918
5064287109678 1 417008753
5064286179722 1 417008751
50643336...

result:

ok 742071 numbers

Test #20:

score: 0
Accepted
time: 1788ms
memory: 58276kb

input:

499933 499965
72617 216291885 45223 29 1517450 155867 10785010 6 1 47638 106 1232724 4005 4 4040433 334 130000 11 48132 805044 12 1677547 26009001 5234576 1679070 5 127890154 13289 1272784 1440 20049103 808392 2665 6788 108359263 98826036 1 24738 95797 2727601 811799944 447729824 1 101488 53176 5474...

output:

17271893460704 1 999960431
14412166335901 1 963587687
14412509235472 1 963587687
9879482788366 1 487060977
9879139888906 1 487060977
9879482788366 1 487060977
8798446378594 1 466760205
8798446327112 1 466760205
8798446327112 1 466760205
8798103427652 1 466760205
8404573062274 1 461173170
84049159547...

result:

ok 740415 numbers

Test #21:

score: 0
Accepted
time: 148ms
memory: 58312kb

input:

500000 500000
694829454 483733551 292460415 823782593 744624297 420561207 399213478 337739884 966310522 302471278 183626881 581269571 466684416 722213719 236851903 122262701 673832771 705845795 574424551 718654321 772976205 631315433 307437345 586483008 479499589 932783947 821055825 812342412 546414...

output:

266584300996313 100003034 999999925
266570575819349 100003034 999999925
266576352144850 100003034 999999925
266593471832108 100003034 999999925
266595934324779 100003034 999999925
266580628726340 100003034 999999925
266578623948237 100003034 999999925
266607429907225 100003034 999999925
266590994304...

result:

ok 750000 numbers

Test #22:

score: 0
Accepted
time: 254ms
memory: 58272kb

input:

499965 499960
753595026 746922541 928926464 772122918 826680095 830796765 987135861 945779707 905440724 815594326 873548346 777549959 992851668 713760013 706212336 763291625 923131022 868302524 832005252 977289791 965060653 971529129 947481825 850890330 849555389 885017337 747189086 904825982 909506...

output:

394228444675352 638476595 992851668
366233708362000 582542614 956120387
366234853510603 582542614 928365051
329827594098851 509796316 904332053
329865012335034 509796316 954215507
308846250513802 467764208 974937883
280629477444705 411334912 788535458
280663806581097 411334912 956134436
280638400093...

result:

ok 749838 numbers

Test #23:

score: 0
Accepted
time: 281ms
memory: 58232kb

input:

499999 499982
1000000000 1 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1 1000000000 1000000000 1 1000000000 1 1000000000 1000000000 100000...

output:

1699044 1 4
1698929 1 4
6891048 1 2801891
9891354572 1 865714391
3322317813 1 518232365
1698995 1 4
549554491 1 142433925
1698932 1 4
1698793 1 4
1698983 1 4
1698977 1 4
2848354658 1 450073828
6567898566 1 826816568
577561997 1 142433925
1699031 1 4
2369766 1 670733
1698983 1 4
2354011653 1 41428579...

result:

ok 757170 numbers

Test #24:

score: 0
Accepted
time: 297ms
memory: 58220kb

input:

499989 499995
1000000000 1 1000000000 1000000000 1 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1 1000000000 1000000000 1000000000 1 1000000000 1000000000 1 1 1000000000 1000000000 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...

output:

1700120 1 4
1700192 1 4
1700049 1 4
1700126 1 4
1699904 1 4
1700155 1 4
32099639 1 30399596
1700051 1 4
32099918 1 30399596
1700193 1 4
1700076 1 4
1700056 1 4
1394509186 1 779944694
1700089 1 4
1700012 1 4
614564424 1 493613506
1700014 1 4
1700088 1 4
1699858 1 4
1700255 1 4
62088472 1 55397226
170...

result:

ok 757287 numbers

Test #25:

score: -20
Time Limit Exceeded

input:

499922 499935
11675 72387 21650698 2901106 114 1653620 270730582 10729 3357301 3018547 3792337 24180210 6571 500743 1022100 516125 121 22 215 76497 15 809135 15299 1 35667 1080 1 5 13 1628952 1009080 3283 4544900 87 41868005 347520 2814 50 98 11670217 532 152661093 3 29543585 2055103 2916 2990 65033...

output:

17322119593834 1 999855468
17321650855018 1 999855468
17312363726122 1 999808653
17304914441385 1 999779778
17301671365378 1 999766942
17299351385570 1 999755404
17301282540205 1 999755404
17294894309924 1 999728414
17292979800708 1 999715867
17288740255962 1 999695597
17286512913411 1 999688896
172...

result: