QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#76403 | #4946. 青蕈领主 | alpha1022 | 100 ✓ | 368ms | 5484kb | C++17 | 8.8kb | 2023-02-09 20:14:07 | 2023-02-09 20:14:09 |
Judging History
answer
#include <cstdio>
#include <chrono>
#include <random>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <initializer_list>
using ll = long long;
using namespace std;
const int mod = 998244353, G = 3;
inline int norm(int x) {
return x >= mod ? x - mod : x;
}
inline int reduce(int x) {
return x < 0 ? x + mod : x;
}
inline int neg(int x) {
return x ? mod - x : 0;
}
inline void add(int &x, int y) {
if ((x += y - mod) < 0)
x += mod;
}
inline void sub(int &x, int y) {
if ((x -= y) < 0)
x += mod;
}
inline void fam(int &x, int y, int z) {
x = (x + (ll)y * z) % mod;
}
inline int mpow(int a, int b) {
int ret = 1;
for (; b; b >>= 1)
(b & 1) && (ret = (ll)ret * a % mod),
a = (ll)a * a % mod;
return ret;
}
const int BRUTE_N2_LIMIT = 50;
struct NumberTheory {
typedef pair<int, int> P2_Field;
mt19937 rng;
NumberTheory(): rng(chrono::steady_clock::now().time_since_epoch().count()) {}
void exGcd(int a, int b, int &x, int &y) {
if (!b) {
x = 1, y = 0;
return;
}
exGcd(b, a % b, y, x), y -= a / b * x;
}
int inv(int a, int p = mod) {
int x, y;
exGcd(a, p, x, y);
if (x < 0)
x += p;
return x;
}
template<class Integer>
bool quadRes(Integer a, Integer b) {
if (a <= 1)
return 1;
while (a % 4 == 0)
a /= 4;
if (a % 2 == 0)
return (b % 8 == 1 || b % 8 == 7) == quadRes(a / 2, b);
return ((a - 1) % 4 == 0 || (b - 1) % 4 == 0) == quadRes(b % a, a);
}
int sqrt(int x, int p = mod) {
if (p == 2 || x <= 1)
return x;
int w, v, k = (p + 1) / 2;
do
w = rng() % p;
while (quadRes(v = ((ll)w * w - x + p) % p, p));
P2_Field res(1, 0), a(w, 1);
for (; k; k >>= 1) {
if (k & 1)
res = P2_Field(((ll)res.first * a.first + (ll)res.second * a.second % p * v) % p, ((ll)res.first * a.second + (ll)res.second * a.first) % p);
a = P2_Field(((ll)a.first * a.first + (ll)a.second * a.second % p * v) % p, 2LL * a.first * a.second % p);
}
return min(res.first, p - res.first);
}
} nt;
namespace Simple {
int n = 1;
vector<int> fac({1, 1}), ifac({1, 1}), inv({0, 1});
void build(int m) {
n = m;
fac.resize(n + 1), ifac.resize(n + 1), inv.resize(n + 1);
inv[1] = 1;
for (int i = 2; i <= n; ++i)
inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
fac[0] = ifac[0] = 1;
for (int i = 1; i <= n; ++i)
fac[i] = (ll)fac[i - 1] * i % mod,
ifac[i] = (ll)ifac[i - 1] * inv[i] % mod;
}
void check(int k) {
int m = n;
if (k > m) {
while (k > m)
m <<= 1;
build(m);
}
}
inline int gfac(int k) {
check(k);
return fac[k];
}
inline int gifac(int k) {
check(k);
return ifac[k];
}
inline int ginv(int k) {
check(k);
return inv[k];
}
}
struct SimpleSequence {
function<int(int)> func;
inline SimpleSequence(const function<int(int)> &func): func(func) {}
inline int operator[](int k) const {
return func(k);
}
} gfac(Simple::gfac), gifac(Simple::gifac), ginv(Simple::ginv);
inline int binom(int n, int m) {
if (m > n || m < 0)
return 0;
return (ll)gfac[n] * gifac[m] % mod * gifac[n - m] % mod;
}
namespace NTT {
int L = -1;
vector<int> root;
void init(int l) {
L = l;
root.resize((1 << L) + 1);
int n = 1 << L, *w = root.data();
w[0] = 1, w[1 << L] = mpow(31, 1 << (21 - L));
for (int i = L; i; --i)
w[1 << (i - 1)] = (ll)w[1 << i] * w[1 << i] % mod;
for (int i = 1; i < n; ++i)
w[i] = (ll)w[i & (i - 1)] * w[i & -i] % mod;
}
void DIF(int *a, int l) {
int n = 1 << l;
for (int len = n >> 1; len; len >>= 1)
for (int *j = a, *o = root.data(); j != a + n; j += len << 1, ++o)
for (int *k = j; k != j + len; ++k) {
int r = (ll)*o * k[len] % mod;
k[len] = reduce(*k - r), add(*k, r);
}
}
void DIT(int *a, int l) {
int n = 1 << l;
for (int len = 1; len < n; len <<= 1)
for (int *j = a, *o = root.data(); j != a + n; j += len << 1, ++o)
for (int *k = j; k != j + len; ++k) {
int r = norm(*k + k[len]);
k[len] = (ll)*o * (*k - k[len] + mod) % mod, *k = r;
}
}
void fft(int *a, int lgn, int d = 1) {
if (L < lgn)
init(lgn);
int n = 1 << lgn;
if (d == 1)
DIF(a, lgn);
else {
DIT(a, lgn), reverse(a + 1, a + n);
int nInv = mod - (mod - 1) / n;
for (int i = 0; i < n; ++i)
a[i] = (ll)a[i] * nInv % mod;
}
}
}
using NTT::fft;
struct RelaxedConvolution {
static const int LG = 19;
static const int B = 16;
void run(int *f, int *g, int n, const function<void(int)> &relax) {
vector<vector<int>> savef(LG + 1), saveg(LG + 1);
function<void(int, int)> divideConquer = [&](int l, int r) {
if (r - l <= BRUTE_N2_LIMIT) {
for (int i = l + 1; i <= r; ++i) {
for (int j = l; j < i; ++j)
fam(f[i], f[j], g[i - j]);
if (l > 0)
for (int j = l; j < i; ++j)
fam(f[i], g[j], f[i - j]);
relax(i);
}
return ;
}
if (l == 0) {
int mid = ((l + r) >> 1) + 5;
divideConquer(l, mid);
int lgd = 0;
while ((1 << lgd) <= r)
++lgd;
vector<int> tf(1 << lgd), tg(1 << lgd);
for (int i = 0; i < mid; ++i)
tf[i] = f[i], tg[i] = g[i];
fft(tf.data(), lgd), fft(tg.data(), lgd);
for (int i = 0; i < (1 << lgd); ++i)
tf[i] = (ll)tf[i] * tg[i] % mod;
fft(tf.data(), lgd, -1);
for (int i = mid + 1; i <= r; ++i)
add(f[i], tf[i]);
divideConquer(mid, r);
return ;
}
int d = (r - l) / B + 1, lgd = 0, lg;
while ((1 << lgd) <= d * 2)
++lgd;
d = (1 << (lgd - 1)) - 1, lg = (r - l + d - 1) / d;
vector<int> dftf = savef[lgd], dftg = saveg[lgd];
dftf.resize(lg << (lgd + 1)), dftg.resize(lg << (lgd + 1));
for (int i = lg << lgd; i < (lg << (lgd + 1)); ++i)
dftf[i] = dftg[i] = 0;
int ef = lg;
for (int i = 0; i < lg; ++i) {
if ((i << lgd) < savef[lgd].size())
continue;
if ((i + 2) * d >= l)
--ef;
for (int j = 0; j <= min(d * 2, n - i * d); ++j)
dftf[(i << lgd) + j] = f[i * d + j],
dftg[(i << lgd) + j] = g[i * d + j];
fft(dftf.data() + (i << lgd), lgd), fft(dftg.data() + (i << lgd), lgd);
}
if (savef[lgd].size() < (ef << lgd))
savef[lgd] = vector<int>(dftf.begin(), dftf.begin() + (ef << lgd)),
saveg[lgd] = vector<int>(dftg.begin(), dftg.begin() + (ef << lgd));
for (int i = 0; i < lg; ++i) {
if (i) {
for (int j = 0; j < (1 << lgd); ++j)
add(dftf[((lg + i) << lgd) + j], dftg[((lg + i) << lgd) + j]);
fft(dftf.data() + ((lg + i) << lgd), lgd, -1);
}
for (int j = 1; j <= min(d, r - l - i * d); ++j)
add(f[l + i * d + j], dftf[((lg + i) << lgd) + d + j]);
divideConquer(l + i * d, min(l + (i + 1) * d, r));
if (i + 1 < lg) {
for (int j = 0; j < d; ++j)
dftf[((lg + i) << lgd) + j] = f[l + i * d + j],
dftg[((lg + i) << lgd) + j] = g[l + i * d + j];
for (int j = d; j < (1 << lgd); ++j)
dftf[((lg + i) << lgd) + j] = dftg[((lg + i) << lgd) + j] = 0;
fft(dftf.data() + ((lg + i) << lgd), lgd), fft(dftg.data() + ((lg + i) << lgd), lgd);
}
for (int j = i + 1; j < lg; ++j)
for (int k = 0; k < (1 << lgd); ++k)
fam(dftf[((lg + j) << lgd) + k], dftg[((j - i - 1) << lgd) + k], dftf[((lg + i) << lgd) + k]),
fam(dftg[((lg + j) << lgd) + k], dftf[((j - i - 1) << lgd) + k], dftg[((lg + i) << lgd) + k]);
}
};
relax(0), divideConquer(0, n);
}
} rc;
const int N = 5e4;
int T, n;
int f[N + 5], g[N + 5];
int a[N + 5], sta[N + 5], top;
int ans;
int main() {
scanf("%d%d", &T, &n);
rc.run(f, g, n, [&](int k) {
if (k < 2) return ;
if (k == 2) f[k] = 2;
fam(f[k], k - 1, f[k - 1]);
g[k] = (ll)(k - 1) * f[k] % mod;
});
f[0] = 1, f[1] = 2;
for (; T; --T) {
for (int i = 1; i <= n; ++i)
scanf("%d", a + i);
if (a[n] != n) {
puts("0");
continue;
}
ans = 1, top = 0;
for (int i = 1; i <= n && ans; ++i) {
int c = 0;
for (; top && i - a[i] + 1 <= sta[top]; --top) {
++c;
if (i - a[i] > sta[top] - a[sta[top]]) {
ans = 0;
break;
}
}
sta[++top] = i, ans = (ll)ans * f[c] % mod;
}
printf("%d\n", ans);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 2ms
memory: 3064kb
input:
1 10 1 1 3 1 2 1 4 1 2 10
output:
64
result:
ok 1 number(s): "64"
Test #2:
score: 5
Accepted
time: 2ms
memory: 2872kb
input:
1 10 1 1 3 1 2 1 2 7 9 10
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: 5
Accepted
time: 0ms
memory: 3060kb
input:
100 10 1 2 1 2 1 1 1 1 5 10 1 1 1 1 1 1 1 1 9 10 1 2 1 1 1 1 1 8 1 10 1 1 1 1 1 1 2 1 1 10 1 1 2 4 1 1 1 1 5 10 1 1 3 1 1 1 1 1 9 10 1 1 3 1 2 1 2 1 4 10 1 1 1 1 1 3 1 8 1 10 1 1 1 1 1 1 1 1 3 10 1 1 3 1 1 1 2 3 1 10 1 1 1 1 1 1 6 1 2 10 1 1 1 3 1 1 1 1 5 10 1 1 3 1 5 1 1 1 9 10 1 1 1 4 1 1 1 1 5 10...
output:
256 87360 2400 87360 128 2400 64 352 9600 704 704 128 128 128 2400 128 2400 2400 2400 64 128 1408 128 9600 443296 128 128 9600 9600 443296 0 443296 256 2400 0 64 87360 443296 443296 128 0 443296 0 256 443296 443296 1408 9600 128 443296 704 443296 0 443296 2400 704 443296 87360 2400 704 443296 87360 ...
result:
ok 100 numbers
Test #4:
score: 5
Accepted
time: 1ms
memory: 2884kb
input:
100 10 1 1 1 1 1 1 7 1 2 10 1 1 1 1 1 6 1 1 3 10 1 1 1 1 1 1 1 3 1 10 1 2 1 2 1 1 3 1 1 10 1 1 1 1 5 1 7 1 1 10 1 1 1 1 1 2 1 1 1 10 1 2 1 1 1 4 1 1 3 10 1 1 1 1 1 2 1 8 1 10 1 1 1 1 5 1 1 1 2 10 1 1 1 2 1 1 1 1 8 10 1 1 1 1 5 1 1 1 6 10 1 1 1 1 1 5 1 8 1 10 1 2 1 2 1 2 1 1 3 10 1 1 1 1 1 1 1 1 1 10...
output:
2400 352 9600 704 128 87360 64 2400 512 2400 0 128 256 443296 9600 2400 87360 0 443296 87360 87360 1408 64 2400 64 443296 256 64 128 352 443296 0 443296 128 0 0 704 443296 704 443296 9600 128 2400 9600 87360 352 128 443296 128 704 0 1408 128 9600 443296 704 2400 2400 443296 0 128 2400 443296 9600 35...
result:
ok 100 numbers
Test #5:
score: 5
Accepted
time: 2ms
memory: 3096kb
input:
1 300 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...
output:
731696071
result:
ok 1 number(s): "731696071"
Test #6:
score: 5
Accepted
time: 2ms
memory: 3088kb
input:
1 300 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
654818711
result:
ok 1 number(s): "654818711"
Test #7:
score: 5
Accepted
time: 1ms
memory: 3020kb
input:
100 300 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 1 1 1 1 1 25 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 1 1 17 1...
output:
629582282 936488602 14854846 0 972850406 335643474 401801367 518359524 0 42431632 964390278 0 735641393 402072933 0 315498454 714104802 235533741 71997442 584545233 143385672 0 243017113 986234659 955040013 187506887 47264449 0 134183782 140053056 645326653 706116063 793388530 755635337 660249932 35...
result:
ok 100 numbers
Test #8:
score: 5
Accepted
time: 0ms
memory: 2916kb
input:
100 300 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 16 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 9 1 1 1 1 46 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 13 1 1 1 1 21 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 12 1 40 1 1 1 1 1 1 1 1 1 1 ...
output:
213721346 242599023 719011592 0 422638207 728716801 710719728 177328520 0 443663955 995539661 0 0 0 582405109 301065834 482480764 189294107 882417753 263472408 583100647 887062292 558090353 374255923 176488287 958825157 132492749 27789769 297287037 0 0 2733249 643517198 0 20415575 953067857 74118762...
result:
ok 100 numbers
Test #9:
score: 5
Accepted
time: 2ms
memory: 2920kb
input:
1 997 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
495842312
result:
ok 1 number(s): "495842312"
Test #10:
score: 5
Accepted
time: 4ms
memory: 2944kb
input:
100 1000 1 1 1 2 4 1 6 1 2 3 11 1 1 2 1 4 1 1 1 2 5 1 11 1 1 2 3 1 18 1 2 1 1 1 6 1 1 2 4 5 1 1 3 9 1 1 2 1 5 1 7 1 2 1 1 2 1 4 24 1 1 1 1 3 1 1 7 1 2 1 2 61 1 2 3 1 2 1 4 8 9 82 1 2 3 1 1 6 1 2 9 1 1 3 1 5 1 1 8 1 1 3 1 1 23 1 2 1 4 1 1 7 1 2 3 4 1 2 1 8 1 2 1 12 1 1 2 1 1 2 1 1 3 4 8 1 2 3 15 1 1 ...
output:
639441690 325951010 772826730 707904063 750757689 685150437 3586144 711874830 882896695 312252618 0 0 625591512 0 0 953293767 310960913 665863278 61999458 536746177 269479775 755348118 0 816896717 0 0 0 890648230 0 435292445 0 528885058 277580975 916252312 0 958726742 640472413 682980893 661293405 0...
result:
ok 100 numbers
Test #11:
score: 5
Accepted
time: 6ms
memory: 3124kb
input:
100 1000 1 1 1 2 3 1 1 3 1 2 6 1 1 12 1 1 3 4 1 2 1 1 1 3 4 1 9 1 1 29 1 2 1 4 1 2 1 1 1 1 3 5 7 1 1 1 3 1 2 16 1 2 1 4 1 1 2 3 1 2 6 8 9 1 1 16 1 1 3 40 1 2 3 74 1 1 1 2 1 2 1 4 1 1 11 1 2 3 1 2 6 1 2 3 4 1 1 3 1 9 10 1 2 3 4 1 1 1 2 3 5 1 2 1 1 11 1 2 1 2 5 1 7 8 34 1 2 37 1 2 1 1 1 49 1 1 1 2 4 6...
output:
0 0 706651534 439786013 0 70411622 0 0 0 835773719 0 0 0 107157784 27212808 568144383 407628078 308471256 890881779 0 0 0 0 389644399 0 452029310 55646018 0 183690719 0 0 0 0 609100480 611850278 81354283 0 89798335 375537513 0 902011601 957022140 0 903873199 0 276820482 0 247728618 866180585 4914605...
result:
ok 100 numbers
Test #12:
score: 5
Accepted
time: 9ms
memory: 3052kb
input:
100 1000 1 1 1 2 3 1 1 3 1 2 6 1 1 12 1 1 3 4 1 2 1 1 1 3 4 1 9 1 1 29 1 2 1 4 1 2 1 1 1 1 3 5 7 1 1 1 3 1 2 16 1 2 1 4 1 1 2 3 1 2 6 8 9 1 1 16 1 1 3 40 1 2 3 74 1 1 1 2 1 2 1 4 1 1 11 1 2 3 1 2 6 1 2 3 4 1 1 3 1 9 10 1 2 3 4 1 1 1 2 3 5 1 2 1 1 11 1 2 1 2 5 1 7 8 34 1 2 37 1 2 1 1 1 49 1 1 1 2 4 6...
output:
0 0 706651534 439786013 0 70411622 0 0 0 835773719 0 0 0 107157784 27212808 568144383 407628078 308471256 890881779 0 0 0 0 389644399 0 452029310 55646018 0 183690719 0 0 0 0 609100480 611850278 81354283 0 89798335 375537513 0 902011601 957022140 0 903873199 0 276820482 0 247728618 866180585 4914605...
result:
ok 100 numbers
Test #13:
score: 5
Accepted
time: 43ms
memory: 3248kb
input:
100 5000 1 1 1 2 4 1 1 7 1 1 3 1 2 1 2 1 9 1 2 1 2 1 6 1 17 1 19 1 1 1 2 1 1 1 1 7 1 1 1 39 1 1 1 2 1 2 1 6 48 1 1 51 1 1 2 1 4 5 1 2 1 1 1 6 1 13 1 1 2 1 4 1 1 3 1 10 1 1 3 1 15 1 2 1 2 3 1 1 36 1 1 1 2 3 1 1 1 7 1 1 2 1 4 1 1 1 1 10 1 20 1 2 1 1 3 1 1 66 1 1 1 2 3 1 1 1 2 4 1 1 1 1 5 1 17 1 1 1 4 ...
output:
0 292588696 344051249 351335346 0 985560804 0 0 744141033 0 318360253 509056631 897631526 210708530 0 282499786 0 0 298272534 0 866815275 708474811 0 0 533348880 0 0 0 496288915 0 288732736 613115755 275961405 582960568 0 777792174 304810404 835564816 0 809847872 0 0 890711747 27774048 0 838137435 8...
result:
ok 100 numbers
Test #14:
score: 5
Accepted
time: 39ms
memory: 3224kb
input:
100 5000 1 1 2 3 1 5 1 1 1 1 3 1 2 1 9 1 1 1 2 3 1 21 1 1 3 1 5 6 1 2 3 4 1 1 2 4 36 38 1 1 1 1 2 4 1 1 3 1 9 1 11 1 1 1 1 1 2 1 20 1 2 1 24 1 1 1 1 2 3 31 1 33 1 2 1 4 1 2 7 1 1 2 4 12 1 2 3 4 1 1 7 8 1 10 1 1 13 1 2 1 4 1 19 1 2 1 4 5 1 7 1 2 3 1 2 1 2 1 6 1 2 3 20 1 1 2 3 1 2 1 2 1 1 3 135 1 1 1 ...
output:
153322044 150492767 0 994490869 0 0 0 855074869 0 788845897 849135324 558695774 329454393 0 0 0 739924836 452723945 0 786225052 0 0 0 185397693 73624630 988094148 0 836735505 57947855 705987810 106069205 0 0 885756183 494461680 182794483 0 482961814 31686100 0 0 249571642 543812012 0 722599260 64625...
result:
ok 100 numbers
Test #15:
score: 5
Accepted
time: 30ms
memory: 3348kb
input:
100 5000 1 1 1 2 1 2 6 1 1 2 10 1 1 1 2 1 6 1 8 1 1 3 1 2 1 2 1 1 1 1 12 1 2 3 1 1 3 1 1 2 1 11 1 2 3 4 5 6 1 19 1 1 3 1 1 2 3 1 2 3 4 8 1 1 11 1 1 1 68 1 2 3 4 5 1 75 1 2 1 2 1 2 1 8 1 2 3 1 1 2 15 1 2 1 4 96 1 1 3 1 2 1 7 1 9 106 1 2 1 1 1 1 7 1 2 1 1 2 1 1 6 1 8 1 12 1 1 2 1 5 1 2 3 1 2 1 2 1 2 1...
output:
946701850 983965823 543510180 0 234696913 532101369 36100829 817231065 772588292 709229991 29442326 651065274 0 837031094 0 0 316959187 97361210 0 989103922 345758410 347379164 0 897533810 488460689 0 0 497682855 33909352 194898623 0 0 118515226 0 284902892 251441025 850822408 357498752 892873025 0 ...
result:
ok 100 numbers
Test #16:
score: 5
Accepted
time: 37ms
memory: 3332kb
input:
100 5000 1 1 1 3 4 1 1 2 3 1 1 6 1 8 14 1 1 2 3 1 2 3 1 1 1 4 8 1 2 3 1 17 1 19 1 2 3 1 2 1 2 1 6 1 2 1 46 1 1 1 1 1 4 1 2 1 4 9 1 1 2 15 1 1 3 4 5 1 2 1 4 71 1 1 3 1 5 78 1 2 3 1 2 6 1 1 2 1 1 1 4 1 8 9 1 1 2 1 2 3 1 1 9 1 1 22 1 1 2 1 5 1 29 1 2 1 4 5 41 1 2 1 1 5 1 1 1 2 1 1 1 1 5 8 1 1 3 4 1 1 6...
output:
0 0 0 387445433 53260884 0 253952014 537163051 36559794 0 511384985 0 832504854 740181150 330078867 405525929 569684673 0 0 827053910 613985912 647990716 75829151 918618470 295766219 845315492 0 0 129206830 666746707 586695222 81186019 0 35517922 0 392622181 0 722722877 685721668 0 788434307 7688927...
result:
ok 100 numbers
Test #17:
score: 5
Accepted
time: 338ms
memory: 5204kb
input:
100 50000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 5 1 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
938322083 0 627807333 0 553973202 0 0 14048401 0 950421047 0 622576077 0 744029553 793127481 645301924 533609841 852154523 625396972 62789084 413008358 292040298 656049825 581436181 922659811 0 0 0 91815535 506836479 156002945 205212058 316354153 344645416 521003850 532634702 926445048 641763410 519...
result:
ok 100 numbers
Test #18:
score: 5
Accepted
time: 357ms
memory: 5484kb
input:
100 50000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 6 1 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 9 1 32 1 1 1 1 2 1 1 1 1 1 1 1 1 1 3 1 1 65 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
624885832 833309143 968068549 16720417 467661900 0 983405586 43591434 547668905 950286049 530347421 0 0 909087345 658815045 0 794306626 14976636 357941460 150818230 715847749 638450467 0 0 155568509 0 879137806 428155583 300267776 779360110 39013493 751776921 685994614 809532425 0 0 28163073 6789027...
result:
ok 100 numbers
Test #19:
score: 5
Accepted
time: 368ms
memory: 5308kb
input:
100 50000 1 1 2 3 1 5 1 1 1 3 5 1 2 14 15 1 2 1 1 2 1 1 1 3 4 1 10 11 14 15 1 2 3 1 20 1 2 3 1 1 2 4 1 2 10 1 1 3 4 1 2 1 4 5 1 7 1 2 10 1 1 1 1 2 1 2 6 1 1 3 1 5 1 1 8 15 1 2 34 1 1 1 2 1 1 2 3 1 2 7 1 1 2 4 1 1 97 1 99 1 1 1 1 2 6 7 1 1 1 1 3 5 6 1 1 2 11 1 2 1 15 1 1 124 1 1 1 2 5 1 2 8 9 1 1 1 3...
output:
475040820 821423600 161407909 880735181 500071559 337741049 134440032 894840892 976405119 528519244 473904119 936942481 875766540 93375618 980295619 621222155 0 393457466 0 0 281655372 418588257 269174342 31667135 0 0 462648500 0 528191112 831811998 548436806 0 0 917468062 373787292 425247061 235798...
result:
ok 100 numbers
Test #20:
score: 5
Accepted
time: 354ms
memory: 5480kb
input:
100 50000 1 1 1 1 1 3 1 1 6 1 1 1 10 1 12 1 1 1 4 1 2 1 4 1 2 3 1 1 2 3 5 1 18 1 2 3 1 1 1 1 1 2 1 2 1 10 1 2 1 1 1 16 1 2 3 23 1 2 3 1 5 1 2 1 1 5 6 1 2 3 1 11 1 1 1 4 1 2 1 2 3 1 5 1 9 1 11 1 1 1 3 1 2 79 1 1 2 3 4 1 1 1 2 5 1 2 3 1 5 15 17 1 1 1 1 1 1 2 5 1 27 1 29 1 2 1 2 3 1 7 8 1 2 3 1 133 1 2...
output:
0 0 682944657 750632782 263950446 693440161 405059290 525305126 44971279 123548737 0 741272096 576480062 0 677196555 0 145863649 0 0 0 987541820 0 714088381 470820324 0 893509858 0 0 258145392 0 374442624 393753011 495298252 455139328 0 454995497 462625493 552202545 35811919 51255305 465265116 94156...
result:
ok 100 numbers
Extra Test:
score: 0
Extra Test Passed