QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#301762 | #4922. 生活在对角线下 | zyc070419 | 100 ✓ | 1267ms | 49560kb | C++14 | 15.1kb | 2024-01-10 10:51:17 | 2024-01-10 10:51:18 |
Judging History
answer
#include <bits/stdc++.h>
#define PII pair<int, int>
using namespace std;
const int N = 1e5 + 3;
const int W = (N * 3);
const int M = 3e5 + 3;
const int mod = 998244353;
const int pr = 3;
const int ig = 332748118;
const int inv2 = 499122177;
inline int read() {
char ch = getchar(); int x = 0, f = 1;
while (!isdigit(ch)) {if (ch == '-') {f = -1;} ch = getchar();}
while (isdigit(ch)) {x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
return x * f;
}
int fac[W], inv[W];
inline int add(int x, int y) {x += y; return x >= mod ? x - mod : x;}
inline int del(int x, int y) {x -= y; return x < 0 ? x + mod : x;}
inline void Add(int &x, int y) {x = add(x, y);}
inline void Del(int &x, int y) {x = del(x, y);}
inline int qpow(int x, int y) {
int res = 1;
while (y) {
if (y & 1) res = 1ll * res * x % mod;
x = 1ll * x * x % mod;
y >>= 1;
}
return res;
}
inline int C(int x, int y) {return (x < 0 || y < 0 || x < y) ? 0 : 1ll * fac[x] * inv[y] % mod * inv[x - y] % mod;}
struct Poly {
int len, INV, oo;
vector<int> f, g;
void NTT(vector<int> &F) {
int x, y, pw, g;
for (int j = (len >> 1); j; j >>= 1) {
g = qpow(pr, (mod - 1) / (j << 1));
for (int i = 0; i < len; i += (j << 1)) {
pw = 1;
for (int k = 0; k < j; ++k, pw = 1ll * pw * g % mod) {
x = F[i + k]; y = F[i + j + k];
F[i + k] = add(x, y);
F[i + j + k] = 1ll * pw * del(x, y) % mod;
}
}
}
}
void INTT(vector<int> &F) {
int x, y, pw, g;
for (int j = 1; j < len; j <<= 1) {
g = qpow(ig, (mod - 1) / (j << 1));
for (int i = 0; i < len; i += (j << 1)) {
pw = 1;
for (int k = 0; k < j; ++k, pw = 1ll * pw * g % mod) {
x = F[i + k]; y = 1ll * pw * F[i + j + k] % mod;
F[i + k] = add(x, y);
F[i + j + k] = del(x, y);
}
}
}
for (int i = 0; i < len; ++i) F[i] = 1ll * F[i] * INV % mod;
}
void mul() {
NTT(f); NTT(g);
for (int i = 0; i < len; ++i) f[i] = 1ll * f[i] * g[i] % mod;
INTT(f);
}
void init(int n) {
len = 1; oo = n;
while (len <= n + n) len <<= 1;
INV = qpow(len, mod - 2);
f.clear(); g.clear();
f.resize(len + 5); g.resize(len + 5);
}
void get() {for (int i = oo + 1; i < f.size(); ++i) f[i] = g[i] = 0;}
void clear() {for (int i = 0; i < f.size(); ++i) f[i] = g[i] = 0;}
}t;
int T, c, p, q, L, cnt, pos[10][10], pw[N][10], S[10][10];
PII id[10];
inline int calc(int x, int y, int k) {return 1ll * pw[x][id[k].first] * pw[y][id[k].second] % mod;}
namespace subtask1 {
const int N1 = 1005;
int f[N1][N1], g[N1][N1][10];
bool check() {return L <= 1000;}
void solve() {
f[0][0] = 1;
for (int i = 0; i < cnt; ++i) g[0][0][i] = calc(0, 0, i);
for (int i = 0; i <= L; ++i)
for (int j = 0; j <= L; ++j) {
if (i == 0 && j == 0) continue;
if (i) Add(f[i][j], f[i - 1][j]);
if (j) Add(f[i][j], f[i][j - 1]);
for (int k = 0; k < cnt; ++k) {
if (i) Add(g[i][j][k], g[i - 1][j][k]);
if (j) Add(g[i][j][k], g[i][j - 1][k]);
if (j <= i) Add(g[i][j][k], 1ll * f[i][j] * calc(i, j, k) % mod);
}
}
int n, m, ans;
while (T--) {
n = read(); m = read(); ans = 0;
for (int i = 0; i < cnt; ++i) Add(ans, 1ll * g[n][m][i] * read() % mod);
printf("%d\n", ans);
}
}
}
namespace subtask2 {
int f[N], g[N], n, m, v, ans;
bool check() {return T == 1 && p == 0 && q == 0;}
void solve() {
n = read(); m = read(); v = read();
if (n == m) {
g[n] = qpow(4, n);
f[n] = 1ll * del(1ll * (n + m + 1) * C(n + m, n) % mod, g[n]) * inv2 % mod;
printf("%lld\n", 1ll * add(f[n], g[n]) * v % mod);
}else if (n < m) {
g[0] = 1;
for (int i = 1; i <= n; ++i) g[i] = 4ll * g[i - 1] % mod;
for (int i = 0; i <= n; ++i) {
f[i] = 1ll * del(1ll * (i + i + 1) * C(i + i, i) % mod, g[i]) * inv2 % mod;
Add(ans, 1ll * add(f[i], g[i]) * del(C(n - i + m - i - 1, n - i), C(n - i + m - i - 1, n - i - 1)) % mod);
}
ans = 1ll * ans * v % mod;
printf("%d\n", ans);
}else {
g[0] = 1; ans = 1ll * (n + m + 1) * C(n + m, n) % mod;
for (int i = 1; i <= m; ++i) g[i] = 4ll * g[i - 1] % mod;
for (int i = 0; i <= m; ++i) {
f[i] = 1ll * del(1ll * (i + i + 1) * C(i + i, i) % mod, g[i]) * inv2 % mod;
Del(ans, 1ll * f[i] * del(C(n - i - 1 + m - i, m - i), C(n - i - 1 + m - i, n - i)) % mod);
}
ans = 1ll * ans * v % mod;
printf("%d\n", ans);
}
}
}
namespace subtask3 {
bool check() {return p == 0 && q == 0;}
void solve() {
t.init(L + 5);
if (c == 0) {
for (int i = 0, g = 1; i <= L; ++i, g = 4ll * g % mod)
t.f[i] = 1ll * add(1ll * (i + i + 1) * C(i + i, i) % mod, g) * inv2 % mod;
int n, m, v;
while (T--) {
n = read(); m = read(); v = read();
printf("%lld\n", 1ll * t.f[n] * v % mod);
}
}else if (c > 0) {
for (int i = 0, g = 1; i <= L; ++i, g = 4ll * g % mod)
t.f[i] = 1ll * add(1ll * (i + i + 1) * C(i + i, i) % mod, g) * inv2 % mod;
for (int i = 0; i <= L; ++i) t.g[i] = del(C(i + i + c - 1, i), C(i + i + c - 1, i - 1));
t.mul();
int n, m, v;
while (T--) {
n = read(); m = read(); v = read();
printf("%lld\n", 1ll * t.f[n] * v % mod);
}
}else {
c = -c;
for (int i = 0, g = 1; i <= L; ++i, g = 4ll * g % mod)
t.f[i] = 1ll * del(1ll * (i + i + 1) * C(i + i, i) % mod, g) * inv2 % mod;
for (int i = 0; i <= L; ++i) t.g[i] = del(C(i + i + c - 1, i), C(i + i + c - 1, i - 1));
t.mul();
int n, m, v;
while (T--) {
n = read(); m = read(); v = read();
printf("%lld\n", 1ll * del(1ll * (n + m + 1) * C(n + m, n) % mod, t.f[m]) * v % mod);
}
}
}
}
namespace subtask4 {
int ans, a[10], val[N << 1], pre[N << 1], f[N];
bool check() {return T == 1;}
int work(int n, int m, int k, int lim) {
if (n < 0 || m < 0) return 0;
for (int i = 0; i <= n + m; ++i) {
val[i] = 1;
for (int j = 1; j <= k; ++j) val[i] = 1ll * val[i] * (i + j) % mod;
if (i == 0) pre[i] = val[i];
else pre[i] = add(pre[i - 1], val[i]);
}
int res;
if (n == m) {
res = 1ll * pre[n + m] * C(n + m, n) % mod;
for (int i = 0; i <= n; ++i) Add(res, 1ll * C(i + i, i) * C(n - i + m - i, n - i) % mod * val[i + i] % mod);
res = 1ll * res * inv2 % mod;
}else if (n < m) {
t.init(n);
for (int i = 0; i <= n; ++i) {
t.f[i] = 1ll * C(i + i, i) * val[i + i] % mod;
t.g[i] = C(i + i, i);
}
t.mul(); res = 0;
for (int i = 0, tmp; i <= n; ++i) {
tmp = 1ll * add(1ll * pre[i + i] * C(i + i, i) % mod, t.f[i]) * inv2 % mod;
Add(res, 1ll * tmp * del(C(n - i + m - i - 1, n - i), C(n - i + m - i - 1, n - i - 1)) % mod);
}
}else {
t.init(m);
for (int i = 0; i <= m; ++i) {
t.f[i] = 1ll * C(i + i, i) * val[i + i] % mod;
t.g[i] = C(i + i, i);
}
t.mul(); res = 1ll * pre[n + m] * C(n + m, n) % mod;
for (int i = 0, tmp; i <= m; ++i) {
tmp = 1ll * del(1ll * pre[i + i] * C(i + i, i) % mod, t.f[i]) * inv2 % mod;
Del(res, 1ll * tmp * del(C(n - i - 1 + m - i, m - i), C(n - i - 1 + m - i, m - i - 1)) % mod);
}
}
for (int o = 0; o < lim; ++o)
for (int i = o; i <= n && i - o <= m; ++i)
Del(res, 1ll * C(i + i - o, i) * C(n - i + m - i + o, n - i) % mod * val[i + i - o] % mod);
for (int o = lim; o < 0; ++o)
for (int i = 0; i <= n && i - o <= m; ++i)
Add(res, 1ll * C(i + i - o, i) * C(n - i + m - i + o, n - i) % mod * val[i + i - o] % mod);
return res;
}
void solve() {
int n, m;
n = read(); m = read();
for (int i = 0; i < cnt; ++i) a[i] = read();
for (int s = 0; s <= p && s <= n; ++s) {
for (int t = 0, res; t <= q && t <= m; ++t) {
res = 0;
for (int u = s; u <= p; ++u)
for (int v = t; v <= q; ++v)
Add(res, 1ll * a[pos[u][v]] * S[u][s] % mod * S[v][t] % mod);
Add(ans, 1ll * res * work(n - s, m - t, s + t, t - s) % mod);
}
}
printf("%d\n", ans);
}
}
namespace subtask5 {
int mem[10][N], val[N << 1], pre[N << 1], ans, a[10];
void work(int d, int k, int lim, int op) {
for (int i = 0; i <= L + L; ++i) {
val[i] = 1;
for (int j = 1; j <= k; ++j) val[i] = 1ll * val[i] * (i + j) % mod;
if (i == 0) pre[i] = val[i];
else pre[i] = add(pre[i - 1], val[i]);
}
for (int i = 0; i <= L; ++i) {
t.f[i] = 1ll * C(i + i, i) * val[i + i] % mod;
t.g[i] = C(i + i, i);
}
t.mul(); t.get();
if (d == 0) {
for (int i = 0; i <= L; ++i) mem[op][i] = 1ll * add(1ll * pre[i + i] * C(i + i, i) % mod, t.f[i]) * inv2 % mod;
t.clear();
for (int o = 0; o < lim; ++o) {
for (int i = o; i <= L; ++i) {
t.f[i] = 1ll * C(i + i - o, i) * val[i + i - o] % mod;
t.g[L - i] = C(L - i + L - i + d + o, L - i);
}
t.mul();
for (int i = 0; i <= L; ++i) Del(mem[op][i], t.f[i]);
t.clear();
}
for (int o = lim; o < 0; ++o) {
for (int i = 0; i <= L; ++i) {
t.f[i] = 1ll * C(i + i - o, i) * val[i + i - o] % mod;
t.g[L - i] = C(L - i + L - i + d + o, L - i);
}
t.mul();
for (int i = 0; i <= L; ++i) Add(mem[op][i], t.f[i]);
t.clear();
}
}else if (d > 0) {
for (int i = 0; i <= L; ++i) t.f[i] = 1ll * add(1ll * pre[i + i] * C(i + i, i) % mod, t.f[i]) * inv2 % mod;
for (int i = 0; i <= L; ++i) t.g[i] = del(C(i + i + d - 1, i), C(i + i + d - 1, i - 1));
t.mul();
for (int i = 0; i <= L; ++i) mem[op][i] = t.f[i];
t.clear();
for (int o = 0; o < lim; ++o) {
for (int i = o; i <= L; ++i) {
t.f[i] = 1ll * C(i + i - o, i) * val[i + i - o] % mod;
t.g[L - i] = C(L - i + L - i + d + o, L - i);
}
t.mul();
for (int i = 0; i <= L; ++i) Del(mem[op][i], t.f[i]);
t.clear();
}
for (int o = lim; o < 0; ++o) {
for (int i = 0; i <= L; ++i) {
t.f[i] = 1ll * C(i + i - o, i) * val[i + i - o] % mod;
t.g[L - i] = C(L - i + L - i + d + o, L - i);
}
t.mul();
for (int i = 0; i <= L; ++i) Add(mem[op][i], t.f[i]);
t.clear();
}
}else {
d = -d;
for (int i = 0; i <= L; ++i) t.f[i] = 1ll * del(1ll * pre[i + i] * C(i + i, i) % mod, t.f[i]) * inv2 % mod;
for (int i = 0; i <= L; ++i) t.g[i] = del(C(i + d - 1 + i, i), C(i + d - 1 + i, i - 1));
t.mul();
for (int i = 0; i <= L; ++i) mem[op][i] = t.f[i];
t.clear(); lim = -lim;
for (int o = 1; o <= lim; ++o) {
for (int i = o; i <= L; ++i) {
t.f[i] = 1ll * C(i + i - o, i) * val[i + i - o] % mod;
t.g[L - i] = C(L - i + L - i + d + o, L - i);
}
t.mul();
for (int i = 0; i <= L; ++i) Del(mem[op][i], t.f[i]);
t.clear();
}
for (int o = lim + 1; o <= 0; ++o) {
for (int i = 0; i <= L; ++i) {
t.f[i] = 1ll * C(i + i - o, i) * val[i + i - o] % mod;
t.g[L - i] = C(L - i + L - i + d + o, L - i);
}
t.mul();
for (int i = 0; i <= L; ++i) Add(mem[op][i], t.f[i]);
t.clear();
}
for (int i = 0; i <= L; ++i) mem[op][i] = del(1ll * pre[i + i + d] * C(i + i + d, i) % mod, mem[op][i]);
}
}
void solve() {
t.init(L);
for (int i = 0, s, t; i < cnt; ++i) {
s = id[i].first; t = id[i].second;
work(c - t + s, s + t, t - s, i);
}
int n, m;
while (T--) {
n = read(); m = read();
for (int i = 0; i < cnt; ++i) a[i] = read();
ans = 0;
for (int s = 0; s <= p && s <= n; ++s) {
for (int t = 0; t <= q && t <= m; ++t) {
int res = 0;
for (int u = s; u <= p; ++u)
for (int v = t; v <= q; ++v)
Add(res, 1ll * S[u][s] * S[v][t] % mod * a[pos[u][v]] % mod);
if (c - t + s >= 0) Add(ans, 1ll * res * mem[pos[s][t]][n - s] % mod);
else Add(ans, 1ll * res * mem[pos[s][t]][m - t] % mod);
}
}
printf("%d\n", ans);
}
}
}
int main() {
fac[0] = 1;
for (int i = 1; i <= M; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
inv[M] = qpow(fac[M], mod - 2);
for (int i = M; i >= 1; --i) inv[i - 1] = 1ll * inv[i] * i % mod;
S[0][0] = 1;
for (int i = 1; i < 10; ++i)
for (int j = 1; j <= i; ++j)
S[i][j] = add(S[i - 1][j - 1], 1ll * S[i - 1][j] * j % mod);
T = read(); c = read(); p = read(); q = read(); L = read(); L = max(L, L + c);
for (int i = 0; i <= p; ++i)
for (int j = 0; j <= q; ++j)
id[pos[i][j] = cnt++] = make_pair(i, j);
for (int i = 0; i <= L; ++i) {
pw[i][0] = 1;
for (int j = 1; j <= max(p, q); ++j) pw[i][j] = 1ll * pw[i][j - 1] * i % mod;
}
if (subtask1 :: check()) subtask1 :: solve();
else if (subtask2 :: check()) subtask2 :: solve();
else if (subtask3 :: check()) subtask3 :: solve();
else if (subtask4 :: check()) subtask4 :: solve();
else subtask5 :: solve();
return 0;
}
详细
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 26ms
memory: 49552kb
input:
1 -10 1 2 1000 825 815 107973512 400177523 812303207 164088430 603506669 337780072
output:
360076089
result:
ok 1 number(s): "360076089"
Test #2:
score: 0
Accepted
time: 36ms
memory: 49332kb
input:
1 424 1 4 576 130 554 926445673 393820912 634481616 292175028 733650737 100427548 899689095 876811717 849191704 696040532
output:
564712546
result:
ok 1 number(s): "564712546"
Test #3:
score: 0
Accepted
time: 15ms
memory: 49336kb
input:
1 -171 2 1 1000 805 634 250066876 719653007 284194184 531322789 491311782 185842441
output:
910556244
result:
ok 1 number(s): "910556244"
Test #4:
score: 0
Accepted
time: 28ms
memory: 49560kb
input:
1 11 4 1 989 142 153 581558550 138798754 575233123 788754497 582314564 303591688 635874631 658261955 615116681 498307457
output:
918405181
result:
ok 1 number(s): "918405181"
Test #5:
score: 0
Accepted
time: 22ms
memory: 49496kb
input:
1 -87 1 2 1000 164 77 264180617 338145439 610918500 800846696 216126209 112962819
output:
629819261
result:
ok 1 number(s): "629819261"
Subtask #2:
score: 9
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 9
Accepted
time: 45ms
memory: 49252kb
input:
100000 -99 2 1 1000 712 613 238230707 820405654 473765646 826816733 751513618 421153458 209 110 22075351 398854663 148159396 487281124 972932017 200517786 383 284 22252771 205525630 491328752 607545155 561318911 135661425 929 830 156478040 89922795 380802607 32081978 898588032 110586958 956 857 4206...
output:
863094157 570366074 281608243 247495628 396961441 855444791 694374848 782506902 280202079 688077364 610676536 115373962 360154110 834242083 887647721 164293717 759683961 710870451 213441970 863772654 514218158 532711794 558875294 421795761 517787006 458381459 506983637 742686106 435175768 111255264 ...
result:
ok 100000 numbers
Test #7:
score: 0
Accepted
time: 52ms
memory: 49276kb
input:
100000 252 3 1 748 130 382 311369319 709099006 49474431 724072531 761415026 251406187 389170658 169808960 581 833 89779535 938252574 504798466 677842435 654289171 763708659 719082912 762770851 691 943 571693157 187035992 300995260 403041189 726726538 63983502 814000657 315732021 121 373 339102104 42...
output:
516270157 614211606 655396807 981733406 752565578 312973289 850750616 826813023 753739511 227580123 199177890 403714939 559334967 370464926 363937285 583678656 239132195 834163477 111915553 68813179 875627540 299872127 660063389 31474925 464946255 125818391 645016505 267670615 440441568 356463850 84...
result:
ok 100000 numbers
Test #8:
score: 0
Accepted
time: 58ms
memory: 49204kb
input:
100000 195 2 2 805 325 520 266481322 663615421 428019284 968378746 158386978 211891009 161987045 142931644 790431809 621 816 756898302 952132541 196745128 424307295 926376261 130425563 604844618 645296808 252920984 60 255 873310227 887037637 787608776 98214115 355810775 242821836 537250851 650821017...
output:
922269244 757786754 400099571 332972619 780501723 469958234 540206804 924583388 519189002 566620024 244468115 73221163 663221021 159111716 451144022 658783977 656844692 831466434 186871631 60740257 542611012 773315130 755261907 193772041 628947709 363111530 452621670 349808610 264947076 342250907 16...
result:
ok 100000 numbers
Subtask #3:
score: 20
Accepted
Test #9:
score: 20
Accepted
time: 0ms
memory: 10628kb
input:
1 4683 0 0 95317 86560 91243 412303217
output:
952052072
result:
ok 1 number(s): "952052072"
Test #10:
score: 0
Accepted
time: 7ms
memory: 10504kb
input:
1 -24796 0 0 100000 93338 68542 849332154
output:
980840409
result:
ok 1 number(s): "980840409"
Test #11:
score: 0
Accepted
time: 3ms
memory: 10276kb
input:
1 40156 0 0 59844 39551 79707 566086447
output:
620552907
result:
ok 1 number(s): "620552907"
Test #12:
score: 0
Accepted
time: 3ms
memory: 10468kb
input:
1 -714 0 0 100000 72672 71958 817542139
output:
799272798
result:
ok 1 number(s): "799272798"
Test #13:
score: 0
Accepted
time: 5ms
memory: 9952kb
input:
1 23418 0 0 76582 6862 30280 442920403
output:
642352133
result:
ok 1 number(s): "642352133"
Test #14:
score: 0
Accepted
time: 6ms
memory: 10424kb
input:
1 42983 0 0 57017 42753 85736 380012689
output:
828068267
result:
ok 1 number(s): "828068267"
Test #15:
score: 0
Accepted
time: 0ms
memory: 10140kb
input:
1 -25448 0 0 100000 47466 22018 617788426
output:
485886943
result:
ok 1 number(s): "485886943"
Test #16:
score: 0
Accepted
time: 6ms
memory: 10080kb
input:
1 -35138 0 0 100000 49912 14774 472000456
output:
323681794
result:
ok 1 number(s): "323681794"
Test #17:
score: 0
Accepted
time: 3ms
memory: 10284kb
input:
1 15928 0 0 84072 57657 73585 31014982
output:
184096139
result:
ok 1 number(s): "184096139"
Test #18:
score: 0
Accepted
time: 0ms
memory: 10192kb
input:
1 5316 0 0 94684 36186 41502 601085246
output:
51887433
result:
ok 1 number(s): "51887433"
Subtask #4:
score: 20
Accepted
Dependency #3:
100%
Accepted
Test #19:
score: 20
Accepted
time: 38ms
memory: 11596kb
input:
100000 43925 0 0 56075 36770 80695 880793638 55133 99058 946571985 27169 71094 601132030 42027 85952 954509221 1261 45186 326012305 12030 55955 997023025 9914 53839 788665071 39921 83846 193760311 25774 69699 584278712 28428 72353 45133606 32564 76489 40466335 35483 79408 491164633 1587 45512 842380...
output:
332757564 673855662 612475468 823636534 480158617 642667251 497333900 509207503 811150980 417148607 922658720 104640134 806209587 173065009 605751740 862381731 38248058 821044620 841331399 289617079 251770008 141909273 16627417 373489864 231237810 941325561 178798279 674579054 924181592 61271475 964...
result:
ok 100000 numbers
Test #20:
score: 0
Accepted
time: 48ms
memory: 11496kb
input:
100000 -24410 0 0 100000 88811 64401 883320435 98680 74270 679694811 25736 1326 585801443 58045 33635 248117495 75671 51261 370680099 54439 30029 971994977 59364 34954 824527105 83366 58956 743467199 86814 62404 560320056 79263 54853 982330282 31352 6942 755041686 56396 31986 625187969 95451 71041 6...
output:
944753157 183242929 363439527 347484131 162238407 874219996 466587038 69445583 299052607 25676433 596600163 562511304 969440848 734888105 717978251 646284734 285785033 177137639 757127623 981404389 646133036 419072122 570786562 49543639 324434058 643959988 425580060 576826099 385768604 231992533 414...
result:
ok 100000 numbers
Test #21:
score: 0
Accepted
time: 49ms
memory: 11600kb
input:
100000 -5861 0 0 100000 16952 11091 854232561 61287 55426 808396787 36941 31080 498670332 78084 72223 125065027 77939 72078 113005933 66811 60950 561023395 8690 2829 85984152 86780 80919 73284065 24701 18840 962634657 49186 43325 820164989 13544 7683 181059009 82733 76872 475302128 59169 53308 30753...
output:
953252694 312702564 226453117 67575786 903898714 513740725 876463803 777825703 146006471 2374918 297784488 386629852 320437877 988885626 718795318 32469771 761373569 413225682 535374528 890489090 946876926 547336815 741402601 164218598 624314043 440338456 358510966 78123388 844278570 353784116 33016...
result:
ok 100000 numbers
Test #22:
score: 0
Accepted
time: 42ms
memory: 11496kb
input:
100000 36351 0 0 63649 63623 99974 215842464 38932 75283 281762844 36628 72979 412528519 32243 68594 274539771 12583 48934 35262820 58794 95145 584821840 55654 92005 405023451 54594 90945 121054191 13799 50150 945750972 3396 39747 123637787 24436 60787 60557209 28533 64884 16469063 62629 98980 97582...
output:
174547901 368722952 48857280 38439764 222892265 312334973 776332784 870332855 155759525 948664848 557524993 498142735 312543625 96578298 812380665 262256294 625974911 11727861 934671647 410990281 662266734 602386252 129790362 105856770 514479617 606174145 351070683 902755038 185658666 319441312 6292...
result:
ok 100000 numbers
Test #23:
score: 0
Accepted
time: 52ms
memory: 11604kb
input:
100000 -30740 0 0 100000 68807 38067 675336699 46303 15563 123039099 67930 37190 232230088 54579 23839 35352609 92730 61990 284529851 67176 36436 665212494 57299 26559 133796107 49959 19219 33773652 84236 53496 372759887 99484 68744 426876149 34577 3837 572112278 61585 30845 172184077 77857 47117 90...
output:
36920501 226235095 750211143 333187562 373628984 295265220 37657937 466124753 990905489 551665113 446537030 431018050 86173594 169742883 218477019 236694053 535757873 691309698 571533347 44799594 978410954 207318736 924231440 714349634 256005837 765738237 355457430 213887617 753194413 829442039 4620...
result:
ok 100000 numbers
Test #24:
score: 0
Accepted
time: 49ms
memory: 11508kb
input:
100000 -38460 0 0 100000 51513 13053 225553548 46939 8479 742237301 76548 38088 403832837 58372 19912 532371282 69056 30596 227486715 57631 19171 992007340 43442 4982 456446541 98517 60057 139482341 93593 55133 617856070 94670 56210 632588368 61305 22845 540079128 42989 4529 243030634 61305 22845 60...
output:
264377260 988347451 122980170 868000378 424450627 937049667 82203152 65434176 511951571 866041634 172830523 592267120 339840284 510003002 301057898 661439490 614715916 352897087 347380257 99947743 217323734 533045349 197971764 276536330 181518107 810369320 38076519 795663640 628535813 745310656 9165...
result:
ok 100000 numbers
Test #25:
score: 0
Accepted
time: 49ms
memory: 11500kb
input:
100000 -21781 0 0 100000 98045 76264 260148888 51675 29894 775592370 96562 74781 6673060 61291 39510 561247689 51571 29790 374708153 56745 34964 902344534 38026 16245 499287321 46349 24568 80542300 44223 22442 235391104 44474 22693 180934225 73722 51941 571180203 98775 76994 186933783 37624 15843 66...
output:
403860096 918023019 505862766 325574001 758856670 454849577 390589711 142177895 563486806 252645563 120628328 553587845 992851487 933771813 401873497 993790093 184884214 294133840 346874311 513672329 312442149 595232497 772328343 814181956 380438506 927087216 253560503 970622427 910857175 430512071 ...
result:
ok 100000 numbers
Subtask #5:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #3:
100%
Accepted
Test #26:
score: 20
Accepted
time: 132ms
memory: 11380kb
input:
1 -40679 1 3 100000 75191 34512 321693501 896183087 224533692 282076683 38691763 630172019 273852722 127891101
output:
198237763
result:
ok 1 number(s): "198237763"
Test #27:
score: 0
Accepted
time: 156ms
memory: 11468kb
input:
1 9664 2 2 90336 59042 68706 717663780 865518514 750039632 169626890 79109800 564485240 923181348 328257325 651332745
output:
828389140
result:
ok 1 number(s): "828389140"
Test #28:
score: 0
Accepted
time: 286ms
memory: 12840kb
input:
1 -4911 3 1 100000 95506 90595 160758317 884378184 967471539 538413947 340046 935215889 819083010 963236120
output:
158427640
result:
ok 1 number(s): "158427640"
Test #29:
score: 0
Accepted
time: 68ms
memory: 11532kb
input:
1 -38940 1 1 100000 89122 50182 506966463 371134907 64554268 110662481
output:
467436544
result:
ok 1 number(s): "467436544"
Test #30:
score: 0
Accepted
time: 170ms
memory: 11580kb
input:
1 38149 1 4 61851 56735 94884 619552926 550261250 164045481 845972436 653872372 83118942 170826528 44296576 620740108 779756438
output:
630384750
result:
ok 1 number(s): "630384750"
Test #31:
score: 0
Accepted
time: 38ms
memory: 10604kb
input:
1 32508 1 4 67492 13875 46383 892100417 119341289 88840851 667390755 718238291 932491650 571612544 199447761 746443436 655377775
output:
312746560
result:
ok 1 number(s): "312746560"
Test #32:
score: 0
Accepted
time: 90ms
memory: 10444kb
input:
1 17588 1 4 82412 20625 38213 604068892 481834833 499227629 228921456 166798064 682396844 196078975 611249263 782949550 681017843
output:
221586768
result:
ok 1 number(s): "221586768"
Test #33:
score: 0
Accepted
time: 72ms
memory: 10540kb
input:
1 29346 2 2 70654 23916 53262 559895810 85578539 527902788 213523265 498308006 369409104 182816498 97996179 302398399
output:
797586870
result:
ok 1 number(s): "797586870"
Test #34:
score: 0
Accepted
time: 90ms
memory: 11376kb
input:
1 16678 1 2 83322 37554 54232 982410397 959727597 885392514 32666406 55592928 308044539
output:
944958454
result:
ok 1 number(s): "944958454"
Test #35:
score: 0
Accepted
time: 345ms
memory: 12548kb
input:
1 -2973 4 1 100000 70671 67698 944119814 134201307 205772284 308145616 960255142 417904059 70545226 873525649 971531131 564183606
output:
886221045
result:
ok 1 number(s): "886221045"
Test #36:
score: 0
Accepted
time: 160ms
memory: 11604kb
input:
1 -15018 2 2 100000 70554 55536 617923951 429701274 222750395 260363494 223870584 211569086 968515859 797859940 788983097
output:
444934086
result:
ok 1 number(s): "444934086"
Test #37:
score: 0
Accepted
time: 36ms
memory: 10352kb
input:
1 1779 1 3 98221 15045 16824 639812780 322958416 989224166 985184904 189238062 18251715 874601450 598892837
output:
917232252
result:
ok 1 number(s): "917232252"
Test #38:
score: 0
Accepted
time: 59ms
memory: 10452kb
input:
1 -12131 3 1 100000 28660 16529 789001202 692765454 147387760 382308809 425360331 287102216 374854545 42527051
output:
320231596
result:
ok 1 number(s): "320231596"
Test #39:
score: 0
Accepted
time: 31ms
memory: 10304kb
input:
1 24291 3 1 75709 9425 33716 9848163 654684310 967986364 108885198 824132881 105594392 29421429 537706322
output:
489020938
result:
ok 1 number(s): "489020938"
Test #40:
score: 0
Accepted
time: 144ms
memory: 11520kb
input:
1 -16067 1 3 100000 77427 61360 179822901 517194 808059226 643416162 441055045 613299853 353364121 929654400
output:
526064056
result:
ok 1 number(s): "526064056"
Subtask #6:
score: 10
Accepted
Test #41:
score: 10
Accepted
time: 527ms
memory: 15176kb
input:
100000 0 2 1 100000 48964 48964 666670967 90494987 74847122 615108201 29533064 582540229 14418 14418 391779909 223696706 701170191 885097597 551643398 25626747 81584 81584 951326734 520293397 13860946 896899117 821166399 282263457 76849 76849 598606953 879771697 930252135 671750715 673503431 3060699...
output:
513261452 727599133 935022075 486566245 581605882 190874624 492903919 212718785 390117408 13902475 85548183 635628561 482394025 962073695 362740677 938001783 889953951 725536236 308635636 699865601 901798869 464425652 743201170 92575030 846809630 169046922 528318328 181301191 961103497 451810607 792...
result:
ok 100000 numbers
Test #42:
score: 0
Accepted
time: 1202ms
memory: 16704kb
input:
100000 0 4 1 100000 62874 62874 118183474 407193132 685767410 687439227 635193908 610100986 258734574 238431118 899478481 761001837 51740 51740 444395131 500444257 428937362 53260346 30808281 906820217 513141079 288839678 554203046 663643475 35914 35914 356034890 347998675 273353479 349503145 372514...
output:
90079244 739339489 893419903 384951658 501534088 627460520 515642072 133867011 245310344 38632363 463152272 875958325 685091735 564873808 923675127 506219676 835026926 594979789 343226945 318102253 564901512 435775641 520245858 654449246 974902905 301999370 874735377 124394474 531442263 667337270 83...
result:
ok 100000 numbers
Test #43:
score: 0
Accepted
time: 284ms
memory: 14784kb
input:
100000 0 1 1 100000 83076 83076 784524998 238343754 699444053 193415149 11931 11931 355735062 430827321 287184363 194146905 91685 91685 248401162 668812139 449763793 590716247 78873 78873 971383652 14982086 221574168 121402275 26705 26705 364632629 623913927 214647623 17014014 49871 49871 263152609 ...
output:
802238644 451994968 843226074 709558669 347484361 274977121 318242262 3003995 257310491 883438002 280843999 528814010 271908664 945085650 492738471 977479030 525082715 842693153 252354040 298201390 872453061 208575147 937984577 678583627 733514865 41580096 401571067 274115222 395399652 179231522 937...
result:
ok 100000 numbers
Test #44:
score: 0
Accepted
time: 799ms
memory: 16588kb
input:
100000 0 2 2 100000 42300 42300 306457952 603264155 604535680 373299692 720452989 584402391 244134586 764918594 149155452 96154 96154 385928288 721874710 32823875 997921405 288963987 798618815 52914070 480392455 835325898 22519 22519 857743113 78508560 335894675 636079175 257465089 226652298 5563045...
output:
141992402 675599235 48013284 700276770 870607175 695357162 754603770 744644560 328387578 779395955 691351991 749020285 219297277 416658156 801975761 287252871 95156690 502693643 859436736 751262539 372636784 789118941 114563659 346856771 895806035 984183707 868346378 178435731 197918806 73584128 672...
result:
ok 100000 numbers
Test #45:
score: 0
Accepted
time: 823ms
memory: 16024kb
input:
100000 0 1 3 100000 11362 11362 801230778 277039031 516703939 337243321 332454631 792471639 975430381 110954619 40296 40296 81718908 611718437 88044277 605359397 166308037 639878719 541084927 996814184 90922 90922 259539282 44240476 746297299 224814811 377419670 846027497 887046473 935009556 83954 8...
output:
509415585 345953605 300915155 337129523 37705935 985749046 509167332 298084321 186170721 665255439 256338589 647056594 894014776 673493231 550884946 531517917 311691611 150189476 800606928 934725818 764831103 696313960 418481305 470916807 876494136 473764716 597224168 111651899 43420720 496779890 87...
result:
ok 100000 numbers
Test #46:
score: 0
Accepted
time: 1187ms
memory: 16784kb
input:
100000 0 4 1 100000 19976 19976 930307296 347896923 488422790 122006616 254292499 385320296 118841452 305855473 220506095 734110746 76511 76511 733970715 953620799 892153455 488725274 392229425 520312991 439397817 112142735 957290217 381693407 26327 26327 21580999 691947757 83624823 464367410 980975...
output:
225738555 214759727 108832407 762261275 864099566 720689765 718654473 882803028 203399073 265919421 271852236 206814944 963677189 246953800 793508085 850883446 974333494 298581206 438825170 9001044 296169693 220497567 416695424 629190242 619581187 441655724 267190171 778132646 2223771 899421067 4824...
result:
ok 100000 numbers
Test #47:
score: 0
Accepted
time: 540ms
memory: 15740kb
input:
100000 0 1 2 100000 73838 73838 274549763 865063181 32136903 53475699 519269603 405273531 71697 71697 876944090 280541147 203483885 101922547 186440707 307240260 22793 22793 618744968 181134563 330314386 216801164 639812156 24034170 51945 51945 37335644 549161545 241567218 295424268 954415389 432786...
output:
158769345 91752448 318980478 682463374 812203482 231065712 259747790 126945803 29984182 39995008 437957831 105835667 416780632 413312665 816060362 591547303 882687698 680499421 493928363 159339065 26276621 783584492 647783605 843283824 309112435 563441364 100206956 270102855 675153271 90110905 45327...
result:
ok 100000 numbers
Test #48:
score: 0
Accepted
time: 526ms
memory: 15184kb
input:
100000 0 1 2 100000 10963 10963 118533036 71877326 625707967 848757723 693498077 753443682 25930 25930 800025480 532304292 789668511 269301094 29714643 851090628 87397 87397 263900861 257160326 107105197 827826496 959850057 230900328 23859 23859 107139126 839685760 81346250 667647079 22541961 395830...
output:
231379920 254333418 252771315 418214494 739827152 243827675 651485321 424653515 142557212 490388274 31937549 356959822 145014447 701639245 370915853 351197761 284200447 431712993 957175103 275959444 890290532 319487714 214844885 921725847 697743209 419367023 20279153 345734736 164369300 119618322 91...
result:
ok 100000 numbers
Subtask #7:
score: 20
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Test #49:
score: 20
Accepted
time: 1258ms
memory: 16788kb
input:
100000 44065 1 4 55935 23522 67587 115697709 250840030 165009947 842555732 563322183 818820348 364798078 741236992 72382973 894471863 22349 66414 331413115 751507905 78093404 118581431 302540454 821297841 951969998 127102858 311650434 66062983 35778 79843 171409163 321548635 938366212 552348158 9622...
output:
194703718 933481500 28605993 329825293 53817655 508455134 145321964 440184137 26017897 467183301 938302350 355410613 259882394 864361063 452573478 963425150 521790749 354722591 791345896 856590347 19092787 526314594 312737188 920815046 644020560 116965447 862160485 957172717 638379462 118166064 6070...
result:
ok 100000 numbers
Test #50:
score: 0
Accepted
time: 889ms
memory: 16088kb
input:
100000 10749 1 3 89251 75129 85878 174054637 402977226 141335346 8719859 244797592 559859827 338410579 542163466 46112 56861 200484095 166415586 599792413 352547710 606389754 923578076 613329260 100914089 44787 55536 895743213 842441896 428153285 176329574 38588174 369802154 86978584 693358219 30093...
output:
12326565 99295116 422147399 203414029 429195153 308091533 240437796 907291329 238685443 404883202 871424372 829452725 966698750 972036261 891040072 606860040 905932694 879407935 502592766 334626097 471801025 791497285 192426443 104737909 635979209 167537106 70565732 976939227 876560268 631229384 543...
result:
ok 100000 numbers
Test #51:
score: 0
Accepted
time: 888ms
memory: 16116kb
input:
100000 11620 3 1 88380 44768 56388 210735744 669094243 253405759 861068315 184114438 106829151 58630910 447655020 35678 47298 281947942 256401626 667224420 218993053 258868367 441310831 284991224 745468260 49509 61129 32983345 69938082 766910044 866161354 506439940 9688611 202350215 995309740 25970 ...
output:
127210827 642383910 774140297 22766391 615742345 135121650 525607674 717767341 598889727 963699066 37985632 448705412 665633645 452522711 911413114 166460090 767525206 992917976 706375069 611640409 795465682 272990194 971128890 238563010 948090048 414758436 742461938 9093990 287702062 607902507 6998...
result:
ok 100000 numbers
Test #52:
score: 0
Accepted
time: 884ms
memory: 16004kb
input:
100000 -46678 3 1 100000 47524 846 264005457 793708314 12830957 47414090 807103496 117378608 298062124 89523116 88688 42010 210403733 532678094 848410081 185471047 974845881 386924034 188057378 431515145 96577 49899 507210825 560947266 881601643 328887780 773135198 700107075 938576475 789224435 6772...
output:
690028412 814002820 789781479 798025560 846502756 578038110 134368067 343443769 950106279 723157090 785092868 589231643 465021155 203130053 317664195 240768261 273754447 920832343 730372476 664445837 693929027 172771362 623084556 113949574 951677435 76387861 278691947 42665661 40217249 717685593 459...
result:
ok 100000 numbers
Test #53:
score: 0
Accepted
time: 337ms
memory: 14784kb
input:
100000 25599 1 1 74401 59971 85570 153367105 115848051 176798572 339706280 5838 31437 364158648 549009508 549155875 892174391 11050 36649 682206503 244156449 513942977 624839121 42277 67876 984544581 212279670 278636683 816761020 69173 94772 151633636 749132455 34874776 242438895 36589 62188 8656379...
output:
541611693 34023632 200968063 222889656 307072771 981431355 453275911 129141510 154159146 772233936 855793245 114962139 243624559 623088863 818788154 607231091 213882490 380653820 998173525 572506142 609820661 733560425 339608423 464890918 519337309 389235939 133323980 8407140 286819339 373083397 533...
result:
ok 100000 numbers
Test #54:
score: 0
Accepted
time: 578ms
memory: 15800kb
input:
100000 19723 1 2 80277 16287 36010 66451573 9897753 170281642 986073268 29326354 649803782 68300 88023 663705367 895576262 858108403 697641723 365508175 969989373 20015 39738 779213185 921310804 497374852 596572595 535520215 104113780 20615 40338 950062157 772340571 755527356 509351245 110730819 339...
output:
148768233 415896120 877658211 209433882 467254351 118929512 95528150 54725070 14781954 439950919 81977270 439836163 824822189 16362100 568593692 820698649 233056937 299244722 712759413 921099084 84296127 498066210 554641769 44019576 898768066 835440412 587818721 588735742 164884011 297167669 5829651...
result:
ok 100000 numbers
Test #55:
score: 0
Accepted
time: 886ms
memory: 15908kb
input:
100000 -39812 3 1 100000 61085 21273 860849922 159655970 927594251 234178354 825743236 460120917 358391831 669735449 50693 10881 860801564 316807856 281298880 76513526 553707371 845425691 645493054 500191230 77931 38119 206079303 823584989 529228039 593257430 34549439 146517170 757433054 84406030 53...
output:
158049911 584756665 92298120 754764323 610598700 384156898 13163318 621893875 82326681 776997059 235964715 470406352 399352383 2785257 865565795 505112717 267919901 319637632 128309062 578278400 594803290 38450471 367301198 358730693 75929199 509841590 309863817 46646563 162092025 611952446 23262432...
result:
ok 100000 numbers
Test #56:
score: 0
Accepted
time: 577ms
memory: 15140kb
input:
100000 -42762 1 2 100000 50812 8050 344660878 148363051 45574440 424722519 777816356 742918318 77317 34555 903616188 536626049 627543289 40003021 661728391 902755339 62521 19759 886077579 47372371 476022070 802707235 791666474 902340035 65278 22516 359062497 19406490 964894487 614413283 276542545 32...
output:
186323653 367728321 11651589 974942560 68106590 731409172 374461859 371467358 443172074 170088904 144972036 64101995 589283762 691797806 49635552 114620664 147990036 195483040 578096962 117904655 542086565 32875023 746164797 698603190 49713418 569623939 248409998 336013533 911441489 242569378 824390...
result:
ok 100000 numbers
Test #57:
score: 0
Accepted
time: 1267ms
memory: 16756kb
input:
100000 -35075 4 1 100000 85661 50586 113197302 118680497 276145564 503797153 20879696 861555766 25844909 392686957 873438377 932257647 60123 25048 290330497 171309685 984701199 691238913 50893418 528988892 743744220 951005364 730835136 264782783 77491 42416 862050233 763094629 228379424 111762222 28...
output:
388382609 776255445 92589191 178387253 394835344 482271231 395709241 503611030 840052391 197079690 435052955 124260580 120511188 148526263 971826402 391164342 962767736 658754192 366571051 464090279 501340628 141767293 875362707 425297829 781779275 872203457 177556445 198827025 342561571 351600317 1...
result:
ok 100000 numbers
Test #58:
score: 0
Accepted
time: 892ms
memory: 16012kb
input:
100000 -14270 3 1 100000 35123 20853 106383303 12814068 92151695 395526682 897321335 238755916 997534288 462721978 71718 57448 379599452 283261704 848934781 552834015 60183336 18726489 604667483 744983675 69722 55452 215239450 268572246 947877501 22998832 588951016 963782402 42936395 862114931 88216...
output:
899392491 540677429 314153558 989086407 497974087 329891954 106736652 171526016 963395822 346504926 526299477 54725846 760511676 249350778 67103044 533412663 917063680 261876781 255219952 237255738 691456683 826768815 491427635 774859626 838744184 963672305 581310398 287203230 628149199 274231798 19...
result:
ok 100000 numbers