QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#248143 | #7623. Coloring Tape | ucup-team987# | AC ✓ | 1112ms | 4408kb | C++20 | 19.1kb | 2023-11-11 17:39:30 | 2023-11-11 17:39:30 |
Judging History
你现在查看的是测评时间为 2023-11-11 17:39:30 的历史记录
- [2023-11-12 17:57:18]
- hack成功,自动添加数据
- (//qoj.ac/hack/447)
- [2023-11-11 17:39:30]
- 提交
answer
/**
* date : 2023-11-11 18:39:20
* author : Nyaan
*/
#define NDEBUG
using namespace std;
// intrinstic
#include <immintrin.h>
#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 <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// utility
namespace Nyaan {
using ll = long long;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = vector<vector<T>>;
using vi = vector<int>;
using vl = vector<long long>;
using vd = V<double>;
using vs = V<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename U>
struct P : pair<T, U> {
template <typename... Args>
P(Args... args) : pair<T, U>(args...) {}
using pair<T, U>::first;
using pair<T, U>::second;
P &operator+=(const P &r) {
first += r.first;
second += r.second;
return *this;
}
P &operator-=(const P &r) {
first -= r.first;
second -= r.second;
return *this;
}
P &operator*=(const P &r) {
first *= r.first;
second *= r.second;
return *this;
}
template <typename S>
P &operator*=(const S &r) {
first *= r, second *= r;
return *this;
}
P operator+(const P &r) const { return P(*this) += r; }
P operator-(const P &r) const { return P(*this) -= r; }
P operator*(const P &r) const { return P(*this) *= r; }
template <typename S>
P operator*(const S &r) const {
return P(*this) *= r;
}
P operator-() const { return P{-first, -second}; }
};
using pl = P<ll, ll>;
using pi = P<int, int>;
using vp = V<pl>;
constexpr int inf = 1001001001;
constexpr long long infLL = 4004004004004004004LL;
template <typename T>
int sz(const T &t) {
return t.size();
}
template <typename T, typename U>
inline bool amin(T &x, U y) {
return (y < x) ? (x = y, true) : false;
}
template <typename T, typename U>
inline bool amax(T &x, U y) {
return (x < y) ? (x = y, true) : false;
}
template <typename T>
inline T Max(const vector<T> &v) {
return *max_element(begin(v), end(v));
}
template <typename T>
inline T Min(const vector<T> &v) {
return *min_element(begin(v), end(v));
}
template <typename T>
inline long long Sum(const vector<T> &v) {
return accumulate(begin(v), end(v), 0LL);
}
template <typename T>
int lb(const vector<T> &v, const T &a) {
return lower_bound(begin(v), end(v), a) - begin(v);
}
template <typename T>
int ub(const vector<T> &v, const T &a) {
return upper_bound(begin(v), end(v), a) - begin(v);
}
constexpr long long TEN(int n) {
long long ret = 1, x = 10;
for (; n; x *= x, n >>= 1) ret *= (n & 1 ? x : 1);
return ret;
}
template <typename T, typename U>
pair<T, U> mkp(const T &t, const U &u) {
return make_pair(t, u);
}
template <typename T>
vector<T> mkrui(const vector<T> &v, bool rev = false) {
vector<T> ret(v.size() + 1);
if (rev) {
for (int i = int(v.size()) - 1; i >= 0; i--) ret[i] = v[i] + ret[i + 1];
} else {
for (int i = 0; i < int(v.size()); i++) ret[i + 1] = ret[i] + v[i];
}
return ret;
};
template <typename T>
vector<T> mkuni(const vector<T> &v) {
vector<T> ret(v);
sort(ret.begin(), ret.end());
ret.erase(unique(ret.begin(), ret.end()), ret.end());
return ret;
}
template <typename F>
vector<int> mkord(int N, F f) {
vector<int> ord(N);
iota(begin(ord), end(ord), 0);
sort(begin(ord), end(ord), f);
return ord;
}
template <typename T>
vector<int> mkinv(vector<T> &v) {
int max_val = *max_element(begin(v), end(v));
vector<int> inv(max_val + 1, -1);
for (int i = 0; i < (int)v.size(); i++) inv[v[i]] = i;
return inv;
}
vector<int> mkiota(int n) {
vector<int> ret(n);
iota(begin(ret), end(ret), 0);
return ret;
}
template <typename T>
T mkrev(const T &v) {
T w{v};
reverse(begin(w), end(w));
return w;
}
template <typename T>
bool nxp(vector<T> &v) {
return next_permutation(begin(v), end(v));
}
// 返り値の型は入力の T に依存
// i 要素目 : [0, a[i])
template <typename T>
vector<vector<T>> product(const vector<T> &a) {
vector<vector<T>> ret;
vector<T> v;
auto dfs = [&](auto rc, int i) -> void {
if (i == (int)a.size()) {
ret.push_back(v);
return;
}
for (int j = 0; j < a[i]; j++) v.push_back(j), rc(rc, i + 1), v.pop_back();
};
dfs(dfs, 0);
return ret;
}
// F : function(void(T&)), mod を取る操作
// T : 整数型のときはオーバーフローに注意する
template <typename T>
T Power(T a, long long n, const T &I, const function<void(T &)> &f) {
T res = I;
for (; n; f(a = a * a), n >>= 1) {
if (n & 1) f(res = res * a);
}
return res;
}
// T : 整数型のときはオーバーフローに注意する
template <typename T>
T Power(T a, long long n, const T &I = T{1}) {
return Power(a, n, I, function<void(T &)>{[](T &) -> void {}});
}
template <typename T>
T Rev(const T &v) {
T res = v;
reverse(begin(res), end(res));
return res;
}
template <typename T>
vector<T> Transpose(const vector<T> &v) {
using U = typename T::value_type;
int H = v.size(), W = v[0].size();
vector res(W, T(H, U{}));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
res[j][i] = v[i][j];
}
}
return res;
}
template <typename T>
vector<T> Rotate(const vector<T> &v, int clockwise = true) {
using U = typename T::value_type;
int H = v.size(), W = v[0].size();
vector res(W, T(H, U{}));
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (clockwise) {
res[W - 1 - j][i] = v[i][j];
} else {
res[j][H - 1 - i] = v[i][j];
}
}
}
return res;
}
} // namespace Nyaan
// bit operation
namespace Nyaan {
__attribute__((target("popcnt"))) inline int popcnt(const u64 &a) {
return _mm_popcnt_u64(a);
}
inline int lsb(const u64 &a) { return a ? __builtin_ctzll(a) : 64; }
inline int ctz(const u64 &a) { return a ? __builtin_ctzll(a) : 64; }
inline int msb(const u64 &a) { return a ? 63 - __builtin_clzll(a) : -1; }
template <typename T>
inline int gbit(const T &a, int i) {
return (a >> i) & 1;
}
template <typename T>
inline void sbit(T &a, int i, bool b) {
if (gbit(a, i) != b) a ^= T(1) << i;
}
constexpr long long PW(int n) { return 1LL << n; }
constexpr long long MSK(int n) { return (1LL << n) - 1; }
} // namespace Nyaan
// inout
namespace Nyaan {
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << p.first << " " << p.second;
return os;
}
template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
is >> p.first >> p.second;
return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
int s = (int)v.size();
for (int i = 0; i < s; i++) os << (i ? " " : "") << v[i];
return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
for (auto &x : v) is >> x;
return is;
}
istream &operator>>(istream &is, __int128_t &x) {
string S;
is >> S;
x = 0;
int flag = 0;
for (auto &c : S) {
if (c == '-') {
flag = true;
continue;
}
x *= 10;
x += c - '0';
}
if (flag) x = -x;
return is;
}
istream &operator>>(istream &is, __uint128_t &x) {
string S;
is >> S;
x = 0;
for (auto &c : S) {
x *= 10;
x += c - '0';
}
return is;
}
ostream &operator<<(ostream &os, __int128_t x) {
if (x == 0) return os << 0;
if (x < 0) os << '-', x = -x;
string S;
while (x) S.push_back('0' + x % 10), x /= 10;
reverse(begin(S), end(S));
return os << S;
}
ostream &operator<<(ostream &os, __uint128_t x) {
if (x == 0) return os << 0;
string S;
while (x) S.push_back('0' + x % 10), x /= 10;
reverse(begin(S), end(S));
return os << S;
}
void in() {}
template <typename T, class... U>
void in(T &t, U &...u) {
cin >> t;
in(u...);
}
void out() { cout << "\n"; }
template <typename T, class... U, char sep = ' '>
void out(const T &t, const U &...u) {
cout << t;
if (sizeof...(u)) cout << sep;
out(u...);
}
struct IoSetupNya {
IoSetupNya() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
cerr << fixed << setprecision(7);
}
} iosetupnya;
} // namespace Nyaan
// debug
#ifdef NyaanDebug
#define trc(...) (void(0))
#else
#define trc(...) (void(0))
#endif
#ifdef NyaanLocal
#define trc2(...) (void(0))
#else
#define trc2(...) (void(0))
#endif
// macro
#define each(x, v) for (auto&& x : v)
#define each2(x, y, v) for (auto&& [x, y] : v)
#define all(v) (v).begin(), (v).end()
#define rep(i, N) for (long long i = 0; i < (long long)(N); i++)
#define repr(i, N) for (long long i = (long long)(N)-1; i >= 0; i--)
#define rep1(i, N) for (long long i = 1; i <= (long long)(N); i++)
#define repr1(i, N) for (long long i = (N); (long long)(i) > 0; i--)
#define reg(i, a, b) for (long long i = (a); i < (b); i++)
#define regr(i, a, b) for (long long i = (b)-1; i >= (a); i--)
#define fi first
#define se second
#define ini(...) \
int __VA_ARGS__; \
in(__VA_ARGS__)
#define inl(...) \
long long __VA_ARGS__; \
in(__VA_ARGS__)
#define ins(...) \
string __VA_ARGS__; \
in(__VA_ARGS__)
#define in2(s, t) \
for (int i = 0; i < (int)s.size(); i++) { \
in(s[i], t[i]); \
}
#define in3(s, t, u) \
for (int i = 0; i < (int)s.size(); i++) { \
in(s[i], t[i], u[i]); \
}
#define in4(s, t, u, v) \
for (int i = 0; i < (int)s.size(); i++) { \
in(s[i], t[i], u[i], v[i]); \
}
#define die(...) \
do { \
Nyaan::out(__VA_ARGS__); \
return; \
} while (0)
namespace Nyaan {
void solve();
}
int main() { Nyaan::solve(); }
//
// enumerate x : x \subset b
vector<int> enumerate_subset(int b) {
vector<int> res;
for (int i = b; i >= 0; --i) res.push_back(i &= b);
return res;
};
// enumerate x : x \in {n} and x \superset b
vector<int> enumerate_superset(int b, int n) {
vector<int> res;
for (int i = b; i < (1 << n); i = (i + 1) | b) res.push_back(i);
return res;
}
/**
* @brief 下位集合/上位集合の列挙
*/
//
template <typename T>
void superset_zeta_transform(vector<T>& f) {
int n = f.size();
assert((n & (n - 1)) == 0);
for (int i = 1; i < n; i <<= 1) {
for (int j = 0; j < n; j++) {
if ((j & i) == 0) {
f[j] += f[j | i];
}
}
}
}
template <typename T>
void superset_mobius_transform(vector<T>& f) {
int n = f.size();
assert((n & (n - 1)) == 0);
for (int i = 1; i < n; i <<= 1) {
for (int j = 0; j < n; j++) {
if ((j & i) == 0) {
f[j] -= f[j | i];
}
}
}
}
template <typename T>
void subset_zeta_transform(vector<T>& f) {
int n = f.size();
assert((n & (n - 1)) == 0);
for (int i = 1; i < n; i <<= 1) {
for (int j = 0; j < n; j++) {
if ((j & i) == 0) {
f[j | i] += f[j];
}
}
}
}
template <typename T>
void subset_mobius_transform(vector<T>& f) {
int n = f.size();
assert((n & (n - 1)) == 0);
for (int i = 1; i < n; i <<= 1) {
for (int j = 0; j < n; j++) {
if ((j & i) == 0) {
f[j | i] -= f[j];
}
}
}
}
/**
* @brief Zeta Transform / Moebius Transform
*/
//
template <uint32_t mod>
struct LazyMontgomeryModInt {
using mint = LazyMontgomeryModInt;
using i32 = int32_t;
using u32 = uint32_t;
using u64 = uint64_t;
static constexpr u32 get_r() {
u32 ret = mod;
for (i32 i = 0; i < 4; ++i) ret *= 2 - mod * ret;
return ret;
}
static constexpr u32 r = get_r();
static constexpr u32 n2 = -u64(mod) % mod;
static_assert(mod < (1 << 30), "invalid, mod >= 2 ^ 30");
static_assert((mod & 1) == 1, "invalid, mod % 2 == 0");
static_assert(r * mod == 1, "this code has bugs.");
u32 a;
constexpr LazyMontgomeryModInt() : a(0) {}
constexpr LazyMontgomeryModInt(const int64_t &b)
: a(reduce(u64(b % mod + mod) * n2)){};
static constexpr u32 reduce(const u64 &b) {
return (b + u64(u32(b) * u32(-r)) * mod) >> 32;
}
constexpr mint &operator+=(const mint &b) {
if (i32(a += b.a - 2 * mod) < 0) a += 2 * mod;
return *this;
}
constexpr mint &operator-=(const mint &b) {
if (i32(a -= b.a) < 0) a += 2 * mod;
return *this;
}
constexpr mint &operator*=(const mint &b) {
a = reduce(u64(a) * b.a);
return *this;
}
constexpr mint &operator/=(const mint &b) {
*this *= b.inverse();
return *this;
}
constexpr mint operator+(const mint &b) const { return mint(*this) += b; }
constexpr mint operator-(const mint &b) const { return mint(*this) -= b; }
constexpr mint operator*(const mint &b) const { return mint(*this) *= b; }
constexpr mint operator/(const mint &b) const { return mint(*this) /= b; }
constexpr bool operator==(const mint &b) const {
return (a >= mod ? a - mod : a) == (b.a >= mod ? b.a - mod : b.a);
}
constexpr bool operator!=(const mint &b) const {
return (a >= mod ? a - mod : a) != (b.a >= mod ? b.a - mod : b.a);
}
constexpr mint operator-() const { return mint() - mint(*this); }
constexpr mint operator+() const { return mint(*this); }
constexpr mint pow(u64 n) const {
mint ret(1), mul(*this);
while (n > 0) {
if (n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
constexpr mint inverse() const {
int x = get(), y = mod, u = 1, v = 0, t = 0, tmp = 0;
while (y > 0) {
t = x / y;
x -= t * y, u -= t * v;
tmp = x, x = y, y = tmp;
tmp = u, u = v, v = tmp;
}
return mint{u};
}
friend ostream &operator<<(ostream &os, const mint &b) {
return os << b.get();
}
friend istream &operator>>(istream &is, mint &b) {
int64_t t;
is >> t;
b = LazyMontgomeryModInt<mod>(t);
return (is);
}
constexpr u32 get() const {
u32 ret = reduce(a);
return ret >= mod ? ret - mod : ret;
}
static constexpr u32 get_mod() { return mod; }
};
using namespace std;
// コンストラクタの MAX に 「C(n, r) や fac(n) でクエリを投げる最大の n 」
// を入れると倍速くらいになる
// mod を超えて前計算して 0 割りを踏むバグは対策済み
template <typename T>
struct Binomial {
vector<T> f, g, h;
Binomial(int MAX = 0) {
assert(T::get_mod() != 0 && "Binomial<mint>()");
f.resize(1, T{1});
g.resize(1, T{1});
h.resize(1, T{1});
if (MAX > 0) extend(MAX + 1);
}
void extend(int m = -1) {
int n = f.size();
if (m == -1) m = n * 2;
m = min<int>(m, T::get_mod());
if (n >= m) return;
f.resize(m);
g.resize(m);
h.resize(m);
for (int i = n; i < m; i++) f[i] = f[i - 1] * T(i);
g[m - 1] = f[m - 1].inverse();
h[m - 1] = g[m - 1] * f[m - 2];
for (int i = m - 2; i >= n; i--) {
g[i] = g[i + 1] * T(i + 1);
h[i] = g[i] * f[i - 1];
}
}
T fac(int i) {
if (i < 0) return T(0);
while (i >= (int)f.size()) extend();
return f[i];
}
T finv(int i) {
if (i < 0) return T(0);
while (i >= (int)g.size()) extend();
return g[i];
}
T inv(int i) {
if (i < 0) return -inv(-i);
while (i >= (int)h.size()) extend();
return h[i];
}
T C(int n, int r) {
if (n < 0 || n < r || r < 0) return T(0);
return fac(n) * finv(n - r) * finv(r);
}
inline T operator()(int n, int r) { return C(n, r); }
template <typename I>
T multinomial(const vector<I>& r) {
static_assert(is_integral<I>::value == true);
int n = 0;
for (auto& x : r) {
if (x < 0) return T(0);
n += x;
}
T res = fac(n);
for (auto& x : r) res *= finv(x);
return res;
}
template <typename I>
T operator()(const vector<I>& r) {
return multinomial(r);
}
T C_naive(int n, int r) {
if (n < 0 || n < r || r < 0) return T(0);
T ret = T(1);
r = min(r, n - r);
for (int i = 1; i <= r; ++i) ret *= inv(i) * (n--);
return ret;
}
T P(int n, int r) {
if (n < 0 || n < r || r < 0) return T(0);
return fac(n) * finv(n - r);
}
// [x^r] 1 / (1-x)^n
T H(int n, int r) {
if (n < 0 || r < 0) return T(0);
return r == 0 ? 1 : C(n + r - 1, r);
}
};
//
using namespace Nyaan;
using mint = LazyMontgomeryModInt<998244353>;
// using mint = LazyMontgomeryModInt<1000000007>;
using vm = vector<mint>;
using vvm = vector<vm>;
Binomial<mint> C;
using namespace Nyaan;
int diff[555][15][15][2];
int pre[15][15];
void q() {
inl(N, M, RR);
rep(i, RR) {
ini(c, x, y, d);
--c, --x, --y;
if (x > y) swap(x, y);
diff[c][x][y][d] = 1;
}
vm dp(PW(N));
dp.back() = 1;
rep1(m, M - 1) {
// [l, r) を 1 色で塗る
auto check = [&](int l, int r) -> bool {
// diff = 1 制約
reg(i, l, r) reg(j, i + 1, r) {
if (diff[m][i][j][1]) return false;
}
// l 側
rep(i, l) reg(j, l, N) {
if (diff[m][i][j][0]) return false;
}
rep(i, r) reg(j, r, N) {
if (diff[m][i][j][0]) return false;
}
return true;
};
// 空はダメ
rep(i, N) pre[i][i] = false;
// 非空
rep(i, N) reg(j, i + 1, N + 1) { pre[i][j] = check(i, j); }
trc(dp);
auto dp2 = dp;
superset_zeta_transform(dp2);
trc(dp2);
vm nx(1 << N);
int oldb = 0;
int nxtb = 0;
int last_pos = 0;
auto dfs = [&](auto rc, int i) -> void {
if (i == N) {
if (last_pos != N) return;
trc(nxtb,oldb);
nx[nxtb] += dp2[oldb];
return;
}
int old_last = last_pos;
// i を使わない
rc(rc, i + 1);
// i を使う
int pos = i;
if (last_pos > pos) {
return;
} else if (last_pos < pos) {
// 上に行くべし
if (pre[old_last][pos + 1]) {
oldb ^= 1 << i;
nxtb ^= 1 << old_last;
last_pos = pos + 1;
rc(rc, i + 1);
last_pos = old_last;
oldb ^= 1 << i;
nxtb ^= 1 << old_last;
}
} else {
assert(last_pos == pos);
// 停滞 ~ 下に行く
reg(pos2, pos, N) {
if (pre[pos][pos2 + 1]) {
oldb ^= 1 << i;
nxtb ^= 1 << pos2;
last_pos = pos2 + 1;
rc(rc, i + 1);
last_pos = old_last;
oldb ^= 1 << i;
nxtb ^= 1 << pos2;
}
}
}
};
dfs(dfs, 0);
dp = nx;
trc(dp);
}
out(accumulate(all(dp), mint{}));
}
void Nyaan::solve() {
int t = 1;
// in(t);
while (t--) q();
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3556kb
input:
3 5 3 3 2 3 0 4 1 2 0 5 1 3 0
output:
19
result:
ok 1 number(s): "19"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3444kb
input:
5 10 10 9 3 4 1 2 4 5 0 7 2 3 0 9 2 3 0 6 3 5 0 6 2 4 1 2 4 5 0 1 1 3 1 7 2 4 0 10 2 3 0
output:
1514
result:
ok 1 number(s): "1514"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
5 10 20 8 4 5 0 2 2 5 1 8 4 5 0 10 3 5 0 7 1 3 1 1 2 4 1 6 3 5 1 10 3 5 0 4 1 5 1 7 3 4 1 2 2 4 1 8 3 4 0 9 3 5 0 5 2 5 1 9 4 5 0 9 1 2 0 6 1 5 1 8 3 5 0 2 2 4 1 8 3 5 0
output:
28131
result:
ok 1 number(s): "28131"
Test #4:
score: 0
Accepted
time: 5ms
memory: 3624kb
input:
10 100 200 95 5 7 0 7 4 6 1 62 9 10 0 32 5 8 1 31 2 6 1 75 7 9 1 1 4 7 1 18 7 10 1 75 1 8 1 87 6 9 1 44 7 8 1 68 6 9 1 95 4 6 0 34 1 2 1 70 1 6 1 31 5 9 1 15 6 10 1 48 5 8 1 51 3 7 1 39 5 9 1 23 2 3 1 7 8 9 1 84 7 10 1 13 4 9 1 18 3 6 1 59 9 10 0 31 8 10 1 6 7 9 1 76 3 10 1 41 5 6 0 33 3 4 1 96 1 10...
output:
655333622
result:
ok 1 number(s): "655333622"
Test #5:
score: 0
Accepted
time: 11ms
memory: 3872kb
input:
10 200 200 106 9 10 0 93 4 10 1 199 3 7 0 73 2 9 1 105 8 9 0 38 9 10 1 73 8 10 1 153 3 9 1 123 2 5 1 159 7 9 0 154 5 7 1 162 3 7 0 113 1 5 1 131 7 9 1 67 4 6 1 178 6 10 0 157 7 9 0 147 9 10 0 154 7 10 0 123 3 4 1 39 8 10 1 139 2 9 1 191 9 10 0 36 4 5 1 17 2 8 1 124 3 7 1 9 9 10 1 71 9 10 1 181 7 8 0...
output:
552037151
result:
ok 1 number(s): "552037151"
Test #6:
score: 0
Accepted
time: 17ms
memory: 3924kb
input:
10 300 200 252 1 5 0 48 9 10 1 18 9 10 1 233 9 10 0 195 2 9 1 125 2 5 1 263 7 9 1 24 1 6 1 258 2 10 1 272 8 10 1 76 5 7 1 147 1 7 1 93 9 10 1 30 6 9 1 10 1 10 1 56 2 10 1 93 8 9 1 206 6 9 1 65 1 9 1 226 3 5 0 88 7 8 1 151 3 4 1 292 9 10 0 129 2 3 1 292 9 10 0 180 7 10 1 4 5 10 1 10 9 10 1 151 4 7 1 ...
output:
4494096
result:
ok 1 number(s): "4494096"
Test #7:
score: 0
Accepted
time: 27ms
memory: 4216kb
input:
10 500 300 210 4 7 1 341 8 9 0 371 2 5 0 21 4 10 1 370 8 9 0 368 1 6 0 395 7 9 0 287 6 10 1 299 3 7 1 379 1 9 1 164 4 10 1 390 7 9 0 455 6 9 0 208 8 10 1 402 3 10 0 112 8 10 1 279 3 10 1 180 7 10 1 456 2 6 0 121 5 6 1 312 5 7 0 335 8 10 0 318 2 10 1 497 8 10 0 108 8 9 0 247 3 6 1 155 5 6 1 308 1 2 0...
output:
705403853
result:
ok 1 number(s): "705403853"
Test #8:
score: 0
Accepted
time: 143ms
memory: 4176kb
input:
12 500 300 115 3 10 1 152 10 12 1 89 8 12 1 276 4 7 0 467 6 7 0 405 5 9 0 189 4 9 1 197 1 3 1 341 7 8 0 67 7 8 1 266 2 6 1 78 8 12 1 317 11 12 0 417 8 10 0 380 2 8 0 255 2 5 1 80 7 9 1 317 5 11 1 470 5 9 0 373 3 4 0 413 4 10 0 393 9 12 0 362 8 10 1 42 7 12 1 486 3 5 0 229 1 5 0 224 6 7 0 55 3 10 1 4...
output:
378086467
result:
ok 1 number(s): "378086467"
Test #9:
score: 0
Accepted
time: 138ms
memory: 4320kb
input:
12 500 500 54 11 12 1 325 10 11 0 83 2 3 1 148 3 10 1 165 3 11 1 16 11 12 1 363 8 10 1 78 11 12 1 258 4 12 1 237 8 11 1 403 2 10 1 354 1 9 1 234 4 7 1 454 9 11 0 160 11 12 1 393 1 3 0 375 9 11 0 494 1 3 0 200 6 12 1 414 11 12 0 217 9 10 0 92 5 9 1 172 5 6 1 110 8 12 1 339 4 12 1 429 2 4 0 29 10 11 1...
output:
948753642
result:
ok 1 number(s): "948753642"
Test #10:
score: 0
Accepted
time: 858ms
memory: 4332kb
input:
14 500 500 362 4 12 1 225 5 9 1 428 5 9 1 101 8 10 1 488 5 9 0 249 11 14 1 232 2 6 1 220 4 10 1 20 7 13 1 154 4 13 1 480 8 14 0 9 2 4 1 201 7 10 1 174 10 11 0 169 13 14 0 256 10 12 1 403 11 13 0 492 10 14 0 167 6 12 1 123 11 13 1 471 9 10 0 77 5 9 1 51 6 10 1 411 11 14 1 422 11 13 0 7 1 7 1 284 5 11...
output:
103280588
result:
ok 1 number(s): "103280588"
Test #11:
score: 0
Accepted
time: 1112ms
memory: 3588kb
input:
14 500 0
output:
750061283
result:
ok 1 number(s): "750061283"
Test #12:
score: 0
Accepted
time: 1054ms
memory: 3672kb
input:
14 495 0
output:
662120858
result:
ok 1 number(s): "662120858"
Test #13:
score: 0
Accepted
time: 1079ms
memory: 3588kb
input:
14 490 0
output:
456608006
result:
ok 1 number(s): "456608006"
Test #14:
score: 0
Accepted
time: 1078ms
memory: 3572kb
input:
14 500 5 123 7 12 1 24 13 14 1 170 6 13 1 304 2 8 1 475 10 11 0
output:
715116697
result:
ok 1 number(s): "715116697"
Test #15:
score: 0
Accepted
time: 1058ms
memory: 3628kb
input:
14 500 10 237 5 9 1 36 3 14 1 470 5 13 1 315 4 6 1 28 9 12 1 220 11 14 0 160 9 12 1 312 10 11 0 72 7 12 1 230 8 11 0
output:
434022866
result:
ok 1 number(s): "434022866"
Test #16:
score: 0
Accepted
time: 1059ms
memory: 3692kb
input:
14 500 15 339 5 10 1 326 4 7 1 421 12 14 0 225 13 14 1 307 1 3 0 285 2 4 0 33 8 10 1 226 2 3 0 478 13 14 1 347 5 11 1 138 5 13 1 141 9 14 1 417 2 8 1 172 6 11 1 222 7 14 1
output:
268520991
result:
ok 1 number(s): "268520991"
Test #17:
score: 0
Accepted
time: 1057ms
memory: 3668kb
input:
14 500 20 357 5 14 1 296 10 14 1 490 9 10 0 221 11 12 1 490 12 13 0 469 5 13 1 93 2 8 1 482 12 14 0 461 2 7 1 152 2 13 1 34 8 14 1 60 9 12 1 195 4 5 0 1 6 8 1 3 5 11 1 129 11 13 1 124 13 14 1 434 11 13 0 141 4 5 1 80 6 12 1
output:
691528902
result:
ok 1 number(s): "691528902"
Test #18:
score: 0
Accepted
time: 885ms
memory: 3956kb
input:
14 500 100 85 13 14 0 130 2 7 0 38 5 10 0 450 1 2 1 103 8 10 0 410 11 14 1 39 10 14 0 29 3 4 0 98 9 11 0 226 6 9 1 17 5 6 0 475 9 12 1 337 12 13 1 42 10 11 0 457 8 10 1 49 1 2 0 222 9 13 0 105 7 11 0 403 6 8 1 151 2 8 0 13 11 12 0 483 10 14 1 304 5 9 1 197 5 14 0 58 4 7 0 482 1 12 1 331 12 13 1 398 ...
output:
0
result:
ok 1 number(s): "0"
Test #19:
score: 0
Accepted
time: 742ms
memory: 4068kb
input:
14 498 200 457 10 13 0 163 6 10 0 23 2 5 0 109 5 8 0 113 12 14 0 294 10 12 0 1 10 14 0 451 1 2 0 275 1 13 0 345 10 14 0 171 2 9 0 392 8 11 0 184 13 14 0 328 10 11 0 84 10 13 0 238 6 12 0 306 6 13 0 56 8 14 0 404 10 14 0 90 3 10 0 446 12 14 0 303 9 11 0 71 11 12 0 362 10 13 0 405 13 14 1 258 4 13 0 1...
output:
0
result:
ok 1 number(s): "0"
Test #20:
score: 0
Accepted
time: 675ms
memory: 4252kb
input:
14 497 300 265 5 12 0 368 6 14 0 400 3 10 0 408 13 14 1 494 9 11 1 8 13 14 0 132 10 14 0 203 4 10 0 86 13 14 0 96 3 9 0 39 11 14 0 439 8 9 0 161 1 13 0 264 1 7 0 176 8 10 0 8 10 12 0 299 2 13 0 285 1 13 0 392 7 8 1 143 11 13 0 84 10 11 1 270 1 9 0 311 8 10 0 39 5 10 0 282 4 11 0 45 9 10 0 465 12 14 ...
output:
0
result:
ok 1 number(s): "0"
Test #21:
score: 0
Accepted
time: 555ms
memory: 4408kb
input:
14 499 500 349 7 10 0 440 11 13 0 391 5 11 0 461 8 10 1 172 12 14 0 139 5 10 0 79 3 4 0 456 10 11 0 276 11 14 0 484 5 6 1 178 11 13 0 295 8 11 0 384 3 8 0 112 9 11 0 170 3 7 0 490 12 14 1 243 7 9 0 360 4 7 0 302 10 12 0 266 5 8 0 350 8 12 0 282 7 12 0 480 7 11 1 312 10 13 0 356 13 14 0 277 4 5 0 245...
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 1027ms
memory: 3552kb
input:
14 500 3 2 1 2 0 2 2 3 0 2 1 3 1
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
1 500 0
output:
1
result:
ok 1 number(s): "1"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
4 2 0
output:
17
result:
ok 1 number(s): "17"
Extra Test:
score: 0
Extra Test Passed