QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#181489 | #7219. The Mighty Spell | ckiseki | WA | 3ms | 3864kb | C++14 | 4.2kb | 2023-09-16 19:42:31 | 2023-09-16 19:42:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifdef CKISEKI
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
template <typename ...T>
void debug_(const char *s, T ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int cnt = sizeof...(T);
(..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
template <typename I>
void orange_(const char *s, I L, I R) {
cerr << "\e[1;32m[ " << s << " ] = [ ";
for (int f = 0; L != R; ++L)
cerr << (f++ ? ", " : "") << *L;
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
const int mod = 1000000007;
int Eval(int x, vector<int> a) {
int s = 0;
for (int y: a)
s = (1LL * s * x + y) % mod;
return s;
}
/*
int take_any(int a) {
int s = 1;
for (int i = 0; i < a; i++)
s = (s * 2) % mod;
return s;
}
int take_atleast_one(int a) {
int s = 0;
for (int i = 0; i < a; i++)
s = (s * 2 + 1) % mod;
return s;
}
*/
int modpow(int64_t e, int p) {
int64_t r = 1;
while (p) {
if (p & 1) r = r * e % mod;
e = e * e % mod;
p >>= 1;
}
return r;
}
int modinv(int z) {
return modpow(z, mod - 2);
}
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n);
for (int &x: a) cin >> x, --x;
vector<int> g(n + 1);
for (int i = 0; i <= n; i++) {
g[i] = Eval(i, {2, 3, 3, 3});
}
g[0] = 0;
auto tg = g;
// for (int i = 0; i <= n; i++) {
// for (int j = 0; j < i; j++) {
// g[i] = (g[i] - 1LL * g[j] * (i - j + 1) % mod + mod) % mod;
// }
// }
orange(g.begin(), g.end());
// return 0;
for (int i = n; i >= 0; i--) {
tg[i] = g[i];
if (i >= 2) tg[i] = (tg[i] + 1 * g[i - 2] % mod + mod) % mod;
if (i >= 1) tg[i] = (tg[i] - 2 * g[i - 1] % mod + mod) % mod;
}
g = tg;
/*
int real_ans = 0;
for (int s = 0; s < 1<<n; s++) {
vector<int> ok(m);
for (int i = 0; i < n; i++)
if (s >> i & 1) ok[a[i]] = true;
bool flag = false;
for (int j = 0; j < m; j++) {
if (!ok[j]) flag = true;
}
if (flag) continue;
int coef = 0;
for (int l = 0; l < n; l++) {
int m = 0;
for (int r = l; r < n; r++) {
m |= 1 << r;
if ((s & m) == m)
(coef += g[r - l + 1]) %= mod;
}
}
(real_ans += coef) %= mod;
}
debug(real_ans);
*/
vector<int> cnt(m);
for (int &x: a) ++cnt[x];
for (int j = 0; j < m; j++) if (cnt[j] == 0) {
cout << 0 << '\n';
return 0;
}
vector<int> p1(n + 1), p2(n + 1), ip1(n + 1), ip2(n + 1);
p1[0] = 0;
for (int i = 1; i <= n; i++) {
p1[i] = (p1[i - 1] + p1[i - 1] + 1) % mod;
}
p2[0] = 1;
for (int i = 1; i <= n; i++) {
p2[i] = (p2[i - 1] + p2[i - 1]) % mod;
}
for (int i = 0; i <= n; i++) {
ip1[i] = modpow(p1[i], mod - 2);
ip2[i] = modpow(p2[i], mod - 2);
}
const auto take_atleast_one = [&](int z) { return p1[z]; };
const auto take_any = [&](int z) { return p2[z]; };
const auto inv_take_atleast_one = [&](int z) { return ip1[z]; };
// const auto inv_take_any = [&](int z) { return ip2[z]; };
vector<int> pre(n + 2);
for (int i = 1; i <= n; i++) {
pre[i + 1] = (pre[i] + 1LL * g[i] * modinv(take_any(i))) % mod;
}
const auto gao = [&](int i, int l, int r) {
l -= i;
r -= i;
++l, ++r;
return (pre[r] - pre[l] + mod) % mod;
// int res = 0;
// for (int j = l; j < r; j++) {
// res = (res + 1LL * g[j - i + 1] * modinv(take_any(j - i + 1))) % mod;
// }
// return res;
};
int64_t tot = 1;
for (int j = 0; j < m; j++) {
tot = tot * take_atleast_one(cnt[j]) % mod;
}
int ans = 0;
vector<int> pos(m, -1);
for (int i = n - 1; i >= 0; i--) {
pos[a[i]] = i;
int64_t prod = tot;
vector<int> evt;
for (int j = 0; j < m; j++) {
if (pos[j] != -1) {
evt.emplace_back(pos[j]);
}
}
sort(evt.begin(), evt.end());
int f = i;
for (int p: evt) {
int v = a[p];
ans = (ans + prod * gao(i, f, p)) % mod;
f = p;
prod = prod * inv_take_atleast_one(cnt[v]) % mod;
// prod = prod * modinv(take_atleast_one(cnt[v])) % mod;
prod = prod * take_any(cnt[v]) % mod;
}
ans = (ans + prod * gao(i, f, n)) % mod;
}
cout << ans << '\n';
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3488kb
input:
3 2 1 2 2
output:
152
result:
ok answer is '152'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
4 3 1 2 1 2
output:
0
result:
ok answer is '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
6 3 1 2 3 3 2 1
output:
3627
result:
ok answer is '3627'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5 5 1 4 5 3 2
output:
343
result:
ok answer is '343'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
5 5 1 5 4 3 2
output:
343
result:
ok answer is '343'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 5 3 1 5 4 2
output:
343
result:
ok answer is '343'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
5 5 4 1 2 3 5
output:
343
result:
ok answer is '343'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
5 5 2 3 2 2 2
output:
0
result:
ok answer is '0'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
5 5 1 2 2 2 5
output:
0
result:
ok answer is '0'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
5 5 4 2 1 3 5
output:
343
result:
ok answer is '343'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5 5 2 3 4 5 1
output:
343
result:
ok answer is '343'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 5 4 3 5 2 1
output:
343
result:
ok answer is '343'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 5 3 4 5 2 1
output:
343
result:
ok answer is '343'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
5 5 4 3 3 5 2
output:
0
result:
ok answer is '0'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
5 5 1 4 4 1 1
output:
0
result:
ok answer is '0'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5 5 1 5 2 4 3
output:
343
result:
ok answer is '343'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
5 5 4 2 5 3 1
output:
343
result:
ok answer is '343'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
5 5 3 1 4 5 2
output:
343
result:
ok answer is '343'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
5 5 5 1 3 4 2
output:
343
result:
ok answer is '343'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
5 5 4 5 3 5 5
output:
0
result:
ok answer is '0'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
5 5 2 2 3 4 2
output:
0
result:
ok answer is '0'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
5 5 4 5 1 2 3
output:
343
result:
ok answer is '343'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
5 5 3 5 1 2 4
output:
343
result:
ok answer is '343'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
5 5 5 4 1 2 3
output:
343
result:
ok answer is '343'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
5 5 5 3 4 1 2
output:
343
result:
ok answer is '343'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
5 5 3 1 2 1 5
output:
0
result:
ok answer is '0'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
5 5 3 1 4 2 5
output:
343
result:
ok answer is '343'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
5 5 1 2 4 5 3
output:
343
result:
ok answer is '343'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
5 5 4 3 1 5 2
output:
343
result:
ok answer is '343'
Test #30:
score: 0
Accepted
time: 1ms
memory: 3804kb
input:
5 5 2 1 3 4 5
output:
343
result:
ok answer is '343'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
5 5 4 2 1 3 5
output:
343
result:
ok answer is '343'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5 5 4 3 1 4 3
output:
0
result:
ok answer is '0'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
5 5 3 4 1 1 3
output:
0
result:
ok answer is '0'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
20 5 5 2 5 1 5 5 2 4 5 5 2 5 5 5 5 4 2 5 3 4
output:
102882880
result:
ok answer is '102882880'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
20 5 3 2 1 2 2 2 2 2 4 3 2 2 3 3 5 2 2 1 2 5
output:
134653185
result:
ok answer is '134653185'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
20 5 1 2 3 2 1 3 5 1 2 4 5 2 3 4 5 1 4 3 4 5
output:
315505338
result:
ok answer is '315505338'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
20 5 5 2 2 4 2 3 5 1 1 3 1 5 2 4 4 3 1 4 3 5
output:
312062382
result:
ok answer is '312062382'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
20 5 3 4 2 5 4 5 5 4 1 4 3 3 4 3 4 2 3 2 5 3
output:
188515821
result:
ok answer is '188515821'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
20 5 3 5 1 3 3 4 5 2 1 1 3 1 2 5 2 1 1 2 5 2
output:
197857329
result:
ok answer is '197857329'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
20 10 3 8 6 8 9 2 1 5 8 6 7 8 4 8 6 8 10 8 8 8
output:
4905343
result:
ok answer is '4905343'
Test #41:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
20 10 10 5 1 8 7 2 7 2 6 2 2 2 2 2 4 2 3 7 9 7
output:
3724041
result:
ok answer is '3724041'
Test #42:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
20 10 5 1 9 6 10 4 5 3 2 4 8 3 7 1 8 6 2 9 10 7
output:
52978806
result:
ok answer is '52978806'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
20 10 5 8 6 2 1 10 3 8 9 7 6 5 10 9 1 7 3 4 4 2
output:
53309955
result:
ok answer is '53309955'
Test #44:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
20 10 1 8 1 7 9 7 9 9 7 4 1 6 2 7 8 6 6 9 6 7
output:
0
result:
ok answer is '0'
Test #45:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
20 10 1 10 10 10 2 9 1 1 7 2 3 9 5 10 8 4 1 4 2 5
output:
0
result:
ok answer is '0'
Test #46:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
20 20 9 16 3 18 8 19 6 4 2 17 1 15 10 11 5 13 12 7 14 20
output:
17263
result:
ok answer is '17263'
Test #47:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
20 20 2 17 18 12 15 20 11 9 10 5 6 16 7 8 4 13 3 1 19 14
output:
17263
result:
ok answer is '17263'
Test #48:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
20 20 14 15 19 8 3 20 9 12 18 7 5 11 4 2 16 6 1 17 10 13
output:
17263
result:
ok answer is '17263'
Test #49:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
20 20 18 9 3 4 13 12 15 11 2 16 19 7 10 20 17 8 6 1 14 5
output:
17263
result:
ok answer is '17263'
Test #50:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
20 20 7 6 4 14 20 13 1 15 5 18 16 10 1 16 12 14 5 13 1 3
output:
0
result:
ok answer is '0'
Test #51:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
20 20 17 17 5 16 9 14 14 1 2 4 19 8 9 5 9 20 5 16 20 9
output:
0
result:
ok answer is '0'
Test #52:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
20 20 20 1 16 5 19 11 8 7 2 3 12 6 17 14 13 18 4 10 15 9
output:
17263
result:
ok answer is '17263'
Test #53:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
20 20 2 13 6 1 17 3 11 9 8 10 7 5 16 14 4 15 18 19 20 12
output:
17263
result:
ok answer is '17263'
Test #54:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
20 20 17 11 13 5 2 14 18 7 6 9 10 3 16 15 8 1 19 4 12 20
output:
17263
result:
ok answer is '17263'
Test #55:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
20 20 7 13 1 15 9 2 8 20 4 5 12 3 11 14 10 18 6 17 16 19
output:
17263
result:
ok answer is '17263'
Test #56:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
20 20 11 8 17 7 10 20 20 12 7 3 7 14 15 4 14 7 11 1 12 20
output:
0
result:
ok answer is '0'
Test #57:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
20 20 20 18 17 14 11 2 13 3 10 1 16 3 1 16 10 8 4 8 13 3
output:
0
result:
ok answer is '0'
Test #58:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
20 20 1 20 7 4 18 11 9 8 3 6 16 13 19 2 12 14 15 17 10 5
output:
17263
result:
ok answer is '17263'
Test #59:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
20 20 8 4 5 18 16 15 19 2 13 1 14 7 10 12 17 3 6 9 20 11
output:
17263
result:
ok answer is '17263'
Test #60:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
20 20 13 14 8 9 18 17 20 6 15 3 2 16 12 11 1 10 19 4 7 5
output:
17263
result:
ok answer is '17263'
Test #61:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
20 20 4 10 17 8 19 1 16 3 14 6 7 11 13 15 20 9 12 5 2 18
output:
17263
result:
ok answer is '17263'
Test #62:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
20 20 19 17 19 8 7 1 18 13 16 16 20 11 5 8 17 19 11 14 4 8
output:
0
result:
ok answer is '0'
Test #63:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
20 20 7 1 14 13 20 16 10 18 16 12 5 7 16 14 6 12 11 20 10 19
output:
0
result:
ok answer is '0'
Test #64:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
500 5 3 5 5 3 5 3 5 5 3 3 3 3 3 3 1 3 3 3 3 3 3 3 5 3 3 3 1 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 5 3 3 3 5 3 3 5 2 3 3 3 5 3 3 3 3 1 3 3 5 3 3 5 3 3 5 3 5 3 3 3 3 3 3 5 3 5 3 3 5 3 5 3 5 3 3 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 5 3 3 5 5 3 3 3 3 3 5 3 5 3 3 3 3 5 3 3 3 3 3 3 3 3 3 ...
output:
255072751
result:
ok answer is '255072751'
Test #65:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
500 5 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 5 1 5 5 1 1 1 1 1 5 5 1 1 1 1 5 4 5 4 1 1 1 1 1 1 5 1 1 5 1 1 5 1 5 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 4 1 5 1 5 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 5 1 1 3 4 5 1 5 1 1 1 1 5 5 1 1 1 1 1 1 1 1 5 1 1 1 5 1 1 1 1 5 1 5 1 4 1 1 1 4 5 5 1 ...
output:
825435010
result:
ok answer is '825435010'
Test #66:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
500 5 1 2 4 3 2 2 4 5 4 2 4 2 5 5 5 5 1 4 1 2 4 4 2 1 2 5 4 3 1 1 2 4 3 3 2 3 4 5 4 1 3 2 3 3 5 2 2 3 2 2 3 2 5 2 1 1 3 1 4 2 4 3 3 2 4 1 5 2 4 3 3 3 2 2 3 3 4 5 2 1 4 3 5 5 2 2 3 4 3 1 5 4 3 1 3 1 5 1 3 1 3 2 5 3 1 2 2 5 4 4 5 5 4 1 2 1 4 5 1 4 3 5 4 1 4 5 3 3 4 3 4 2 2 5 5 3 4 5 3 5 3 5 3 1 2 2 2 ...
output:
451686600
result:
ok answer is '451686600'
Test #67:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
500 5 4 1 3 1 1 1 4 1 1 5 1 5 3 5 4 1 1 4 2 5 5 5 2 5 2 2 5 3 1 5 3 3 2 5 4 5 1 3 4 3 5 1 5 3 1 3 5 2 2 3 2 4 2 3 5 5 3 1 5 3 2 4 2 1 2 1 5 4 3 5 2 5 5 4 2 3 1 5 4 4 3 1 3 3 1 3 3 4 3 1 2 2 3 4 3 1 2 3 4 1 1 1 5 4 2 3 4 5 4 1 2 4 3 3 4 5 3 3 4 4 2 4 5 5 3 2 2 1 5 2 4 2 2 2 2 1 4 3 5 3 4 3 5 5 3 3 5 ...
output:
377242617
result:
ok answer is '377242617'
Test #68:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
500 5 1 3 2 1 1 5 2 5 5 1 4 4 1 3 2 2 4 1 4 2 4 3 5 4 4 3 2 1 2 2 2 2 4 5 4 1 2 3 3 4 4 3 3 2 4 5 3 5 1 1 1 3 4 5 2 3 3 5 4 4 1 1 2 3 1 3 2 1 2 4 1 4 2 3 1 3 4 2 2 3 1 3 1 1 5 4 2 4 1 5 5 5 5 3 1 2 4 3 1 4 3 4 2 2 3 1 5 2 3 4 4 2 4 2 4 3 5 4 3 1 1 4 4 1 5 3 2 1 5 1 5 4 4 4 5 1 5 3 2 5 4 4 2 3 3 3 3 ...
output:
416085601
result:
ok answer is '416085601'
Test #69:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
500 5 1 3 4 5 5 5 3 3 4 4 1 3 2 1 1 5 4 4 3 1 3 4 3 4 3 1 4 4 1 4 4 3 4 4 1 1 3 2 1 5 4 2 2 3 3 2 3 4 5 5 5 2 3 4 1 5 2 5 5 4 4 2 5 5 1 1 5 3 4 1 1 1 4 2 4 5 2 4 3 5 1 5 1 4 4 3 4 5 5 5 1 1 4 5 5 1 2 3 3 4 3 4 3 3 1 5 4 5 4 2 1 1 4 5 2 1 4 2 1 1 3 3 1 5 2 1 2 3 2 3 3 1 5 1 4 3 4 4 2 4 4 1 4 4 3 1 4 ...
output:
320473255
result:
ok answer is '320473255'
Test #70:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
500 10 7 7 7 5 5 7 7 7 7 7 7 5 7 5 5 7 7 7 6 5 7 7 7 7 5 6 7 7 7 7 7 7 5 7 7 7 9 7 7 7 5 5 7 7 7 7 7 5 7 5 7 7 7 5 5 5 7 5 5 6 5 7 5 5 5 7 7 5 5 7 9 7 5 7 6 7 7 5 7 7 7 7 7 7 7 7 6 7 5 7 7 5 5 7 7 7 7 7 7 7 7 7 7 5 7 7 5 7 7 7 7 7 5 7 7 7 5 7 7 7 7 7 7 6 7 7 9 5 5 5 5 7 7 7 7 7 7 7 7 7 7 7 7 7 5 7 4...
output:
239772932
result:
ok answer is '239772932'
Test #71:
score: 0
Accepted
time: 1ms
memory: 3512kb
input:
500 10 1 1 9 10 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 9 1 1 6 1 1 1 1 7 1 1 9 10 9 1 1 1 1 1 9 1 1 1 10 1 1 1 1 1 1 1 10 1 10 10 1 1 1 7 1 10 1 1 1 1 1 1 1 10 1 1 1 1 10 9 1 1 9 10 1 1 1 1 1 1 1 10 1 10 9 1 1 1 10 10 10 1 1 1 1 9 3 9 1 1 1 1 10 1 1 1 1 10 1 1 10 7 1 1 1 1 1 1 9 1 1 1 1 1 10 1 10 1 1 1 1...
output:
516842141
result:
ok answer is '516842141'
Test #72:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
500 10 7 4 8 5 5 1 7 10 2 1 1 4 2 5 3 10 8 7 1 9 2 1 2 1 3 3 5 3 4 3 10 1 1 5 7 1 10 1 6 6 4 8 7 5 5 3 8 10 7 3 6 2 10 5 9 2 9 8 6 2 4 5 8 10 2 1 9 5 8 8 3 1 8 3 5 3 2 2 8 4 5 9 6 6 10 9 6 7 10 8 6 4 5 9 10 1 5 3 7 10 9 8 6 1 8 9 10 4 7 8 1 4 1 10 8 5 7 5 2 5 10 2 7 7 1 2 6 8 2 3 5 4 2 6 1 4 10 8 9 ...
output:
180962819
result:
ok answer is '180962819'
Test #73:
score: 0
Accepted
time: 1ms
memory: 3864kb
input:
500 10 9 6 4 5 9 7 5 9 6 1 7 7 2 8 9 4 2 4 4 8 10 1 3 7 9 6 4 1 2 6 9 2 3 10 5 7 5 8 9 2 6 4 8 1 4 9 6 7 8 1 7 5 6 5 6 1 3 9 8 8 1 8 10 5 9 10 1 3 10 1 6 9 8 7 3 3 7 8 4 6 7 2 9 1 3 4 5 3 6 1 1 7 8 2 2 6 6 10 9 5 8 8 6 1 7 2 4 7 1 9 4 7 3 3 7 4 10 3 10 8 4 2 5 2 5 7 2 9 4 8 10 8 10 2 4 8 6 2 9 3 2 4...
output:
627406288
result:
ok answer is '627406288'
Test #74:
score: 0
Accepted
time: 1ms
memory: 3860kb
input:
500 10 9 6 3 4 6 5 7 9 9 3 6 6 6 6 7 8 10 10 6 4 4 8 8 10 3 1 5 8 4 9 10 5 5 4 1 8 1 7 4 6 2 4 7 5 2 1 4 5 9 10 1 4 1 1 1 8 5 8 1 4 7 10 7 8 9 9 4 3 4 5 9 4 2 9 10 9 9 6 3 10 7 10 5 8 10 1 6 10 6 2 5 9 8 3 3 9 9 3 5 4 6 8 1 8 3 6 2 4 3 3 7 6 1 9 9 6 5 5 2 3 10 8 6 6 5 10 6 5 1 9 5 10 3 8 10 2 1 9 8 ...
output:
561848920
result:
ok answer is '561848920'
Test #75:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
500 10 4 8 10 1 1 3 3 4 6 7 10 7 7 3 8 8 3 4 8 2 9 7 3 8 1 4 7 6 4 2 7 8 7 2 9 2 10 3 8 7 3 9 9 6 3 7 2 4 3 4 8 7 2 3 1 9 3 3 9 5 9 2 9 5 1 10 10 3 8 10 2 10 5 9 8 7 8 5 7 3 3 9 9 8 6 4 8 3 9 7 3 3 7 4 10 1 4 4 4 9 3 3 8 5 6 3 8 1 4 4 6 10 4 2 10 3 6 4 5 3 10 10 5 1 3 1 9 6 3 2 10 3 2 7 10 3 9 3 6 7...
output:
762179727
result:
ok answer is '762179727'
Test #76:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
500 20 18 18 18 2 18 6 2 18 12 6 12 18 18 12 12 6 12 6 6 2 18 12 18 18 18 12 6 18 12 12 6 18 12 18 18 18 6 6 18 18 18 18 6 18 18 18 7 2 12 18 12 18 6 2 18 2 20 12 6 10 18 18 18 18 7 13 18 18 18 12 18 18 18 12 12 18 18 6 12 6 6 7 12 12 18 18 6 8 7 18 18 18 18 12 6 12 7 1 7 18 18 18 18 6 6 18 18 18 18...
output:
537535822
result:
ok answer is '537535822'
Test #77:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
500 20 1 18 18 19 18 19 2 18 18 2 18 6 6 19 18 9 18 6 6 1 18 1 6 18 19 18 18 18 19 1 19 19 15 6 18 1 19 13 18 10 19 19 6 18 19 19 18 15 18 19 6 18 18 19 15 18 18 1 18 18 18 18 18 1 6 19 18 18 18 19 19 18 6 18 6 18 18 19 18 19 19 18 18 18 18 18 6 19 18 18 18 19 18 19 18 18 18 18 2 19 11 18 18 18 6 18...
output:
505939107
result:
ok answer is '505939107'
Test #78:
score: 0
Accepted
time: 1ms
memory: 3548kb
input:
500 20 11 19 17 1 5 20 20 3 8 16 9 17 13 20 11 8 17 9 13 15 10 10 18 3 4 11 9 2 1 8 5 6 20 20 14 5 3 5 16 17 8 17 2 17 7 11 12 4 12 10 1 20 7 18 4 16 5 6 11 2 11 14 16 15 5 18 1 10 4 11 11 4 8 15 15 8 4 15 1 11 14 20 1 7 8 7 1 20 12 13 6 4 16 18 14 1 15 11 18 2 18 11 17 3 10 10 1 11 11 17 17 7 2 6 6...
output:
299282126
result:
ok answer is '299282126'
Test #79:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
500 20 19 17 19 13 13 7 20 11 16 18 8 4 17 11 3 19 17 12 18 8 17 2 2 5 14 7 6 4 15 3 4 10 18 15 4 2 7 18 12 16 14 15 18 4 5 7 1 12 19 3 12 12 11 5 6 8 9 15 17 14 14 20 14 15 4 12 19 7 7 15 20 20 16 16 19 17 5 1 19 8 1 5 14 19 20 10 7 3 3 11 6 2 7 5 4 10 16 10 9 1 13 9 20 9 2 12 4 3 6 8 12 13 19 8 8 ...
output:
639893943
result:
ok answer is '639893943'
Test #80:
score: 0
Accepted
time: 1ms
memory: 3568kb
input:
500 20 12 5 4 10 10 19 8 1 18 16 16 17 16 13 3 11 14 1 1 2 14 6 7 20 13 9 4 5 9 20 11 19 1 15 8 12 11 16 1 15 19 1 2 8 9 18 9 19 2 8 1 7 11 7 5 15 15 9 18 3 20 17 7 2 16 10 11 8 19 6 14 10 5 20 4 3 6 14 19 9 9 8 19 7 15 11 13 4 15 20 17 7 16 5 16 1 2 17 6 18 14 18 1 17 19 15 7 10 16 10 19 5 17 18 17...
output:
900646697
result:
ok answer is '900646697'
Test #81:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
500 20 11 15 9 16 7 5 10 3 10 5 15 19 9 15 6 8 8 11 13 17 4 12 15 3 4 1 4 14 1 20 7 8 7 13 11 1 1 3 18 5 2 20 12 4 16 6 3 15 8 6 20 4 10 1 5 17 11 14 10 11 19 5 4 19 19 7 17 11 7 16 11 12 4 9 12 11 18 16 20 7 19 3 17 11 7 14 6 8 6 2 11 19 4 4 18 4 16 14 5 12 10 13 3 1 6 18 14 13 15 8 20 13 10 5 3 12...
output:
979272254
result:
ok answer is '979272254'
Test #82:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
500 40 33 12 12 40 12 12 33 27 37 38 8 12 12 2 38 12 33 32 8 37 12 12 7 2 38 4 30 12 12 3 22 16 8 12 33 16 38 26 2 16 12 40 16 12 12 18 18 16 32 30 2 8 12 2 16 16 37 12 16 2 12 40 38 32 12 18 2 12 8 37 33 16 38 38 12 18 12 16 2 16 12 12 33 2 21 8 18 16 12 2 38 8 12 16 2 12 33 16 8 8 16 37 40 12 12 3...
output:
704934301
result:
ok answer is '704934301'
Test #83:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
500 40 5 9 23 7 23 35 2 33 27 9 5 5 27 30 2 40 27 40 2 27 7 27 7 2 7 27 22 2 27 2 5 22 27 22 34 2 22 27 9 27 40 22 22 2 27 2 27 27 23 17 7 22 38 23 27 27 2 22 2 27 2 5 23 2 27 23 7 40 23 27 27 27 22 7 5 2 2 2 2 2 2 2 25 22 22 22 22 27 7 24 30 27 38 7 39 40 22 2 5 25 5 7 22 7 22 10 2 2 40 28 2 22 2 2...
output:
674540769
result:
ok answer is '674540769'
Test #84:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
500 40 31 24 31 11 1 32 13 2 15 32 5 23 22 6 27 31 30 1 30 28 22 28 26 40 39 11 7 4 16 1 6 8 1 19 9 24 7 22 8 13 8 2 2 1 21 17 29 13 24 14 32 23 36 10 32 3 34 14 6 13 12 17 25 12 7 4 11 26 38 16 5 3 38 19 9 25 24 9 3 39 33 10 7 20 5 32 29 15 4 17 22 4 40 39 3 33 12 2 35 17 15 23 30 28 39 7 10 38 21 ...
output:
329732263
result:
ok answer is '329732263'
Test #85:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
500 40 40 7 7 1 28 4 34 21 15 27 32 12 18 9 9 19 17 21 8 17 18 13 19 24 16 22 31 23 40 22 17 13 39 19 4 24 31 38 15 12 14 16 40 7 16 37 40 4 18 26 17 4 16 25 39 37 20 3 31 14 30 38 39 32 22 39 25 36 23 32 14 33 19 15 1 11 13 24 34 39 35 33 35 19 17 37 20 34 20 25 25 38 33 30 29 30 35 11 23 28 22 21 ...
output:
754219638
result:
ok answer is '754219638'
Test #86:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
500 40 33 32 25 8 23 8 34 25 16 8 5 25 16 35 9 5 6 1 10 16 17 38 22 25 23 5 5 36 34 7 24 32 1 38 14 2 3 15 4 35 16 36 3 13 22 20 29 27 40 36 24 8 26 21 39 15 1 23 36 22 31 10 12 29 32 6 1 15 40 7 37 14 31 32 40 39 1 19 7 1 1 21 35 6 16 4 38 6 13 4 35 12 12 11 28 6 3 38 15 40 17 10 32 24 18 15 7 17 2...
output:
843957197
result:
ok answer is '843957197'
Test #87:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
500 40 36 17 20 3 18 36 6 28 8 29 2 10 9 9 29 24 8 13 21 29 25 8 18 10 10 2 7 18 36 18 38 12 39 32 28 1 34 7 14 15 11 25 35 39 18 24 37 23 3 9 12 29 10 20 32 25 22 1 5 8 17 22 14 34 19 27 30 22 6 35 30 38 4 31 39 25 9 4 9 16 36 40 11 18 10 16 24 24 6 9 1 35 3 20 37 25 40 10 25 1 12 25 25 18 17 37 8 ...
output:
348483675
result:
ok answer is '348483675'
Test #88:
score: 0
Accepted
time: 1ms
memory: 3628kb
input:
500 50 5 2 46 7 2 5 7 3 20 30 5 28 2 33 7 35 2 35 14 5 46 7 35 35 7 7 20 20 7 5 36 28 35 4 8 34 30 35 25 5 2 36 36 7 2 2 20 27 7 43 35 5 2 45 20 7 7 5 2 2 7 20 46 23 14 33 20 5 5 7 7 20 20 13 25 2 7 7 34 7 7 20 36 5 7 35 7 10 23 2 7 34 20 14 35 46 20 5 5 5 5 7 25 5 2 5 5 2 7 7 35 2 34 5 36 2 36 25 7...
output:
609417022
result:
ok answer is '609417022'
Test #89:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
500 50 25 14 3 3 18 14 36 18 22 3 18 11 23 37 22 39 22 37 3 6 31 22 22 17 3 23 22 22 23 3 26 30 3 46 18 17 22 6 22 30 30 2 22 3 3 22 23 48 18 17 30 22 23 22 6 22 14 6 15 22 23 17 36 22 22 3 17 3 14 20 30 18 18 3 3 3 23 3 23 14 18 17 23 37 22 39 6 30 3 23 6 39 6 3 3 23 30 17 17 6 30 17 27 15 22 30 3 ...
output:
477945404
result:
ok answer is '477945404'
Test #90:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
500 50 18 15 28 10 24 7 16 36 49 2 25 14 17 6 40 4 30 20 26 29 30 40 24 42 21 50 7 37 43 18 48 8 4 27 29 30 26 32 11 31 43 15 10 17 14 28 48 31 38 14 37 49 33 19 5 1 32 12 46 24 9 9 47 15 29 8 13 13 46 11 9 1 12 21 37 1 36 30 22 25 45 37 1 43 16 29 11 16 2 17 41 46 43 30 34 42 18 42 23 45 15 10 13 2...
output:
777701638
result:
ok answer is '777701638'
Test #91:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
500 50 44 23 9 8 47 21 35 45 42 12 2 23 24 25 49 32 27 47 4 1 24 3 27 45 13 15 15 28 29 42 37 18 26 48 23 8 16 33 7 32 25 34 25 21 50 5 40 23 14 10 22 11 14 13 30 27 30 38 28 21 25 12 37 39 40 11 7 23 6 27 7 3 18 1 10 13 34 16 9 4 39 1 44 3 8 35 2 18 31 34 10 22 49 10 16 22 20 17 41 14 7 3 29 29 19 ...
output:
731977280
result:
ok answer is '731977280'
Test #92:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
500 50 17 29 35 42 26 47 10 38 50 18 14 3 17 20 50 45 18 3 4 13 15 26 36 15 3 48 13 4 40 41 36 33 35 17 25 24 24 26 14 23 31 22 17 13 7 26 22 7 35 26 50 2 13 41 28 6 24 43 43 38 11 29 38 12 5 44 28 26 45 22 7 27 9 36 19 35 17 2 28 39 28 2 36 3 6 34 36 48 9 16 36 26 30 19 35 30 38 35 41 14 50 38 21 3...
output:
794540368
result:
ok answer is '794540368'
Test #93:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
500 50 45 7 25 48 8 48 12 11 46 13 50 27 17 37 46 31 21 34 25 46 33 2 49 47 6 9 8 24 34 45 37 17 26 24 40 6 36 5 32 26 47 7 45 28 21 7 39 26 11 36 7 44 26 46 10 39 35 1 44 18 30 36 45 12 26 2 10 34 47 49 21 41 49 33 2 48 42 32 40 24 11 13 4 8 25 44 7 37 43 35 9 50 37 12 7 48 33 18 12 33 38 12 39 15 ...
output:
719351656
result:
ok answer is '719351656'
Test #94:
score: -100
Wrong Answer
time: 3ms
memory: 3772kb
input:
5000 5 2 4 4 4 2 5 4 4 2 4 4 4 4 4 4 4 4 3 2 2 4 2 4 4 2 4 4 4 4 4 4 4 3 4 4 2 3 4 4 4 4 4 4 2 2 4 2 4 2 4 2 4 4 4 2 4 4 4 4 4 4 4 4 4 4 4 2 4 4 2 4 4 4 4 4 4 4 4 2 5 4 4 2 2 4 4 4 4 4 4 4 2 4 4 4 4 2 4 4 4 4 3 4 4 2 4 4 4 2 4 4 4 2 3 4 2 2 4 4 4 4 3 4 4 2 2 2 2 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 4 4...
output:
954143578
result:
wrong answer expected '572500849', found '954143578'