QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#689504 | #9488. Do Not Turn Back | Misuki# | AC ✓ | 703ms | 4460kb | C++20 | 11.9kb | 2024-10-30 17:29:47 | 2024-10-30 17:29:49 |
Judging History
answer
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <variant>
#include <bit>
#include <compare>
#include <concepts>
#include <numbers>
#include <ranges>
#include <span>
//#define int ll
#define INT128_MAX (__int128)(((unsigned __int128) 1 << ((sizeof(__int128) * __CHAR_BIT__) - 1)) - 1)
#define INT128_MIN (-INT128_MAX - 1)
#define clock chrono::steady_clock::now().time_since_epoch().count()
using namespace std;
template<class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2> pr) {
return os << pr.first << ' ' << pr.second;
}
template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &arr) {
for(size_t i = 0; T x : arr) {
os << x;
if (++i != N) os << ' ';
}
return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec) {
for(size_t i = 0; T x : vec) {
os << x;
if (++i != size(vec)) os << ' ';
}
return os;
}
template<class T>
ostream& operator<<(ostream& os, const set<T> &s) {
for(size_t i = 0; T x : s) {
os << x;
if (++i != size(s)) os << ' ';
}
return os;
}
template<class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2> &m) {
for(size_t i = 0; pair<T1, T2> x : m) {
os << x;
if (++i != size(m)) os << ' ';
}
return os;
}
#ifdef DEBUG
#define dbg(...) cerr << '(', _do(#__VA_ARGS__), cerr << ") = ", _do2(__VA_ARGS__)
template<typename T> void _do(T &&x) { cerr << x; }
template<typename T, typename ...S> void _do(T &&x, S&&...y) { cerr << x << ", "; _do(y...); }
template<typename T> void _do2(T &&x) { cerr << x << endl; }
template<typename T, typename ...S> void _do2(T &&x, S&&...y) { cerr << x << ", "; _do2(y...); }
#else
#define dbg(...)
#endif
using ll = long long;
using ull = unsigned long long;
using ldb = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
//#define double ldb
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using max_heap = priority_queue<T>;
template<ranges::forward_range rng, class T = ranges::range_value_t<rng>, class OP = plus<T>>
void pSum(rng &v) {
if (!v.empty())
for(T p = v[0]; T &x : v | views::drop(1))
x = p = OP()(p, x);
}
template<ranges::forward_range rng, class T = ranges::range_value_t<rng>, class OP>
void pSum(rng &v, OP op) {
if (!v.empty())
for(T p = v[0]; T &x : v | views::drop(1))
x = p = op(p, x);
}
template<ranges::forward_range rng>
void Unique(rng &v) {
ranges::sort(v);
v.resize(unique(v.begin(), v.end()) - v.begin());
}
template<ranges::random_access_range rng>
rng invPerm(rng p) {
rng ret = p;
for(int i = 0; i < ssize(p); i++)
ret[p[i]] = i;
return ret;
}
template<ranges::random_access_range rng, ranges::random_access_range rng2>
rng Permute(rng v, rng2 p) {
rng ret = v;
for(int i = 0; i < ssize(p); i++)
ret[p[i]] = v[i];
return ret;
}
template<bool directed>
vector<vector<int>> readGraph(int n, int m, int base) {
vector<vector<int>> g(n);
for(int i = 0; i < m; i++) {
int u, v; cin >> u >> v;
u -= base, v -= base;
g[u].emplace_back(v);
if constexpr (!directed)
g[v].emplace_back(u);
}
return g;
}
template<class T>
void setBit(T &msk, int bit, bool x) {
msk = (msk & ~(T(1) << bit)) | (T(x) << bit);
}
template<class T> void flipBit(T &msk, int bit) { msk ^= T(1) << bit; }
template<class T> bool getBit(T msk, int bit) { return msk >> bit & T(1); }
template<class T>
T floorDiv(T a, T b) {
if (b < 0) a *= -1, b *= -1;
return a >= 0 ? a / b : (a - b + 1) / b;
}
template<class T>
T ceilDiv(T a, T b) {
if (b < 0) a *= -1, b *= -1;
return a >= 0 ? (a + b - 1) / b : a / b;
}
template<class T> bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
//reference: https://github.com/NyaanNyaan/library/blob/master/modint/montgomery-modint.hpp#L10
//note: mod should be a prime less than 2^30.
template<uint32_t mod>
struct MontgomeryModInt {
using mint = MontgomeryModInt;
using i32 = int32_t;
using u32 = uint32_t;
using u64 = uint64_t;
static constexpr u32 get_r() {
u32 res = 1, base = mod;
for(i32 i = 0; i < 31; i++)
res *= base, base *= base;
return -res;
}
static constexpr u32 get_mod() {
return mod;
}
static constexpr u32 n2 = -u64(mod) % mod; //2^64 % mod
static constexpr u32 r = get_r(); //-P^{-1} % 2^32
u32 a;
static u32 reduce(const u64 &b) {
return (b + u64(u32(b) * r) * mod) >> 32;
}
static u32 transform(const u64 &b) {
return reduce(u64(b) * n2);
}
MontgomeryModInt() : a(0) {}
MontgomeryModInt(const int64_t &b)
: a(transform(b % mod + mod)) {}
mint pow(u64 k) const {
mint res(1), base(*this);
while(k) {
if (k & 1)
res *= base;
base *= base, k >>= 1;
}
return res;
}
mint inverse() const { return (*this).pow(mod - 2); }
u32 get() const {
u32 res = reduce(a);
return res >= mod ? res - mod : res;
}
mint& operator+=(const mint &b) {
if (i32(a += b.a - 2 * mod) < 0) a += 2 * mod;
return *this;
}
mint& operator-=(const mint &b) {
if (i32(a -= b.a) < 0) a += 2 * mod;
return *this;
}
mint& operator*=(const mint &b) {
a = reduce(u64(a) * b.a);
return *this;
}
mint& operator/=(const mint &b) {
a = reduce(u64(a) * b.inverse().a);
return *this;
}
mint operator-() { return mint() - mint(*this); }
bool operator==(mint b) const {
return (a >= mod ? a - mod : a) == (b.a >= mod ? b.a - mod : b.a);
}
bool operator!=(mint b) const {
return (a >= mod ? a - mod : a) != (b.a >= mod ? b.a - mod : b.a);
}
friend mint operator+(mint c, mint d) { return c += d; }
friend mint operator-(mint c, mint d) { return c -= d; }
friend mint operator*(mint c, mint d) { return c *= d; }
friend mint operator/(mint c, mint d) { return c /= d; }
friend ostream& operator<<(ostream& os, const mint& b) {
return os << b.get();
}
friend istream& operator>>(istream& is, mint& b) {
int64_t val;
is >> val;
b = mint(val);
return is;
}
};
using mint = MontgomeryModInt<998244353>;
//source: KACTL(for det() and inv())
template<class Mint>
struct matrix : vector<vector<Mint>> {
matrix(int n, int m) : vector<vector<Mint>>(n, vector<Mint>(m, 0)) {}
matrix(int n) : vector<vector<Mint>>(n, vector<Mint>(n, 0)) {}
int n() const { return ssize(*this); }
int m() const { return ssize((*this)[0]); }
static matrix I(int n) {
auto res = matrix(n, n);
for(int i = 0; i < n; i++)
res[i][i] = 1;
return res;
}
matrix& operator+=(const matrix &b) {
assert(n() == b.n());
assert(m() == b.m());
for(int i = 0; i < n(); i++)
for(int j = 0; j < m(); j++)
(*this)[i][j] += b[i][j];
return *this;
}
matrix& operator-=(const matrix &b) {
assert(n() == b.n());
assert(m() == b.m());
for(int i = 0; i < n(); i++)
for(int j = 0; j < m(); j++)
(*this)[i][j] -= b[i][j];
return *this;
}
matrix& operator*=(const matrix &b) {
assert(m() == b.n());
auto res = matrix(n(), b.m());
for(int i = 0; i < n(); i++)
for(int k = 0; k < m(); k++)
for(int j = 0; j < b.m(); j++)
res[i][j] += (*this)[i][k] * b[k][j];
this -> swap(res);
return *this;
}
matrix pow(ll k) const {
assert(n() == m());
auto res = I(n()), base = *this;
while(k) {
if (k & 1) res *= base;
base *= base, k >>= 1;
}
return res;
}
Mint det() const {
Mint res = 1;
auto a = *this;
for(int i = 0; i < n(); i++) {
for(int j = i + 1; j < m(); j++) {
while(a[j][i] != 0) {
Mint t = a[i][i] / a[j][i];
if (t != 0)
for(int k = i; k < n(); k++)
a[i][k] -= a[j][k] * t;
swap(a[i], a[j]);
res = -res;
}
}
res *= a[i][i];
if (res == 0) return 0;
}
return res;
}
matrix inv() const {
assert(n() == m());
matrix a = *this, tmp = I(n());
vector<int> col(n());
for(int i = 0; i < n(); i++) col[i] = i;
for(int i = 0; i < n(); i++) {
int r = i, c = i;
for(int j = i; j < n(); j++) {
for(int k = i; k < n(); k++) {
if (a[j][k] != 0) {
r = j, c = k;
goto found;
}
}
}
return matrix(0);
found:
a[i].swap(a[r]), tmp[i].swap(tmp[r]);
for(int j = 0; j < n(); j++)
swap(a[j][i], a[j][c]), swap(tmp[j][i], tmp[j][c]);
swap(col[i], col[c]);
Mint v = 1 / a[i][i];
for(int j = i + 1; j < n(); j++) {
Mint f = a[j][i] * v;
a[j][i] = 0;
for(int k = i + 1; k < n(); k++)
a[j][k] -= f * a[i][k];
for(int k = 0; k < n(); k++)
tmp[j][k] -= f * tmp[i][k];
}
for(int j = i + 1; j < n(); j++)
a[i][j] *= v;
for(int j = 0; j < n(); j++)
tmp[i][j] *= v;
a[i][i] = 1;
}
for(int i = n() - 1; i > 0; i--) {
for(int j = 0; j < i; j++) {
Mint v = a[j][i];
for(int k = 0; k < n(); k++)
tmp[j][k] -= v * tmp[i][k];
}
}
for(int i = 0; i < n(); i++)
for(int j = 0; j < n(); j++)
a[col[i]][col[j]] = tmp[i][j];
return a;
}
matrix operator-() { return matrix(n(), m()) - (*this); }
friend matrix operator+(matrix a, matrix b) { return a += b; }
friend matrix operator-(matrix a, matrix b) { return a -= b; }
friend matrix operator*(matrix a, matrix b) { return a *= b; }
friend ostream& operator<<(ostream& os, const matrix& b) {
for(int i = 0; i < b.n(); i++) {
os << '\n';
for(int j = 0; j < b.m(); j++)
os << b[i][j] << ' ';
}
return os;
}
friend istream& operator>>(istream& is, matrix& b) {
for(int i = 0; i < b.n(); i++)
for(int j = 0; j < b.m(); j++)
is >> b[i][j];
return is;
}
};
signed main() {
ios::sync_with_stdio(false), cin.tie(NULL);
int n, m, k; cin >> n >> m >> k;
vector g(n, vector<bool>(n, false));
vector<int> d(n);
for(int i = 0; i < m; i++) {
int u, v; cin >> u >> v;
u--, v--;
d[u]++, d[v]++;
g[u][v] = g[v][u] = true;
}
matrix<mint> M(2 * n, 2 * n);
for(int i = n; i < 2 * n; i++)
M[i][i - n] += 1;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++)
if (g[i][j])
M[i][j] += 1;
M[i][i + n] += 1 - d[i];
}
//cout << M << '\n';
matrix<mint> x(2 * n, 1);
for(int u = 0; u < n; u++)
for(int v = 1; v < n; v++)
if (g[0][u] and g[u][v])
x[v][0] += 1;
for(int i = 0; i < n; i++)
if (g[0][i])
x[i + n][0] = 1;
//cout << x << '\n';
//cout << '\n';
if (k == 1) {
cout << x.back()[0] << '\n';
return 0;
}
x = M.pow(k - 2) * x;
cout << x[n - 1][0] << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3812kb
input:
6 8 5 1 2 1 3 2 3 2 4 3 5 4 5 4 6 5 6
output:
2
result:
ok "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
11 11 2023 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 1 11
output:
1
result:
ok "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3600kb
input:
7 21 1000000000 1 2 1 3 1 4 1 5 1 6 1 7 2 3 2 4 2 5 2 6 2 7 3 4 3 5 3 6 3 7 4 5 4 6 4 7 5 6 5 7 6 7
output:
405422475
result:
ok "405422475"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
12 56 78144853 1 2 1 3 1 4 1 6 1 7 1 9 1 10 1 11 1 12 2 4 2 5 2 6 2 8 2 9 2 10 2 11 2 12 3 4 3 5 3 6 3 7 3 8 3 9 3 11 3 12 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 5 6 5 7 5 8 5 9 5 10 5 11 5 12 6 8 6 9 6 10 7 8 7 9 7 11 7 12 8 9 8 10 8 11 8 12 9 10 9 11 9 12 10 11 11 12
output:
843326021
result:
ok "843326021"
Test #5:
score: 0
Accepted
time: 2ms
memory: 3636kb
input:
13 61 268435455 1 2 1 3 1 4 1 5 1 6 1 8 1 9 1 10 1 11 1 12 1 13 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 12 2 13 3 4 3 5 3 6 3 7 3 8 3 9 3 10 4 6 4 7 4 9 4 12 4 13 5 6 5 7 5 9 5 11 5 13 6 7 6 8 6 9 6 11 6 12 6 13 7 8 7 10 7 11 7 12 8 9 8 10 8 11 8 12 8 13 9 10 9 12 9 13 10 11 10 12 10 13 11 12 11 13 12 13
output:
69651169
result:
ok "69651169"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
14 79 33554431 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 2 3 2 4 2 5 2 6 2 7 2 8 2 11 2 12 2 14 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 4 5 4 6 4 7 4 8 4 9 4 11 4 12 5 6 5 7 5 10 5 11 5 12 5 13 5 14 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 7 8 7 9 7 10 7 11 7 12 7 13 7 14 8 10 8 11 8...
output:
793621538
result:
ok "793621538"
Test #7:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
15 92 439487671 1 2 1 3 1 5 1 7 1 8 1 9 1 10 1 11 1 13 1 14 1 15 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 3 12 3 13 3 14 3 15 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 12 4 13 4 14 4 15 5 7 5 8 5 10 5 11 5 12 5 13 5 14 6 7 6 8 6 9 6 10 6 11 6 12 6 13 6 14 6 1...
output:
196201187
result:
ok "196201187"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
5 10 230391930 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5 4 5
output:
552614127
result:
ok "552614127"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
5 8 268435455 1 2 1 3 1 4 2 3 2 4 2 5 3 4 4 5
output:
666456772
result:
ok "666456772"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
6 13 67108863 1 2 1 3 1 4 1 5 2 4 2 5 2 6 3 4 3 5 3 6 4 5 4 6 5 6
output:
317571510
result:
ok "317571510"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
7 18 67108863 1 2 1 3 1 4 1 5 1 6 1 7 2 3 2 4 2 5 2 6 2 7 3 5 3 6 4 5 4 6 4 7 5 6 6 7
output:
921436359
result:
ok "921436359"
Test #12:
score: 0
Accepted
time: 1ms
memory: 3616kb
input:
11 43 115349891 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 2 3 2 6 2 7 2 8 2 9 2 11 3 4 3 5 3 8 3 9 3 10 4 5 4 6 4 7 4 8 4 9 4 11 5 6 5 7 5 9 5 10 5 11 6 7 6 9 6 10 6 11 7 8 7 9 7 10 7 11 8 9 8 11 9 10 9 11
output:
853336717
result:
ok "853336717"
Test #13:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
14 78 758166229 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 2 3 2 4 2 5 2 6 2 7 2 8 2 10 2 11 2 14 3 5 3 6 3 7 3 8 3 9 3 10 3 11 4 5 4 6 4 7 4 8 4 9 4 10 4 11 4 13 4 14 5 6 5 7 5 8 5 9 5 10 5 11 5 13 5 14 6 7 6 8 6 9 6 10 6 11 6 12 6 14 7 8 7 9 7 10 7 11 7 12 7 13 7 14 8 9 8 10 8 11 8 1...
output:
949739691
result:
ok "949739691"
Test #14:
score: 0
Accepted
time: 81ms
memory: 3808kb
input:
52 51 376665160 1 2 1 3 2 4 4 5 5 6 5 7 3 8 5 9 5 10 5 11 6 12 4 13 2 14 6 15 14 16 9 17 8 18 15 19 11 20 9 21 1 22 21 23 3 24 24 25 24 26 10 27 7 28 24 29 16 30 6 31 4 32 5 33 10 34 33 35 32 36 19 37 29 38 18 39 17 40 13 41 39 42 3 43 12 44 34 45 20 46 38 47 27 48 43 49 5 50 6 51 4 52
output:
0
result:
ok "0"
Test #15:
score: 0
Accepted
time: 1ms
memory: 3812kb
input:
29 28 4 1 2 1 3 2 4 1 5 3 6 3 7 6 8 4 9 3 10 6 11 10 12 4 13 3 14 9 15 6 16 14 17 16 18 11 19 19 20 8 21 6 22 18 23 18 24 3 25 2 26 8 27 1 28 8 29
output:
1
result:
ok "1"
Test #16:
score: 0
Accepted
time: 589ms
memory: 4460kb
input:
99 98 33554431 46 94 29 46 29 75 50 75 50 61 6 61 6 10 10 49 38 49 38 86 37 86 37 66 31 66 31 71 41 71 41 67 22 67 22 52 52 62 62 74 74 89 53 89 53 91 69 91 40 69 40 97 45 97 9 45 9 18 18 23 23 25 25 43 43 92 3 92 3 5 5 28 28 58 19 58 17 19 17 80 4 80 4 56 24 56 21 24 1 21 1 95 51 95 36 51 36 96 20 ...
output:
0
result:
ok "0"
Test #17:
score: 0
Accepted
time: 1ms
memory: 3964kb
input:
98 97 2 1 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 2 32 2 33 2 34 2 35 2 36 2 37 2 38 2 39 2 40 2 41 2 42 2 43 2 44 2 45 2 46 2 47 2 48 2 49 2 50 2 51 2 52 2 53 2 54 2 55 2 56 2 57 2 58 2 59 2 60 2 61 ...
output:
1
result:
ok "1"
Test #18:
score: 0
Accepted
time: 385ms
memory: 4368kb
input:
91 91 68838384 35 46 29 46 29 75 50 75 50 61 6 61 6 10 10 49 38 49 38 86 37 86 37 66 31 66 31 71 41 71 41 67 22 67 22 52 52 62 62 74 74 89 53 89 53 91 69 91 40 69 40 79 45 79 9 45 9 18 18 23 23 25 25 43 12 43 3 12 3 5 5 28 28 58 19 58 17 19 17 80 4 80 4 56 24 56 21 24 1 21 1 64 51 64 36 51 36 47 20 ...
output:
1
result:
ok "1"
Test #19:
score: 0
Accepted
time: 445ms
memory: 4116kb
input:
92 92 860263916 30 45 45 60 60 66 66 78 15 78 9 15 9 14 14 35 35 37 37 85 24 85 24 65 64 65 10 64 10 53 32 53 22 32 22 51 51 80 80 92 77 92 43 77 33 43 33 39 39 82 6 82 2 6 2 88 40 88 40 58 25 58 25 72 72 91 7 91 7 8 8 57 48 57 21 48 21 68 68 79 55 79 12 55 12 38 1 38 1 90 63 90 13 63 13 44 44 54 47...
output:
1
result:
ok "1"
Test #20:
score: 0
Accepted
time: 404ms
memory: 4052kb
input:
91 4095 412854823 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 ...
output:
309435713
result:
ok "309435713"
Test #21:
score: 0
Accepted
time: 495ms
memory: 4156kb
input:
92 4186 67108863 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1...
output:
445773689
result:
ok "445773689"
Test #22:
score: 0
Accepted
time: 574ms
memory: 4116kb
input:
93 4278 536870911 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 ...
output:
664971360
result:
ok "664971360"
Test #23:
score: 0
Accepted
time: 505ms
memory: 4196kb
input:
94 4371 531304381 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 ...
output:
33852961
result:
ok "33852961"
Test #24:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
10 38 187055368 1 2 1 3 1 5 1 6 1 8 1 9 1 10 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 3 4 3 5 3 6 3 7 3 8 3 9 3 10 4 5 4 6 4 7 4 8 4 9 5 7 5 8 5 9 5 10 6 7 6 8 6 9 6 10 7 8 7 10 8 10
output:
174346166
result:
ok "174346166"
Test #25:
score: 0
Accepted
time: 13ms
memory: 3500kb
input:
31 395 508956048 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 12 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 23 1 24 1 25 1 26 1 27 1 28 1 30 1 31 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 16 2 17 2 18 2 19 2 20 2 22 2 23 2 24 2 25 2 26 2 27 2 28 2 29 2 30 2 31 3 4 3 5 3 7 3 8 3 9 3 10 3 11 3 1...
output:
898454226
result:
ok "898454226"
Test #26:
score: 0
Accepted
time: 50ms
memory: 3716kb
input:
46 843 103688348 1 2 1 3 1 4 1 5 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 33 1 34 1 35 1 36 1 37 1 38 1 41 1 42 1 43 1 44 1 45 2 3 2 4 2 5 2 6 2 7 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 18 2 19 2 20 2 22 2 23 2 26 2...
output:
804037438
result:
ok "804037438"
Test #27:
score: 0
Accepted
time: 379ms
memory: 4240kb
input:
81 2612 536870911 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 21 1 22 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 49 1 50 1 51 1 52 1 53 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 63 1 64 1 65 ...
output:
439960927
result:
ok "439960927"
Test #28:
score: 0
Accepted
time: 616ms
memory: 4260kb
input:
98 3845 134217727 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 13 1 15 1 16 1 17 1 18 1 20 1 21 1 22 1 23 1 24 1 26 1 27 1 30 1 32 1 33 1 34 1 35 1 38 1 40 1 41 1 42 1 44 1 45 1 46 1 48 1 49 1 50 1 51 1 52 1 53 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 69 1 71 1 72 1 74 1 75 ...
output:
687576024
result:
ok "687576024"
Test #29:
score: 0
Accepted
time: 36ms
memory: 3636kb
input:
38 559 33554431 1 2 1 3 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 14 1 15 1 16 1 18 1 20 1 21 1 23 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 38 2 4 2 5 2 6 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 2 18 2 19 2 20 2 21 2 22 2 24 2 25 2 26 2 28 2 29 2 30 2 31 2 32 2 34 3 4 3 5 3 6 3 7 3 8 3 9 3...
output:
245031029
result:
ok "245031029"
Test #30:
score: 0
Accepted
time: 105ms
memory: 3732kb
input:
53 1106 268435455 1 2 1 3 1 4 1 5 1 6 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 2 3 2 4 2 5 2 6 2 7 2 9 2 10 2 11 2 13 2 14 ...
output:
437352844
result:
ok "437352844"
Test #31:
score: 0
Accepted
time: 48ms
memory: 3732kb
input:
43 725 710015779 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 14 1 15 1 16 1 18 1 19 1 20 1 23 1 24 1 26 1 27 1 28 1 29 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 39 1 40 1 41 1 42 1 43 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 20 2 21 2 23 2 24 2 26 2 27 2 29 2 32 2 3...
output:
287707534
result:
ok "287707534"
Test #32:
score: 0
Accepted
time: 186ms
memory: 3928kb
input:
66 1737 67108863 1 2 1 3 1 5 1 6 1 7 1 8 1 9 1 10 1 12 1 13 1 15 1 16 1 17 1 18 1 21 1 22 1 23 1 24 1 25 1 26 1 31 1 32 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 45 1 46 1 47 1 49 1 50 1 51 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62 1 63 1 64 1 66 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2...
output:
655903832
result:
ok "655903832"
Test #33:
score: 0
Accepted
time: 10ms
memory: 3888kb
input:
29 327 815825607 1 2 1 3 1 4 1 5 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 18 1 19 1 20 1 21 1 23 1 24 1 25 1 26 1 27 1 28 1 29 2 3 2 5 2 6 2 7 2 8 2 9 2 10 2 12 2 13 2 14 2 15 2 16 2 17 2 18 2 19 2 21 2 23 2 24 2 25 2 26 2 27 2 28 2 29 3 4 3 6 3 7 3 9 3 10 3 11 3 12 3 13 3 15 3 16 3 17 3 18 3 20 ...
output:
3611745
result:
ok "3611745"
Test #34:
score: 0
Accepted
time: 703ms
memory: 4260kb
input:
100 4950 536870911 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59...
output:
77654284
result:
ok "77654284"
Test #35:
score: 0
Accepted
time: 703ms
memory: 4260kb
input:
100 3962 536870911 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 12 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 35 1 36 1 37 1 38 1 39 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 51 1 53 1 54 1 55 1 56 1 57 1 58 1 60 1 61 1 62 1 63 1 64 1 65 1 67...
output:
277610741
result:
ok "277610741"
Test #36:
score: 0
Accepted
time: 685ms
memory: 4188kb
input:
99 3919 536870911 1 2 1 3 1 4 1 5 1 7 1 9 1 10 1 11 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 23 1 24 1 25 1 27 1 28 1 29 1 32 1 33 1 34 1 36 1 37 1 38 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 56 1 57 1 58 1 59 1 60 1 62 1 63 1 64 1 65 1 66 1 67 1 68 1 70 1 7...
output:
377999899
result:
ok "377999899"
Extra Test:
score: 0
Extra Test Passed