QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#772640#8820. Exchanging Kubic 2hos_lyricAC ✓3405ms10492kbC++148.1kb2024-11-22 20:58:412024-11-22 20:58:42

Judging History

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

  • [2024-11-22 20:58:42]
  • 评测
  • 测评结果:AC
  • 用时:3405ms
  • 内存:10492kb
  • [2024-11-22 20:58:41]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")

////////////////////////////////////////////////////////////////////////////////
template <unsigned M_> struct ModInt {
  static constexpr unsigned M = M_;
  unsigned x;
  constexpr ModInt() : x(0U) {}
  constexpr ModInt(unsigned x_) : x(x_ % M) {}
  constexpr ModInt(unsigned long long x_) : x(x_ % M) {}
  constexpr ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
  constexpr ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
  ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
  ModInt &operator*=(const ModInt &a) { x = (static_cast<unsigned long long>(x) * a.x) % M; return *this; }
  ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
  ModInt pow(long long e) const {
    if (e < 0) return inv().pow(-e);
    ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
  }
  ModInt inv() const {
    unsigned a = M, b = x; int y = 0, z = 1;
    for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
    assert(a == 1U); return ModInt(y);
  }
  ModInt operator+() const { return *this; }
  ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
  ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
  ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
  ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
  ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
  template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
  template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
  template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
  template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
  explicit operator bool() const { return x; }
  bool operator==(const ModInt &a) const { return (x == a.x); }
  bool operator!=(const ModInt &a) const { return (x != a.x); }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
////////////////////////////////////////////////////////////////////////////////

constexpr unsigned MO = 998244353;
using Mint = ModInt<MO>;


/*
  d[i] := a[i] - a[i-1]  (1 <= i <= N-1)
  operation on i:
    find max l s.t. l <= i && d[l] > 0, do d[l] -= 1
    find min r s.t. i <  r && d[r] > 0, do d[r] -= 1
  
  relaxed:
    choose l <= i && d[l] > 0, do d[l] -= 1
    choose i <  r && d[r] > 0, do d[r] -= 1
  
  same?
  
  hall for relaxed
  ~~>
  cost = max{0, max{ (a[j]-a[i]) - ((N-1-i) + j) | 0 <= i <= j < N }}
       = max{0, max{ (a[j]-j) - (a[i]-i) - (N-1) | 0 <= i <= j < N }}
       = max{0, max{ (a[j]-j) - (a[i]-i) - (N-1) | 0 <= i,j < N }}  (too small if i > j)
       = max{0, max(a[i]-i) - min(a[i]-i) - (N-1)}
  
  - fix min and count (max - min >= N)
  - fix max and count (max - min >= N)
*/

namespace exper {
int N;
vector<int> D;
int brute() {
  int mn = 1001001001;
  vector<int> is(N);
  for (int i = 0; i < N; ++i) is[i] = i;
  do {
    auto ds = D;
    for (const int i : is) {
      for (int l = i    ; l > 0; --l) if (ds[l]) { --ds[l]; break; }
      for (int r = i + 1; r < N; ++r) if (ds[r]) { --ds[r]; break; }
    }
    int cost = 0;
    for (int j = 1; j < N; ++j) cost += ds[j];
    chmin(mn, cost);
  } while (next_permutation(is.begin(), is.end()));
  return mn;
}
int hall() {
  vector<int> as(N, 0);
  for (int i = 1; i < N; ++i) as[i] = as[i - 1] + D[i];
  int cost = 0;
  for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) chmax(cost, (as[j]-j) - (as[i]-i) - (N-1));
  return cost;
}
void test() {
  const auto brt = brute();
  const auto hal = hall();
  if (brt != hal) {
    cerr << "FAIL " << N << " " << D << ": " << brt << " " << hal << endl;
    assert(false);
  }
}
void gen(int i) {
  if (i == N) {
    test();
  } else {
    for (D[i] = 0; D[i] <= N; ++D[i]) gen(i + 1);
  }
}
void run() {
  for (N = 1; ; ++N) {
    D.assign(N + 1, 0);
    gen(1);
    cerr << "PASSED N = " << N << endl;
  }
}
}  // exper
// PASSED N = 7

constexpr int INF = 1001001001;

int N;
int M[410];
int A[410][810];

Mint dp[410][810][2][2];

int main() {
  // exper::run();
  
  for (; ~scanf("%d", &N); ) {
    for (int i = 0; i < N; ++i) {
      scanf("%d", &M[i]);
      for (int j = 0; j < M[i]; ++j) {
        scanf("%d", &A[i][j]);
      }
      sort(A[i], A[i] + M[i]);
    }
    
    Mint ans = 0;
#define REP for (int u = 0; u < 2; ++u) for (int v = 0; v < 2; ++v)
    {
      int mn0 = +INF, mn1 = +INF;
      for (int i = 0; i < N-1; ++i) if (M[i]) {
        chmin(mn0, A[i][0] - i);
        chmin(mn1, A[i][M[i]-1] - i);
      }
      for (int mn = mn0; mn <= mn1; ++mn) {
        for (int i = 0; i < N; ++i) for (int j = 0; j < M[i]; ++j) REP dp[i][j][u][v] = 0;
        for (int i = 0; i < N; ++i) {
          Mint sum[2][2] = {};
          if (!i) sum[0][0] += 1;
          int jj = 0;
          for (int j = 0; j < M[i]; ++j) {
            const int b = A[i][j] - i;
            if (b >= mn) {
              if (i) {
                for (; jj < M[i - 1] && A[i - 1][jj] <= A[i][j]; ++jj) {
                  REP sum[u][v] += dp[i - 1][jj][u][v];
                }
              }
              REP dp[i][j][u || (b == mn)][v || (b >= mn + N)] += sum[u][v];
            }
          }
        }
        Mint here = 0;
        for (int j = 0; j < M[N-1]; ++j) here += dp[N-1][j][1][1];
// cerr<<"mn="<<mn<<": "<<here<<endl;
        ans -= here * mn;
      }
    }
    {
      int mx0 = -INF, mx1 = -INF;
      for (int i = 0; i < N; ++i) if (M[i]) {
        chmax(mx0, A[i][0] - i);
        chmax(mx1, A[i][M[i]-1] - i);
      }
      for (int mx = mx0; mx <= mx1; ++mx) {
        for (int i = 0; i < N; ++i) for (int j = 0; j < M[i]; ++j) REP dp[i][j][u][v] = 0;
        for (int i = 0; i < N; ++i) {
          Mint sum[2][2] = {};
          if (!i) sum[0][0] += 1;
          int jj = 0;
          for (int j = 0; j < M[i]; ++j) {
            const int b = A[i][j] - i;
            if (b <= mx) {
              if (i) {
                for (; jj < M[i - 1] && A[i - 1][jj] <= A[i][j]; ++jj) {
                  REP sum[u][v] += dp[i - 1][jj][u][v];
                }
              }
              REP dp[i][j][u || (b == mx)][v || (b <= mx - N)] += sum[u][v];
            }
          }
        }
        Mint here = 0;
        for (int j = 0; j < M[N-1]; ++j) here += dp[N-1][j][1][1];
// cerr<<"mx="<<mx<<": "<<here<<endl;
        ans += here * (mx - (N-1));
      }
    }
    
    printf("%u\n", ans.x);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

0

result:

ok "0"

Test #2:

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

input:

5
4 1 2 3 7
4 5 7 8 9
4 2 3 6 9
5 0 1 4 7 9
8 0 1 2 3 6 7 8 9

output:

16

result:

ok "16"

Test #3:

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

input:

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

output:

27895

result:

ok "27895"

Test #4:

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

input:

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

output:

625955

result:

ok "625955"

Test #5:

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

input:

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

output:

792393

result:

ok "792393"

Test #6:

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

input:

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

output:

360237

result:

ok "360237"

Test #7:

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

input:

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

output:

5546330

result:

ok "5546330"

Test #8:

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

input:

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

output:

8298325

result:

ok "8298325"

Test #9:

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

input:

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

output:

8321362

result:

ok "8321362"

Test #10:

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

input:

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

output:

14615813

result:

ok "14615813"

Test #11:

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

input:

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

output:

6260430

result:

ok "6260430"

Test #12:

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

input:

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

output:

14649479

result:

ok "14649479"

Test #13:

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

input:

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

output:

11884364

result:

ok "11884364"

Test #14:

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

input:

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

output:

12608630

result:

ok "12608630"

Test #15:

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

input:

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

output:

15597786

result:

ok "15597786"

Test #16:

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

input:

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

output:

18162391

result:

ok "18162391"

Test #17:

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

input:

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

output:

13636845

result:

ok "13636845"

Test #18:

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

input:

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

output:

23060640

result:

ok "23060640"

Test #19:

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

input:

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

output:

16391978

result:

ok "16391978"

Test #20:

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

input:

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

output:

17643155

result:

ok "17643155"

Test #21:

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

input:

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

output:

22529158

result:

ok "22529158"

Test #22:

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

input:

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

output:

23343575

result:

ok "23343575"

Test #23:

score: 0
Accepted
time: 2597ms
memory: 10204kb

input:

400
398 1 2 3 7 15 17 18 19 22 23 26 29 30 31 34 37 39 40 41 42 43 46 47 48 49 50 51 53 58 59 61 63 64 66 68 72 73 74 78 79 80 81 82 86 92 95 99 102 103 105 109 111 112 113 115 116 118 121 123 124 127 129 130 132 134 135 136 138 139 140 141 145 146 149 151 152 155 156 157 158 160 161 162 163 164 167...

output:

32030707

result:

ok "32030707"

Test #24:

score: 0
Accepted
time: 3088ms
memory: 10248kb

input:

400
525 0 3 4 5 6 7 8 13 14 17 19 20 21 22 23 25 26 27 29 30 32 33 34 35 36 39 40 44 49 50 51 55 57 58 60 61 63 64 65 66 67 68 69 70 71 72 73 74 78 79 80 81 82 84 85 86 88 90 91 92 93 94 95 96 98 99 100 101 103 104 105 106 107 108 111 113 115 116 117 118 119 120 121 122 123 124 125 127 129 130 132 1...

output:

850087104

result:

ok "850087104"

Test #25:

score: 0
Accepted
time: 3269ms
memory: 10372kb

input:

400
608 0 2 3 4 6 7 8 9 10 18 19 22 23 24 26 27 28 29 30 31 33 34 35 36 37 38 39 40 41 42 43 44 45 47 48 49 50 51 52 53 55 56 57 58 60 62 63 64 65 66 67 68 69 71 72 73 74 75 76 79 80 81 82 83 84 85 86 88 89 90 91 92 93 94 95 96 97 98 101 104 105 107 108 109 110 111 112 113 114 115 116 117 118 119 12...

output:

85811240

result:

ok "85811240"

Test #26:

score: 0
Accepted
time: 3334ms
memory: 10284kb

input:

400
639 0 1 2 4 5 6 7 8 9 10 12 13 15 16 17 18 19 20 23 24 25 26 27 29 30 31 33 34 35 37 38 39 40 42 44 45 46 47 49 52 55 56 57 58 59 60 61 62 63 64 65 69 70 71 72 74 75 76 77 78 79 80 81 82 83 84 87 88 89 90 91 92 93 94 96 97 98 100 101 102 103 104 105 108 111 112 113 114 115 116 117 118 119 120 12...

output:

570853649

result:

ok "570853649"

Test #27:

score: 0
Accepted
time: 3373ms
memory: 10260kb

input:

400
669 0 2 3 4 5 6 7 8 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 27 28 30 31 32 34 35 36 37 38 39 40 41 42 44 46 47 48 49 51 53 54 55 56 58 59 61 62 63 64 65 66 67 69 70 71 73 74 75 76 77 78 80 81 82 83 84 85 86 87 89 90 91 92 94 95 96 97 98 99 100 101 102 105 107 109 110 112 113 114 115 116 117...

output:

560397199

result:

ok "560397199"

Test #28:

score: 0
Accepted
time: 3372ms
memory: 10220kb

input:

400
688 0 1 2 3 4 7 9 10 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 41 42 43 44 45 46 47 48 49 50 51 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 95 96 98 99 100 101 102 103 104 105 10...

output:

123702640

result:

ok "123702640"

Test #29:

score: 0
Accepted
time: 3391ms
memory: 10492kb

input:

400
709 1 2 3 4 5 6 7 8 9 10 11 12 15 16 18 19 20 21 22 23 24 25 27 28 29 30 31 32 33 34 35 36 37 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 1...

output:

906888562

result:

ok "906888562"

Test #30:

score: 0
Accepted
time: 3405ms
memory: 10224kb

input:

400
723 0 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 38 39 41 42 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 78 79 81 82 83 84 85 88 89 90 91 92 93 94 95 97 98 99 100 101 102 103 104 105 106 107 108 1...

output:

823364539

result:

ok "823364539"

Test #31:

score: 0
Accepted
time: 3390ms
memory: 10220kb

input:

400
714 1 2 3 4 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 25 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 56 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 74 75 76 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 99 100 102 103 104 105 107 109 1...

output:

36533235

result:

ok "36533235"

Test #32:

score: 0
Accepted
time: 3399ms
memory: 10184kb

input:

400
719 0 1 3 4 5 6 7 8 9 10 12 13 14 15 16 17 19 20 21 22 23 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 56 58 59 60 62 63 64 65 66 67 69 70 71 72 74 75 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 10...

output:

406818175

result:

ok "406818175"

Test #33:

score: 0
Accepted
time: 3382ms
memory: 10468kb

input:

400
732 0 3 4 5 6 7 8 9 10 11 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35 36 37 38 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 57 58 60 61 62 63 64 65 66 68 69 70 71 72 73 74 75 76 77 78 79 82 83 85 86 90 91 92 93 94 95 96 97 98 99 100 102 103 104 105 106 107 108 109 111 11...

output:

481255039

result:

ok "481255039"

Test #34:

score: 0
Accepted
time: 3389ms
memory: 10216kb

input:

400
748 0 1 2 3 4 5 6 7 9 10 12 13 15 16 17 18 19 20 21 22 23 24 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 60 61 62 63 64 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 94 95 96 97 99 100 101 102 103 104 105 108 ...

output:

460391813

result:

ok "460391813"

Test #35:

score: 0
Accepted
time: 3384ms
memory: 10096kb

input:

400
731 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21 22 23 25 26 27 28 29 30 31 32 33 34 35 37 38 39 40 41 42 43 44 45 46 47 49 51 52 53 54 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 96 97 99 100 101 102 103 104 105 106 107 ...

output:

576690716

result:

ok "576690716"

Test #36:

score: 0
Accepted
time: 3391ms
memory: 10204kb

input:

400
762 0 1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 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 64 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 10...

output:

103234180

result:

ok "103234180"

Test #37:

score: 0
Accepted
time: 3363ms
memory: 10072kb

input:

400
749 0 1 2 3 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 33 35 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 83 84 85 86 87 89 90 91 92 93 95 96 97 98 100 101 102 103 104 105 106 ...

output:

601648123

result:

ok "601648123"

Test #38:

score: 0
Accepted
time: 3376ms
memory: 10168kb

input:

400
755 0 1 2 4 5 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 51 52 53 54 55 56 57 58 59 60 61 62 63 65 66 67 68 69 70 71 72 73 74 75 76 77 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 100 101 104 105 10...

output:

328082778

result:

ok "328082778"

Test #39:

score: 0
Accepted
time: 3365ms
memory: 10340kb

input:

400
762 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18 20 21 22 23 24 26 27 29 30 31 32 33 34 35 36 37 38 40 41 42 43 44 46 47 48 49 50 51 52 53 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 88 89 90 92 93 94 95 96 97 98 99 100 101 103 104 105 106 107 1...

output:

276511237

result:

ok "276511237"

Test #40:

score: 0
Accepted
time: 3354ms
memory: 10080kb

input:

400
755 0 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 19 20 21 22 23 24 25 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 81 82 83 84 85 86 87 89 90 91 92 93 94 95 96 97 99 100 101 102 103 104 ...

output:

709788991

result:

ok "709788991"

Test #41:

score: 0
Accepted
time: 3360ms
memory: 10492kb

input:

400
770 0 1 2 3 4 5 6 7 8 9 10 12 13 14 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 81 82 83 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 102 103 10...

output:

712048847

result:

ok "712048847"

Test #42:

score: 0
Accepted
time: 3358ms
memory: 10216kb

input:

400
763 0 1 2 3 4 5 6 7 9 10 11 12 13 14 16 17 18 19 20 21 22 23 24 25 26 27 28 29 31 32 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 104 ...

output:

624491828

result:

ok "624491828"

Extra Test:

score: 0
Extra Test Passed