QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#783292 | #9646. 子集和 | JWRuixi | 100 ✓ | 1135ms | 164940kb | C++17 | 5.2kb | 2024-11-26 07:37:24 | 2024-11-26 07:37:30 |
Judging History
answer
#ifdef LOCAL
#include "stdafx.h"
#else
#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define sz(v) ((int) (v).size())
#define me(f, x) memset(f, x, sizeof(f))
#define mc(f, g) memcpy(f, g, sizeof(g))
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;
using vi = vector<int>;
#endif
using uint = unsigned;
using ull = unsigned long long;
using u128 = __uint128_t;
namespace IO {
char ibuf[1 << 20], *iS, *iT, obuf[1 << 20], *oS = obuf;
#define wrsp(x) wr(x), pc(' ')
#define wrln(x) wr(x), pc('\n')
// Helps
#ifndef LOCAL
#define gh() (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, 1 << 20, stdin), (iS == iT ? EOF : *iS++) : *iS++)
#else
#define gh() getchar()
#endif
IL void flush () {
fwrite(obuf, 1, oS - obuf, stdout), oS = obuf;
}
struct Flusher {
~Flusher () {
flush();
}
} AutoFlush;
IL void pc (char ch) {
if (oS == obuf + (1 << 20)) flush();
*oS++ = ch;
}
//
IL uint rd () {
char ch = gh();
uint x = 0;
while (ch < '0' || ch > '9') ch = gh();
while (ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gh();
return x;
}
char buf[64], *tp = buf;
template<typename T>
IL void wr (T x) {
do {
*tp++ = x % 10;
x /= 10;
} while (x);
while (tp != buf) {
pc((*--tp) | 48);
}
}
}
using IO::rd;
using IO::wr;
using IO::pc;
constexpr int P = 1e9 + 7;
IL void qm (int &x) {
x += (x >> 31) & P;
}
IL void ad (int &x, const ull &y) {
x = (x + y) % P;
}
constexpr int N = 1e4 + 9;
constexpr int M = 205;
constexpr int Q = 1e6 + 9;
int n, m, q, a[N], b[N];
LL ns[Q];
int _f[M];
IL int mod (int x) {
return x >= m ? x - m : x;
}
struct poly {
int f[M];
poly () { me(f, 0); }
int& at (int x) {
return f[mod(x)];
}
poly operator * (const poly &rhs) const {
poly s;
L (i, 0, m - 1) {
if (int x = f[i]) {
L (j, 0, m - 1) {
ad(s.at(i + j), x * (ull)rhs.f[j]);
}
}
}
return s;
}
poly& operator += (const poly &rhs) {
L (i, 0, m - 1) {
qm(f[i] += rhs.f[i] - P);
}
return *this;
}
void upd (int a, int b) {
mc(_f, f);
L (i, 0, m - 1) {
if (int x = f[i]) {
qm(_f[mod(i + a)] += x - P);
qm(_f[mod(i + b)] += x - P);
}
}
mc(f, _f);
}
} pre[N], suf[N], f[N][2], g[N][2], h[N];
vector<tuple<int, int, int, int>> qq[N * 4];
void ins (int l, int r, int o, int x) {
if (l < 1 || r > n) {
return;
}
int L = 1, R = n, p = 1;
while (1) {
int md = (L + R) / 2;
if (r <= md) {
R = md;
p = p * 2;
} else if (md < l) {
L = md + 1;
p = p * 2 + 1;
} else {
break;
}
}
qq[p].eb(l, r, o, x);
}
void calc (int l, int r, poly v) {
if (l == r) {
h[l] = v;
return;
}
int md = (l + r) >> 1;
poly v1 = v;
L (i, l, md) {
v1.upd(a[i], b[i]);
}
poly v2 = v;
L (i, md + 1, r) {
v2.upd(a[i], b[i]);
}
calc(l, md, v2);
calc(md + 1, r, v1);
}
void dfs (int l, int r, int p) {
if (l == r) {
return;
}
int md = (l + r) >> 1;
dfs(l, md, p * 2);
dfs(md + 1, r, p * 2 + 1);
if (qq[p].empty()) {
return;
}
calc(l, md, pre[l - 1]);
calc(md + 1, r, suf[r + 1]);
h[l - 1] = f[l - 1][1];
L (i, l, md) {
h[l - 1].upd(a[i], b[i]);
}
h[r + 1] = g[r + 1][1];
L (i, md + 1, r) {
h[r + 1].upd(a[i], b[i]);
}
L (i, l, md) {
h[i] += h[i - 1];
}
R (i, r, md + 1) {
h[i] += h[i + 1];
}
static int k;
for (auto [x, y, o, i] : qq[p]) {
u128 s = h[x].f[0] * (ull)h[y].f[0];
for (k = 1; k + 4 < m; k += 4) {
s += h[x].f[k + 0] * (ull)h[y].f[m - k - 0];
s += h[x].f[k + 1] * (ull)h[y].f[m - k - 1];
s += h[x].f[k + 2] * (ull)h[y].f[m - k - 2];
s += h[x].f[k + 3] * (ull)h[y].f[m - k - 3];
}
while (k < m) {
s += h[x].f[k] * (ull)h[y].f[m - k];
++k;
}
ns[i] += o * (int)(s % (uint)P);
}
}
int main () {
ios::sync_with_stdio(0), cin.tie(0);
n = rd(), m = rd(), q = rd();
L (i, 1, n) {
a[i] = rd(), b[i] = rd();
}
pre[0].f[0] = 1;
suf[n + 1].f[0] = 1;
L (i, 1, n) {
(pre[i] = pre[i - 1]).upd(a[i], b[i]);
}
R (i, n, 1) {
(suf[i] = suf[i + 1]).upd(a[i], b[i]);
}
f[0][0].f[0] = 1;
g[n + 1][0].f[0] = 1;
L (i, 1, n) {
L (o, 0, 1) {
(f[i][o] = f[i - 1][o]).upd(a[i], b[i]);
}
f[i][1] += f[i - 1][0];
}
R (i, n, 1) {
L (o, 0, 1) {
(g[i][o] = g[i + 1][o]).upd(a[i], b[i]);
}
g[i][1] += g[i + 1][0];
}
L (i, 1, q) {
int l1 = rd(), r1 = rd(), l2 = rd(), r2 = rd();
ins(r1, l2, 1, i);
ins(l1 - 1, l2, -1, i);
ins(r1, r2 + 1, -1, i);
ins(l1 - 1, r2 + 1, 1, i);
}
dfs(1, n, 1);
L (i, 1, q) {
ns[i] %= P;
if (ns[i] < 0) {
ns[i] += P;
}
wrln(ns[i]);
}
}
// I love WHQ!
詳細信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 54ms
memory: 73468kb
input:
100 200 100000 53 120 79 20 25 123 27 67 81 138 76 2 38 78 9 110 11 176 48 181 140 66 152 17 168 11 57 37 183 83 198 99 45 20 6 178 15 133 129 12 151 109 65 98 130 121 163 110 152 191 182 158 128 171 75 103 75 135 80 103 151 112 193 97 17 99 132 25 36 131 8 34 27 15 75 22 44 99 49 68 1 71 184 48 20 ...
output:
933131782 150378770 921041143 949395706 328267280 714744887 70308222 137813211 956846337 978609678 711621584 517493311 136743300 389224576 602628217 611992804 945664660 424531522 598216785 781127035 804258949 637160508 821037608 375447913 118793825 346369291 761580989 668670458 763413378 364495111 9...
result:
ok 100000 lines
Test #2:
score: 5
Accepted
time: 62ms
memory: 70872kb
input:
100 199 100000 128 50 63 72 51 197 196 0 59 191 151 134 102 146 119 148 50 178 68 180 21 92 115 130 135 114 98 136 78 67 178 116 135 39 123 111 34 63 107 142 143 122 167 4 34 39 196 73 161 185 126 47 197 38 19 64 143 132 67 84 62 53 91 189 128 103 130 50 46 24 102 162 129 149 173 72 126 170 36 135 1...
output:
74502811 599602967 316542460 224298649 611711364 619667825 348220189 780535782 257304137 119998328 833877643 324817095 451572747 550827743 306474659 593701179 898294379 849130708 309433095 73959042 354575018 924108912 447223787 51646855 2964910 212904922 720069277 586857779 730179857 556530738 44693...
result:
ok 100000 lines
Test #3:
score: 5
Accepted
time: 44ms
memory: 73264kb
input:
100 200 100000 143 9 38 36 64 29 186 107 8 28 5 162 55 34 179 121 199 31 54 92 22 195 81 185 50 187 1 89 51 28 49 197 194 48 79 177 106 163 139 5 48 113 102 181 143 22 183 139 31 187 41 144 183 87 199 104 146 71 5 149 95 0 62 119 49 11 60 176 176 132 165 73 116 31 104 30 160 39 115 179 176 179 76 58...
output:
727907275 547995799 490564275 210804694 499892278 605267524 540884896 522930635 503209456 363514310 782897100 587023354 728958982 577193683 658011585 890159478 472188525 839012948 846244244 588552024 357575351 827994638 216841059 661851732 548841684 316190299 610991019 878266555 596966101 480640508 ...
result:
ok 100000 lines
Test #4:
score: 5
Accepted
time: 50ms
memory: 73372kb
input:
100 199 100000 136 28 197 197 38 6 156 149 105 94 4 19 174 80 73 170 155 38 190 20 82 156 38 45 165 161 78 164 145 110 62 125 147 81 53 123 175 184 157 113 29 159 96 108 170 93 113 114 141 46 185 36 58 153 159 73 115 126 103 175 1 67 15 25 91 36 161 198 174 104 5 75 70 195 63 79 123 20 195 42 52 60 ...
output:
920593336 571484468 815262569 769551976 242499121 227154977 970948879 414409026 900442572 927623625 439211664 446108258 737535091 852775086 686923958 204434314 247505230 478507877 625517011 811629956 196980757 15201613 164050452 202921748 886592227 321811625 655911559 940738305 699619956 813453159 4...
result:
ok 100000 lines
Subtask #2:
score: 5
Accepted
Dependency #1:
100%
Accepted
Test #5:
score: 5
Accepted
time: 67ms
memory: 73596kb
input:
500 200 100000 54 86 94 36 19 156 100 166 183 102 184 26 147 19 140 173 132 132 30 20 152 38 73 156 177 110 166 116 43 145 129 11 51 125 171 45 74 59 189 21 8 18 73 29 178 22 187 58 11 66 183 108 158 2 101 194 90 53 118 61 194 30 75 21 104 84 46 113 164 111 85 121 106 126 153 27 35 86 74 28 37 81 29...
output:
550878246 568253959 737617715 955272636 824389583 304421386 199117026 298332688 263123251 221096312 422830721 817738617 15626822 343113048 971135773 716994905 160860863 956616684 993541038 677587879 44726426 813079220 51099455 436033250 542225075 640201195 13600131 234159042 785870374 797962462 8568...
result:
ok 100000 lines
Test #6:
score: 5
Accepted
time: 69ms
memory: 70748kb
input:
500 199 100000 99 134 165 90 9 93 8 52 77 75 131 57 128 34 137 155 130 186 139 9 58 83 108 17 3 178 26 15 3 20 136 49 196 96 49 164 173 22 126 88 114 164 175 65 152 26 48 76 102 20 62 176 131 114 0 28 94 60 59 103 192 50 183 43 42 81 98 174 39 136 104 83 197 179 167 98 97 187 79 133 177 102 142 137 ...
output:
105019463 627081852 351586314 217195857 239084096 233201620 421244970 78330096 898438403 62484704 229096902 752938517 187102385 178900183 19379519 426266927 242618382 46108658 699919862 859795313 829996346 309163965 427288706 778584329 841497506 773580795 978176447 53180548 984873544 146608770 89034...
result:
ok 100000 lines
Test #7:
score: 5
Accepted
time: 63ms
memory: 73588kb
input:
500 200 100000 25 181 183 146 130 171 198 161 48 14 137 199 175 195 98 163 32 149 156 53 158 52 41 127 148 48 38 199 139 179 24 135 62 10 164 31 118 136 42 142 53 154 145 113 167 46 32 161 107 128 44 63 32 20 114 139 125 112 149 41 107 191 71 120 197 175 105 168 172 2 68 96 104 128 109 6 156 155 35 ...
output:
182036290 213244831 913133024 738110740 422040948 700642330 524551582 12716295 963027771 416514619 861570054 935560410 187951943 981574486 970350098 323523784 443725996 21209082 11015807 735734429 842175751 347101825 867771757 209663451 397153590 528131876 762968064 627919780 655822194 912865098 886...
result:
ok 100000 lines
Test #8:
score: 5
Accepted
time: 62ms
memory: 70944kb
input:
500 199 100000 125 112 10 115 49 159 55 86 198 105 73 187 89 127 108 22 100 109 9 50 90 77 21 48 13 88 18 89 127 145 195 130 197 58 143 192 108 25 1 116 100 35 171 183 123 35 104 187 90 11 56 195 41 176 50 107 157 80 141 27 6 29 60 134 117 146 26 99 29 79 5 65 181 47 38 39 9 7 63 95 152 102 65 45 18...
output:
187269929 287806633 155618344 716938279 374281195 945012184 337209511 992401500 753649162 121166541 394138080 31420964 382320615 139419346 279494982 243641264 671601736 532734541 977947914 707578150 382817210 322829373 104770490 515198945 282473045 605593692 177069922 951140193 950679477 424214972 3...
result:
ok 100000 lines
Subtask #3:
score: 20
Accepted
Test #9:
score: 20
Accepted
time: 108ms
memory: 71112kb
input:
10000 20 100000 13 3 1 2 5 11 8 9 8 3 17 16 16 17 10 6 19 17 8 17 10 6 17 7 15 6 17 15 7 18 19 6 19 10 0 11 5 7 17 17 13 8 13 3 7 19 8 13 8 3 9 6 5 19 4 2 1 18 12 8 2 8 10 8 9 17 7 8 10 0 13 4 6 0 1 7 1 10 18 17 9 1 2 18 11 2 7 14 14 12 15 12 7 9 4 9 16 11 17 11 1 17 3 3 1 15 11 4 19 6 7 11 11 17 7 ...
output:
758908657 341890636 45541633 446352066 95294209 914655574 279834088 586254421 62385237 10394675 944499480 215898683 777920225 313244361 938216168 172689349 328201410 707950593 757681636 280198610 677368999 708883406 577914886 505835765 666172463 627383641 597910157 34469547 143036498 279491455 21229...
result:
ok 100000 lines
Test #10:
score: 20
Accepted
time: 106ms
memory: 73728kb
input:
10000 19 100000 12 1 17 0 12 1 5 11 0 2 1 3 15 10 0 0 18 15 0 6 3 11 5 7 1 5 9 15 5 14 14 15 17 5 18 14 7 17 6 12 3 14 11 2 9 9 11 11 3 1 5 3 4 5 9 1 12 7 0 13 6 8 8 12 14 6 1 18 15 9 15 18 12 1 7 16 13 5 13 12 12 14 7 16 3 0 18 8 7 0 10 3 1 16 4 5 6 10 3 13 11 9 14 5 2 16 6 7 11 13 8 7 15 3 9 17 6 ...
output:
991792974 992648364 315967061 81713661 201122142 619056706 134692674 665354725 651068791 251274181 393470167 98411878 146883613 719449802 46800652 418749215 766515502 717503379 117844726 89682468 700231850 99749324 119474708 414319084 518568859 289528463 834743293 41789893 269638900 774311919 773885...
result:
ok 100000 lines
Test #11:
score: 20
Accepted
time: 114ms
memory: 70792kb
input:
10000 20 100000 10 17 1 9 12 8 10 5 1 5 9 16 6 6 5 17 17 5 5 7 18 8 11 18 8 16 9 14 13 2 14 11 0 5 18 18 10 14 7 19 12 16 8 14 7 15 2 1 15 8 11 7 9 6 17 3 11 3 10 11 11 8 17 4 10 0 16 6 12 5 18 12 1 3 6 10 4 15 13 13 8 0 13 13 15 2 17 9 14 11 15 10 2 5 19 7 13 14 6 0 12 8 13 13 17 14 12 9 3 14 12 8 ...
output:
154414033 381047491 255643085 871112570 964664 790899786 783142515 34192251 327040073 3847766 544721926 885165901 701385492 111804886 749746237 595466258 138813933 634763211 830644517 294796879 488084036 944501209 399212205 612878250 30245226 290096897 212779062 664444749 765080834 349470950 3667753...
result:
ok 100000 lines
Test #12:
score: 20
Accepted
time: 116ms
memory: 71188kb
input:
10000 19 100000 9 4 7 5 2 6 3 17 10 1 16 16 14 10 16 14 3 1 8 8 18 1 4 4 4 5 1 17 18 4 5 16 0 15 3 7 7 6 13 4 11 5 9 3 2 8 9 14 14 3 7 11 2 6 5 8 18 18 5 5 4 11 3 18 7 4 11 10 12 8 2 12 6 4 2 2 4 18 16 8 17 16 13 14 16 7 16 6 0 13 5 18 7 3 6 5 8 4 5 4 8 6 9 10 12 6 2 0 4 2 5 7 1 3 13 9 12 4 6 9 14 1...
output:
939348072 867942298 101686061 821815654 427542739 374274912 805909238 547069751 831365443 474846350 66088385 320714519 446824681 503160463 934710327 200822261 471509729 751930951 102027997 459823431 529732728 721942591 899893049 15902395 349277385 251992672 879925189 577099490 753274580 130438260 50...
result:
ok 100000 lines
Subtask #4:
score: 15
Accepted
Dependency #3:
100%
Accepted
Test #13:
score: 15
Accepted
time: 837ms
memory: 162628kb
input:
10000 150 1000000 113 147 44 10 15 124 135 111 34 108 141 0 130 45 48 136 33 88 125 85 35 98 74 137 48 52 103 113 0 90 49 131 128 46 92 97 132 97 51 0 9 33 120 40 49 67 132 101 116 149 95 56 46 147 134 73 9 81 117 70 40 138 65 111 82 80 99 141 109 25 2 12 36 134 135 81 107 79 30 75 87 97 101 58 116 ...
output:
253499178 235231973 652718454 396786830 6643365 190384730 810537445 97306114 454166361 37632117 407401149 358183480 260468077 321470216 129225028 271481416 69966807 646931805 560420639 811831637 273054120 499738410 981974900 171710046 335682706 693570507 449620493 847778400 823682298 720418456 21345...
result:
ok 1000000 lines
Test #14:
score: 15
Accepted
time: 873ms
memory: 162056kb
input:
10000 149 1000000 39 86 148 63 16 105 147 89 88 3 114 1 73 75 84 50 124 54 100 76 64 8 96 76 128 79 113 136 139 112 58 71 73 75 125 37 70 47 138 135 33 4 69 76 136 96 7 54 71 0 132 104 126 92 11 9 115 135 25 145 42 144 130 9 93 144 24 20 7 70 55 10 113 40 148 7 137 91 138 121 128 139 31 77 101 125 7...
output:
535217918 761584790 620624329 329444422 674063360 338595230 661445721 877210347 40357186 672994714 712277823 880533832 564990728 303237968 487127385 446822397 700507815 462022159 146127054 549901603 936809530 693011870 526631094 639202007 701628572 569815607 848937041 49322880 389947874 284553410 33...
result:
ok 1000000 lines
Test #15:
score: 15
Accepted
time: 867ms
memory: 161976kb
input:
10000 150 1000000 13 121 3 73 147 60 115 86 110 62 13 59 123 104 92 23 132 98 23 17 93 106 108 99 9 51 7 124 129 24 76 56 63 88 115 122 12 36 53 69 49 64 97 129 93 73 73 30 41 118 141 63 12 142 121 118 112 130 15 147 8 22 35 127 115 145 149 132 133 3 75 29 7 33 8 49 118 48 34 26 64 73 0 104 31 87 2 ...
output:
714044132 442816931 812472039 648917510 939088619 492410096 377323267 265548942 82228679 902563452 568937269 274664027 313752968 96500443 953580916 520678542 962493953 452661383 895294692 864829786 146079301 38100315 55349989 338162174 279323734 257494347 411521501 265385776 744289123 846270620 2873...
result:
ok 1000000 lines
Test #16:
score: 15
Accepted
time: 865ms
memory: 161740kb
input:
10000 149 1000000 37 68 2 14 125 74 2 117 78 110 93 99 91 114 133 144 27 27 104 118 111 97 23 148 134 81 75 23 57 31 27 118 76 127 41 11 140 19 35 55 99 103 49 33 82 60 17 138 37 97 51 50 143 48 50 144 8 75 123 123 40 47 110 138 75 102 146 45 93 76 138 19 121 11 94 105 83 34 145 55 26 30 19 42 88 98...
output:
958934316 640406943 641940569 783598665 780412216 906658853 7433061 229704176 967872141 99427878 819605114 308650609 378583182 521075005 121721820 74583217 75375734 482256752 581882726 618736648 162362957 570134024 180191224 63378965 652391147 695575146 177935527 886817892 464576460 265296526 645850...
result:
ok 1000000 lines
Subtask #5:
score: 15
Accepted
Dependency #3:
100%
Accepted
Test #17:
score: 15
Accepted
time: 469ms
memory: 70884kb
input:
10000 200 100000 137 37 68 58 80 53 27 98 63 129 163 78 190 39 85 119 173 140 154 146 57 176 121 137 56 28 55 157 190 93 82 59 94 20 191 134 73 104 172 78 198 164 72 97 152 159 48 129 137 193 147 111 173 142 74 124 133 19 131 149 187 27 86 199 173 6 140 55 184 101 96 37 59 93 131 31 154 136 181 31 2...
output:
191327892 671255578 194216485 71010608 525068107 431111961 958981308 528558315 237590750 172799319 281057413 880210558 49366643 463644850 543916083 535708959 574117692 627742429 200124204 368704339 876346642 698470635 227543129 766542790 589825484 584981118 636771663 333453120 54092645 475905490 734...
result:
ok 100000 lines
Test #18:
score: 15
Accepted
time: 169ms
memory: 74316kb
input:
10000 199 100000 71 191 28 119 12 74 77 185 180 32 124 24 63 152 112 196 33 12 170 155 22 76 156 48 156 54 126 81 104 176 198 111 18 42 6 6 111 125 193 144 103 50 106 4 183 19 78 162 119 130 105 36 61 196 20 150 26 184 164 164 130 61 197 42 125 103 114 192 135 104 54 93 110 55 151 96 104 130 16 33 1...
output:
634029039 173313696 487008545 384600054 694474963 736297504 412745139 404448375 882333894 405575017 859558107 96006429 127845019 988859561 930064354 606876996 643552353 159731588 874474440 265967074 609693632 177796165 816597502 279120802 439827283 796332240 952345723 319506899 107133939 377908089 6...
result:
ok 100000 lines
Test #19:
score: 15
Accepted
time: 197ms
memory: 74452kb
input:
10000 199 100000 163 169 71 101 136 54 192 168 112 63 151 115 143 152 111 142 145 167 192 139 98 56 175 131 119 57 185 12 4 92 138 19 94 152 88 115 28 119 43 120 162 74 180 113 132 73 25 132 185 183 124 166 38 122 91 133 123 92 41 158 56 141 49 4 140 20 44 0 59 68 116 166 1 141 122 197 102 130 116 1...
output:
929238060 196608886 564908014 200768339 282465233 513940972 830922646 437932771 615305788 295059588 542542639 394168186 319169382 710114585 423658926 639755133 762994383 395770360 344682564 337122181 708208130 244140319 513549479 617846810 442505238 304522203 785941813 730915435 907529429 214860553 ...
result:
ok 100000 lines
Test #20:
score: 15
Accepted
time: 459ms
memory: 73496kb
input:
10000 200 100000 0 0 0 0 0 0 0 0 0 0 0 0 33 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
486600192 367371510 371231406 645082612 666742937 134425845 6887888 289079950 976130536 34579926 927366078 542909187 318958255 452071331 960166160 96879932 797122397 271832572 249509109 45393975 267269728 543426101 1303457 699110741 1658370 50863073 3593852 986711814 337988036 315279753 895192143 11...
result:
ok 100000 lines
Test #21:
score: 15
Accepted
time: 196ms
memory: 73604kb
input:
10000 200 100000 126 54 113 146 92 114 136 89 88 26 1 139 103 110 28 13 135 130 159 118 112 117 1 58 38 26 97 91 132 142 86 6 198 165 146 18 33 8 51 148 67 72 169 130 141 27 16 157 22 81 91 113 140 30 78 8 136 13 176 24 9 87 193 147 15 10 160 32 53 61 55 133 96 81 160 17 76 59 175 81 85 195 172 95 4...
output:
42822545 434877289 767698657 920422443 953230070 332259952 796197013 191742925 816488634 13308092 423917247 800873938 911990775 695506546 138044515 420199534 644078646 103556266 785302469 592617520 463007534 716880191 998049961 898137866 33301882 413017893 444593569 875987425 813366593 10034094 9050...
result:
ok 100000 lines
Subtask #6:
score: 10
Accepted
Test #22:
score: 10
Accepted
time: 1135ms
memory: 164940kb
input:
10000 200 1000000 97 97 195 195 64 64 195 195 178 178 194 194 194 194 162 162 51 51 38 38 126 126 134 134 88 88 116 116 187 187 57 57 102 102 7 7 63 63 29 29 182 182 18 18 140 140 83 83 45 45 76 76 143 143 43 43 186 186 2 2 108 108 172 172 103 103 0 0 106 106 98 98 74 74 193 193 70 70 197 197 98 98 ...
output:
375579248 568017802 367880294 786059879 269444849 188660178 345602841 264480437 672009634 789868108 849100350 362780798 5342086 627391255 179300804 311677935 460345911 508275787 359950095 340334788 424707436 137047638 928731395 950488420 234906906 49618951 819183827 621425800 135239151 150650834 805...
result:
ok 1000000 lines
Test #23:
score: 10
Accepted
time: 937ms
memory: 163364kb
input:
10000 199 1000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
966953291 142664015 304353460 150389063 352992029 227638344 883216041 899526626 25611440 557135221 106554870 64858778 300895299 293838544 318581528 582395622 16626473 186368261 183046361 649732534 317166670 587407833 140122960 481594890 294090064 382607550 271757658 187466221 986950194 787178241 705...
result:
ok 1000000 lines
Test #24:
score: 10
Accepted
time: 651ms
memory: 157996kb
input:
10000 199 1000000 149 149 183 183 3 3 52 52 50 50 143 143 74 74 179 179 138 138 77 77 126 126 182 182 114 114 2 2 149 149 4 4 18 18 78 78 74 74 52 52 144 144 1 1 131 131 134 134 11 11 3 3 103 103 12 12 168 168 13 13 14 14 133 133 50 50 39 39 109 109 188 188 104 104 173 173 188 188 151 151 104 104 69...
output:
329642380 764291000 525705398 340432701 149117270 307861923 853026158 769126219 340452856 696828782 268482569 449953889 680013813 334843434 709544221 185170004 42430140 331601938 258739441 266569642 963596652 995338747 516473935 7141405 781495071 95578778 388437125 542543851 871147978 101710030 1543...
result:
ok 1000000 lines
Test #25:
score: 10
Accepted
time: 676ms
memory: 139424kb
input:
10000 200 1000000 196 196 143 143 139 139 12 12 50 50 19 19 57 57 197 197 150 150 21 21 42 42 4 4 80 80 12 12 128 128 83 83 176 176 179 179 195 195 151 151 113 113 161 161 14 14 11 11 93 93 67 67 183 183 132 132 39 39 40 40 194 194 66 66 135 135 171 171 73 73 18 18 102 102 30 30 154 154 174 174 95 9...
output:
522202748 212001229 654991254 206591747 268838746 516126078 151432529 467244119 429327640 391594742 777979354 29157709 347462066 895685947 734588937 703258579 307910791 43495943 168738817 711162879 505996495 142518245 691585428 635527739 118839194 372637101 975159522 513273202 762575852 546987649 48...
result:
ok 1000000 lines
Subtask #7:
score: 5
Accepted
Test #26:
score: 5
Accepted
time: 983ms
memory: 141912kb
input:
10000 200 1000000 14 75 130 107 183 182 191 153 161 32 123 1 147 44 85 129 45 12 146 172 158 191 26 48 120 30 47 0 112 146 6 197 126 62 38 42 180 120 32 141 30 122 132 41 106 56 174 21 166 78 116 11 157 40 112 88 33 59 129 146 51 143 92 136 143 36 153 154 127 34 69 131 142 143 139 33 31 137 114 19 9...
output:
194159697 324622215 183382381 481487803 828347112 457775962 972744304 388248055 694146875 271460261 481272668 741117114 796824404 883570276 538867436 346745365 789572920 923800409 401944901 57470761 249910563 432239756 632572658 980282783 836056824 685590906 966253130 386142517 536208744 293319780 1...
result:
ok 1000000 lines
Test #27:
score: 5
Accepted
time: 964ms
memory: 143808kb
input:
10000 199 1000000 6 185 109 92 33 23 14 61 118 9 8 148 160 159 9 146 57 143 198 12 113 181 20 85 33 79 68 172 64 67 39 69 72 37 149 187 110 33 11 185 173 59 165 127 26 33 80 109 104 59 138 159 180 5 53 98 149 28 184 147 190 101 33 166 88 143 42 61 196 130 178 58 59 88 180 146 37 120 16 118 197 4 92 ...
output:
640530760 811314254 451075224 686189443 47462063 977733683 419752699 196223739 75954022 390456726 107274535 956070631 683953940 65748207 288163499 984399063 304191881 324218294 393189450 289756063 825403610 464380993 738238635 7967144 916489597 781724114 837803607 612652838 416666067 399414816 45968...
result:
ok 1000000 lines
Test #28:
score: 5
Accepted
time: 1026ms
memory: 143724kb
input:
10000 200 1000000 74 160 138 111 52 84 154 168 15 7 48 96 39 74 195 86 30 193 23 31 11 139 77 54 61 96 150 70 123 94 111 159 187 20 138 74 149 60 128 79 34 15 130 92 61 21 86 40 22 142 195 2 196 122 145 25 124 151 150 172 123 118 57 172 23 194 77 98 162 94 44 35 196 184 3 16 185 92 16 122 131 73 23 ...
output:
878859441 537189151 512724939 419709102 278689947 72215807 354368087 199017808 449946105 170604757 49331816 943860526 775936956 718575823 306016632 166870327 619349264 730936360 561510 482516140 542360801 379651744 69900659 507632331 413886253 224336418 811338596 60468990 531398616 775210805 6321885...
result:
ok 1000000 lines
Test #29:
score: 5
Accepted
time: 1013ms
memory: 141252kb
input:
10000 199 1000000 81 66 19 9 97 30 33 127 65 63 115 54 3 19 89 41 16 8 5 48 140 106 192 17 42 17 100 33 181 160 25 114 170 179 115 78 165 5 160 60 119 156 149 69 123 127 169 90 177 35 81 37 87 23 178 101 97 59 175 160 186 138 88 61 123 134 57 134 98 38 107 22 57 25 65 102 81 23 26 53 189 97 140 83 1...
output:
655737011 483723145 165497732 478728095 281902730 601233905 120177001 954960010 870635894 706672301 334348110 655737011 50992794 465541650 35350896 588772697 488327734 236184059 621849592 119032690 380236452 264380504 568606823 704748616 816204325 584171429 823207267 347806148 2653861 511292784 7731...
result:
ok 1000000 lines
Subtask #8:
score: 25
Accepted
Dependency #2:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Test #30:
score: 25
Accepted
time: 1060ms
memory: 161216kb
input:
10000 200 1000000 113 95 84 54 5 129 6 143 49 35 159 189 199 28 112 7 95 51 50 19 192 80 172 112 178 68 85 112 117 20 133 54 17 138 122 162 184 103 58 131 129 14 102 188 173 189 34 50 179 13 18 16 68 79 121 166 144 97 6 182 167 194 63 75 28 8 127 18 135 92 54 27 20 189 16 130 184 12 103 9 72 0 79 78...
output:
363158645 514332533 704398648 132173517 592098858 817888178 102265218 243035959 15424856 809163735 848669667 409246027 489687245 707341416 293017859 402173020 909738800 941962596 414802565 235717613 664510634 171983812 588050674 42776869 180479017 476637651 45868518 103326743 695499811 917784296 490...
result:
ok 1000000 lines
Test #31:
score: 25
Accepted
time: 1056ms
memory: 163780kb
input:
10000 199 1000000 182 103 135 55 4 130 180 146 126 152 95 76 31 21 152 133 152 133 128 191 174 22 120 88 180 82 173 68 81 21 77 166 57 165 16 42 47 83 176 104 73 48 151 79 116 143 108 2 193 75 39 148 180 30 86 49 47 14 140 121 29 23 106 83 4 155 198 91 85 121 40 108 23 156 60 189 149 167 7 66 132 45...
output:
460852944 695644342 178139639 967111502 439664315 97194017 202302221 159386507 173450021 550754129 624327855 765454953 761157085 708167710 792248272 780499491 439518512 484878272 211369257 135827831 56185641 816470826 351927643 988800155 468572934 519040564 586545004 453720408 931149984 790936640 73...
result:
ok 1000000 lines
Test #32:
score: 25
Accepted
time: 1012ms
memory: 164816kb
input:
10000 200 1000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
92353327 777802570 712650763 814962723 218196913 533785431 463837341 340782897 82438270 509189670 444995428 330564381 636853643 798174478 527869754 870154260 189116653 566747344 3717453 582902604 888621813 486132203 247684865 772943793 897826405 114167180 467984004 17218091 854582568 281843959 64496...
result:
ok 1000000 lines
Test #33:
score: 25
Accepted
time: 998ms
memory: 159020kb
input:
10000 199 1000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
395343464 591481071 134903235 733372651 359775480 589122328 690323571 214469825 729761105 783036452 306171733 661625243 630180779 23658831 252559814 17956494 341035915 564601445 788038029 10701302 575131440 331910162 987923188 191409088 457295567 727045695 929039555 556553937 59103219 664659527 4800...
result:
ok 1000000 lines
Test #34:
score: 25
Accepted
time: 649ms
memory: 159344kb
input:
10000 200 1000000 144 172 144 86 178 187 27 73 37 76 98 165 8 50 43 10 36 56 109 72 94 184 138 166 5 3 99 95 167 98 95 103 165 30 183 8 95 89 135 89 7 33 122 14 111 51 68 167 107 56 60 96 166 53 96 9 170 81 14 147 170 36 118 41 171 193 27 2 146 94 13 117 134 139 97 12 28 197 37 185 82 166 79 150 95 ...
output:
921100958 847440705 857542067 50170892 46388568 276026623 987382975 498449223 160473875 429537020 207021059 420373006 552317902 113636166 817285788 508219355 866365034 109590845 495241962 854955435 742698865 243319221 479278209 951256075 102482722 929624692 985197336 401543065 594779617 622165393 25...
result:
ok 1000000 lines
Test #35:
score: 25
Accepted
time: 622ms
memory: 150584kb
input:
10000 199 1000000 180 83 24 132 19 71 54 45 19 41 161 94 83 10 110 182 56 126 33 141 169 198 166 23 74 183 36 42 54 128 90 41 20 135 4 180 99 28 150 108 63 196 87 34 114 162 129 86 198 14 133 81 147 22 58 9 170 14 58 130 41 147 70 103 117 20 41 151 177 89 102 174 115 98 106 143 146 107 54 19 138 64 ...
output:
386136032 901304200 816667299 990113435 496280977 860896696 348679071 421240455 472166014 355824208 22299611 635312178 361357355 481406760 773362368 910007976 165508865 561147894 920572275 134612920 430118825 259797826 960004915 377432616 500780961 10117888 458355188 652822746 371479045 640094983 64...
result:
ok 1000000 lines
Test #36:
score: 25
Accepted
time: 667ms
memory: 140236kb
input:
10000 200 1000000 179 159 167 197 75 37 112 71 38 87 73 8 90 64 39 156 134 39 11 149 82 82 77 118 64 95 89 54 180 5 81 72 74 60 116 150 195 130 71 197 57 18 83 166 62 121 114 8 159 112 88 183 96 151 38 84 131 196 108 193 118 49 48 165 63 80 83 180 172 88 70 83 170 64 189 65 162 85 57 139 143 77 188 ...
output:
471657260 312394902 872823718 662974997 710020427 850663536 574259369 310263954 902764505 723350399 805877112 380039659 737100017 438986804 957581939 874152183 518224742 933576896 311883164 417426712 785262777 522803329 923679174 371749743 905710761 636139440 214783891 795675329 791809049 383804820 ...
result:
ok 1000000 lines
Test #37:
score: 25
Accepted
time: 648ms
memory: 138432kb
input:
10000 199 1000000 167 97 198 96 26 185 78 58 162 180 152 49 155 106 14 106 5 195 116 122 2 84 93 75 148 109 160 195 189 183 180 156 102 140 99 61 0 119 131 87 15 172 7 5 147 41 157 8 134 21 98 109 196 191 164 136 1 13 197 1 177 10 145 123 163 189 107 0 86 111 64 167 79 133 76 140 172 178 48 60 157 6...
output:
11581491 72838846 902368781 940955296 71440812 606694588 899912131 269127606 723107104 425455112 824441250 519648565 672083582 417108268 670212743 54136132 263729021 831044700 70015554 890695396 929113419 107113689 481854307 408093686 392683708 671525394 358934285 693482824 878041923 276133494 68970...
result:
ok 1000000 lines