QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190008 | #4922. 生活在对角线下 | hos_lyric# | 10 | 350ms | 27272kb | C++14 | 19.9kb | 2023-09-28 06:16:09 | 2024-07-04 02:47:45 |
Judging History
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 <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 = 998244353U;
constexpr unsigned MO2 = 2U * MO;
constexpr int FFT_MAX = 23;
using Mint = ModInt<MO>;
constexpr Mint FFT_ROOTS[FFT_MAX + 1] = {1U, 998244352U, 911660635U, 372528824U, 929031873U, 452798380U, 922799308U, 781712469U, 476477967U, 166035806U, 258648936U, 584193783U, 63912897U, 350007156U, 666702199U, 968855178U, 629671588U, 24514907U, 996173970U, 363395222U, 565042129U, 733596141U, 267099868U, 15311432U};
constexpr Mint INV_FFT_ROOTS[FFT_MAX + 1] = {1U, 998244352U, 86583718U, 509520358U, 337190230U, 87557064U, 609441965U, 135236158U, 304459705U, 685443576U, 381598368U, 335559352U, 129292727U, 358024708U, 814576206U, 708402881U, 283043518U, 3707709U, 121392023U, 704923114U, 950391366U, 428961804U, 382752275U, 469870224U};
constexpr Mint FFT_RATIOS[FFT_MAX] = {911660635U, 509520358U, 369330050U, 332049552U, 983190778U, 123842337U, 238493703U, 975955924U, 603855026U, 856644456U, 131300601U, 842657263U, 730768835U, 942482514U, 806263778U, 151565301U, 510815449U, 503497456U, 743006876U, 741047443U, 56250497U, 867605899U};
constexpr Mint INV_FFT_RATIOS[FFT_MAX] = {86583718U, 372528824U, 373294451U, 645684063U, 112220581U, 692852209U, 155456985U, 797128860U, 90816748U, 860285882U, 927414960U, 354738543U, 109331171U, 293255632U, 535113200U, 308540755U, 121186627U, 608385704U, 438932459U, 359477183U, 824071951U, 103369235U};
// as[rev(i)] <- \sum_j \zeta^(ij) as[j]
void fft(Mint *as, int n) {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << FFT_MAX);
int m = n;
if (m >>= 1) {
for (int i = 0; i < m; ++i) {
const unsigned x = as[i + m].x; // < MO
as[i + m].x = as[i].x + MO - x; // < 2 MO
as[i].x += x; // < 2 MO
}
}
if (m >>= 1) {
Mint prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned x = (prod * as[i + m]).x; // < MO
as[i + m].x = as[i].x + MO - x; // < 3 MO
as[i].x += x; // < 3 MO
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
for (; m; ) {
if (m >>= 1) {
Mint prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned x = (prod * as[i + m]).x; // < MO
as[i + m].x = as[i].x + MO - x; // < 4 MO
as[i].x += x; // < 4 MO
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m >>= 1) {
Mint prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned x = (prod * as[i + m]).x; // < MO
as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x; // < 2 MO
as[i + m].x = as[i].x + MO - x; // < 3 MO
as[i].x += x; // < 3 MO
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
}
for (int i = 0; i < n; ++i) {
as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x; // < 2 MO
as[i].x = (as[i].x >= MO) ? (as[i].x - MO) : as[i].x; // < MO
}
}
// as[i] <- (1/n) \sum_j \zeta^(-ij) as[rev(j)]
void invFft(Mint *as, int n) {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << FFT_MAX);
int m = 1;
if (m < n >> 1) {
Mint prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + m; ++i) {
const unsigned long long y = as[i].x + MO - as[i + m].x; // < 2 MO
as[i].x += as[i + m].x; // < 2 MO
as[i + m].x = (prod.x * y) % MO; // < MO
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
m <<= 1;
}
for (; m < n >> 1; m <<= 1) {
Mint prod = 1U;
for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
for (int i = i0; i < i0 + (m >> 1); ++i) {
const unsigned long long y = as[i].x + MO2 - as[i + m].x; // < 4 MO
as[i].x += as[i + m].x; // < 4 MO
as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x; // < 2 MO
as[i + m].x = (prod.x * y) % MO; // < MO
}
for (int i = i0 + (m >> 1); i < i0 + m; ++i) {
const unsigned long long y = as[i].x + MO - as[i + m].x; // < 2 MO
as[i].x += as[i + m].x; // < 2 MO
as[i + m].x = (prod.x * y) % MO; // < MO
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m < n) {
for (int i = 0; i < m; ++i) {
const unsigned y = as[i].x + MO2 - as[i + m].x; // < 4 MO
as[i].x += as[i + m].x; // < 4 MO
as[i + m].x = y; // < 4 MO
}
}
const Mint invN = Mint(n).inv();
for (int i = 0; i < n; ++i) {
as[i] *= invN;
}
}
void fft(vector<Mint> &as) {
fft(as.data(), as.size());
}
void invFft(vector<Mint> &as) {
invFft(as.data(), as.size());
}
vector<Mint> convolve(vector<Mint> as, vector<Mint> bs) {
if (as.empty() || bs.empty()) return {};
const int len = as.size() + bs.size() - 1;
int n = 1;
for (; n < len; n <<= 1) {}
as.resize(n); fft(as);
bs.resize(n); fft(bs);
for (int i = 0; i < n; ++i) as[i] *= bs[i];
invFft(as);
as.resize(len);
return as;
}
vector<Mint> square(vector<Mint> as) {
if (as.empty()) return {};
const int len = as.size() + as.size() - 1;
int n = 1;
for (; n < len; n <<= 1) {}
as.resize(n); fft(as);
for (int i = 0; i < n; ++i) as[i] *= as[i];
invFft(as);
as.resize(len);
return as;
}
////////////////////////////////////////////////////////////////////////////////
// 0 = \sum_{j=0}^d (\sum_{k=0}^e css[j][k] i^k) as[i - j] (d <= i < |as|)
template <unsigned M>
vector<vector<ModInt<M>>> findPRecurrence(const vector<ModInt<M>> &as, int e,
bool verbose = false) {
using Mint = ModInt<M>;
const int asLen = as.size();
// asLen - d >= (d + 1) (e + 1) - 1 (otherwise definitely dim Ker >= 2)
const int d0 = (asLen + 2) / (e + 2) - 1;
if (d0 < 0) {
if (verbose) {
fprintf(stderr, "[findPRecurrence] |as| >= e must hold.\n");
fflush(stderr);
}
return {};
}
const int m = asLen - d0, n = (d0 + 1) * (e + 1);
vector<vector<Mint>> bss(m, vector<Mint>(n, 0));
for (int i = d0; i < asLen; ++i) for (int j = 0; j <= d0; ++j) {
Mint pw = 1;
for (int k = 0; k <= e; ++k) {
bss[i - d0][j * (e + 1) + k] = pw * as[i - j];
pw *= i;
}
}
int r = 0;
vector<int> hs;
for (int h = 0; h < n; ++h) {
for (int i = r; i < m; ++i) if (bss[i][h]) {
bss[r].swap(bss[i]);
break;
}
if (r < m && bss[r][h]) {
const Mint s = bss[r][h].inv();
for (int j = h; j < n; ++j) bss[r][j] *= s;
for (int i = 0; i < m; ++i) if (i != r) {
const Mint t = bss[i][h];
for (int j = h; j < n; ++j) bss[i][j] -= t * bss[r][j];
}
++r;
} else {
hs.push_back(h);
}
}
if (hs.empty()) {
if (verbose) {
fprintf(stderr, "[findPRecurrence] Not found: d = %d, e = %d.\n", d0, e);
fflush(stderr);
}
return {};
}
vector<vector<Mint>> css(d0 + 1, vector<Mint>(e + 1, 0));
for (int j = 0; j <= d0; ++j) for (int k = 0; k <= e; ++k) {
const int h = j * (e + 1) + k;
css[j][k] = (h < hs[0]) ? -bss[h][hs[0]] : (h == hs[0]) ? 1 : 0;
}
int d = hs[0] / (e + 1);
for (int i = d0; i < asLen; ++i) {
Mint sum = 0;
for (int j = 0; j <= d0; ++j) {
Mint coef = 0, pw = 1;
for (int k = 0; k <= e; ++k) {
coef += css[j][k] * pw;
pw *= i;
}
sum += coef * as[i - j];
}
for (; sum; ) {
if (i - ++d < 0) break;
assert(d <= d0);
Mint coef = 0, pw = 1;
for (int k = 0; k <= e; ++k) {
coef += css[d][k] * pw;
pw *= i;
}
sum += coef * as[i - d];
}
}
css.resize(d + 1);
if (verbose) {
const int hsLen = hs.size();
if (hsLen > d0 - d + 1) {
fprintf(stderr, "[findPRecurrence] Degenerate? (dim Ker = %d)\n", hsLen);
}
fprintf(stderr, "[findPRecurrence] d = %d, e = %d, non-trivial: %d\n", d, e,
asLen - d - (d + 1) * (e + 1) + 1);
fprintf(stderr, "{\n");
for (int j = 0; j <= d; ++j) {
fprintf(stderr, " {");
for (int k = 0; k <= e; ++k) {
const unsigned c = css[j][k].x;
if (k > 0) fprintf(stderr, ", ");
fprintf(stderr, "%d", static_cast<int>((c < M - c) ? c : (c - M)));
}
fprintf(stderr, "},\n");
}
fprintf(stderr, "}\n");
fflush(stderr);
}
return css;
}
// 0 = \sum_{j=0}^d (\sum_{k=0}^e css[j][k] i^k) as[i - j] (d <= i < |as|)
template <unsigned M>
vector<ModInt<M>> extendPRecurrence(vector<ModInt<M>> as,
const vector<vector<ModInt<M>>> &css,
int n) {
using Mint = ModInt<M>;
assert(!css.empty());
const int d = css.size() - 1, e = css[0].size() - 1;
for (int j = 0; j <= d; ++j) assert(static_cast<int>(css[j].size()) == e + 1);
const int asLen = as.size();
as.resize(n);
for (int i = asLen; i < n; ++i) {
Mint sum = 0;
for (int j = 1; j <= d; ++j) {
Mint coef = 0, pw = 1;
for (int k = 0; k <= e; ++k) {
coef += css[j][k] * pw;
pw *= i;
}
sum += coef * as[i - j];
}
{
Mint coef = 0, pw = 1;
for (int k = 0; k <= e; ++k) {
coef += css[0][k] * pw;
pw *= i;
}
as[i] = -sum / coef;
}
}
return as;
}
////////////////////////////////////////////////////////////////////////////////
constexpr int LIM_INV = 400'010;
Mint inv[LIM_INV], fac[LIM_INV], invFac[LIM_INV];
void prepare() {
inv[1] = 1;
for (int i = 2; i < LIM_INV; ++i) {
inv[i] = -((Mint::M / i) * inv[Mint::M % i]);
}
fac[0] = invFac[0] = 1;
for (int i = 1; i < LIM_INV; ++i) {
fac[i] = fac[i - 1] * i;
invFac[i] = invFac[i - 1] * inv[i];
}
}
Mint binom(Int n, Int k) {
if (n < 0) {
if (k >= 0) {
return ((k & 1) ? -1 : +1) * binom(-n + k - 1, k);
} else if (n - k >= 0) {
return (((n - k) & 1) ? -1 : +1) * binom(-k - 1, n - k);
} else {
return 0;
}
} else {
if (0 <= k && k <= n) {
assert(n < LIM_INV);
return fac[n] * invFac[k] * invFac[n - k];
} else {
return 0;
}
}
}
Mint path(int dx, int dy) {
return (dx >= 0 && dy >= 0) ? (fac[dx + dy] * invFac[dx] * invFac[dy]) : 0;
}
constexpr int MAX_T = 100'010;
constexpr int MAX_PQ = 10;
int T, C, P, Q, L;
int N[MAX_T], M[MAX_T];
Mint F[MAX_T][MAX_PQ];
namespace expr {
Mint dp[110][110][210];
void run(int n) {
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
for (int x = 0; x <= n; ++x) for (int y = 0; y <= n; ++y) {
if (y <= x) {
for (int k = x + y + 1; k >= 1; --k) dp[x][y][k] = dp[x][y][k - 1];
dp[x][y][0] = 0;
}
for (int k = 0; k <= x + y + 1; ++k) dp[x + 1][y][k] += dp[x][y][k];
for (int k = 0; k <= x + y + 1; ++k) dp[x][y + 1][k] += dp[x][y][k];
}
for (int x = 0; x <= n; ++x) {
Mint g = 0, h = 0;
for (int k = 0; k <= x + x + 1; ++k) {
g += dp[x][x][k] * k;
h += dp[x][x][k] * (x + x + 1 - k);
}
cerr << x << ": " << g + h << " " << g << " " << h << "; "; pv(dp[x][x], dp[x][x] + (x + x + 1 + 1));
}
}
} // expr
namespace brute {
constexpr int SMALL = 1010;
Mint dp[MAX_PQ][SMALL][SMALL][2];
vector<Mint> run() {
memset(dp, 0, sizeof(dp));
for (int p = 0; p < P; ++p) for (int q = 0; q < Q; ++q) {
const int id = p * Q + q;
dp[id][0][0][0] = 1;
for (int x = 0; x <= L; ++x) for (int y = 0; y <= L + C; ++y) {
if (y <= x) {
dp[id][x][y][1] += dp[id][x][y][0] * Mint(x).pow(p) * Mint(y).pow(q);
}
dp[id][x + 1][y][0] += dp[id][x][y][0];
dp[id][x + 1][y][1] += dp[id][x][y][1];
dp[id][x][y + 1][0] += dp[id][x][y][0];
dp[id][x][y + 1][1] += dp[id][x][y][1];
}
// cerr<<"p = "<<p<<", q = "<<q<<endl;
// for(int x=0;x<=L;++x){for(int y=0;y<=L+C;++y)cerr<<dp[id][x][y][0]<<","<<dp[id][x][y][1]<<" ";cerr<<endl;}
}
vector<Mint> ans(T, 0);
for (int t = 0; t < T; ++t) {
for (int p = 0; p < P; ++p) for (int q = 0; q < Q; ++q) {
const int id = p * Q + q;
ans[t] += F[t][id] * dp[id][N[t]][M[t]][1];
}
}
return ans;
}
} // brute
namespace sub4 {
vector<Mint> run() {
vector<Mint> gs(L + 1, 0), hs(L + 1, 0);
for (int n = 0; n <= L; ++n) {
gs[n] = ((2 * n + 1) * path(n, n) + Mint(4).pow(n)) / 2;
hs[n] = path(n, n) * (2 * n + 1) - gs[n];
}
// cerr<<"gs = "<<gs<<endl;
// cerr<<"hs = "<<hs<<endl;
vector<Mint> ggs, hhs;
if (C >= 0) {
vector<Mint> ps(L + 1, 0);
for (int n = 1; n <= L; ++n) {
ps[n] = path(n, n + C - 1) - path(n + C, n - 1);
}
ps[0] = 1;
ggs = convolve(gs, ps);
ggs.resize(L + 1);
// cerr<<"ps = "<<ps<<", ggs = "<<ggs<<endl;
} else {
vector<Mint> ps(L + 1, 0);
for (int m = 1; m <= L; ++m) {
ps[m] = path(m - C - 1, m) - path(m - 1, m - C);
}
ps[0] = 1;
hhs = convolve(hs, ps);
hhs.resize(L + 1);
// cerr<<"ps = "<<ps<<", hhs = "<<hhs<<endl;
}
vector<Mint> ans(T, 0);
for (int t = 0; t < T; ++t) {
if (C >= 0) {
/*
Mint sum = 0;
for (int x = 0; x < N[t]; ++x) {
// (x, x) -> (x, x+1)
sum += gs[x] * (path(N[t] - x, M[t] - (x+1)) - path(M[t] - x, N[t] - (x+1)));
}
sum += gs[N[t]];
ans[t] += F[t][0] * sum;
*/
ans[t] += F[t][0] * ggs[N[t]];
} else {
/*
Mint sum = 0;
for (int y = 0; y < M[t]; ++y) {
// (y, y) -> (y+1, y)
sum += hs[y] * (path(N[t] - (y+1), M[t] - y) - path(M[t] - (y+1), N[t] - y));
}
sum += hs[M[t]];
ans[t] += F[t][0] * sum;
*/
ans[t] += F[t][0] * (path(N[t], M[t]) * (N[t] + M[t] + 1) - hhs[M[t]]);
}
}
return ans;
}
} // sub4
namespace fast {
constexpr int SZ = 200;
Mint dp[SZ + 1][SZ + 1][2];
vector<Mint> gss[MAX_PQ];
vector<Mint> run() {
for (int p = 0; p < P; ++p) for (int q = 0; q < Q; ++q) {
memset(dp, 0, sizeof(dp));
dp[0][0][0] = 1;
for (int x = 0; x < SZ; ++x) for (int y = 0; y < SZ; ++y) {
if (y <= x) {
dp[x][y][1] += dp[x][y][0] * Mint(x).pow(p) * Mint(y).pow(q);
}
dp[x + 1][y][0] += dp[x][y][0];
dp[x + 1][y][1] += dp[x][y][1];
dp[x][y + 1][0] += dp[x][y][0];
dp[x][y + 1][1] += dp[x][y][1];
}
vector<Mint> as(SZ);
for (int x = 0; x < SZ; ++x) {
as[x] = dp[x][x][1];
}
// cerr << "x^" << p << " y^" << q << endl;
// findPRecurrence(as, 1, true);
const auto css = findPRecurrence(as, 1, false);
gss[p * Q + q] = extendPRecurrence(as, css, L + 1);
}
if (C >= 0) {
vector<Mint> ps(L + 1, 0);
for (int n = 1; n <= L; ++n) {
ps[n] = path(n, n + C - 1) - path(n + C, n - 1);
}
ps[0] = 1;
for (int id = 0; id < P * Q; ++id) {
gss[id] = convolve(gss[id], ps);
gss[id].resize(L + 1);
}
} else {
vector<Mint> ps(L + 1, 0);
for (int m = 1; m <= L; ++m) {
ps[m] = path(m - C - 1, m) - path(m - 1, m - C);
}
ps[0] = 1;
// TODO
}
vector<Mint> ans(T, 0);
for (int t = 0; t < T; ++t) {
if (C >= 0) {
for (int id = 0; id < P * Q; ++id) {
ans[t] += F[t][id] * gss[id][N[t]];
}
} else {
// TODO
}
}
return ans;
}
} // fast
int main() {
prepare();
// expr::run(10);
for (; ~scanf("%d%d%d%d%d", &T, &C, &P, &Q, &L); ) {
++P;
++Q;
for (int t = 0; t < T; ++t) {
scanf("%d%d", &N[t], &M[t]);
assert(N[t] >= 0);
assert(M[t] >= 0);
assert(N[t] + C == M[t]);
for (int p = 0; p < P; ++p) for (int q = 0; q < Q; ++q) {
scanf("%u", &F[t][p * Q + q].x);
}
}
const auto ans = fast::run();
for (int t = 0; t < T; ++t) {
printf("%u\n", ans[t].x);
}
#ifdef LOCAL
const auto brt=brute::run();
for(int t=0;t<T;++t)if(brt[t]!=ans[t]){
cerr<<N[t]<<" "<<M[t]<<"; ";pv(F[t],F[t]+P*Q);
cerr<<"brt[t] = "<<brt[t]<<endl;
cerr<<"ans[t] = "<<ans[t]<<endl;
break;
}
assert(brt==ans);
#endif
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 14ms
memory: 13732kb
input:
1 -10 1 2 1000 825 815 107973512 400177523 812303207 164088430 603506669 337780072
output:
0
result:
wrong answer 1st numbers differ - expected: '360076089', found: '0'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #9:
score: 20
Accepted
time: 21ms
memory: 15732kb
input:
1 4683 0 0 95317 86560 91243 412303217
output:
952052072
result:
ok 1 number(s): "952052072"
Test #10:
score: -20
Wrong Answer
time: 16ms
memory: 12236kb
input:
1 -24796 0 0 100000 93338 68542 849332154
output:
0
result:
wrong answer 1st numbers differ - expected: '980840409', found: '0'
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 10
Accepted
Test #41:
score: 10
Accepted
time: 206ms
memory: 22328kb
input:
100000 0 2 1 100000 48964 48964 666670967 90494987 74847122 615108201 29533064 582540229 14418 14418 391779909 223696706 701170191 885097597 551643398 25626747 81584 81584 951326734 520293397 13860946 896899117 821166399 282263457 76849 76849 598606953 879771697 930252135 671750715 673503431 3060699...
output:
513261452 727599133 935022075 486566245 581605882 190874624 492903919 212718785 390117408 13902475 85548183 635628561 482394025 962073695 362740677 938001783 889953951 725536236 308635636 699865601 901798869 464425652 743201170 92575030 846809630 169046922 528318328 181301191 961103497 451810607 792...
result:
ok 100000 numbers
Test #42:
score: 0
Accepted
time: 350ms
memory: 26448kb
input:
100000 0 4 1 100000 62874 62874 118183474 407193132 685767410 687439227 635193908 610100986 258734574 238431118 899478481 761001837 51740 51740 444395131 500444257 428937362 53260346 30808281 906820217 513141079 288839678 554203046 663643475 35914 35914 356034890 347998675 273353479 349503145 372514...
output:
90079244 739339489 893419903 384951658 501534088 627460520 515642072 133867011 245310344 38632363 463152272 875958325 685091735 564873808 923675127 506219676 835026926 594979789 343226945 318102253 564901512 435775641 520245858 654449246 974902905 301999370 874735377 124394474 531442263 667337270 83...
result:
ok 100000 numbers
Test #43:
score: 0
Accepted
time: 138ms
memory: 19952kb
input:
100000 0 1 1 100000 83076 83076 784524998 238343754 699444053 193415149 11931 11931 355735062 430827321 287184363 194146905 91685 91685 248401162 668812139 449763793 590716247 78873 78873 971383652 14982086 221574168 121402275 26705 26705 364632629 623913927 214647623 17014014 49871 49871 263152609 ...
output:
802238644 451994968 843226074 709558669 347484361 274977121 318242262 3003995 257310491 883438002 280843999 528814010 271908664 945085650 492738471 977479030 525082715 842693153 252354040 298201390 872453061 208575147 937984577 678583627 733514865 41580096 401571067 274115222 395399652 179231522 937...
result:
ok 100000 numbers
Test #44:
score: 0
Accepted
time: 306ms
memory: 25980kb
input:
100000 0 2 2 100000 42300 42300 306457952 603264155 604535680 373299692 720452989 584402391 244134586 764918594 149155452 96154 96154 385928288 721874710 32823875 997921405 288963987 798618815 52914070 480392455 835325898 22519 22519 857743113 78508560 335894675 636079175 257465089 226652298 5563045...
output:
141992402 675599235 48013284 700276770 870607175 695357162 754603770 744644560 328387578 779395955 691351991 749020285 219297277 416658156 801975761 287252871 95156690 502693643 859436736 751262539 372636784 789118941 114563659 346856771 895806035 984183707 868346378 178435731 197918806 73584128 672...
result:
ok 100000 numbers
Test #45:
score: 0
Accepted
time: 283ms
memory: 27272kb
input:
100000 0 1 3 100000 11362 11362 801230778 277039031 516703939 337243321 332454631 792471639 975430381 110954619 40296 40296 81718908 611718437 88044277 605359397 166308037 639878719 541084927 996814184 90922 90922 259539282 44240476 746297299 224814811 377419670 846027497 887046473 935009556 83954 8...
output:
509415585 345953605 300915155 337129523 37705935 985749046 509167332 298084321 186170721 665255439 256338589 647056594 894014776 673493231 550884946 531517917 311691611 150189476 800606928 934725818 764831103 696313960 418481305 470916807 876494136 473764716 597224168 111651899 43420720 496779890 87...
result:
ok 100000 numbers
Test #46:
score: 0
Accepted
time: 349ms
memory: 26180kb
input:
100000 0 4 1 100000 19976 19976 930307296 347896923 488422790 122006616 254292499 385320296 118841452 305855473 220506095 734110746 76511 76511 733970715 953620799 892153455 488725274 392229425 520312991 439397817 112142735 957290217 381693407 26327 26327 21580999 691947757 83624823 464367410 980975...
output:
225738555 214759727 108832407 762261275 864099566 720689765 718654473 882803028 203399073 265919421 271852236 206814944 963677189 246953800 793508085 850883446 974333494 298581206 438825170 9001044 296169693 220497567 416695424 629190242 619581187 441655724 267190171 778132646 2223771 899421067 4824...
result:
ok 100000 numbers
Test #47:
score: 0
Accepted
time: 202ms
memory: 21768kb
input:
100000 0 1 2 100000 73838 73838 274549763 865063181 32136903 53475699 519269603 405273531 71697 71697 876944090 280541147 203483885 101922547 186440707 307240260 22793 22793 618744968 181134563 330314386 216801164 639812156 24034170 51945 51945 37335644 549161545 241567218 295424268 954415389 432786...
output:
158769345 91752448 318980478 682463374 812203482 231065712 259747790 126945803 29984182 39995008 437957831 105835667 416780632 413312665 816060362 591547303 882687698 680499421 493928363 159339065 26276621 783584492 647783605 843283824 309112435 563441364 100206956 270102855 675153271 90110905 45327...
result:
ok 100000 numbers
Test #48:
score: 0
Accepted
time: 206ms
memory: 22616kb
input:
100000 0 1 2 100000 10963 10963 118533036 71877326 625707967 848757723 693498077 753443682 25930 25930 800025480 532304292 789668511 269301094 29714643 851090628 87397 87397 263900861 257160326 107105197 827826496 959850057 230900328 23859 23859 107139126 839685760 81346250 667647079 22541961 395830...
output:
231379920 254333418 252771315 418214494 739827152 243827675 651485321 424653515 142557212 490388274 31937549 356959822 145014447 701639245 370915853 351197761 284200447 431712993 957175103 275959444 890290532 319487714 214844885 921725847 697743209 419367023 20279153 345734736 164369300 119618322 91...
result:
ok 100000 numbers
Subtask #7:
score: 0
Skipped
Dependency #1:
0%