QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#283351 | #5525. Increasing Grid | Misuki# | AC ✓ | 19ms | 9684kb | C++20 | 5.7kb | 2023-12-14 15:19:33 | 2023-12-14 15:19:34 |
Judging History
answer
#pragma GCC optimize("O2")
#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <compare>
#include <complex>
#include <concepts>
#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 <numbers>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <set>
#include <span>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <variant>
#define int ll
#define INT128_MAX (__int128)(((unsigned __int128) 1 << ((sizeof(__int128) * __CHAR_BIT__) - 1)) - 1)
#define INT128_MIN (-INT128_MAX - 1)
namespace R = std::ranges;
namespace V = std::views;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using tiii = tuple<int, int, int>;
using ldb = long double;
//#define double ldb
template<class T>
ostream& operator<<(ostream& os, const pair<T, T> pr) {
return os << pr.first << ' ' << pr.second;
}
template<class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N> &arr) {
for(const T &X : arr)
os << X << ' ';
return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec) {
for(const T &X : vec)
os << X << ' ';
return os;
}
/**
* template name: MontgomeryModInt
* author: Misuki
* reference: https://github.com/NyaanNyaan/library/blob/master/modint/montgomery-modint.hpp#L10
* last update: 2023/11/30
* 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) {
return (a >= mod ? a - mod : a) == (b.a >= mod ? b.a - mod : b.a);
}
bool operator!=(mint b) {
return (a >= mod ? a - mod : a) != (b.a >= mod ? b.a - mod : b.a);
}
friend mint operator+(mint a, mint b) { return a += b; }
friend mint operator-(mint a, mint b) { return a -= b; }
friend mint operator*(mint a, mint b) { return a *= b; }
friend mint operator/(mint a, mint b) { return a /= b; }
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>;
signed main() {
ios::sync_with_stdio(false), cin.tie(NULL);
int t; cin >> t;
while(t--) {
int n, m; cin >> n >> m;
vector a(n, vector<int>(m));
for(auto &v : a) {
for(int &x : v) {
cin >> x;
if (x != -1)
x--;
}
}
vector cl(n + 1, vector<int>(m + 1)), cr(n + 1, vector<int>(m + 1));
bool ok = true;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if (a[i][j] == i + j)
cl[i][j] = true;
else if (a[i][j] == i + j + 1)
cr[i][j] = true;
else if (a[i][j] != -1)
ok = false;
}
}
if (!ok) {
cout << 0 << '\n';
continue;
}
for(int i = n - 1; i >= 0; i--)
for(int j = m - 1; j >= 0; j--)
cl[i][j] |= cl[i + 1][j] | cl[i][j + 1];
for(int i = 0; i <= n; i++) {
for(int j = 0; j <= m; j++) {
if (i > 0) cr[i][j] |= cr[i - 1][j];
if (j > 0) cr[i][j] |= cr[i][j - 1];
}
}
vector dp(n + 1, vector<mint>(m + 1));
dp[0][m] = 1;
for(int i = 0; i <= n; i++) {
for(int j = m; j >= 0; j--) {
if (j > 0 and !cl[i][j - 1])
dp[i][j - 1] += dp[i][j];
if (i < n and (j == 0 or !cr[i][j - 1]))
dp[i + 1][j] += dp[i][j];
}
}
cout << dp[n][0] << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
4 2 3 1 2 -1 -1 4 5 4 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 4 -1 -1 -1 -1 -1 4 4 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 5 -1 -1 -1 -1 -1 3 5 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
output:
4 0 17 55
result:
ok 4 number(s): "4 0 17 55"
Test #2:
score: 0
Accepted
time: 10ms
memory: 9272kb
input:
1 2857 70 -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:
266977954
result:
ok 1 number(s): "266977954"
Test #3:
score: 0
Accepted
time: 10ms
memory: 9268kb
input:
1 3225 62 -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:
43003510
result:
ok 1 number(s): "43003510"
Test #4:
score: 0
Accepted
time: 10ms
memory: 8868kb
input:
1 34 5882 -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:
181277996
result:
ok 1 number(s): "181277996"
Test #5:
score: 0
Accepted
time: 10ms
memory: 9572kb
input:
1 6 33333 -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:
942557054
result:
ok 1 number(s): "942557054"
Test #6:
score: 0
Accepted
time: 6ms
memory: 8696kb
input:
1 470 425 -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:
321320838
result:
ok 1 number(s): "321320838"
Test #7:
score: 0
Accepted
time: 6ms
memory: 5324kb
input:
3 406 164 -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:
100583745 965682993 506401552
result:
ok 3 number(s): "100583745 965682993 506401552"
Test #8:
score: 0
Accepted
time: 9ms
memory: 5288kb
input:
3 617 108 -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:
155894158 696179809 26941117
result:
ok 3 number(s): "155894158 696179809 26941117"
Test #9:
score: 0
Accepted
time: 9ms
memory: 5580kb
input:
3 784 85 -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:
737523059 603224993 597349569
result:
ok 3 number(s): "737523059 603224993 597349569"
Test #10:
score: 0
Accepted
time: 9ms
memory: 5372kb
input:
3 29 2298 -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:
396891105 947304368 510868160
result:
ok 3 number(s): "396891105 947304368 510868160"
Test #11:
score: 0
Accepted
time: 9ms
memory: 5316kb
input:
3 247 269 -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:
379112706 335134214 355847359
result:
ok 3 number(s): "379112706 335134214 355847359"
Test #12:
score: 0
Accepted
time: 4ms
memory: 4180kb
input:
10 204 98 -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:
61226798 40628357 439703518 849778142 656626189 169864409 849924485 969955039 428968320 858402932
result:
ok 10 numbers
Test #13:
score: 0
Accepted
time: 10ms
memory: 4216kb
input:
100 74 27 -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:
626032214 502739587 940612786 578571800 88511598 317568922 846512485 662780782 971010183 361731076 838456187 444876395 546444396 361731076 49679494 756067232 127657859 626032214 345074838 501501 612101462 304454789 317568922 304454789 546444396 683337149 679990133 794529481 2001 846512485 124419476 ...
result:
ok 100 numbers
Test #14:
score: 0
Accepted
time: 9ms
memory: 3856kb
input:
1000 14 14 -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:
40116600 1221759 5151 1221759 20160075 40116600 30045015 40116600 13884156 6724520 40116600 37442160 34597290 37442160 6724520 316251 3262623 316251 40116600 30045015 201 30421755 30045015 30045015 316251 52394 37442160 1221759 34597290 52394 3262623 316251 201 6724520 40116600 1221759 13884156 4011...
result:
ok 1000 numbers
Test #15:
score: 0
Accepted
time: 16ms
memory: 3612kb
input:
10000 20 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
output:
21 84 126 126 66 84 21 21 84 126 21 66 21 21 21 21 66 21 84 66 84 66 66 66 126 21 126 84 84 84 84 21 126 126 66 21 21 84 126 21 84 84 21 21 66 66 21 66 84 21 84 66 21 126 84 21 84 66 66 126 66 66 21 21 126 66 66 126 66 84 126 66 126 66 21 21 84 126 66 21 66 21 21 84 126 126 66 21 66 126 21 84 66 84 ...
result:
ok 10000 numbers
Test #16:
score: 0
Accepted
time: 10ms
memory: 9192kb
input:
1 2857 70 -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:
226015187
result:
ok 1 number(s): "226015187"
Test #17:
score: 0
Accepted
time: 10ms
memory: 9068kb
input:
1 3225 62 -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:
927015823
result:
ok 1 number(s): "927015823"
Test #18:
score: 0
Accepted
time: 10ms
memory: 8808kb
input:
1 34 5882 1 -1 3 -1 -1 6 7 8 9 -1 11 12 -1 14 15 -1 -1 18 -1 20 21 22 -1 -1 25 26 27 28 29 30 31 -1 -1 -1 -1 36 -1 38 -1 -1 -1 -1 43 44 -1 -1 -1 48 -1 50 51 -1 -1 54 -1 56 -1 -1 59 60 -1 62 63 64 65 -1 67 -1 -1 -1 -1 -1 73 74 75 -1 77 -1 79 80 81 -1 83 -1 85 86 87 88 89 -1 91 92 93 94 95 96 97 98 -1...
output:
990886230
result:
ok 1 number(s): "990886230"
Test #19:
score: 0
Accepted
time: 5ms
memory: 9576kb
input:
1 6 33333 -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:
422786771
result:
ok 1 number(s): "422786771"
Test #20:
score: 0
Accepted
time: 7ms
memory: 8584kb
input:
1 470 425 -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:
877984607
result:
ok 1 number(s): "877984607"
Test #21:
score: 0
Accepted
time: 9ms
memory: 5456kb
input:
3 406 164 -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:
326935456 584792895 464096788
result:
ok 3 number(s): "326935456 584792895 464096788"
Test #22:
score: 0
Accepted
time: 10ms
memory: 5540kb
input:
3 617 108 -1 -1 -1 4 -1 -1 7 -1 9 10 -1 12 13 14 15 -1 17 -1 19 -1 -1 -1 -1 24 25 -1 -1 -1 29 -1 31 32 -1 -1 35 -1 -1 -1 39 -1 -1 42 43 -1 -1 -1 47 48 49 -1 -1 52 -1 54 55 56 57 58 59 -1 61 62 -1 64 65 66 -1 -1 -1 70 71 -1 -1 74 -1 -1 -1 78 -1 -1 -1 -1 83 84 -1 86 -1 -1 -1 90 91 92 -1 94 95 -1 97 -1...
output:
364084446 692976084 535691147
result:
ok 3 number(s): "364084446 692976084 535691147"
Test #23:
score: 0
Accepted
time: 9ms
memory: 5384kb
input:
3 784 85 -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:
408436895 106596377 329390492
result:
ok 3 number(s): "408436895 106596377 329390492"
Test #24:
score: 0
Accepted
time: 6ms
memory: 5416kb
input:
3 29 2298 -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:
488213402 857645806 987649594
result:
ok 3 number(s): "488213402 857645806 987649594"
Test #25:
score: 0
Accepted
time: 11ms
memory: 5348kb
input:
3 247 269 -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:
901504397 956940083 609589347
result:
ok 3 number(s): "901504397 956940083 609589347"
Test #26:
score: 0
Accepted
time: 13ms
memory: 7584kb
input:
10 204 98 -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:
423835890 772235276 655736616 170741944 25381097 793735997 16194064 4 192 522241336
result:
ok 10 numbers
Test #27:
score: 0
Accepted
time: 11ms
memory: 3940kb
input:
100 74 27 -1 -1 3 4 5 6 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 19 20 21 22 -1 -1 25 -1 27 -1 -1 -1 -1 -1 -1 -1 -1 10 -1 12 13 -1 -1 -1 17 18 19 -1 -1 22 -1 24 25 26 -1 -1 3 -1 5 -1 -1 8 -1 -1 -1 12 13 -1 -1 -1 -1 18 19 20 -1 22 -1 -1 -1 -1 27 -1 -1 -1 -1 -1 -1 -1 9 -1 11 12 13 14 15 -1 -1 18 -1 -1 21 -...
output:
694977529 296372109 961307647 302497360 294566522 410164164 135 868063660 752605382 664715962 117696471 221184 96768 76608 944234136 225917224 209375095 38367 108 158735542 552772149 308270859 623714867 276214491 630502747 509548188 778934141 265571436 343358036 830148880 47520 4992 23077887 8555835...
result:
ok 100 numbers
Test #28:
score: 0
Accepted
time: 14ms
memory: 3664kb
input:
1000 14 14 -1 -1 -1 4 -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 -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 16 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 -1 -1 -1 -1 -1 -1 7 8 -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:
4116125 64 2281400 27720 17133020 60 8 36 977980 238560 39694 6 1430 16 440 816 4504 1540962 25637976 451 11623030 1088 12 1714669 19955909 849387 24 12288 128 9381848 2857855 247800 120 66582 6054087 1082706 16 343710 54 24866478 49469 8 612 320 7368240 651287 24 640 240 24677926 1440 24506482 8073...
result:
ok 1000 numbers
Test #29:
score: 0
Accepted
time: 19ms
memory: 3560kb
input:
10000 20 1 -1 -1 -1 -1 6 7 -1 9 10 -1 -1 -1 -1 -1 -1 -1 -1 -1 20 -1 20 1 -1 -1 4 -1 -1 7 -1 9 10 -1 -1 -1 -1 15 16 17 18 -1 20 21 10 2 1 -1 2 -1 -1 -1 -1 6 -1 -1 6 8 7 9 8 -1 9 -1 -1 -1 1 20 1 2 -1 -1 5 6 -1 -1 9 -1 -1 -1 -1 -1 -1 17 -1 -1 -1 -1 2 10 1 -1 -1 4 5 -1 -1 9 -1 -1 -1 -1 4 5 -1 8 9 -1 11 ...
output:
5 3 8 7 6 1 14 2 56 60 21 4 1 9 5 7 12 3 1 3 24 6 5 3 5 76 17 19 15 11 12 17 14 12 1 70 2 7 6 5 8 7 25 4 3 7 8 17 24 5 45 20 20 6 9 11 13 3 9 6 6 1 5 63 48 15 7 16 7 10 5 12 8 12 3 2 24 1 28 9 75 4 1 4 60 71 1 2 7 4 15 9 7 12 9 2 72 4 11 4 8 3 9 20 2 4 10 60 12 51 81 3 9 36 2 1 18 24 7 3 2 20 2 1 8 ...
result:
ok 10000 numbers
Test #30:
score: 0
Accepted
time: 5ms
memory: 9292kb
input:
1 2857 70 -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:
0
result:
ok 1 number(s): "0"
Test #31:
score: 0
Accepted
time: 11ms
memory: 9144kb
input:
1 3225 62 -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:
0
result:
ok 1 number(s): "0"
Test #32:
score: 0
Accepted
time: 5ms
memory: 8884kb
input:
1 34 5882 -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:
0
result:
ok 1 number(s): "0"
Test #33:
score: 0
Accepted
time: 10ms
memory: 9684kb
input:
1 6 33333 -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:
0
result:
ok 1 number(s): "0"
Test #34:
score: 0
Accepted
time: 9ms
memory: 8592kb
input:
1 470 425 -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:
890874805
result:
ok 1 number(s): "890874805"
Test #35:
score: 0
Accepted
time: 4ms
memory: 5336kb
input:
3 406 164 -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:
0 0 692246464
result:
ok 3 number(s): "0 0 692246464"
Test #36:
score: 0
Accepted
time: 9ms
memory: 5552kb
input:
3 617 108 -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:
379270627 830168837 0
result:
ok 3 number(s): "379270627 830168837 0"
Test #37:
score: 0
Accepted
time: 10ms
memory: 6168kb
input:
3 784 85 -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:
683914361 0 0
result:
ok 3 number(s): "683914361 0 0"
Test #38:
score: 0
Accepted
time: 9ms
memory: 5304kb
input:
3 29 2298 -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 50 -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:
0 0 0
result:
ok 3 number(s): "0 0 0"
Test #39:
score: 0
Accepted
time: 9ms
memory: 5300kb
input:
3 247 269 -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:
0 163867028 314228181
result:
ok 3 number(s): "0 163867028 314228181"
Test #40:
score: 0
Accepted
time: 8ms
memory: 4232kb
input:
10 204 98 -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:
977871808 0 452851657 0 956810861 165517803 0 60504822 632702764 0
result:
ok 10 numbers
Test #41:
score: 0
Accepted
time: 3ms
memory: 3876kb
input:
100 74 27 -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:
0 0 284542063 0 996507058 643504531 0 172034941 0 0 865745389 513166363 376276690 0 876231714 0 0 0 0 0 935471683 0 937930370 164057082 0 0 0 0 158671184 0 0 590035196 0 797759166 0 0 0 0 99743472 0 0 0 0 0 34944594 0 279799476 0 0 0 0 0 430525026 377470096 28587772 0 0 741007574 0 0 0 577605907 977...
result:
ok 100 numbers
Test #42:
score: 0
Accepted
time: 13ms
memory: 3752kb
input:
1000 14 14 -1 -1 -1 -1 -1 -1 -1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 13 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 15 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 17 -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:
0 0 0 0 0 0 0 0 0 0 0 10530 184870 22386 0 0 350 6720143 9327696 0 0 0 0 0 5328687 0 0 0 0 0 12397 0 0 15301 0 0 0 0 0 0 0 857208 0 0 18575 0 0 7220 99968 94240 5040 0 0 0 0 1000792 0 875150 0 10846143 0 2244 0 0 334125 0 0 22638 0 0 0 37542195 0 0 0 0 0 0 0 0 7102753 0 33649 0 30032464 0 5910900 0 ...
result:
ok 1000 numbers
Test #43:
score: 0
Accepted
time: 19ms
memory: 3544kb
input:
10000 20 1 -1 3 -1 -1 -1 6 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 20 -1 20 1 -1 2 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 13 -1 -1 -1 18 -1 19 20 20 1 -1 -1 -1 -1 5 -1 -1 -1 -1 -1 -1 -1 13 -1 -1 -1 -1 18 -1 -1 2 10 -1 -1 -1 -1 -1 6 -1 -1 -1 11 -1 -1 -1 -1 -1 -1 8 -1 10 -1 20 1 1 -1 -1 -1 -1 -1 8 9 -1 -1 -1 -1 13 -...
output:
0 0 3 1 0 21 0 0 2 5 1 0 1 0 0 0 75 2 21 12 0 80 0 35 0 21 0 0 64 4 15 29 0 3 56 0 0 0 0 4 2 6 3 0 0 0 10 0 1 0 5 0 18 0 0 0 2 106 0 0 0 0 0 0 4 0 1 10 0 0 15 25 21 35 15 3 0 51 0 64 0 0 3 0 19 0 0 0 0 0 9 0 0 0 0 0 3 0 0 0 16 1 20 0 0 17 4 55 0 45 1 0 0 0 51 0 29 0 8 13 0 0 111 8 0 0 0 0 0 10 6 3 0...
result:
ok 10000 numbers