QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#620544 | #9444. Again Permutation Problem | maspy | AC ✓ | 40ms | 4176kb | C++20 | 22.9kb | 2024-10-07 19:06:52 | 2024-10-07 19:06:53 |
Judging History
answer
#line 1 "/home/maspy/compro/library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
// https://codeforces.com/blog/entry/96344
#pragma GCC optimize("Ofast,unroll-loops")
// いまの CF だとこれ入れると動かない?
// #pragma GCC target("avx2,popcnt")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;
template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'010'000'000;
template <>
constexpr ll infty<ll> = 2'020'000'000'000'000'000;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * 2'000'000'000'000'000'000;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;
using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)
#define FOR_subset(t, s) for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define stoi stoll
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
template <typename T>
T floor(T a, T b) {
return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
T q = floor(x, y);
return {q, x - q * y};
}
template <typename T, typename U>
T SUM(const vector<U> &A) {
T sm = 0;
for (auto &&a: A) sm += a;
return sm;
}
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()
template <typename T>
T POP(deque<T> &que) {
T a = que.front();
que.pop_front();
return a;
}
template <typename T>
T POP(pq<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(pqg<T> &que) {
T a = que.top();
que.pop();
return a;
}
template <typename T>
T POP(vc<T> &que) {
T a = que.back();
que.pop_back();
return a;
}
template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
if (check_ok) assert(check(ok));
while (abs(ok - ng) > 1) {
auto x = (ng + ok) / 2;
(check(x) ? ok : ng) = x;
}
return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
FOR(iter) {
double x = (ok + ng) / 2;
(check(x) ? ok : ng) = x;
}
return (ok + ng) / 2;
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
return (a > b ? a = b, 1 : 0);
}
// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
vc<int> A(S.size());
FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
return A;
}
template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
int N = A.size();
vector<T> B(N + 1);
FOR(i, N) { B[i + 1] = B[i] + A[i]; }
if (off == 0) B.erase(B.begin());
return B;
}
// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
vector<int> ids(len(A));
iota(all(ids), 0);
sort(all(ids), [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
return ids;
}
// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
vc<T> B(len(I));
FOR(i, len(I)) B[i] = A[I[i]];
return B;
}
template <typename T, typename... Vectors>
void concat(vc<T> &first, const Vectors &... others) {
vc<T> &res = first;
(res.insert(res.end(), others.begin(), others.end()), ...);
}
#endif
#line 1 "/home/maspy/compro/library/other/io.hpp"
#define FASTIO
#include <unistd.h>
// https://judge.yosupo.jp/submission/21623
namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf
uint32_t pil = 0, pir = 0, por = 0;
struct Pre {
char num[10000][4];
constexpr Pre() : num() {
for (int i = 0; i < 10000; i++) {
int n = i;
for (int j = 3; j >= 0; j--) {
num[i][j] = n % 10 | '0';
n /= 10;
}
}
}
} constexpr pre;
inline void load() {
memcpy(ibuf, ibuf + pil, pir - pil);
pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
pil = 0;
if (pir < SZ) ibuf[pir++] = '\n';
}
inline void flush() {
fwrite(obuf, 1, por, stdout);
por = 0;
}
void rd(char &c) {
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
}
void rd(string &x) {
x.clear();
char c;
do {
if (pil + 1 > pir) load();
c = ibuf[pil++];
} while (isspace(c));
do {
x += c;
if (pil == pir) load();
c = ibuf[pil++];
} while (!isspace(c));
}
template <typename T>
void rd_real(T &x) {
string s;
rd(s);
x = stod(s);
}
template <typename T>
void rd_integer(T &x) {
if (pil + 100 > pir) load();
char c;
do
c = ibuf[pil++];
while (c < '-');
bool minus = 0;
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (c == '-') { minus = 1, c = ibuf[pil++]; }
}
x = 0;
while ('0' <= c) { x = x * 10 + (c & 15), c = ibuf[pil++]; }
if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
if (minus) x = -x;
}
}
void rd(int &x) { rd_integer(x); }
void rd(ll &x) { rd_integer(x); }
void rd(i128 &x) { rd_integer(x); }
void rd(u32 &x) { rd_integer(x); }
void rd(u64 &x) { rd_integer(x); }
void rd(u128 &x) { rd_integer(x); }
void rd(double &x) { rd_real(x); }
void rd(long double &x) { rd_real(x); }
void rd(f128 &x) { rd_real(x); }
template <class T, class U>
void rd(pair<T, U> &p) {
return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T>
void rd_tuple(T &t) {
if constexpr (N < std::tuple_size<T>::value) {
auto &x = std::get<N>(t);
rd(x);
rd_tuple<N + 1>(t);
}
}
template <class... T>
void rd(tuple<T...> &tpl) {
rd_tuple(tpl);
}
template <size_t N = 0, typename T>
void rd(array<T, N> &x) {
for (auto &d: x) rd(d);
}
template <class T>
void rd(vc<T> &x) {
for (auto &d: x) rd(d);
}
void read() {}
template <class H, class... T>
void read(H &h, T &... t) {
rd(h), read(t...);
}
void wt(const char c) {
if (por == SZ) flush();
obuf[por++] = c;
}
void wt(const string s) {
for (char c: s) wt(c);
}
void wt(const char *s) {
size_t len = strlen(s);
for (size_t i = 0; i < len; i++) wt(s[i]);
}
template <typename T>
void wt_integer(T x) {
if (por > SZ - 100) flush();
if (x < 0) { obuf[por++] = '-', x = -x; }
int outi;
for (outi = 96; x >= 10000; outi -= 4) {
memcpy(out + outi, pre.num[x % 10000], 4);
x /= 10000;
}
if (x >= 1000) {
memcpy(obuf + por, pre.num[x], 4);
por += 4;
} else if (x >= 100) {
memcpy(obuf + por, pre.num[x] + 1, 3);
por += 3;
} else if (x >= 10) {
int q = (x * 103) >> 10;
obuf[por] = q | '0';
obuf[por + 1] = (x - q * 10) | '0';
por += 2;
} else
obuf[por++] = x | '0';
memcpy(obuf + por, out + outi + 4, 96 - outi);
por += 96 - outi;
}
template <typename T>
void wt_real(T x) {
ostringstream oss;
oss << fixed << setprecision(15) << double(x);
string s = oss.str();
wt(s);
}
void wt(int x) { wt_integer(x); }
void wt(ll x) { wt_integer(x); }
void wt(i128 x) { wt_integer(x); }
void wt(u32 x) { wt_integer(x); }
void wt(u64 x) { wt_integer(x); }
void wt(u128 x) { wt_integer(x); }
void wt(double x) { wt_real(x); }
void wt(long double x) { wt_real(x); }
void wt(f128 x) { wt_real(x); }
template <class T, class U>
void wt(const pair<T, U> val) {
wt(val.first);
wt(' ');
wt(val.second);
}
template <size_t N = 0, typename T>
void wt_tuple(const T t) {
if constexpr (N < std::tuple_size<T>::value) {
if constexpr (N > 0) { wt(' '); }
const auto x = std::get<N>(t);
wt(x);
wt_tuple<N + 1>(t);
}
}
template <class... T>
void wt(tuple<T...> tpl) {
wt_tuple(tpl);
}
template <class T, size_t S>
void wt(const array<T, S> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
template <class T>
void wt(const vector<T> val) {
auto n = val.size();
for (size_t i = 0; i < n; i++) {
if (i) wt(' ');
wt(val[i]);
}
}
void print() { wt('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
wt(head);
if (sizeof...(Tail)) wt(' ');
print(forward<Tail>(tail)...);
}
// gcc expansion. called automaticall after main.
void __attribute__((destructor)) _d() { flush(); }
} // namespace fastio
using fastio::read;
using fastio::print;
using fastio::flush;
#if defined(LOCAL)
#define SHOW(...) SHOW_IMPL(__VA_ARGS__, SHOW6, SHOW5, SHOW4, SHOW3, SHOW2, SHOW1)(__VA_ARGS__)
#define SHOW_IMPL(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define SHOW1(x) print(#x, "=", (x)), flush()
#define SHOW2(x, y) print(#x, "=", (x), #y, "=", (y)), flush()
#define SHOW3(x, y, z) print(#x, "=", (x), #y, "=", (y), #z, "=", (z)), flush()
#define SHOW4(x, y, z, w) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w)), flush()
#define SHOW5(x, y, z, w, v) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v)), flush()
#define SHOW6(x, y, z, w, v, u) print(#x, "=", (x), #y, "=", (y), #z, "=", (z), #w, "=", (w), #v, "=", (v), #u, "=", (u)), flush()
#else
#define SHOW(...)
#endif
#define INT(...) \
int __VA_ARGS__; \
read(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
read(__VA_ARGS__)
#define U32(...) \
u32 __VA_ARGS__; \
read(__VA_ARGS__)
#define U64(...) \
u64 __VA_ARGS__; \
read(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
read(__VA_ARGS__)
#define CHAR(...) \
char __VA_ARGS__; \
read(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
read(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
read(name)
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
read(name)
void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"
#line 1 "/home/maspy/compro/library/seq/permutation_group_basis.hpp"
// https://codeforces.com/blog/entry/111290
// https://codeforces.com/gym/421334/problem/A
// https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_j
template <int NMAX>
struct Permutation_Group_Basis {
using A = array<u8, NMAX>;
int n;
// Basis[i]: i 未満は固定して i を動かす部分
// 作れる群:g=g[0]g[1]...g[n-1]
// g[i]: i 未満を固定して i を動かす写像
// g から g[i] を復元するには,小さい i から順に決める
vvc<A> Basis;
// q := p
void cp(int lv, const A& p, A& q) { FOR(i, lv, n) q[i] = p[i]; }
// r := pq
void op(int lv, const A& p, A& q, A& r) { FOR(i, lv, n) r[i] = p[q[i]]; }
// q := inv(p)
void inv(int lv, const A& p, A& q) { FOR(i, lv, n) q[p[i]] = i; }
// N^2 個以下生成元を sims filter で管理
struct S {
int n, lv;
A dat[NMAX][NMAX];
A idat[NMAX][NMAX];
bool exist[NMAX][NMAX];
S(int n, int lv) : n(n), lv(lv) { FOR(i, NMAX) FOR(j, NMAX) exist[i][j] = 0; }
void cp(int lv, const A& p, A& q) { FOR(i, lv, n) q[i] = p[i]; }
void op(int lv, const A& p, A& q, A& r) { FOR(i, lv, n) r[i] = p[q[i]]; }
void inv(int lv, const A& p, A& q) { FOR(i, lv, n) q[p[i]] = i; }
void add(A& p) {
static A tmp;
FOR(i, lv, n) {
if (p[i] == i) continue;
if (!exist[i][p[i]]) {
cp(i, p, dat[i][p[i]]);
inv(i, p, idat[i][p[i]]);
exist[i][p[i]] = 1;
break;
}
op(i, idat[i][p[i]], p, tmp);
cp(i, tmp, p);
}
}
vc<A> get_all() {
vc<A> ANS;
FOR(i, lv, n) {
FOR(j, i, n) {
if (!exist[i][j]) continue;
A a = dat[i][j];
FOR(k, i) a[k] = k;
ANS.eb(a);
}
}
return ANS;
}
};
Permutation_Group_Basis(int n, vvc<int> generator) : n(n), Basis(n) {
S gen(n, 0);
for (auto& pp: generator) {
assert(len(pp) == n);
A a;
FOR(i, n) a[i] = pp[i];
gen.add(a);
}
FOR(lv, n) gen = step(gen);
}
private:
S step(S gen) {
auto X = gen.get_all();
int lv = gen.lv;
vc<A> basis(n);
vc<A> ibasis(n);
vc<bool> vis(n);
auto dfs = [&](auto& dfs, int v) -> void {
auto& p = basis[v];
for (auto& q: X) {
int w = q[v];
if (vis[w]) continue;
vis[w] = 1;
op(lv, q, p, basis[w]);
inv(lv, basis[w], ibasis[w]);
dfs(dfs, w);
}
};
vis[lv] = 1;
FOR(i, n) basis[lv][i] = ibasis[lv][i] = i;
dfs(dfs, lv);
S nxtgen(n, lv + 1);
static A tmp, tmp2;
FOR(u, lv, n) {
if (!vis[u]) continue;
FOR(i, lv) basis[u][i] = i;
Basis[lv].eb(basis[u]);
for (auto& s: X) {
assert(vis[s[u]]);
op(lv, ibasis[s[u]], s, tmp);
op(lv, tmp, basis[u], tmp2);
assert(tmp2[lv] == lv);
nxtgen.add(tmp2);
}
}
return nxtgen;
}
};
#line 2 "/home/maspy/compro/library/mod/modint_common.hpp"
struct has_mod_impl {
template <class T>
static auto check(T &&x) -> decltype(x.get_mod(), std::true_type{});
template <class T>
static auto check(...) -> std::false_type;
};
template <class T>
class has_mod : public decltype(has_mod_impl::check<T>(std::declval<T>())) {};
template <typename mint>
mint inv(int n) {
static const int mod = mint::get_mod();
static vector<mint> dat = {0, 1};
assert(0 <= n);
if (n >= mod) n %= mod;
while (len(dat) <= n) {
int k = len(dat);
int q = (mod + k - 1) / k;
dat.eb(dat[k * q - mod] * mint::raw(q));
}
return dat[n];
}
template <typename mint>
mint fact(int n) {
static const int mod = mint::get_mod();
assert(0 <= n && n < mod);
static vector<mint> dat = {1, 1};
while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * mint::raw(len(dat)));
return dat[n];
}
template <typename mint>
mint fact_inv(int n) {
static vector<mint> dat = {1, 1};
if (n < 0) return mint(0);
while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * inv<mint>(len(dat)));
return dat[n];
}
template <class mint, class... Ts>
mint fact_invs(Ts... xs) {
return (mint(1) * ... * fact_inv<mint>(xs));
}
template <typename mint, class Head, class... Tail>
mint multinomial(Head &&head, Tail &&... tail) {
return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...);
}
template <typename mint>
mint C_dense(int n, int k) {
static vvc<mint> C;
static int H = 0, W = 0;
auto calc = [&](int i, int j) -> mint {
if (i == 0) return (j == 0 ? mint(1) : mint(0));
return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0);
};
if (W <= k) {
FOR(i, H) {
C[i].resize(k + 1);
FOR(j, W, k + 1) { C[i][j] = calc(i, j); }
}
W = k + 1;
}
if (H <= n) {
C.resize(n + 1);
FOR(i, H, n + 1) {
C[i].resize(W);
FOR(j, W) { C[i][j] = calc(i, j); }
}
H = n + 1;
}
return C[n][k];
}
template <typename mint, bool large = false, bool dense = false>
mint C(ll n, ll k) {
assert(n >= 0);
if (k < 0 || n < k) return 0;
if constexpr (dense) return C_dense<mint>(n, k);
if constexpr (!large) return multinomial<mint>(n, k, n - k);
k = min(k, n - k);
mint x(1);
FOR(i, k) x *= mint(n - i);
return x * fact_inv<mint>(k);
}
template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
assert(n >= 0);
assert(0 <= k && k <= n);
if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
return mint(1) / C<mint, 1>(n, k);
}
// [x^d](1-x)^{-n}
template <typename mint, bool large = false, bool dense = false>
mint C_negative(ll n, ll d) {
assert(n >= 0);
if (d < 0) return mint(0);
if (n == 0) { return (d == 0 ? mint(1) : mint(0)); }
return C<mint, large, dense>(n + d - 1, d);
}
#line 3 "/home/maspy/compro/library/mod/modint.hpp"
template <int mod>
struct modint {
static constexpr u32 umod = u32(mod);
static_assert(umod < u32(1) << 31);
u32 val;
static modint raw(u32 v) {
modint x;
x.val = v;
return x;
}
constexpr modint() : val(0) {}
constexpr modint(u32 x) : val(x % umod) {}
constexpr modint(u64 x) : val(x % umod) {}
constexpr modint(u128 x) : val(x % umod) {}
constexpr modint(int x) : val((x %= mod) < 0 ? x + mod : x){};
constexpr modint(ll x) : val((x %= mod) < 0 ? x + mod : x){};
constexpr modint(i128 x) : val((x %= mod) < 0 ? x + mod : x){};
bool operator<(const modint &other) const { return val < other.val; }
modint &operator+=(const modint &p) {
if ((val += p.val) >= umod) val -= umod;
return *this;
}
modint &operator-=(const modint &p) {
if ((val += umod - p.val) >= umod) val -= umod;
return *this;
}
modint &operator*=(const modint &p) {
val = u64(val) * p.val % umod;
return *this;
}
modint &operator/=(const modint &p) {
*this *= p.inverse();
return *this;
}
modint operator-() const { return modint::raw(val ? mod - val : u32(0)); }
modint operator+(const modint &p) const { return modint(*this) += p; }
modint operator-(const modint &p) const { return modint(*this) -= p; }
modint operator*(const modint &p) const { return modint(*this) *= p; }
modint operator/(const modint &p) const { return modint(*this) /= p; }
bool operator==(const modint &p) const { return val == p.val; }
bool operator!=(const modint &p) const { return val != p.val; }
modint inverse() const {
int a = val, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b), swap(u -= t * v, v);
}
return modint(u);
}
modint pow(ll n) const {
assert(n >= 0);
modint ret(1), mul(val);
while (n > 0) {
if (n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
static constexpr int get_mod() { return mod; }
// (n, r), r は 1 の 2^n 乗根
static constexpr pair<int, int> ntt_info() {
if (mod == 120586241) return {20, 74066978};
if (mod == 167772161) return {25, 17};
if (mod == 469762049) return {26, 30};
if (mod == 754974721) return {24, 362};
if (mod == 880803841) return {23, 211};
if (mod == 943718401) return {22, 663003469};
if (mod == 998244353) return {23, 31};
if (mod == 1004535809) return {21, 836905998};
if (mod == 1045430273) return {20, 363};
if (mod == 1051721729) return {20, 330};
if (mod == 1053818881) return {20, 2789};
return {-1, -1};
}
static constexpr bool can_ntt() { return ntt_info().fi != -1; }
};
#ifdef FASTIO
template <int mod>
void rd(modint<mod> &x) {
fastio::rd(x.val);
x.val %= mod;
// assert(0 <= x.val && x.val < mod);
}
template <int mod>
void wt(modint<mod> x) {
fastio::wt(x.val);
}
#endif
using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
#line 6 "main.cpp"
using mint = modint998;
void solve() {
LL(N, M);
VV(int, A, M, N);
FOR(i, M) FOR(j, N)-- A[i][j];
Permutation_Group_Basis<30> P(N, A);
mint ANS = 0;
// FOR(i, N) {
// for (auto& X: P.Basis[i]) { SHOW(i, X); }
// }
FOR(a, N) {
// (a, a より大きい要素) の場所を追跡
vv(mint, dp, N, N);
FOR(b, a + 1, N) dp[a][b] = 1;
FOR_R(i, N) {
vv(mint, newdp, N, N);
for (auto& X: P.Basis[i]) {
FOR(a, N) FOR(b, N) { newdp[X[a]][X[b]] += dp[a][b]; }
}
swap(dp, newdp);
}
FOR(i, N) FOR(j, i) ANS += dp[i][j];
}
print(ANS);
}
signed main() {
int T = 1;
// INT(T);
FOR(T) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
3 2 1 2 3 2 3 1
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
5 2 3 4 5 1 2 1 5 4 3 2
output:
50
result:
ok 1 number(s): "50"
Test #3:
score: 0
Accepted
time: 40ms
memory: 3880kb
input:
30 12 1 2 9 4 5 6 7 8 3 10 11 12 19 14 15 25 17 18 20 26 21 22 23 24 16 29 27 28 13 30 9 2 27 4 5 10 7 8 1 25 11 12 24 14 15 16 17 18 19 20 21 22 23 28 6 26 3 13 29 30 1 5 3 29 2 6 7 8 9 10 11 12 13 16 15 18 17 14 19 20 21 22 28 27 25 26 24 23 4 30 7 2 3 25 5 6 1 28 21 15 11 12 13 14 10 17 16 18 19 ...
output:
701414999
result:
ok 1 number(s): "701414999"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
1 1 1
output:
0
result:
ok 1 number(s): "0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
2 1 2 1
output:
1
result:
ok 1 number(s): "1"
Test #6:
score: 0
Accepted
time: 0ms
memory: 4140kb
input:
5 1 4 2 3 1 5
output:
5
result:
ok 1 number(s): "5"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
6 3 4 2 3 6 5 1 1 4 3 2 6 5 1 2 4 3 5 6
output:
5400
result:
ok 1 number(s): "5400"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
6 1 1 5 3 4 2 6
output:
5
result:
ok 1 number(s): "5"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
5 3 1 4 3 2 5 1 2 4 5 3 5 2 3 4 1
output:
600
result:
ok 1 number(s): "600"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
6 2 2 1 3 4 5 6 1 2 3 4 5 6
output:
1
result:
ok 1 number(s): "1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
6 4 1 6 3 4 5 2 2 1 4 3 5 6 2 6 5 4 3 1 2 1 6 3 5 4
output:
5400
result:
ok 1 number(s): "5400"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
5 2 3 2 1 4 5 1 5 3 2 4
output:
21
result:
ok 1 number(s): "21"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
3 3 1 3 2 3 1 2 1 3 2
output:
9
result:
ok 1 number(s): "9"
Test #14:
score: 0
Accepted
time: 0ms
memory: 4060kb
input:
4 2 3 1 4 2 4 2 1 3
output:
72
result:
ok 1 number(s): "72"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
3 1 2 3 1
output:
4
result:
ok 1 number(s): "4"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
5 1 2 4 3 5 1
output:
18
result:
ok 1 number(s): "18"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
5 4 3 5 2 4 1 1 2 5 4 3 5 4 3 2 1 4 2 3 1 5
output:
600
result:
ok 1 number(s): "600"
Test #18:
score: 0
Accepted
time: 0ms
memory: 4136kb
input:
5 1 1 5 3 4 2
output:
5
result:
ok 1 number(s): "5"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
5 1 5 2 3 4 1
output:
7
result:
ok 1 number(s): "7"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
4 2 4 3 1 2 3 4 2 1
output:
12
result:
ok 1 number(s): "12"
Test #21:
score: 0
Accepted
time: 0ms
memory: 4136kb
input:
6 3 2 3 1 4 5 6 1 2 3 4 6 5 1 4 3 2 5 6
output:
168
result:
ok 1 number(s): "168"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
6 2 3 4 1 2 5 6 2 3 1 4 5 6
output:
36
result:
ok 1 number(s): "36"
Test #23:
score: 0
Accepted
time: 0ms
memory: 4056kb
input:
4 2 1 3 4 2 4 2 3 1
output:
72
result:
ok 1 number(s): "72"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 2 2 1 3 2 3 1
output:
9
result:
ok 1 number(s): "9"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3944kb
input:
6 2 1 5 4 6 2 3 2 6 4 3 5 1
output:
5400
result:
ok 1 number(s): "5400"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3904kb
input:
6 4 1 2 3 6 5 4 1 5 3 2 6 4 1 2 4 3 5 6 1 4 2 6 5 3
output:
600
result:
ok 1 number(s): "600"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
6 5 1 2 3 4 5 6 1 3 2 4 5 6 1 2 5 4 3 6 1 3 6 4 2 5 1 6 3 4 5 2
output:
120
result:
ok 1 number(s): "120"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3728kb
input:
6 2 1 6 3 5 4 2 4 2 3 1 5 6
output:
84
result:
ok 1 number(s): "84"
Test #29:
score: 0
Accepted
time: 0ms
memory: 4144kb
input:
6 5 2 1 5 4 3 6 1 6 3 4 5 2 1 2 5 4 6 3 1 2 6 4 5 3 6 2 4 3 5 1
output:
5400
result:
ok 1 number(s): "5400"
Test #30:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
6 1 3 6 1 4 5 2
output:
8
result:
ok 1 number(s): "8"
Test #31:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
6 3 1 2 3 4 6 5 6 2 4 3 1 5 6 2 3 4 5 1
output:
72
result:
ok 1 number(s): "72"
Test #32:
score: 0
Accepted
time: 0ms
memory: 4108kb
input:
6 4 1 2 3 6 5 4 6 2 3 4 5 1 6 1 3 4 5 2 1 5 6 4 2 3
output:
5400
result:
ok 1 number(s): "5400"
Test #33:
score: 0
Accepted
time: 0ms
memory: 4136kb
input:
6 3 1 2 6 4 5 3 2 1 3 4 5 6 1 5 3 4 2 6
output:
72
result:
ok 1 number(s): "72"
Test #34:
score: 0
Accepted
time: 0ms
memory: 4104kb
input:
6 5 3 2 6 4 5 1 1 4 3 6 5 2 1 2 4 3 5 6 1 2 4 3 5 6 4 2 1 5 3 6
output:
5400
result:
ok 1 number(s): "5400"
Test #35:
score: 0
Accepted
time: 1ms
memory: 4136kb
input:
6 6 1 5 3 4 2 6 2 6 3 4 5 1 2 6 3 5 4 1 2 1 3 4 5 6 6 2 1 4 5 3 1 5 4 3 2 6
output:
5400
result:
ok 1 number(s): "5400"
Test #36:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
6 30 5 2 6 4 1 3 1 3 5 2 4 6 1 6 3 4 5 2 6 5 3 4 2 1 1 4 3 2 5 6 4 2 6 1 3 5 3 2 6 4 5 1 6 2 3 4 5 1 6 1 3 5 4 2 4 5 3 1 2 6 2 6 1 4 5 3 1 2 3 6 5 4 1 2 6 4 5 3 6 2 3 4 5 1 2 5 3 4 1 6 1 2 3 5 4 6 1 6 4 5 3 2 1 4 3 5 2 6 1 2 4 3 5 6 1 2 3 4 5 6 3 1 2 4 5 6 1 3 6 4 2 5 1 2 3 4 5 6 1 3 2 4 5 6 1 3 5 4...
output:
5400
result:
ok 1 number(s): "5400"
Test #37:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
6 30 1 5 3 4 2 6 1 4 5 2 3 6 3 5 2 4 1 6 1 6 3 2 4 5 6 3 4 2 5 1 6 2 3 4 5 1 1 2 6 4 5 3 1 5 3 4 2 6 1 2 4 6 5 3 1 5 3 6 2 4 4 2 6 1 5 3 1 4 3 2 5 6 1 2 6 4 5 3 2 6 3 4 5 1 4 2 3 1 5 6 1 2 3 4 5 6 1 2 4 3 5 6 1 3 2 5 4 6 1 2 3 4 5 6 5 2 3 4 1 6 6 2 1 4 5 3 4 2 3 1 5 6 2 5 3 4 1 6 4 2 3 1 5 6 4 2 3 5...
output:
5400
result:
ok 1 number(s): "5400"
Test #38:
score: 0
Accepted
time: 0ms
memory: 4140kb
input:
6 30 1 5 3 4 6 2 1 3 4 5 2 6 1 4 3 2 5 6 1 3 4 2 5 6 1 6 5 2 3 4 1 2 3 5 4 6 2 1 3 6 5 4 5 1 2 4 3 6 3 2 5 1 4 6 1 3 2 4 5 6 2 1 3 4 5 6 1 3 2 4 5 6 1 4 5 6 3 2 2 1 3 4 5 6 1 3 5 4 6 2 2 1 3 4 5 6 5 6 3 4 1 2 3 4 1 2 5 6 1 6 3 4 5 2 3 1 6 4 5 2 1 2 6 3 5 4 3 4 1 2 5 6 4 2 3 1 5 6 1 2 3 4 5 6 1 2 3 6...
output:
5400
result:
ok 1 number(s): "5400"
Test #39:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
6 30 6 2 4 3 5 1 4 2 3 1 5 6 6 2 3 4 5 1 3 2 4 6 5 1 5 3 6 4 1 2 1 2 3 5 4 6 1 2 4 3 5 6 5 6 3 2 1 4 2 1 3 4 6 5 1 2 3 5 4 6 1 2 5 4 3 6 4 2 5 1 3 6 4 2 3 5 1 6 1 2 3 5 4 6 1 6 3 5 4 2 6 2 3 4 5 1 6 5 3 4 2 1 5 6 4 3 1 2 1 6 5 4 3 2 2 3 1 4 5 6 1 2 3 5 4 6 1 4 6 2 5 3 1 4 3 5 2 6 1 6 4 3 5 2 1 6 3 4...
output:
5400
result:
ok 1 number(s): "5400"
Test #40:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
6 30 1 6 3 4 2 5 1 2 3 4 6 5 6 2 5 4 1 3 1 2 5 4 3 6 6 2 5 4 3 1 1 6 3 4 5 2 1 6 2 4 5 3 2 1 3 4 5 6 1 2 3 4 5 6 1 4 3 2 5 6 5 2 3 4 1 6 1 4 5 2 3 6 6 2 1 4 5 3 1 5 3 4 2 6 2 1 6 4 5 3 1 3 2 4 6 5 5 1 3 4 2 6 3 2 4 1 5 6 1 3 6 2 5 4 2 5 3 4 1 6 1 2 3 5 4 6 1 2 5 4 3 6 1 2 6 4 5 3 2 4 6 1 5 3 5 2 3 6...
output:
5400
result:
ok 1 number(s): "5400"
Test #41:
score: 0
Accepted
time: 1ms
memory: 3892kb
input:
6 30 1 3 2 5 4 6 4 2 6 1 5 3 1 2 4 6 5 3 4 2 3 1 6 5 1 6 3 4 2 5 3 4 1 2 5 6 1 5 3 2 4 6 3 2 5 4 1 6 1 2 3 4 5 6 1 6 3 4 2 5 4 2 6 1 5 3 4 1 3 2 5 6 4 2 5 1 3 6 1 6 3 2 5 4 4 5 3 1 2 6 5 2 3 1 4 6 3 1 2 4 5 6 1 6 2 4 5 3 3 2 6 4 5 1 4 2 3 6 5 1 1 2 3 5 6 4 1 2 3 4 5 6 1 2 3 4 5 6 3 2 5 4 1 6 1 2 3 4...
output:
2700
result:
ok 1 number(s): "2700"
Test #42:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
6 30 2 4 3 1 5 6 2 4 3 1 5 6 2 5 3 4 1 6 3 5 1 4 2 6 1 2 3 5 6 4 1 3 6 4 5 2 1 4 5 2 3 6 1 2 3 5 6 4 1 4 3 5 2 6 2 3 1 4 5 6 3 2 1 6 5 4 3 2 1 5 4 6 6 1 3 4 5 2 3 2 6 4 5 1 1 2 6 3 5 4 1 5 3 2 4 6 5 1 3 4 2 6 3 1 2 4 5 6 3 4 1 2 5 6 1 4 3 5 2 6 4 2 3 6 5 1 5 1 3 4 2 6 1 5 3 2 4 6 4 3 2 1 5 6 2 3 1 4...
output:
2700
result:
ok 1 number(s): "2700"
Test #43:
score: 0
Accepted
time: 1ms
memory: 3944kb
input:
6 30 6 2 3 5 4 1 1 3 4 2 5 6 1 3 6 4 5 2 5 2 3 6 1 4 3 5 1 4 2 6 3 1 2 4 5 6 1 2 4 3 6 5 1 6 3 2 5 4 3 2 5 4 1 6 4 6 3 1 5 2 4 2 3 5 1 6 1 2 5 3 4 6 2 3 1 4 5 6 1 2 6 3 5 4 2 4 3 1 5 6 1 2 3 4 5 6 3 2 4 1 5 6 4 2 3 1 6 5 5 2 3 6 1 4 1 6 3 4 2 5 1 3 5 4 2 6 6 2 3 4 1 5 3 2 6 4 5 1 5 2 4 3 1 6 1 3 6 4...
output:
2700
result:
ok 1 number(s): "2700"
Test #44:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
6 30 1 2 3 4 5 6 5 2 1 4 3 6 1 3 5 4 2 6 1 2 4 5 3 6 6 1 3 4 5 2 1 2 3 4 5 6 1 5 4 3 2 6 1 5 3 2 4 6 2 1 3 4 6 5 6 2 3 4 1 5 1 2 5 3 4 6 1 3 2 4 6 5 1 3 2 4 6 5 3 2 1 6 5 4 2 5 3 4 1 6 1 6 2 4 5 3 1 4 3 2 6 5 1 2 3 4 5 6 6 2 3 1 5 4 4 2 1 3 5 6 1 3 6 4 5 2 2 4 3 1 5 6 5 2 6 4 1 3 1 2 6 4 3 5 3 4 1 2...
output:
2700
result:
ok 1 number(s): "2700"
Test #45:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
6 30 1 4 3 2 6 5 2 1 4 3 5 6 1 4 3 5 2 6 1 3 4 2 5 6 1 3 5 4 2 6 4 1 3 2 5 6 1 6 4 3 5 2 4 2 6 1 5 3 4 1 3 2 5 6 3 1 2 4 5 6 5 3 2 4 1 6 1 6 3 2 5 4 1 5 2 4 3 6 1 6 3 5 4 2 3 1 2 4 5 6 1 3 4 2 5 6 1 2 5 3 4 6 1 2 3 4 5 6 3 2 5 4 1 6 2 1 3 5 4 6 4 6 3 1 5 2 2 3 1 4 5 6 5 2 1 4 3 6 1 2 5 3 4 6 1 4 6 2...
output:
2700
result:
ok 1 number(s): "2700"
Test #46:
score: 0
Accepted
time: 1ms
memory: 3976kb
input:
17 2 1 2 3 4 5 6 7 8 9 10 15 12 13 14 11 16 17 12 2 3 4 5 6 7 8 9 10 11 1 13 14 15 16 17
output:
54
result:
ok 1 number(s): "54"
Test #47:
score: 0
Accepted
time: 1ms
memory: 3904kb
input:
23 2 6 2 3 4 5 1 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1 20 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2 21 22 23
output:
86
result:
ok 1 number(s): "86"
Test #48:
score: 0
Accepted
time: 2ms
memory: 3924kb
input:
29 1 1 2 3 4 5 6 7 8 9 12 15 10 13 14 11 16 17 18 19 20 21 22 23 24 25 26 27 28 29
output:
8
result:
ok 1 number(s): "8"
Test #49:
score: 0
Accepted
time: 1ms
memory: 4148kb
input:
14 4 1 2 3 4 5 6 13 9 8 10 11 12 7 14 1 8 3 4 5 6 10 2 9 7 11 12 13 14 1 2 3 4 5 9 7 8 6 10 11 12 13 14 1 2 3 4 5 7 6 8 9 10 13 12 11 14
output:
846720
result:
ok 1 number(s): "846720"
Test #50:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
4 3 2 1 3 4 4 2 1 3 3 2 1 4
output:
72
result:
ok 1 number(s): "72"
Test #51:
score: 0
Accepted
time: 1ms
memory: 3852kb
input:
17 4 4 2 3 1 5 11 7 8 9 10 6 12 13 14 15 16 17 8 2 10 4 5 6 7 3 9 1 11 12 13 14 15 16 17 1 2 3 4 8 6 7 5 9 16 11 12 13 14 15 10 17 1 2 3 4 5 6 7 16 9 10 17 12 13 14 15 8 11
output:
1249920
result:
ok 1 number(s): "1249920"
Test #52:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
16 4 1 14 3 2 5 6 7 8 9 10 11 12 13 4 15 16 1 2 9 4 5 6 7 8 3 10 11 12 13 14 15 16 9 2 3 4 5 6 7 8 10 1 11 12 15 14 13 16 1 2 3 4 5 6 7 11 9 10 8 12 13 14 15 16
output:
8592
result:
ok 1 number(s): "8592"
Test #53:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
12 2 9 2 3 4 1 6 7 8 5 10 11 12 1 2 3 5 7 6 8 4 9 10 11 12
output:
9960
result:
ok 1 number(s): "9960"
Test #54:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
19 3 1 2 3 4 5 6 7 8 9 10 15 12 13 14 11 16 17 18 19 1 6 8 4 5 19 7 3 9 10 11 12 13 14 15 16 17 18 2 1 2 3 4 5 6 7 8 9 10 16 12 13 14 15 11 17 18 19
output:
1104
result:
ok 1 number(s): "1104"
Test #55:
score: 0
Accepted
time: 1ms
memory: 4104kb
input:
6 4 1 4 3 2 5 6 1 2 3 5 4 6 5 2 3 6 1 4 1 2 6 3 4 5
output:
5400
result:
ok 1 number(s): "5400"
Test #56:
score: 0
Accepted
time: 2ms
memory: 3852kb
input:
28 4 1 2 3 4 13 6 7 8 9 10 11 12 5 14 15 16 17 18 19 20 21 22 23 26 25 24 27 28 1 2 13 4 5 6 7 8 9 10 11 12 3 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 1 2 9 4 5 6 22 8 3 10 11 12 13 14 15 16 17 18 19 20 21 7 23 24 25 26 27 28 1 2 3 4 5 6 7 8 9 10 11 12 18 14 15 16 17 13 19 20 21 22 23 24 25 26 2...
output:
20256
result:
ok 1 number(s): "20256"
Test #57:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
23 2 1 2 3 4 5 6 7 8 9 10 17 12 21 14 15 16 11 18 19 20 13 22 23 1 14 3 4 5 6 12 8 9 10 11 7 13 2 15 16 17 19 18 20 21 22 23
output:
108
result:
ok 1 number(s): "108"
Test #58:
score: 0
Accepted
time: 0ms
memory: 4096kb
input:
30 1 1 2 3 18 5 6 7 8 9 10 11 12 13 28 15 16 17 4 19 20 21 22 23 24 25 26 27 14 29 30
output:
52
result:
ok 1 number(s): "52"
Test #59:
score: 0
Accepted
time: 1ms
memory: 3824kb
input:
26 4 1 2 3 4 5 6 7 8 9 10 25 22 13 14 15 16 17 18 19 20 21 12 23 24 11 26 2 1 3 4 5 6 7 8 9 16 11 12 13 17 15 10 14 18 19 20 21 22 23 24 25 26 1 2 22 4 15 6 7 8 9 10 11 12 13 14 5 16 17 18 19 20 21 3 23 24 25 26 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 26 24 25 23
output:
2528
result:
ok 1 number(s): "2528"
Test #60:
score: 0
Accepted
time: 1ms
memory: 3900kb
input:
15 1 1 2 3 4 5 6 13 9 8 10 11 12 7 15 14
output:
13
result:
ok 1 number(s): "13"
Test #61:
score: 0
Accepted
time: 1ms
memory: 4108kb
input:
25 1 1 2 3 4 5 6 7 8 9 25 11 12 13 14 15 16 17 18 19 20 21 22 23 24 10
output:
29
result:
ok 1 number(s): "29"
Test #62:
score: 0
Accepted
time: 1ms
memory: 4108kb
input:
15 3 1 14 3 4 5 6 7 8 9 10 11 15 13 12 2 8 2 3 4 5 13 7 1 9 10 11 12 6 14 15 1 2 3 4 5 15 7 8 9 10 11 12 14 13 6
output:
2976
result:
ok 1 number(s): "2976"
Test #63:
score: 0
Accepted
time: 1ms
memory: 3864kb
input:
20 4 1 2 6 4 5 3 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 14 9 10 11 12 13 8 15 16 17 18 19 20 1 2 9 4 5 6 7 8 3 10 13 12 11 14 15 16 17 18 19 20 1 2 20 4 12 5 7 8 9 10 11 6 13 14 15 16 17 18 19 3
output:
106560
result:
ok 1 number(s): "106560"
Test #64:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
26 2 1 2 3 4 15 7 6 8 9 10 11 12 13 14 5 16 17 18 19 20 21 22 23 24 25 26 26 2 3 4 25 6 7 8 9 10 11 12 13 24 15 16 17 18 19 20 21 22 23 14 5 1
output:
712
result:
ok 1 number(s): "712"
Test #65:
score: 0
Accepted
time: 1ms
memory: 3856kb
input:
20 4 1 2 3 4 17 9 7 8 6 10 11 12 13 14 15 16 5 20 19 18 1 2 3 4 5 6 7 13 9 10 11 12 8 14 15 16 17 18 19 20 3 9 1 4 5 6 7 8 2 15 11 12 13 14 10 16 17 18 19 20 1 2 19 4 5 6 7 17 9 10 11 12 13 14 15 16 8 18 3 20
output:
89040
result:
ok 1 number(s): "89040"
Test #66:
score: 0
Accepted
time: 0ms
memory: 4088kb
input:
30 5 1 2 3 4 23 9 7 8 6 10 11 12 13 14 15 16 17 18 19 20 22 21 5 24 25 26 27 28 29 30 1 2 3 4 5 6 7 14 9 10 11 12 13 8 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 29 15 14 17 18 19 20 21 22 23 24 25 28 27 26 16 30 1 2 3 4 5 6 7 8 9 10 11 12 15 14 13 16 17 18 19 20 2...
output:
65472
result:
ok 1 number(s): "65472"
Test #67:
score: 0
Accepted
time: 2ms
memory: 3876kb
input:
30 6 1 2 3 4 5 6 7 29 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 8 30 8 2 14 4 5 6 7 1 9 10 11 12 13 3 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 24 21 22 23 20 29 26 27 28 25 30 1 2 3 4 5 14 7 8 9 10 11 12 13 6 15 16 17 18 19 20 2...
output:
175104
result:
ok 1 number(s): "175104"
Test #68:
score: 0
Accepted
time: 3ms
memory: 4120kb
input:
30 5 1 2 3 4 5 6 7 8 9 14 11 12 13 10 15 16 17 18 30 20 21 22 23 24 25 26 27 28 29 19 1 7 3 4 5 6 2 15 9 10 11 12 13 14 28 16 17 18 19 20 21 22 23 24 25 26 27 8 29 30 19 2 3 4 5 6 7 8 24 10 11 12 13 14 15 16 17 18 1 20 21 22 23 9 25 26 27 28 29 30 1 2 3 4 29 6 7 8 9 10 11 30 13 14 15 16 17 18 19 20 ...
output:
653376
result:
ok 1 number(s): "653376"
Test #69:
score: 0
Accepted
time: 0ms
memory: 4148kb
input:
30 4 1 2 18 4 5 28 7 8 9 10 11 12 23 14 15 16 17 3 19 20 21 22 13 24 25 26 27 6 29 30 1 2 11 4 5 6 7 30 9 10 3 12 16 14 15 13 17 18 19 20 21 22 23 24 25 26 27 28 29 8 1 2 3 4 5 6 7 8 9 10 11 12 27 14 21 16 17 18 19 20 15 22 23 24 25 26 13 28 29 30 1 2 3 4 5 6 7 8 9 30 11 12 13 14 15 16 27 18 19 20 2...
output:
2538432
result:
ok 1 number(s): "2538432"
Test #70:
score: 0
Accepted
time: 2ms
memory: 3852kb
input:
30 3 1 22 7 4 5 6 3 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 23 24 25 26 27 28 29 30 1 2 21 4 9 6 7 8 5 10 11 12 13 14 15 16 17 18 19 20 3 22 23 24 25 26 27 28 29 30 1 2 3 4 5 6 8 7 9 10 11 12 13 14 15 16 17 29 19 20 21 22 23 24 25 26 27 28 18 30
output:
5448
result:
ok 1 number(s): "5448"
Test #71:
score: 0
Accepted
time: 2ms
memory: 3888kb
input:
30 5 1 2 3 22 5 6 7 8 9 10 11 15 13 14 12 16 17 18 19 20 21 4 23 24 25 26 27 28 29 30 1 2 3 4 18 6 7 8 9 10 11 12 13 14 15 16 17 5 19 20 21 22 23 24 25 26 27 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 28 19 20 21 22 23 24 25 26 27 18 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 22 15 16 17 18 19 20 2...
output:
482112
result:
ok 1 number(s): "482112"
Test #72:
score: 0
Accepted
time: 2ms
memory: 4148kb
input:
30 1 19 2 3 30 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 20 21 22 23 24 25 4 27 28 29 26
output:
301
result:
ok 1 number(s): "301"
Test #73:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
30 4 1 2 3 4 5 6 7 8 9 10 11 12 13 28 20 16 17 18 19 15 21 22 23 24 25 26 27 14 29 30 1 2 3 4 5 6 7 8 9 10 26 12 13 14 15 16 17 18 19 20 21 22 27 24 25 11 23 28 29 30 1 25 3 4 5 6 7 8 9 10 2 12 13 14 15 16 17 18 19 20 21 22 23 24 11 26 27 28 29 30 1 2 18 4 5 6 29 8 9 10 11 12 13 14 15 16 17 3 19 20 ...
output:
8928
result:
ok 1 number(s): "8928"
Test #74:
score: 0
Accepted
time: 2ms
memory: 3860kb
input:
30 4 1 30 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 2 1 2 3 4 5 6 7 11 23 22 8 12 13 14 15 16 17 18 19 20 21 10 9 24 25 26 27 28 29 30 1 2 4 3 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 1 12 3 4 5 6 7 8 9 10 11 2 13 14 15 16 17 18 19 20 2...
output:
1460
result:
ok 1 number(s): "1460"
Test #75:
score: 0
Accepted
time: 2ms
memory: 3852kb
input:
30 3 1 10 3 4 5 6 7 8 9 2 11 12 13 14 26 16 17 18 19 20 21 22 30 24 25 15 27 28 29 23 1 2 3 4 6 5 7 8 9 10 11 12 13 25 15 16 17 18 19 20 21 22 23 24 14 26 27 28 29 30 1 2 3 4 5 7 6 8 9 10 22 12 11 14 15 16 17 18 19 20 21 13 23 24 25 26 27 28 29 30
output:
3348
result:
ok 1 number(s): "3348"
Test #76:
score: 0
Accepted
time: 2ms
memory: 3956kb
input:
30 1 2 1 3 4 5 10 27 8 7 6 22 23 13 14 15 16 17 9 18 12 21 20 11 24 25 26 19 28 29 30
output:
596
result:
ok 1 number(s): "596"
Test #77:
score: 0
Accepted
time: 4ms
memory: 3856kb
input:
30 2 1 2 17 4 29 24 16 13 9 10 11 12 8 14 15 5 3 18 19 22 21 27 26 23 25 6 28 20 7 30 1 16 3 12 5 26 7 8 14 9 11 15 21 30 4 10 17 18 19 2 13 20 23 24 25 6 27 28 29 22
output:
35632939
result:
ok 1 number(s): "35632939"
Test #78:
score: 0
Accepted
time: 40ms
memory: 3892kb
input:
30 6 29 12 2 20 11 9 24 25 6 22 5 30 21 14 15 23 17 16 19 18 13 10 4 8 3 26 27 28 1 7 1 8 3 22 16 6 15 20 9 14 11 28 13 10 19 26 27 2 7 5 21 4 23 24 25 12 29 18 17 30 1 28 4 2 5 6 19 8 14 10 17 12 13 3 15 16 7 29 30 20 21 22 18 9 25 27 23 24 11 26 1 2 3 4 6 25 7 12 9 8 11 23 13 18 15 17 16 10 19 20 ...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #79:
score: 0
Accepted
time: 2ms
memory: 4144kb
input:
30 1 28 5 16 29 2 6 18 7 15 10 1 12 13 22 25 3 4 20 19 24 21 26 23 27 9 14 8 11 17 30
output:
827
result:
ok 1 number(s): "827"
Test #80:
score: 0
Accepted
time: 39ms
memory: 3880kb
input:
30 5 23 7 3 14 5 6 8 22 15 20 24 12 16 2 26 4 11 18 1 10 21 13 19 17 9 28 27 25 29 30 1 8 15 2 3 6 14 20 24 10 27 12 13 4 11 16 22 18 19 21 23 17 7 9 25 26 5 28 29 30 1 28 19 4 29 6 7 8 9 10 11 12 21 14 15 16 20 30 3 13 18 22 23 27 2 26 24 25 5 17 1 2 8 4 18 11 7 3 20 28 15 6 13 29 17 16 12 19 5 9 2...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #81:
score: 0
Accepted
time: 36ms
memory: 3764kb
input:
30 6 1 5 14 29 2 6 12 16 24 10 11 15 7 3 13 9 20 18 19 17 21 22 23 8 25 26 27 28 4 30 21 11 3 4 5 1 14 8 29 7 27 12 13 18 15 10 17 30 19 20 6 22 23 24 28 26 9 25 16 2 1 2 7 26 5 4 12 3 9 10 18 8 14 17 29 16 20 24 19 30 21 22 23 11 25 6 27 28 15 13 12 3 18 29 1 6 23 28 30 10 5 11 13 14 15 17 4 16 9 2...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #82:
score: 0
Accepted
time: 21ms
memory: 4156kb
input:
30 3 1 2 18 4 5 15 6 23 9 10 13 12 14 25 27 8 11 3 19 28 21 22 17 24 16 26 7 20 29 30 2 17 3 4 28 18 26 8 9 10 29 12 7 14 5 15 20 23 19 24 21 6 1 13 25 22 27 16 11 30 4 2 14 26 5 6 22 8 9 10 21 12 1 18 15 16 23 7 19 17 11 13 24 30 25 3 27 28 29 20
output:
546259602
result:
ok 1 number(s): "546259602"
Test #83:
score: 0
Accepted
time: 2ms
memory: 3792kb
input:
30 1 1 12 3 15 21 20 7 8 9 17 28 2 30 14 4 27 5 18 13 29 10 19 23 24 25 26 16 11 6 22
output:
1246
result:
ok 1 number(s): "1246"
Test #84:
score: 0
Accepted
time: 34ms
memory: 3920kb
input:
30 4 1 2 3 26 21 6 9 25 7 10 22 8 13 14 15 16 17 5 23 20 18 11 19 12 24 4 27 28 29 30 5 28 3 23 25 6 1 14 9 10 11 12 24 8 15 16 17 18 19 20 7 22 4 13 21 30 26 2 29 27 1 10 30 21 23 6 7 11 9 22 5 12 4 14 2 8 20 19 16 27 13 28 24 3 25 26 17 15 29 18 19 24 10 12 2 23 7 9 6 3 17 16 18 13 15 4 22 14 27 2...
output:
738501311
result:
ok 1 number(s): "738501311"
Test #85:
score: 0
Accepted
time: 29ms
memory: 3928kb
input:
30 4 1 30 3 19 6 5 7 15 22 11 4 12 21 14 2 16 20 18 10 17 8 13 23 29 24 26 27 28 25 9 8 6 24 29 5 2 4 15 10 7 11 18 17 14 1 22 28 12 19 20 9 16 23 3 25 26 27 13 21 30 7 3 28 4 5 6 1 8 12 11 14 9 13 23 15 16 17 18 19 2 22 24 10 21 25 26 27 20 29 30 24 28 3 9 5 15 10 30 8 18 11 12 13 17 16 7 14 29 19 ...
output:
968567468
result:
ok 1 number(s): "968567468"
Test #86:
score: 0
Accepted
time: 2ms
memory: 4080kb
input:
30 1 1 2 3 13 7 21 14 5 18 10 11 8 4 25 24 16 17 6 19 20 9 22 23 15 12 26 27 28 29 30
output:
842
result:
ok 1 number(s): "842"
Test #87:
score: 0
Accepted
time: 33ms
memory: 3884kb
input:
30 5 1 8 3 4 5 6 7 2 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 17 23 4 27 6 11 8 2 10 29 7 13 3 5 20 25 18 19 12 21 22 26 24 14 16 9 15 28 30 12 2 14 28 22 25 7 9 8 10 11 29 13 26 15 16 17 23 19 20 1 5 18 24 6 30 27 4 21 3 8 2 28 19 13 6 9 4 25 10 23 12 22 14 15 5 27 18 21 2...
output:
252043928
result:
ok 1 number(s): "252043928"
Test #88:
score: 0
Accepted
time: 2ms
memory: 4116kb
input:
30 1 14 13 2 4 3 8 18 12 26 7 21 30 23 9 15 19 25 6 16 5 22 17 27 24 1 10 20 28 29 11
output:
19432
result:
ok 1 number(s): "19432"
Test #89:
score: 0
Accepted
time: 38ms
memory: 3884kb
input:
30 2 18 16 11 17 28 13 24 26 10 6 29 1 2 23 25 20 15 8 19 4 14 5 21 7 3 30 12 9 22 27 5 2 20 4 21 14 22 26 8 17 19 18 27 12 15 16 11 30 10 25 9 3 7 1 28 23 13 24 29 6
output:
404585645
result:
ok 1 number(s): "404585645"
Test #90:
score: 0
Accepted
time: 40ms
memory: 4176kb
input:
30 5 1 26 14 10 5 18 11 8 28 23 7 12 13 15 3 2 17 21 6 24 20 22 4 27 25 16 19 29 9 30 21 13 2 27 8 14 19 30 15 11 9 23 12 16 24 4 7 25 20 22 1 29 5 17 26 3 10 18 28 6 1 17 3 4 12 6 23 8 9 10 20 2 30 14 22 16 29 18 19 11 21 15 25 27 5 26 13 28 7 24 9 2 3 4 5 6 7 12 17 10 21 20 24 1 15 19 14 18 8 16 1...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #91:
score: 0
Accepted
time: 8ms
memory: 3872kb
input:
30 2 1 11 10 20 30 5 7 8 25 3 27 28 17 14 22 16 13 18 19 9 23 15 21 24 4 26 2 12 29 6 1 2 7 4 21 6 29 8 9 30 17 12 13 14 18 16 28 10 19 20 23 22 3 24 25 26 27 5 15 11
output:
547624285
result:
ok 1 number(s): "547624285"
Test #92:
score: 0
Accepted
time: 2ms
memory: 3848kb
input:
30 1 1 20 12 4 25 30 11 16 9 8 29 3 13 24 15 14 17 23 19 2 21 18 7 10 5 26 27 28 22 6
output:
3823
result:
ok 1 number(s): "3823"
Test #93:
score: 0
Accepted
time: 8ms
memory: 3848kb
input:
30 2 2 12 3 11 9 19 20 6 14 10 4 1 13 5 25 7 17 18 15 16 21 22 23 24 30 26 8 28 29 27 18 2 10 4 29 15 7 6 30 22 11 12 13 14 27 16 9 3 19 20 21 17 23 24 25 26 8 28 5 1
output:
784118547
result:
ok 1 number(s): "784118547"
Test #94:
score: 0
Accepted
time: 39ms
memory: 3984kb
input:
30 5 1 20 10 21 15 3 7 13 29 6 11 12 22 14 4 16 18 26 19 2 30 8 17 24 25 9 27 28 23 5 9 16 18 30 5 19 11 12 15 13 14 27 22 23 20 1 6 21 4 3 7 25 17 2 10 26 24 29 8 28 12 29 8 30 27 18 15 13 6 7 28 26 20 9 11 25 19 4 2 17 24 5 23 3 21 10 14 1 16 22 3 2 5 25 13 6 7 30 9 10 28 12 29 14 15 16 17 18 8 20...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #95:
score: 0
Accepted
time: 39ms
memory: 3884kb
input:
30 6 4 2 9 16 5 30 1 25 15 6 14 3 13 8 27 11 19 26 12 20 7 18 23 24 10 21 22 28 29 17 1 2 18 3 25 5 7 19 9 27 8 12 13 14 15 16 17 4 20 11 21 22 23 10 26 30 6 28 29 24 7 2 28 1 21 5 15 24 11 10 25 3 4 14 18 9 8 6 19 23 26 17 27 13 22 29 30 20 12 16 30 2 21 4 26 17 29 27 9 6 11 12 1 22 13 16 24 23 20 ...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #96:
score: 0
Accepted
time: 40ms
memory: 3892kb
input:
30 30 1 2 3 4 5 6 10 8 9 7 11 12 13 14 15 16 17 18 19 29 21 22 23 24 25 26 27 28 20 30 1 23 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 19 20 21 22 18 24 25 26 27 28 29 30 1 2 3 4 5 6 7 13 9 10 11 12 8 14 19 16 17 18 15 20 21 22 27 24 25 26 23 28 29 30 1 12 3 4 5 6 7 8 9 10 23 2 13 14 15 16 17 18 19 20 ...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #97:
score: 0
Accepted
time: 32ms
memory: 3816kb
input:
30 30 1 5 3 4 2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 25 28 26 27 24 29 30 1 2 3 4 5 6 7 8 24 10 11 9 13 14 15 16 17 18 19 20 21 22 23 12 25 26 27 28 29 30 1 2 14 4 5 6 7 8 9 10 11 12 13 3 15 16 17 18 19 20 29 22 23 24 25 26 27 28 21 30 1 8 3 4 5 6 7 2 9 10 11 12 13 14 15 16 23 18 19 20 ...
output:
264178870
result:
ok 1 number(s): "264178870"
Test #98:
score: 0
Accepted
time: 38ms
memory: 3852kb
input:
30 30 1 2 3 4 5 6 11 8 9 10 30 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 25 18 19 20 21 22 23 24 17 26 27 28 29 30 1 2 3 4 5 12 7 22 29 10 11 6 13 14 15 16 17 18 19 20 21 8 23 24 25 26 27 28 9 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 16 26 19 23 ...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #99:
score: 0
Accepted
time: 33ms
memory: 4176kb
input:
30 30 1 2 3 4 5 6 24 8 12 10 11 9 13 14 15 16 17 18 19 20 21 22 23 7 25 26 27 28 29 30 1 2 27 4 5 6 7 19 9 10 11 12 13 14 15 16 17 18 8 25 21 22 23 24 20 26 3 28 29 30 16 11 19 4 5 6 7 8 9 10 2 12 13 14 15 1 17 18 3 20 21 22 23 24 25 26 27 28 29 30 1 2 3 4 5 6 7 8 9 29 12 11 13 14 15 16 17 18 19 20 ...
output:
355190935
result:
ok 1 number(s): "355190935"
Test #100:
score: 0
Accepted
time: 40ms
memory: 3772kb
input:
30 30 1 2 22 4 5 6 7 30 9 10 11 12 13 14 15 16 17 18 19 20 21 3 23 24 25 26 27 28 29 8 1 2 3 4 5 6 7 8 9 20 11 12 13 14 15 10 17 18 19 16 21 22 23 24 25 26 27 28 29 30 1 2 27 4 22 6 11 8 9 10 7 12 13 14 15 16 17 18 19 20 21 5 23 24 25 26 3 28 29 30 1 2 3 4 5 6 7 8 9 10 11 18 13 14 15 23 17 12 19 20 ...
output:
404585645
result:
ok 1 number(s): "404585645"
Test #101:
score: 0
Accepted
time: 33ms
memory: 3820kb
input:
30 30 1 2 3 6 5 4 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 28 24 25 26 27 23 29 30 1 27 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 21 20 19 22 23 24 25 26 2 28 29 30 1 2 3 4 5 26 7 8 9 10 11 12 13 14 15 16 21 18 19 20 17 22 23 24 25 6 27 28 29 30 1 2 3 4 5 6 7 8 29 10 11 30 13 14 15 16 17 18 19 20...
output:
113887022
result:
ok 1 number(s): "113887022"
Test #102:
score: 0
Accepted
time: 38ms
memory: 4116kb
input:
30 30 21 2 3 4 5 6 7 8 9 10 25 12 13 14 15 16 17 18 19 20 1 22 23 24 11 26 27 28 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 27 18 19 20 21 22 23 24 25 26 29 28 17 30 1 2 3 4 5 6 7 8 9 10 25 12 13 14 15 16 17 18 19 20 21 22 23 24 11 26 27 29 28 30 1 2 3 4 5 6 28 8 9 14 11 12 13 10 15 16 17 18 19 20...
output:
701414999
result:
ok 1 number(s): "701414999"
Test #103:
score: 0
Accepted
time: 38ms
memory: 3988kb
input:
30 30 1 2 3 4 5 6 29 8 9 10 11 12 13 14 25 16 17 18 19 20 21 22 23 24 15 26 27 28 7 30 1 2 3 4 5 6 7 18 9 10 11 12 13 14 15 16 17 8 19 20 21 24 23 22 25 26 27 28 29 30 1 2 28 4 5 6 7 8 9 10 3 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 11 29 30 1 2 3 4 5 21 7 8 9 24 11 12 13 14 15 16 17 18 19 20...
output:
701414999
result:
ok 1 number(s): "701414999"
Test #104:
score: 0
Accepted
time: 33ms
memory: 3896kb
input:
30 30 1 2 21 4 5 6 3 8 9 10 11 12 13 14 15 16 17 18 19 20 7 22 23 24 25 26 27 28 29 30 1 2 3 4 5 6 7 8 9 10 11 26 23 14 15 16 17 18 19 20 21 22 13 24 25 12 27 28 29 30 1 2 3 4 20 6 7 8 9 10 11 12 13 14 15 16 25 18 19 5 21 22 23 24 17 26 27 28 29 30 1 2 3 4 5 6 7 8 9 10 11 27 13 14 15 16 17 18 19 23 ...
output:
156359319
result:
ok 1 number(s): "156359319"
Test #105:
score: 0
Accepted
time: 39ms
memory: 3884kb
input:
30 30 1 2 3 4 5 6 7 8 9 19 11 30 13 14 15 16 17 18 10 20 21 22 23 24 25 26 27 28 29 12 1 2 3 4 5 16 7 8 9 28 11 12 13 14 15 6 17 18 19 20 21 22 23 24 25 26 27 10 29 30 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 30 23 20 21 22 19 24 25 26 27 28 29 18 1 2 3 4 5 6 7 8 9 10 11 26 13 14 15 16 17 18 19 20 ...
output:
701414999
result:
ok 1 number(s): "701414999"
Test #106:
score: 0
Accepted
time: 4ms
memory: 4148kb
input:
30 2 1 20 6 15 5 22 7 8 13 18 26 23 27 14 4 16 17 10 19 11 12 3 21 24 25 2 29 28 9 30 16 24 3 4 29 6 7 28 23 10 2 25 5 14 15 12 17 18 30 11 21 22 9 20 8 26 27 1 13 19
output:
310634692
result:
ok 1 number(s): "310634692"
Extra Test:
score: 0
Extra Test Passed