QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#940278 | #4346. rpfrdtzls | zlt | 100 ✓ | 1607ms | 113488kb | C++14 | 5.9kb | 2025-03-17 18:31:21 | 2025-03-17 18:31:28 |
Judging History
answer
// Problem: P9057 [Ynoi2004] rpfrdtzls
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P9057
// Memory Limit: 512 MB
// Time Limit: 2500 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
namespace IO {
const int maxn = 1 << 20;
char ibuf[maxn], *iS, *iT, obuf[maxn], *oS = obuf;
inline char gc() {
return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, maxn, stdin), (iS == iT ? EOF : *iS++) : *iS++);
}
template<typename T = int>
inline T read() {
char c = gc();
T x = 0;
bool f = 0;
while (c < '0' || c > '9') {
f |= (c == '-');
c = gc();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ 48);
c = gc();
}
return f ? ~(x - 1) : x;
}
inline void flush() {
fwrite(obuf, 1, oS - obuf, stdout);
oS = obuf;
}
struct Flusher {
~Flusher() {
flush();
}
} AutoFlush;
inline void pc(char ch) {
if (oS == obuf + maxn) {
flush();
}
*oS++ = ch;
}
template<typename T>
inline void write(T x) {
static char stk[64], *tp = stk;
if (x < 0) {
x = ~(x - 1);
pc('-');
}
do {
*tp++ = x % 10;
x /= 10;
} while (x);
while (tp != stk) {
pc((*--tp) | 48);
}
}
template<typename T>
inline void writesp(T x) {
write(x);
pc(' ');
}
template<typename T>
inline void writeln(T x) {
write(x);
pc('\n');
}
}
using IO::read;
using IO::write;
using IO::pc;
using IO::writesp;
using IO::writeln;
const int maxn = 500100;
ll n, m, K, f[maxn], g[maxn], h[maxn], b[maxn], c[maxn], ans[maxn], nt;
int pre[maxn], nxt[maxn];
struct List1 {
int nxt[maxn << 1], hd[maxn], len;
pii to[maxn << 1];
inline void add(int x, pii y) {
to[++len] = y;
nxt[len] = hd[x];
hd[x] = len;
}
} L1, L2;
struct List2 {
int to[maxn], nxt[maxn], len, hd[maxn];
inline void add(int x, int y) {
to[++len] = y;
nxt[len] = hd[x];
hd[x] = len;
}
} L3;
struct que {
ll op, l, r, x;
} a[maxn];
struct BIT1 {
ll c[maxn];
inline void update(ll x, ll d) {
for (int i = x; i <= nt; i += (i & (-i))) {
c[i] += d;
}
}
inline void update(ll l, ll r, ll x) {
if (l > r) {
return;
}
update(l, x);
update(r + 1, -x);
}
inline ll query(ll x) {
ll res = 0;
for (int i = x; i; i -= (i & (-i))) {
res += c[i];
}
return res;
}
} T1, T3, T4;
struct BIT2 {
ll c[maxn];
inline void update(ll x, ll d) {
for (int i = x; i <= n; i += (i & (-i))) {
c[i] += d;
}
}
inline ll query(ll x) {
ll res = 0;
for (int i = x; i; i -= (i & (-i))) {
res += c[i];
}
return res;
}
inline ll query(ll l, ll r) {
return l > r ? 0 : query(r) - query(l - 1);
}
} T2;
inline void update(int i, int k) {
int t = k, y = 0;
lll x = b[k];
while (nxt[t] && x <= K) {
t = nxt[t];
x *= b[t];
y += c[t] + 1;
}
f[k] += (i - g[k]) * h[k];
g[k] = i;
h[k] = y + 1;
y += c[k] + 1;
for (int p = pre[k]; p && t >= pre[k]; p = pre[p]) {
x *= b[p];
while (x / b[t] > K) {
x /= b[t];
y -= c[t] + 1;
t = pre[t];
}
f[p] += (i - g[p]) * h[p];
g[p] = i;
h[p] = y + 1;
y += c[p] + 1;
}
}
void solve() {
n = read();
m = read();
K = read();
nt = 1;
for (int i = 1; i <= m; ++i) {
a[i].op = read();
a[i].l = read();
a[i].r = read();
if (a[i].op == 1) {
a[i].x = read();
L1.add(a[i].l, pii(a[i].x, ++nt));
L3.add(a[i].r + 1, nt);
} else {
L2.add(a[i].l - 1, pii(nt, -i));
L2.add(a[i].r, pii(nt, i));
}
}
b[nt] = K + 1;
set<int> S;
S.insert(0);
S.insert(nt);
g[nt] = h[nt] = 1;
for (int i = 1; i <= n; ++i) {
for (int _ = L3.hd[i]; _; _ = L3.nxt[_]) {
int j = L3.to[_];
j = nt - j + 1;
if (b[j] == 1) {
T2.update(j, -1);
int k = *S.lower_bound(j);
--c[k];
T3.update(pre[k] + 1, j, -1);
T4.update(pre[k] + 1, j, -i);
update(i, k);
} else {
int k = nxt[j];
T1.update(pre[j] + 1, j, f[j] + (i - g[j]) * h[j]);
T1.update(j + 1, k, f[k] + (i - g[k]) * h[k]);
T3.update(pre[j] + 1, j, c[k]);
T4.update(pre[j] + 1, j, c[k] * i);
c[k] += c[j];
f[j] = g[j] = h[j] = f[k] = g[k] = h[k] = b[j] = c[j] = 0;
if (pre[j]) {
nxt[pre[j]] = nxt[j];
}
if (nxt[j]) {
pre[nxt[j]] = pre[j];
}
S.erase(j);
update(i, k);
}
b[j] = 0;
}
for (int _ = L1.hd[i]; _; _ = L1.nxt[_]) {
pii p = L1.to[_];
p.scd = nt - p.scd + 1;
int j = p.scd;
b[j] = p.fst;
if (p.fst == 1) {
T2.update(j, 1);
int k = *S.lower_bound(j);
++c[k];
T3.update(pre[k] + 1, j, 1);
T4.update(pre[k] + 1, j, i);
update(i, k);
} else {
auto it = S.insert(j).fst;
pre[j] = *prev(it);
nxt[j] = *next(it);
T1.update(pre[j] + 1, nxt[j], f[nxt[j]] + (i - g[nxt[j]]) * h[nxt[j]]);
f[nxt[j]] = g[nxt[j]] = h[nxt[j]] = 0;
nxt[pre[j]] = pre[nxt[j]] = j;
int k = nxt[j];
c[j] = T2.query(pre[j] + 1, j);
c[k] = T2.query(j + 1, k);
T3.update(pre[j] + 1, j, -c[k]);
T4.update(pre[j] + 1, j, -c[k] * i);
update(i, k);
}
}
for (int _ = L2.hd[i]; _; _ = L2.nxt[_]) {
pii p = L2.to[_];
int j = nt - p.fst + 1;
ll res = T1.query(j) + T3.query(j) * (i + 1) - T4.query(j);
int k = *S.lower_bound(j);
res += f[k] + (i + 1 - g[k]) * h[k];
if (p.scd > 0) {
ans[p.scd] += res;
} else {
ans[-p.scd] += -res;
}
}
}
for (int i = 1; i <= m; ++i) {
if (a[i].op == 2) {
writeln(ans[i]);
}
}
}
int main() {
int T = 1;
// scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
詳細信息
Subtask #1:
score: 25
Accepted
Test #1:
score: 25
Accepted
time: 1ms
memory: 65136kb
input:
96 96 34 1 32 47 2 1 49 94 9 1 2 65 3 1 16 23 7 1 50 82 10 2 96 96 1 45 45 16 1 41 48 6 2 33 60 1 12 52 7 1 28 28 7 1 14 28 8 1 11 36 7 1 24 58 9 1 65 95 2 2 30 30 1 79 96 863797690 1 52 67 10 1 18 68 1 1 68 73 6 1 33 86 9 1 91 93 49 2 57 69 1 44 86 6 1 93 94 22 1 29 87 1 1 18 60 1 1 47 56 1 1 85 93...
output:
1 83 2 37 279 33 210 119
result:
ok 8 numbers
Test #2:
score: 25
Accepted
time: 0ms
memory: 58772kb
input:
100 100 78 2 48 72 2 77 92 2 8 93 1 68 86 6 2 10 83 2 74 99 2 24 53 1 42 83 1 1 15 63 4 1 49 63 284087082 2 27 37 1 72 72 7 1 52 72 7 1 35 81 4 1 63 96 7 1 20 20 10 1 20 42 9 1 74 86 1 2 38 70 1 63 76 1 2 72 82 2 26 93 2 48 74 2 11 82 2 79 89 2 50 83 2 91 99 1 15 60 1 2 96 98 2 5 68 2 12 66 2 72 72 ...
output:
25 16 86 90 39 30 22 102 57 238 94 238 43 135 15 4 221 206 4 69 109 83 4 145 349 108 123 8 294 158 201 12 49 223 210 14 324 184 38 10 56 397 393 204 235 272 105 145 101 198 21 157 20 14 10 4 52 17 2 3 131 69 24 68 9 76 285 87 104 87 102 58 50 4
result:
ok 74 numbers
Test #3:
score: 25
Accepted
time: 1ms
memory: 62920kb
input:
98 95 361367936 1 36 41 3 2 19 35 2 67 90 2 24 34 1 38 88 6 1 90 90 3 2 70 98 1 15 72 3 1 82 85 9 1 42 49 4 2 38 87 2 75 86 2 44 51 1 30 96 310136671 2 26 54 1 51 81 7 1 50 80 7 1 55 79 495832821 1 4 27 2 1 57 67 1 2 70 74 1 81 84 5 2 84 94 1 27 31 5 2 45 74 1 98 98 54 2 11 94 1 75 83 1 2 92 95 2 71...
output:
17 24 11 49 151 28 30 58 5 22 55 176 8 50 40 52 45 53 96 61 198 110 81 138 106 91 6 27 90 16 97 226 144 81 295 215 45 7 376 73 544
result:
ok 41 numbers
Test #4:
score: 25
Accepted
time: 1ms
memory: 63088kb
input:
100 100 972058200 2 44 57 1 52 53 6 2 30 83 1 20 61 7 2 31 55 2 36 38 2 53 81 1 75 97 9 1 6 39 10 2 26 83 1 46 46 38 1 36 44 5 2 48 69 2 85 98 1 18 20 60 1 94 100 764663994 2 51 78 1 20 87 3 2 76 83 1 61 88 10 2 47 48 2 45 52 1 28 50 7 2 97 97 2 70 83 1 23 32 6 1 7 7 13 1 37 44 1 1 25 58 1 1 48 95 1...
output:
14 56 52 6 39 119 38 27 45 24 6 26 2 51 2 389 55 108 68 8 42 123 135 89 455 157 461 9 268 154 21 19 93 473 7 18 125 322 391 113 655 27
result:
ok 42 numbers
Test #5:
score: 25
Accepted
time: 2ms
memory: 69096kb
input:
100 100 923987061 1 23 47 10 1 27 29 4 1 22 94 6 1 53 91 4 1 24 25 33 1 26 100 8 1 89 90 106211301 1 16 58 4 2 47 68 1 45 76 630254413 1 54 54 41 1 19 20 26 1 52 96 3 1 35 92 2 2 13 23 1 25 43 8 1 6 95 10 1 78 94 4 1 14 54 448825657 1 42 44 49 1 84 90 5 1 52 53 53 1 80 84 9 1 65 73 5 1 35 60 6 2 45 ...
output:
95 24 10 9 101 827 150 356 309 121 208 253
result:
ok 12 numbers
Test #6:
score: 25
Accepted
time: 1ms
memory: 67048kb
input:
95 99 501207498 1 29 44 551806111 1 94 94 3 1 77 77 7 1 36 70 8 1 43 67 1 1 72 83 1 1 5 31 3 1 58 94 9 1 14 64 6 1 5 80 3 2 11 21 1 16 73 9 1 22 36 9 1 86 95 110061832 1 56 59 2 1 92 94 5 1 58 58 7 1 58 87 9 1 8 44 8 1 57 87 826650998 1 20 82 4 1 42 88 4 1 90 93 30 1 4 60 10 1 4 89 10 1 26 84 1 1 56...
output:
41 2 58 5
result:
ok 4 number(s): "41 2 58 5"
Test #7:
score: 25
Accepted
time: 2ms
memory: 58740kb
input:
100 100 816821035 2 88 94 2 98 100 2 44 55 1 26 50 486991111 1 31 76 4 2 35 79 2 10 27 2 15 87 2 6 55 1 66 96 10 1 38 39 46 2 71 72 2 31 52 1 86 92 3 1 95 96 8 2 15 53 1 66 66 330485069 2 54 100 2 80 97 2 83 86 2 5 69 2 25 54 1 95 97 40 1 14 15 19 1 58 61 4 2 21 38 1 82 90 1 1 80 98 1 2 95 99 2 15 5...
output:
7 3 12 87 20 124 80 6 46 69 109 44 9 114 61 32 16 78 164 4 43 72 4 10 59 170 234 241 4 4 21 51 171 122 62 66 25 26 7 28 34 184 71 314 42 49 45 231
result:
ok 48 numbers
Test #8:
score: 25
Accepted
time: 1ms
memory: 63088kb
input:
100 100 279901962 1 77 99 7 1 87 89 18 1 84 92 5 1 24 33 6 1 46 85 6 1 53 85 2 1 97 98 9 1 77 88 9 2 5 59 1 5 72 9 1 49 84 9 1 38 98 4 1 30 41 4 1 89 95 5 1 25 47 7 1 38 94 9 1 83 87 1 1 83 85 56 1 47 49 59 1 24 33 7 1 65 89 3 1 63 91 5 1 40 86 7 1 55 76 9 1 23 96 10 1 33 37 2 1 43 44 47 1 80 87 1 1...
output:
86 700 6 5
result:
ok 4 number(s): "86 700 6 5"
Test #9:
score: 25
Accepted
time: 1ms
memory: 62948kb
input:
100 100 414268061 1 67 88 4 1 47 60 2 1 26 58 1 1 6 81 9 1 66 67 56 1 29 63 4 1 85 92 902308317 1 43 58 8 1 58 85 9 1 100 100 7 1 6 73 3 1 4 6 18 1 58 69 6 1 13 16 63 1 67 68 34 1 63 94 3 2 95 95 1 34 57 4 1 3 16 5 2 56 63 1 23 81 10 1 74 74 19 1 93 100 290731213 1 88 88 2 1 61 93 4 1 15 54 3 1 47 6...
output:
1 58 421 173 465 179
result:
ok 6 numbers
Test #10:
score: 25
Accepted
time: 0ms
memory: 65132kb
input:
96 97 5053755 1 96 96 337843176 1 81 84 3 1 24 27 7 2 95 96 2 38 68 1 65 67 1 1 95 96 9 1 60 76 1 1 87 94 8 1 17 19 52 1 77 81 4 2 76 78 1 28 69 230910008 1 45 95 313459562 1 22 93 10 1 43 90 7 1 37 92 10 1 11 67 7 1 21 31 9 1 64 78 98529330 1 66 68 39 1 56 63 5 2 26 84 1 60 64 9 1 42 77 4 1 75 75 1...
output:
2 31 6 220 9 35 274 65 471 10 90 327 363 120
result:
ok 14 numbers
Subtask #2:
score: 25
Accepted
Dependency #1:
100%
Accepted
Test #11:
score: 25
Accepted
time: 56ms
memory: 68828kb
input:
100000 100000 53 2 89468 99699 1 98621 99691 2 1 72504 76998 7 2 64930 79931 2 23051 52662 2 17107 58927 2 21605 71328 2 25036 73784 2 12781 81155 1 23443 90139 8 1 29204 75572 10 2 70669 93590 2 51121 87351 2 97334 97464 2 1729 10078 2 74367 95375 2 34694 45651 1 28746 28748 10 2 6629 98456 2 30275...
output:
10232 19497 29612 41821 49724 50030 72870 42393 72462 131 8350 36782 21916 158525 4624 43444 3239 13586 70752 440 21370 29712 12330 80943 39489 7808 3925 2897 108649 114015 9700 86918 87997 63156 133709 9521 3838 51347 70568 2355 35730 58704 12392 25445 13056 22084 89629 88845 37095 108603 18859 149...
result:
ok 70111 numbers
Test #12:
score: 25
Accepted
time: 75ms
memory: 74604kb
input:
99999 99995 89 1 27799 62578 5 1 35163 86988 6 1 79957 87046 3 1 42987 76922 4 1 79164 95716 7 1 98671 99953 2 1 77920 88204 8 1 59966 60405 10 1 73898 90278 6 1 1744 48973 1 1 39485 62609 1 1 62947 83213 9 2 81662 97471 1 44024 95606 4 2 43243 96118 1 87724 92185 1 2 60199 88011 1 97982 99475 1 1 4...
output:
38482 182812 86138 10699 146638 13194 74056 179755 186 13151 137766 16113 27185 8785 2877 173752 72202 16259 1833 83847 61468 42348 92428 12169 58478 26967 10967 33855 47500 115011 41372 69631 4341 5962 69626 15480 80615 76997 14306 173959 92582 25203 23216 87239 11742 253974 71547 168117 129645 579...
result:
ok 40085 numbers
Test #13:
score: 25
Accepted
time: 94ms
memory: 81736kb
input:
99996 99995 8522391 1 33176 73631 5 1 88084 88085 6 1 34486 60905 9 1 63121 63936 5 1 67178 98549 9 2 65273 65300 2 28898 99897 1 6880 82378 7 2 25816 85127 2 75939 79500 2 64744 73496 1 49946 66764 4 1 63234 93691 9 2 36199 42933 1 805 17280 8 1 74376 80607 10 1 63127 63130 34 2 74864 80380 2 38644...
output:
56 170066 201517 10686 32578 26940 27585 228907 79525 232810 278292 266466 277195 22081 447196 423018 78492 474567 144374 78412 371110 129428 229705 20076 488053 59430 212 122123 308414 115260 64741 103211 170372 253848 10600 362356 62169 154218 21973 13259 349078 33720 491402 33715 6426 477902 6405...
result:
ok 39772 numbers
Test #14:
score: 25
Accepted
time: 131ms
memory: 73580kb
input:
99998 99998 292973811 1 37138 49473 949805290 1 88393 94415 6 1 71452 82423 5 1 55947 61888 3 1 23870 61143 9 1 20485 73356 173500306 1 56939 76394 6 1 95570 96731 8 1 71102 95083 7 1 31952 48497 2 1 40924 99511 832450228 1 76516 81156 2 1 10995 61190 10 2 25252 72770 1 40818 49356 10 2 28231 93315 ...
output:
92430 120197 368652 147581 35090 60866 334181 252200 41392 178481 518604 351365 10587 84153 44466 72767 108245 123509 38583 17688 60483 139547 18949 205421 186153 574206 30194 314853 457972 12122 89866 633104 260558 268170 46543 12264 435746 105285 771554 34050 1021217 212755 419540 53017 376558 278...
result:
ok 9974 numbers
Test #15:
score: 25
Accepted
time: 96ms
memory: 73592kb
input:
99999 99999 523227320 1 69823 79443 6 1 11368 58493 2 1 98530 99893 10 1 1656 56227 799960107 2 60821 97168 1 80928 96407 5 1 75682 85353 1 2 36783 78286 1 36089 38553 2 2 66022 68921 2 38307 68301 2 86649 94078 2 50768 74180 2 90284 92787 2 60238 83969 2 9358 86804 1 20942 72519 8 2 78775 93346 1 6...
output:
45969 54839 2900 32508 14860 30037 5008 44683 107348 34239 118520 7512 81162 84637 123332 8086 147784 69188 133113 45617 168672 404905 430327 233778 25453 220411 25366 279187 262236 609350 839854 576455 65196 816490 255118 223843 726679 738083 171322 328225 227690 32439 1863 43067 38812 142301 10654...
result:
ok 40190 numbers
Test #16:
score: 25
Accepted
time: 132ms
memory: 71916kb
input:
100000 100000 874130128 1 73890 82748 5 1 95059 98519 393950331 1 34222 34222 32 1 89091 89093 23 1 49079 70818 3 1 57332 88873 436773200 1 28311 64989 4 1 1061 8432 1 1 35035 35317 10 1 78569 79130 5 1 69611 82790 6 1 43919 68208 8 1 73289 73290 56 1 89770 93038 7 2 90622 97148 1 82530 90784 4 1 30...
output:
11034 49000 173441 285585 308947 369452 270842 438274 56975 280768 323751 228963 100945 456534 476275 143739 29281 12587 129241 325009 571221 137756 200381 237388 27667 262752 127158 124184 31068 149670 14040 83280 425827 595747 66173 44599 36439 259653 46163 320799 466923 123153 304946 135551 21828...
result:
ok 10188 numbers
Test #17:
score: 25
Accepted
time: 132ms
memory: 71864kb
input:
100000 100000 693634965 1 80686 92003 7 1 40090 78241 4 1 19382 76259 840121955 1 40042 87698 8 1 87279 91686 9 1 8214 47363 12524774 1 89346 92970 6 1 47484 49480 6 1 76727 82371 7 1 74503 82836 9 1 71449 76622 6 1 5911 44689 6 1 11973 90393 343373414 1 67001 88581 10 1 76767 84102 2 1 82240 83148 ...
output:
151842 191228 52098 306446 239255 37436 170715 208627 82014 229117 367164 8262 167316 37164 339203 143737 198106 289445 495875 57963 12270 106144 27735 20594 101127 8260 47667 53385 296344 77245 18734 10690 162123 225508 628389 507806 508654 285472 242031 115893 23999 78036 127193 49570 189925 1736 ...
result:
ok 10036 numbers
Test #18:
score: 25
Accepted
time: 96ms
memory: 71156kb
input:
100000 100000 238629574 1 77265 87447 4 1 7105 99785 909062442 1 46647 76032 4 1 33228 71291 4 1 36904 41369 3 1 79732 99880 1 1 41478 69554 6 1 93353 94560 5 1 74832 77313 4 1 26279 53959 8 1 10089 14156 819629541 1 12484 84640 304103177 1 24192 52674 6 2 62625 69328 1 89011 91773 5 2 72575 96768 2...
output:
6704 40293 12102 33158 78383 201814 123273 3236 25188 109736 81489 425823 5427 22465 301379 285879 382890 118883 216719 13882 166743 343169 134526 161832 7646 33723 34200 154644 185767 114133 7870 461621 601884 2320 21987 103253 30462 134520 22763 76483 141769 191450 257938 140 345123 254809 149247 ...
result:
ok 40013 numbers
Test #19:
score: 25
Accepted
time: 131ms
memory: 75272kb
input:
99998 99997 988493105 1 11368 96969 5 1 70004 95194 61852639 1 21091 70816 3 1 36266 93226 9 1 41825 55369 10 1 60028 80125 1 1 49575 82002 2 1 37639 37933 1 1 29629 84763 10 2 19939 77543 1 66306 87869 670478528 1 5885 55768 10 1 88066 98954 7 1 7692 11175 5 1 8852 16737 1 1 94905 97074 6 1 62351 9...
output:
305914 50124 116007 40700 136561 19130 8382 327353 136835 2814 424926 61740 980074 574957 31066 277605 829 84593 464570 25526 195353 20794 201617 15937 162 295764 13321 110548 18948 91582 566843 290466 142286 93003 13562 40379 190624 269352 660368 18966 153498 124393 61533 262629 228510 55515 131157...
result:
ok 9949 numbers
Test #20:
score: 25
Accepted
time: 62ms
memory: 68948kb
input:
99997 99998 116549075 2 12266 94523 2 88678 90299 1 62342 87665 6 1 86640 99714 10 2 45214 89187 2 99015 99827 1 87386 98214 2 2 70579 78516 1 94321 96508 9 1 99049 99621 35580948 2 93617 97124 2 98434 99794 2 72747 74622 2 92972 99978 2 12392 39851 2 52850 86758 2 11844 94232 1 96668 96989 3 2 5802...
output:
82258 1622 71846 1513 15876 12712 2642 3752 21181 27460 58445 122153 30789 72545 30521 68291 48645 95610 17662 11152 97485 73970 9856 45645 114389 106701 17823 89848 104704 16233 4290 88772 27365 83616 7856 178165 50297 41656 1356 56431 215804 153392 3500 19657 161981 122117 122852 123615 29147 1772...
result:
ok 70246 numbers
Subtask #3:
score: 25
Accepted
Test #21:
score: 25
Accepted
time: 1168ms
memory: 109784kb
input:
500000 500000 32 1 398994 486295 6 1 495521 496532 3 1 340319 359823 10 1 450253 453343 272125394 1 181453 287632 7 1 161103 427946 5 1 39180 431029 9 1 38269 459066 2 1 460663 462198 10 1 432981 465351 7 1 400126 404950 786797498 1 324472 411628 10 1 498053 498096 10 1 427482 442429 395990662 1 209...
output:
560397 340227 305445 795778 69006 362702 453306 828479 369281 208468 98128 78906 252771 73134 197775 971946 105447 1041915 142548 167392 108746 170379 641833 402986 50960 32753 220986 63352 70593 306481 790938 166011 593360 850779 524644 46717 297221 81796 1101868 288889 1069 854110 426115 183877 10...
result:
ok 50187 numbers
Test #22:
score: 25
Accepted
time: 1212ms
memory: 109920kb
input:
500000 500000 96 1 162409 197608 86491832 1 119401 485466 5 1 469679 469682 49 1 67292 67294 38 1 42525 427048 8 1 24833 42042 7 1 304734 453462 927220523 1 51806 308150 9 1 286883 331903 2 1 59416 105699 3 1 148007 206888 10 1 22526 423440 23280672 1 90058 429103 8 1 255862 471403 2 1 85298 85299 4...
output:
186418 510824 33156 1319124 1691214 264708 23392 398193 11292 308871 854366 1212166 455427 74660 354958 170150 215637 92304 58779 341682 93779 573794 127287 91008 178772 29106 937576 351465 11193 487665 474608 288080 1212486 339597 441154 776945 75895 48822 529106 470736 47612 550063 95895 172816 11...
result:
ok 49916 numbers
Test #23:
score: 25
Accepted
time: 1607ms
memory: 110264kb
input:
499998 499997 298841078 1 178930 497400 5 1 282494 321023 7 1 458577 498826 7 1 312654 316797 7 1 318240 483557 5 1 418527 443860 3 2 489382 494250 1 298290 424085 4 1 4873 59978 2 1 53019 110349 2 1 98077 482947 3 1 136634 443522 7 1 16796 403946 9 1 498226 499248 4 2 474970 491963 1 473445 476212 ...
output:
14607 67548 1264080 64364 26077 62688 18130 2233951 3715112 1149014 85611 1028280 1131879 77796 542587 1160499 1121159 3100377 1555207 1265087 176486 373457 117812 202253 1209854 1413344 784864 1442896 4315236 98420 593151 170636 30092 676844 5742 875118 84629 559189 153208 101695 2085632 235299 461...
result:
ok 50122 numbers
Test #24:
score: 25
Accepted
time: 620ms
memory: 97648kb
input:
499997 499999 514131616 2 296448 424410 2 284153 458016 1 340949 417457 2 2 484448 495248 1 4927 251967 2 2 89428 396422 2 359140 440802 2 294291 408314 2 270366 345900 1 66058 111950 6 2 459621 492598 2 432163 445457 2 168206 191946 1 490501 493312 6 2 477415 486540 1 69353 300773 7 1 456857 456860...
output:
127963 173864 10801 525009 139981 181390 80487 32978 13295 47482 9126 217568 399341 3668 313612 135453 689496 74409 430064 846746 238498 158561 27356 94068 349301 328907 193324 1167906 617828 654048 107346 101967 76499 9052 10456 572125 23359 1000876 2102 859743 159747 142342 423955 538941 241981 10...
result:
ok 349779 numbers
Test #25:
score: 25
Accepted
time: 1044ms
memory: 110824kb
input:
499998 499997 690372988 1 310395 346740 10 1 487217 490982 3 2 15179 276426 1 21337 172367 9 2 368162 427686 1 205835 486053 2 1 440136 460564 10 1 79805 180777 7 2 198236 207808 2 249570 259646 2 238644 276539 1 126024 154951 8 2 238966 327933 2 168709 387982 1 325584 325584 54 2 400089 424896 1 28...
output:
261248 59525 11547 20154 75792 195475 453496 49616 53346 46575 386229 612291 435957 794948 1004940 483398 101562 836645 6131 255185 448435 246463 388867 2338577 53976 130736 53713 104438 1557716 53124 300488 1076469 41233 171111 329473 303030 219613 56166 295107 703844 1451795 1672379 268037 1336648...
result:
ok 200020 numbers
Test #26:
score: 25
Accepted
time: 1504ms
memory: 108892kb
input:
500000 500000 364164191 1 443500 496779 6 1 270630 270631 36 1 135214 454713 2 1 282793 282793 41 1 134073 134073 9 1 414465 414467 31 1 480966 492850 7 1 478484 490642 10 1 100846 141492 9 1 42361 262039 4 1 405798 496143 2 1 167355 167357 5 1 380818 459413 3 1 360877 360880 8 1 190846 355263 3 2 7...
output:
174433 203487 196409 1171830 1484126 2012445 343657 21465 1734261 745281 2197523 1358480 1867946 765769 81538 255511 1342481 679550 1212701 414541 53070 1512776 1994355 2088675 181669 1140144 1138657 1482332 2314557 202868 951192 187099 237814 757026 508213 3117253 1093855 1548198 28055 3338235 9190...
result:
ok 49923 numbers
Test #27:
score: 25
Accepted
time: 1502ms
memory: 109316kb
input:
500000 499996 827808127 1 235034 382158 2 1 329235 332099 8 1 306681 341990 2 1 25078 287305 3 2 183371 447135 2 48429 286956 1 194930 280532 2 1 274149 374701 10 2 38713 397875 1 374042 432188 4 1 226704 454357 551407746 1 431679 486434 4 1 14987 273852 4 1 196656 366437 857938004 1 108950 296711 1...
output:
553000 528979 979212 933724 561881 37488 802007 1724831 2368869 640664 54450 2434415 704447 1037399 107421 3266581 80938 1604165 1792661 1109140 213249 20710 952084 3196702 1653325 14928 686746 1167464 1788962 3324927 987210 305830 683290 783171 105182 99144 1589517 3316961 70093 1433531 83940 91798...
result:
ok 49649 numbers
Test #28:
score: 25
Accepted
time: 569ms
memory: 89908kb
input:
500000 500000 53926318 2 33002 243201 2 180944 319296 1 251642 282476 6 2 245610 287316 2 453978 456487 1 289598 462517 2 2 222231 456775 2 449953 494978 2 219805 471046 1 257692 443159 6 2 403848 420514 2 225567 338196 1 221045 273088 294474305 2 242143 358481 1 94726 239078 2 2 275561 448674 1 369...
output:
210200 138353 72542 2510 432558 57591 454997 50001 272569 280004 506706 247034 176098 395893 104670 167138 608355 9064 430695 426487 530505 740741 1497937 835547 17880 650067 794931 185930 62888 2023807 500769 1838763 1076285 740322 1312761 103859 2864020 709908 133090 364500 200051 47571 459198 186...
result:
ok 350318 numbers
Test #29:
score: 25
Accepted
time: 1370ms
memory: 109464kb
input:
499995 499998 767955629 1 75749 219940 3 1 180210 271542 6 1 391396 434648 6 1 491640 496304 7 1 440656 454659 3 1 413911 453363 8 1 432846 455313 6 2 307195 370502 1 233245 400380 9 1 246843 492655 2 1 374732 437211 9 1 142423 169154 793560992 1 375902 482181 3 1 320728 320730 27 1 55621 55621 48 1...
output:
63308 31734 7965 574384 204141 64506 418083 94028 115732 160380 931359 339484 441514 48212 569634 128555 1488752 915091 208894 2782678 298522 60444 696851 841030 844161 1753187 1908906 4067756 1558906 42872 189172 203768 577232 63330 1563187 592588 341646 242193 86404 137045 659493 6730 1563938 2903...
result:
ok 49879 numbers
Test #30:
score: 25
Accepted
time: 1365ms
memory: 111140kb
input:
499996 499998 761092880 1 216480 228556 2 1 177632 380437 2 1 105945 334622 856602782 1 275888 369963 7 1 185776 339214 7 2 455528 493977 2 79984 484990 1 335733 335735 24 1 394255 394258 55 1 267103 383323 3 1 27482 27484 58 2 352586 381451 1 335110 351565 8 1 43039 237461 2 1 185760 185763 14 1 30...
output:
38450 698337 102962 6996 843371 415967 821452 871238 998605 722883 562802 549383 78353 426413 2544587 255170 1724080 234169 17516 265053 5178 2566896 680243 420678 337328 930006 47086 307472 28738 1546732 201214 791881 1952570 4149682 14967 2644687 133340 241662 583214 509933 131368 1242581 359368 1...
result:
ok 49985 numbers
Subtask #4:
score: 25
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #31:
score: 25
Accepted
time: 590ms
memory: 105352kb
input:
499995 499998 72 1 246180 406533 10 2 287407 485699 1 9038 330826 4 1 256057 371564 7 1 368873 368875 26 1 400744 426296 10 1 271161 428856 10 1 183881 183882 51 2 197605 225857 2 342756 396292 1 177993 246779 8 1 203285 262466 3 2 876 60727 1 53986 53987 53 1 67639 127375 1 1 420697 441340 5 1 3713...
output:
317420 56506 135880 111542 209555 305974 269331 30644 329376 1081216 194760 26892 588184 515254 306096 44844 556521 925290 72831 5201 936742 62470 24449 46663 145978 24154 86176 52925 127338 894798 13962 7906 866399 87033 164574 136143 816929 374593 31754 275634 393624 320298 266215 88384 1152677 99...
result:
ok 200178 numbers
Test #32:
score: 25
Accepted
time: 607ms
memory: 106004kb
input:
499997 499997 87 1 262980 456935 1 1 373395 373398 29 1 222781 222783 25 1 149487 215006 3 1 302293 323887 10 2 313671 453003 2 122501 464180 1 304054 304054 45 1 258327 420552 9 1 250242 448534 10 2 268804 343032 2 206204 306730 2 389339 400774 2 229939 437884 1 82262 239257 2 1 88696 481375 10 1 2...
output:
288887 622758 148458 165822 22872 412921 643871 195777 48186 4864 314131 180434 686551 681484 569686 115262 834780 689079 555932 52167 126547 1069337 235431 17958 375207 944244 50643 754200 344872 966536 494001 411797 166407 818744 216495 191294 65276 381704 388465 21386 248190 463535 108389 81208 7...
result:
ok 200377 numbers
Test #33:
score: 25
Accepted
time: 708ms
memory: 111600kb
input:
499999 499996 987719180 2 286114 444625 2 399817 416918 1 367846 399620 4 1 251300 375710 3 1 154226 361396 8 1 75529 144899 7 1 195819 195822 40 2 32530 187061 1 492780 497435 5 1 141994 250585 3 2 490878 496257 2 431751 482894 1 445325 446309 8 1 270596 285417 8 1 362238 423897 6 2 351625 449962 1...
output:
158512 17102 256739 8858 51144 226616 2799 454277 335766 954550 653305 1173597 943191 7524 174032 602168 589385 307790 333908 455426 1655 510004 252005 194861 296070 257012 531232 297297 1418403 431998 4923 116126 20017 282397 252735 1506 617453 661765 317767 189008 840384 1610411 856925 156306 8834...
result:
ok 200040 numbers
Test #34:
score: 25
Accepted
time: 455ms
memory: 97304kb
input:
499998 499996 26070998 1 174799 313740 9 1 59384 138762 5 1 260220 260223 39 2 90369 274369 2 384000 437312 1 412208 483202 4 1 293777 293780 33 2 466234 471540 2 305550 370596 1 113356 208135 6 2 292314 473811 2 112924 179369 1 474728 474728 16 1 31932 31933 45 2 55703 274261 2 350858 366338 2 1249...
output:
331970 53313 10614 73238 264533 162870 492185 15481 233113 136036 40858 686987 752487 556187 171029 78491 118 277085 13481 241149 109289 115421 282292 10689 106331 4156 132522 102408 121089 1194637 583532 474590 714317 812909 374499 500095 376266 1295644 198682 432107 400456 29121 1700951 715932 163...
result:
ok 349911 numbers
Test #35:
score: 25
Accepted
time: 722ms
memory: 112232kb
input:
499998 499997 913490118 1 437146 451834 7 1 157865 436968 4 2 473265 475156 1 200723 264087 6 2 165425 432678 1 391462 461060 2 1 201472 496936 10 2 269389 435104 1 499411 499701 470845273 1 431837 491031 9 1 409783 474729 9 1 60421 60423 42 1 337492 337495 43 1 231673 389007 10 1 365506 494632 1 1 ...
output:
1892 597873 540791 81260 1051203 17186 1763045 1722396 90769 1026014 68780 1005948 323948 1550927 71921 1153865 1436454 4026185 745001 1696588 819521 950846 1160422 625059 230214 65149 1372881 2697001 1886195 183165 2851993 507915 162292 261586 35271 595367 555422 1085413 1343246 227960 123124 91608...
result:
ok 199473 numbers
Test #36:
score: 25
Accepted
time: 972ms
memory: 113488kb
input:
499995 500000 494643027 1 319767 319770 35 1 220159 475286 6 1 315795 334050 3 1 186126 446702 6 1 308998 359343 4 1 345647 355426 5 2 108128 111229 1 183461 335331 3 1 383206 461332 10 1 3887 161552 1 1 137544 186020 8 1 103496 103496 27 2 497739 497992 1 87115 424686 4 1 252309 356591 8 1 44248 21...
output:
3102 254 1290631 14110 1764566 266794 27530 2316597 3537361 2790923 1784239 111516 248054 6756 900875 834912 1433142 1551330 1233965 1294175 2040984 3013361 1056044 154278 448543 1720106 36820 2871070 109889 87400 1548722 462236 3562 490693 2444186 508461 2500081 432176 151308 267937 16574 2074353 1...
result:
ok 49552 numbers
Test #37:
score: 25
Accepted
time: 465ms
memory: 104612kb
input:
499995 499997 508695827 1 477166 494428 7 2 94700 459130 2 479242 494600 2 112813 431617 2 410762 452761 1 206502 350704 2 2 63265 242357 2 441487 458152 2 191070 346662 2 90682 320854 2 119196 234577 1 179700 437431 373476323 2 435346 483346 1 122842 439506 10 2 197780 353479 2 179278 212857 2 3719...
output:
364431 30546 318805 42000 214949 16666 295754 344526 143458 56268 311400 67160 156550 402282 235864 47564 55822 208498 415455 388382 380156 113557 46648 651467 155420 206218 103932 4218 514996 337822 304748 119004 191628 310556 344549 376071 620085 130002 1194826 552369 367360 40614 1459677 205319 5...
result:
ok 349962 numbers
Test #38:
score: 25
Accepted
time: 703ms
memory: 110364kb
input:
499995 499995 458458040 2 381947 462026 2 201463 384391 2 58802 468954 1 395544 488401 5 2 300203 375232 2 344688 459159 1 495430 495887 1 1 424893 424893 17 2 5914 461904 1 79655 186674 9 2 486879 493653 2 189649 284526 1 220100 326820 8 2 295830 488177 2 321550 413592 1 109691 121331 8 1 464738 46...
output:
80080 182929 410153 75030 178088 522353 8298 94878 315974 115363 205072 371229 264496 177138 571359 349235 511117 1099319 32838 1109788 25681 1548489 886520 5675 704935 331333 430831 725580 819421 62382 179433 1157081 711858 941383 171882 268245 228830 1032973 185447 24340 13632 833071 10322 25545 1...
result:
ok 200196 numbers
Test #39:
score: 25
Accepted
time: 992ms
memory: 113324kb
input:
500000 500000 544353158 1 8564 156145 8 1 478709 479640 2 1 153558 403703 3 1 135254 427764 776616323 1 286052 475383 10 1 386672 466250 972433558 1 362548 399417 5 1 274641 385652 7 1 197422 474825 10 1 216961 484854 1 1 64397 426511 9 1 48564 266955 1 1 41343 168700 9 1 93510 426417 4 1 19712 1971...
output:
486282 1209655 438169 22564 4251879 32641 1273955 1384082 382812 450675 222674 1897949 280357 21119 538939 2115491 677978 1771396 304520 14210 128791 1456509 127140 1955446 377374 492065 670688 952358 2655244 329399 1003046 3009825 2239513 48146 603589 387700 1608503 1625043 4023241 12866 122152 367...
result:
ok 50149 numbers
Test #40:
score: 25
Accepted
time: 1005ms
memory: 112108kb
input:
500000 500000 306020543 1 79270 79270 17 1 107078 155599 6 1 147484 148967 22806684 1 1680 334600 8 2 56855 368715 1 285896 364883 1 1 442122 479429 1 1 153512 409402 6 1 330818 455195 1 1 344829 456050 10 2 283117 378620 1 160819 160822 11 1 136385 427886 2 1 65531 272913 9 1 196844 365771 7 1 2910...
output:
638130 403075 253518 35046 1479221 109492 211827 1556168 115382 286560 55431 1090 3009834 1252940 31626 196413 280724 729162 121728 1566974 30708 797775 2000824 4027856 920113 235958 396967 166793 1524458 192506 1158997 580577 2086159 437974 239695 457060 267054 2209283 3172989 2299731 2415127 45724...
result:
ok 49969 numbers