QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#285705#7687. Randias Permutation TaskmaspyAC ✓143ms52728kbC++2017.0kb2023-12-16 21:35:332023-12-16 21:35:34

Judging History

你现在查看的是最新测评结果

  • [2023-12-16 21:35:34]
  • 评测
  • 测评结果:AC
  • 用时:143ms
  • 内存:52728kb
  • [2023-12-16 21:35:33]
  • 提交

answer

#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using f128 = __float128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
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;
}
#endif
#line 1 "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;

#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 2 "library/random/hash_vector.hpp"

#line 2 "library/random/base.hpp"

u64 RNG_64() {
  static uint64_t x_
      = uint64_t(chrono::duration_cast<chrono::nanoseconds>(
                     chrono::high_resolution_clock::now().time_since_epoch())
                     .count())
        * 10150724397891781847ULL;
  x_ ^= x_ << 7;
  return x_ ^= x_ >> 9;
}

u64 RNG(u64 lim) { return RNG_64() % lim; }

ll RNG(ll l, ll r) { return l + RNG_64() % (r - l); }
#line 2 "library/mod/modint61.hpp"

struct modint61 {
  static constexpr u64 mod = (1ULL << 61) - 1;
  u64 val;
  constexpr modint61() : val(0ULL) {}
  constexpr modint61(u32 x) : val(x) {}
  constexpr modint61(u64 x) : val(x % mod) {}
  constexpr modint61(int x) : val((x < 0) ? (x + static_cast<ll>(mod)) : x) {}
  constexpr modint61(ll x)
      : val(((x %= static_cast<ll>(mod)) < 0) ? (x + static_cast<ll>(mod))
                                              : x) {}
  static constexpr u64 get_mod() { return mod; }
  modint61 &operator+=(const modint61 &a) {
    val = ((val += a.val) >= mod) ? (val - mod) : val;
    return *this;
  }
  modint61 &operator-=(const modint61 &a) {
    val = ((val -= a.val) >= mod) ? (val + mod) : val;
    return *this;
  }
  modint61 &operator*=(const modint61 &a) {
    const unsigned __int128 y = static_cast<unsigned __int128>(val) * a.val;
    val = (y >> 61) + (y & mod);
    val = (val >= mod) ? (val - mod) : val;
    return *this;
  }
  modint61 &operator/=(const modint61 &a) { return (*this *= a.inverse()); }
  modint61 operator+(const modint61 &p) const { return modint61(*this) += p; }
  modint61 operator-(const modint61 &p) const { return modint61(*this) -= p; }
  modint61 operator*(const modint61 &p) const { return modint61(*this) *= p; }
  modint61 operator/(const modint61 &p) const { return modint61(*this) /= p; }
  bool operator==(const modint61 &p) const { return val == p.val; }
  bool operator!=(const modint61 &p) const { return val != p.val; }
  modint61 inverse() const {
    ll 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 modint61(u);
  }
  modint61 pow(ll n) const {
    assert(n >= 0);
    modint61 ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul, n >>= 1;
    }
    return ret;
  }
};

#ifdef FASTIO
void rd(modint61 &x) {
  fastio::rd(x.val);
  assert(0 <= x.val && x.val < modint61::mod);
}

void wt(modint61 x) { fastio::wt(x.val); }
#endif
#line 5 "library/random/hash_vector.hpp"

template <typename T>
u64 hash_vector(vc<T> X) {
  using mint = modint61;
  static vc<mint> hash_base;
  int n = len(X);
  while (len(hash_base) <= n) { hash_base.eb(RNG(mint::get_mod())); }
  mint H = 0;
  FOR(i, n) H += hash_base[i] * mint(X[i]);
  H += hash_base[n];
  return H.val;
}
#line 2 "library/ds/hashmap.hpp"

// u64 -> Val
template <typename Val, int LOG = 20, bool KEEP_IDS = false>
struct HashMap {
  static constexpr int N = (1 << LOG);
  u64* key;
  Val* val;
  vc<int> IDS;
  bitset<N> used;
  const int shift;
  const u64 r = 11995408973635179863ULL;
  HashMap() : key(new u64[N]), val(new Val[N]), shift(64 - LOG) {}
  u32 hash(u64 x) {
    static const u64 FIXED_RANDOM
        = std::chrono::steady_clock::now().time_since_epoch().count();
    return (u64(x + FIXED_RANDOM) * r) >> shift;
  }

  int index(const u64& k) {
    int i = 0;
    for (i = hash(k); used[i] && key[i] != k; (i += 1) &= (N - 1)) {}
    return i;
  }

  Val& operator[](const u64& k) {
    int i = index(k);
    if (!used[i]) {
      used[i] = 1, key[i] = k, val[i] = Val{};
      if constexpr (KEEP_IDS) IDS.eb(i);
    }
    return val[i];
  }

  Val get(const u64& k, Val default_value) {
    int i = index(k);
    if (!used[i]) return default_value;
    return val[i];
  }

  bool count(const u64& k) {
    int i = index(k);
    return used[i] && key[i] == k;
  }

  void reset() {
    static_assert(KEEP_IDS);
    for (auto&& i: IDS) used[i] = 0;
    IDS.clear();
  }

  // f(key, val)
  template <typename F>
  void enumerate_all(F f) {
    static_assert(KEEP_IDS);
    for (auto&& i: IDS) f(key[i], val[i]);
  }
};
#line 6 "main.cpp"

void solve() {
  LL(N, M);

  vvc<int> state;
  HashMap<int, 21, false> MP;

  FOR(M) {
    VEC(int, A, N);
    for (auto& x: A) --x;
    int n = len(state);
    FOR(i, n) {
      vc<int>& S = state[i];
      vc<int> X(N);
      FOR(i, N) X[i] = S[A[i]];
      u64 x = hash_vector(X);
      if (MP.count(x)) continue;
      MP[x] = 1;
      state.eb(X);
    }
    u64 x = hash_vector(A);
    if (MP.count(x)) continue;
    MP[x] = 1;
    state.eb(A);
  }
  print(len(state));
}

signed main() {
  solve();
  return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3920kb

input:

5 4
1 2 3 4 5
5 1 3 4 2
3 4 1 5 2
5 2 4 1 3

output:

8

result:

ok 1 number(s): "8"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

2 1
2 1

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

1 180
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

180 1
52 71 167 89 165 102 119 125 9 128 180 24 48 172 108 22 164 28 159 111 30 91 67 51 136 97 126 133 177 65 115 157 114 11 171 178 23 127 163 103 99 18 56 94 176 77 44 1 124 74 61 87 4 40 63 92 169 84 146 6 88 55 152 49 10 90 43 174 70 50 69 154 73 147 110 20 82 59 112 12 64 143 16 138 5 170 155 ...

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

2 90
1 2
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
2 1
1 2
1 2
1 2
2 1
2 1
2 1
2 1
1 2
1 2
1 2
1 2
2 1
1 2
2 1
1 2
1 2
1 2
2 1
2 1
1 2
2 1
1 2
2 1
1 2
1 2
2 1
1 2
2 1
2 1
2 1
2 1
1 2
2 1
2 1
2 1
2 1
1 2
1 2
2 1
2 1
1 2
1 2
1 2
2 1
1 2
2 1
2 1
1 2
2 1
2 1
2 1
2 1
2 1
2 1
2 1
1 2
1 2
1 2
2 1
1 2
1 2
2 1
1 2
1 2...

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

90 2
43 44 28 69 66 18 5 23 87 8 24 89 31 29 81 1 68 2 78 53 49 54 4 13 77 61 33 57 63 85 55 79 46 35 45 64 65 42 30 6 19 74 82 80 17 26 32 59 7 72 16 3 47 73 39 36 25 34 56 86 71 62 84 40 41 11 50 27 20 14 37 12 38 58 48 83 76 70 51 88 22 90 21 9 10 60 15 52 75 67
9 73 52 51 81 16 71 77 6 57 11 75 ...

output:

3

result:

ok 1 number(s): "3"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

3 60
2 1 3
3 1 2
3 2 1
1 2 3
1 2 3
3 2 1
3 1 2
2 3 1
2 1 3
3 1 2
2 3 1
2 3 1
2 1 3
3 2 1
3 1 2
3 2 1
1 2 3
2 1 3
2 1 3
2 1 3
2 3 1
2 3 1
2 3 1
3 1 2
1 2 3
3 1 2
2 3 1
2 3 1
2 1 3
1 2 3
3 1 2
2 1 3
2 3 1
2 3 1
2 3 1
3 1 2
2 3 1
1 2 3
1 2 3
3 2 1
3 1 2
3 1 2
2 3 1
1 3 2
3 1 2
1 3 2
1 2 3
1 3 2
1 3 2
3...

output:

6

result:

ok 1 number(s): "6"

Test #8:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

60 3
35 38 36 43 59 60 20 16 8 51 58 18 33 26 44 7 41 27 39 9 37 48 25 40 30 14 21 13 5 1 19 11 3 28 57 47 17 56 45 34 12 49 29 32 55 24 31 50 42 22 53 23 4 15 2 46 6 10 52 54
41 49 10 55 3 38 35 29 6 26 2 46 58 39 24 47 51 25 44 37 42 43 20 53 60 12 40 17 28 13 27 57 15 52 8 22 11 14 59 21 48 9 32 ...

output:

7

result:

ok 1 number(s): "7"

Test #9:

score: 0
Accepted
time: 1ms
memory: 4020kb

input:

4 45
1 3 4 2
2 3 4 1
4 1 3 2
4 1 2 3
1 4 3 2
3 4 2 1
2 3 4 1
1 3 2 4
2 1 4 3
4 2 3 1
4 1 3 2
1 3 4 2
2 4 3 1
4 2 3 1
1 3 2 4
3 2 1 4
2 3 4 1
3 2 4 1
1 2 4 3
4 1 2 3
4 3 2 1
3 4 1 2
1 3 2 4
2 4 3 1
4 2 1 3
2 3 4 1
4 2 1 3
4 2 3 1
1 2 3 4
1 3 2 4
1 4 3 2
3 2 4 1
2 3 1 4
1 3 4 2
3 1 2 4
1 3 2 4
3 2 4 1...

output:

24

result:

ok 1 number(s): "24"

Test #10:

score: 0
Accepted
time: 1ms
memory: 3972kb

input:

45 4
44 38 33 27 25 17 35 4 22 41 15 3 10 16 21 28 23 19 34 37 2 32 43 12 6 31 29 9 45 18 11 30 13 26 42 5 39 40 8 24 14 1 7 20 36
28 43 12 34 21 7 20 26 13 1 25 4 44 32 11 15 33 18 14 5 6 42 45 36 9 35 2 30 38 10 41 27 17 23 19 8 29 16 3 37 40 31 39 22 24
5 22 23 43 36 33 29 39 44 9 35 34 7 42 8 11...

output:

15

result:

ok 1 number(s): "15"

Test #11:

score: 0
Accepted
time: 0ms
memory: 10844kb

input:

18 10
13 4 18 16 1 8 17 6 14 2 10 12 5 9 3 11 15 7
1 7 15 13 12 2 17 18 16 11 9 8 6 14 3 4 10 5
1 9 3 4 6 14 5 10 12 13 7 8 16 2 15 17 18 11
2 10 16 3 17 8 4 13 12 11 5 7 14 9 1 15 18 6
7 9 4 14 10 2 17 6 8 16 1 13 12 5 11 18 15 3
13 4 16 10 5 2 9 1 11 3 18 8 6 12 15 14 7 17
9 14 18 17 2 12 16 10 15...

output:

1023

result:

ok 1 number(s): "1023"

Test #12:

score: 0
Accepted
time: 76ms
memory: 45812kb

input:

10 18
9 6 4 8 3 7 10 1 2 5
10 9 8 3 5 6 1 2 7 4
8 2 5 4 9 3 1 7 6 10
10 5 2 8 1 6 4 7 9 3
2 3 5 4 10 9 6 8 7 1
6 7 8 10 5 3 4 1 9 2
10 6 4 2 1 5 3 8 9 7
6 8 9 1 2 4 5 3 7 10
7 6 3 1 5 9 2 10 4 8
10 5 7 4 9 1 2 6 3 8
5 4 6 9 3 7 8 1 2 10
5 9 8 2 7 1 3 10 6 4
5 2 10 3 7 1 4 6 9 8
1 10 2 6 5 7 8 9 3 4
...

output:

252941

result:

ok 1 number(s): "252941"

Test #13:

score: 0
Accepted
time: 0ms
memory: 10776kb

input:

18 10
1 13 12 15 10 17 14 8 5 3 9 7 11 2 6 16 4 18
3 14 1 17 13 10 16 12 8 11 18 7 2 5 6 4 15 9
14 13 4 18 7 9 10 16 11 5 3 12 15 8 1 2 6 17
8 7 17 3 6 10 4 2 15 13 12 18 14 16 11 9 1 5
16 7 10 1 9 5 15 3 4 13 14 8 17 11 6 18 2 12
2 6 1 16 17 9 18 14 12 4 3 11 13 8 7 5 10 15
9 1 16 10 8 17 4 15 2 14...

output:

1023

result:

ok 1 number(s): "1023"

Test #14:

score: 0
Accepted
time: 60ms
memory: 45848kb

input:

10 18
8 4 3 10 2 7 9 5 6 1
4 3 5 10 1 7 9 2 8 6
5 8 3 4 10 1 6 9 2 7
3 1 2 4 9 8 7 6 5 10
2 7 3 8 5 10 9 1 6 4
7 9 4 6 3 5 10 1 2 8
5 7 6 8 4 2 10 1 9 3
9 10 3 2 4 6 8 5 1 7
6 5 7 10 2 3 1 4 8 9
7 1 8 2 3 10 6 9 5 4
9 6 1 5 4 8 10 2 7 3
9 5 6 2 10 1 8 3 4 7
1 10 7 4 3 5 9 6 8 2
6 10 4 5 2 9 7 1 8 3
...

output:

252421

result:

ok 1 number(s): "252421"

Test #15:

score: 0
Accepted
time: 126ms
memory: 52704kb

input:

9 20
9 7 5 1 8 6 4 3 2
2 3 1 7 4 6 9 8 5
4 2 8 5 3 7 9 1 6
6 9 7 8 2 1 5 4 3
6 5 3 7 8 1 2 4 9
3 4 2 8 7 9 1 6 5
8 5 2 7 6 3 1 4 9
4 7 9 6 8 2 3 5 1
3 2 9 1 8 6 7 4 5
4 7 1 3 6 5 9 8 2
2 8 4 1 6 7 9 3 5
2 1 4 7 3 9 6 8 5
3 9 6 7 2 8 1 4 5
6 2 5 8 1 7 4 3 9
9 2 6 7 1 3 4 5 8
7 2 4 1 9 6 5 8 3
7 3 8 1...

output:

342954

result:

ok 1 number(s): "342954"

Test #16:

score: 0
Accepted
time: 0ms
memory: 7744kb

input:

20 9
16 4 6 2 7 8 19 10 5 14 18 13 1 11 12 15 3 9 20 17
19 11 10 14 5 12 17 7 8 15 4 9 1 6 18 3 2 16 20 13
16 10 1 14 17 4 19 15 8 5 13 12 7 9 11 20 2 3 18 6
12 2 11 7 18 17 20 1 9 15 8 5 3 16 13 14 6 10 19 4
15 1 5 16 20 14 9 8 7 18 13 19 12 11 4 3 17 10 2 6
1 9 7 16 18 5 8 15 6 3 17 19 4 11 13 20 ...

output:

511

result:

ok 1 number(s): "511"

Test #17:

score: 0
Accepted
time: 136ms
memory: 52728kb

input:

9 20
2 8 5 9 4 1 6 7 3
4 7 6 9 2 3 8 5 1
7 9 4 5 2 3 8 1 6
9 2 8 1 6 4 5 3 7
6 9 5 3 7 8 1 2 4
9 3 5 6 4 8 2 7 1
9 2 4 1 8 5 7 6 3
2 1 7 3 4 9 5 6 8
2 5 7 4 9 6 3 8 1
5 7 2 4 1 3 9 6 8
1 7 9 4 5 8 6 2 3
6 5 8 2 7 4 9 1 3
2 1 5 6 9 4 7 3 8
3 8 6 5 4 2 1 9 7
6 5 9 7 2 8 3 4 1
8 1 9 5 3 6 4 7 2
7 1 3 2...

output:

342507

result:

ok 1 number(s): "342507"

Test #18:

score: 0
Accepted
time: 2ms
memory: 7560kb

input:

20 9
8 16 5 3 4 7 6 12 17 13 20 10 2 18 19 1 11 15 9 14
3 5 7 18 12 9 2 15 20 8 19 1 10 16 6 4 17 14 11 13
16 18 2 10 20 15 17 4 19 9 5 7 12 11 14 3 13 6 1 8
2 19 18 6 9 11 10 3 17 13 20 16 14 7 15 1 8 12 5 4
11 17 2 6 10 12 5 20 16 7 1 19 9 14 4 8 13 3 15 18
2 12 19 5 4 20 11 18 3 1 10 9 16 17 6 14...

output:

511

result:

ok 1 number(s): "511"

Test #19:

score: 0
Accepted
time: 36ms
memory: 31068kb

input:

8 22
7 5 2 8 4 3 6 1
2 3 5 8 7 1 4 6
3 5 6 8 1 4 2 7
7 8 1 5 4 3 6 2
3 8 2 1 4 5 7 6
5 4 2 8 1 6 3 7
7 2 8 5 3 6 4 1
3 5 7 1 2 6 8 4
3 1 4 5 7 6 2 8
1 2 8 5 7 3 4 6
2 5 1 7 3 4 8 6
2 6 8 5 3 4 1 7
8 2 1 4 6 7 3 5
7 6 2 8 4 3 1 5
6 2 1 8 7 5 4 3
6 7 1 2 8 4 3 5
3 6 4 1 5 7 8 2
6 5 8 1 2 7 4 3
5 7 2 1...

output:

40320

result:

ok 1 number(s): "40320"

Test #20:

score: 0
Accepted
time: 1ms
memory: 5852kb

input:

22 8
14 19 18 20 21 15 22 5 4 7 2 3 17 16 6 10 13 8 1 11 12 9
22 13 18 21 4 7 12 3 5 8 15 14 16 1 17 2 10 9 20 11 19 6
14 15 20 11 13 4 18 17 5 1 6 10 8 19 22 2 9 21 3 7 12 16
20 12 8 2 5 6 22 16 13 4 14 3 9 10 7 1 11 18 17 19 21 15
1 13 7 15 5 18 16 4 22 17 10 21 3 9 6 2 11 12 20 19 8 14
9 8 6 22 1...

output:

255

result:

ok 1 number(s): "255"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3928kb

input:

9 20
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3...

output:

9

result:

ok 1 number(s): "9"

Test #22:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

10 18
2 3 4 5 6 7 8 9 10 1
3 4 5 6 7 8 9 10 1 2
4 5 6 7 8 9 10 1 2 3
5 6 7 8 9 10 1 2 3 4
6 7 8 9 10 1 2 3 4 5
7 8 9 10 1 2 3 4 5 6
8 9 10 1 2 3 4 5 6 7
9 10 1 2 3 4 5 6 7 8
10 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
2 3 4 5 6 7 8 9 10 1
3 4 5 6 7 8 9 10 1 2
4 5 6 7 8 9 10 1 2 3
5 6 7 8 9 10 1 2 3 4
...

output:

10

result:

ok 1 number(s): "10"

Test #23:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

8 22
2 3 4 5 6 7 8 1
3 4 5 6 7 8 1 2
4 5 6 7 8 1 2 3
5 6 7 8 1 2 3 4
6 7 8 1 2 3 4 5
7 8 1 2 3 4 5 6
8 1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8 1
3 4 5 6 7 8 1 2
4 5 6 7 8 1 2 3
5 6 7 8 1 2 3 4
6 7 8 1 2 3 4 5
7 8 1 2 3 4 5 6
8 1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
2 3 4 5 6 7 8 1
3 4 5 6 7 8 1 2
4 5 6 7...

output:

8

result:

ok 1 number(s): "8"

Test #24:

score: 0
Accepted
time: 1ms
memory: 3968kb

input:

18 10
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 2
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 2 3
5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 2 3 4
6 7 8 9 10 11 12 13 14 15 16 17 18 1 2 3 4 5
7 8 9 10 11 12 13 14 15 16 17 18 1 2 3 4 5 6
8 9 10 11 12 13 14 15 16...

output:

18

result:

ok 1 number(s): "18"

Test #25:

score: 0
Accepted
time: 143ms
memory: 52720kb

input:

9 20
4 7 1 6 3 2 9 5 8
7 2 4 6 3 5 8 9 1
9 8 4 6 3 7 1 2 5
5 6 1 7 4 9 3 8 2
6 4 8 1 2 7 9 3 5
4 3 8 5 9 7 2 1 6
9 7 6 1 4 2 8 5 3
5 3 7 6 2 8 1 9 4
7 2 3 5 6 4 9 8 1
2 5 6 1 9 4 7 3 8
1 6 5 9 7 3 4 2 8
5 8 2 9 3 6 1 7 4
2 3 6 9 1 4 5 8 7
3 1 6 9 8 5 7 2 4
7 1 8 4 9 6 5 2 3
2 4 7 9 6 1 3 5 8
1 9 3 2...

output:

342762

result:

ok 1 number(s): "342762"

Test #26:

score: 0
Accepted
time: 0ms
memory: 7680kb

input:

20 9
3 20 9 11 14 7 13 12 6 10 18 5 17 8 2 16 15 4 19 1
8 12 2 15 9 10 16 11 3 14 4 18 1 6 20 7 17 19 5 13
14 17 5 10 11 4 12 13 6 3 15 7 2 1 16 20 18 19 8 9
4 2 8 14 5 19 11 13 18 9 16 1 20 15 6 12 3 17 10 7
20 16 2 1 5 19 18 9 8 7 3 15 11 10 4 12 6 17 14 13
8 17 10 18 1 13 20 6 14 5 3 7 15 12 11 1...

output:

511

result:

ok 1 number(s): "511"

Test #27:

score: 0
Accepted
time: 64ms
memory: 45812kb

input:

10 18
9 6 4 2 8 10 7 3 5 1
10 5 9 3 1 2 4 8 6 7
5 2 7 6 8 10 1 4 3 9
3 8 5 4 7 2 6 10 9 1
9 6 3 10 1 5 4 7 8 2
7 1 4 10 8 9 5 6 3 2
6 5 1 4 7 8 3 10 9 2
2 8 4 6 5 10 9 3 1 7
9 10 4 1 2 3 5 7 6 8
7 8 1 10 2 6 9 5 4 3
4 8 2 7 3 10 5 6 1 9
1 7 10 3 6 2 8 9 5 4
10 3 9 7 6 8 5 2 1 4
2 9 4 1 5 6 10 8 7 3
...

output:

252874

result:

ok 1 number(s): "252874"

Test #28:

score: 0
Accepted
time: 29ms
memory: 31156kb

input:

8 22
4 7 3 5 6 8 2 1
1 5 3 4 8 6 2 7
4 2 5 6 8 7 1 3
4 5 3 2 8 6 1 7
8 7 4 6 3 2 1 5
4 7 1 3 5 8 6 2
1 3 7 4 6 2 5 8
4 7 6 2 8 1 3 5
7 1 4 5 8 6 3 2
8 2 5 6 3 1 4 7
1 8 5 6 3 7 4 2
5 4 3 7 2 6 1 8
8 4 5 2 1 3 6 7
4 2 5 3 1 8 6 7
4 6 5 3 8 2 1 7
8 7 5 3 6 2 4 1
3 5 8 1 6 7 2 4
8 1 7 5 6 2 4 3
7 2 3 5...

output:

40320

result:

ok 1 number(s): "40320"

Test #29:

score: 0
Accepted
time: 2ms
memory: 5592kb

input:

9 20
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
6 2 1 4 7 9 5 8 3
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
5 8 6 9 2 1 4 7 3
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4 6 2 5 7 9
8 1 3 4...

output:

222

result:

ok 1 number(s): "222"

Test #30:

score: 0
Accepted
time: 1ms
memory: 4640kb

input:

8 22
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
5 7 3 1 4 2 8 6
3 2 7 4 1 6 8 5
6 1 5 3 8 2 4 7
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4 1 6 8 5
3 2 7 4...

output:

105

result:

ok 1 number(s): "105"

Test #31:

score: 0
Accepted
time: 1ms
memory: 4084kb

input:

18 10
13 7 5 17 14 8 2 4 6 1 12 10 9 18 16 11 3 15
13 7 5 17 14 8 2 4 6 1 12 10 9 18 16 11 3 15
13 7 5 17 14 8 2 4 6 1 12 10 9 18 16 11 3 15
13 7 5 17 14 8 2 4 6 1 12 10 9 18 16 11 3 15
6 10 12 11 18 14 13 4 1 7 9 15 16 3 5 8 2 17
13 7 5 17 14 8 2 4 6 1 12 10 9 18 16 11 3 15
13 7 5 17 14 8 2 4 6 1 1...

output:

39

result:

ok 1 number(s): "39"

Test #32:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

180 1
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:

1

result:

ok 1 number(s): "1"

Test #33:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

1 1
1

output:

1

result:

ok 1 number(s): "1"

Test #34:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

2 90
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2...

output:

1

result:

ok 1 number(s): "1"

Test #35:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

9 20
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4...

output:

1

result:

ok 1 number(s): "1"

Test #36:

score: 0
Accepted
time: 15ms
memory: 31800kb

input:

9 20
3 2 1 4 5 6 7 8 9
2 1 3 4 5 6 7 8 9
6 2 3 4 5 1 7 8 9
1 7 3 4 5 6 2 8 9
1 4 3 2 5 6 7 8 9
1 2 3 9 5 6 7 8 4
7 2 3 4 5 6 1 8 9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 8 7 6 9
1 2 3 4 5 6 7 9 8
1 2 6 4 5 3 7 8 9
1 2 7 4 5 6 3 8 9
1 2 5 4 3 6 7 8 9
1 9 3 4 5 6 7 8 2
1 2 3 6 5 4 7 8 9
1 2 3 5 4 6 7 8 9
1 2 3 4...

output:

51528

result:

ok 1 number(s): "51528"

Test #37:

score: 0
Accepted
time: 3ms
memory: 28624kb

input:

10 18
8 2 3 4 5 6 7 1 9 10
1 2 4 3 5 6 7 8 9 10
1 2 3 4 5 10 7 8 9 6
8 2 3 4 5 6 7 1 9 10
8 2 3 4 5 6 7 1 9 10
1 2 7 4 5 6 3 8 9 10
1 2 3 9 5 6 7 8 4 10
10 2 3 4 5 6 7 8 9 1
1 2 10 4 5 6 7 8 9 3
1 2 3 4 5 9 7 8 6 10
1 2 5 4 3 6 7 8 9 10
1 2 3 10 5 6 7 8 9 4
1 2 3 4 5 6 7 10 9 8
1 2 3 4 5 6 10 8 9 7
...

output:

13792

result:

ok 1 number(s): "13792"

Test #38:

score: 0
Accepted
time: 2ms
memory: 23356kb

input:

8 22
1 4 3 2 5 6 7 8
1 2 3 8 5 6 7 4
8 2 3 4 5 6 7 1
1 2 3 6 5 4 7 8
1 2 3 7 5 6 4 8
3 2 1 4 5 6 7 8
7 2 3 4 5 6 1 8
1 2 3 4 5 7 6 8
7 2 3 4 5 6 1 8
3 2 1 4 5 6 7 8
1 2 3 4 5 6 7 8
2 1 3 4 5 6 7 8
1 2 3 4 5 6 7 8
4 2 3 1 5 6 7 8
1 2 7 4 5 6 3 8
1 2 3 6 5 4 7 8
1 2 3 4 5 6 7 8
1 2 3 6 5 4 7 8
1 7 3 4...

output:

5136

result:

ok 1 number(s): "5136"

Test #39:

score: 0
Accepted
time: 1ms
memory: 3856kb

input:

4 45
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 4 3 2
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
2 1 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4...

output:

4

result:

ok 1 number(s): "4"

Test #40:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

3 60
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1...

output:

2

result:

ok 1 number(s): "2"

Test #41:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

5 36
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 5 4 3
4 2 3 1 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 4 3...

output:

8

result:

ok 1 number(s): "8"

Test #42:

score: 0
Accepted
time: 1ms
memory: 3904kb

input:

5 36
1 2 3 4 5
1 2 3 4 5
1 4 3 2 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 4 3 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3...

output:

16

result:

ok 1 number(s): "16"

Test #43:

score: 0
Accepted
time: 1ms
memory: 3824kb

input:

4 45
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 3 2 4
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 4 3 2
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3
1 2 4 3...

output:

6

result:

ok 1 number(s): "6"

Test #44:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

5 36
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
4 2 3 1 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 4...

output:

4

result:

ok 1 number(s): "4"

Test #45:

score: 0
Accepted
time: 1ms
memory: 4244kb

input:

5 36
1 2 5 4 3
1 2 5 4 3
4 2 3 1 5
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 4 3 5
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5 4 3
1 2 5...

output:

44

result:

ok 1 number(s): "44"

Test #46:

score: 0
Accepted
time: 1ms
memory: 3932kb

input:

6 30
1 4 3 2 5 6
1 4 3 2 5 6
4 2 3 1 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
6 2 3 4 5 1
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2 5 6
1 4 3 2...

output:

18

result:

ok 1 number(s): "18"

Test #47:

score: 0
Accepted
time: 1ms
memory: 4232kb

input:

6 30
1 2 3 5 4 6
1 2 3 4 6 5
1 5 3 4 2 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 4 3 5 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5 4 6
1 2 3 5...

output:

42

result:

ok 1 number(s): "42"

Test #48:

score: 0
Accepted
time: 1ms
memory: 3956kb

input:

6 30
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 3 4 6 5
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
2 1 3 4 5 6
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4 5 3
1 2 6 4...

output:

12

result:

ok 1 number(s): "12"

Extra Test:

score: 0
Extra Test Passed