QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#110280 | #6513. Expression 3 | Forested | Compile Error | / | / | C++17 | 6.5kb | 2023-06-01 13:29:58 | 2023-06-01 13:30:01 |
Judging History
你现在查看的是最新测评结果
- [2024-02-14 13:23:19]
- hack成功,自动添加数据
- (/hack/531)
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-06-01 13:30:01]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-06-01 13:29:58]
- 提交
answer
#ifndef LOCAL
#define FAST_IO
#endif
// ============
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define OVERRIDE(a, b, c, d, ...) d
#define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i)
#define REP3(i, m, n) for (i32 i = (i32)(m); i < (i32)(n); ++i)
#define REP(...) OVERRIDE(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
#define PER(i, n) for (i32 i = (i32)(n) - 1; i >= 0; --i)
#define ALL(x) begin(x), end(x)
using namespace std;
using u32 = unsigned int;
using u64 = unsigned long long;
using i32 = signed int;
using i64 = signed long long;
using f64 = double;
using f80 = long double;
template <typename T>
using Vec = vector<T>;
template <typename T>
bool chmin(T &x, const T &y) {
if (x > y) {
x = y;
return true;
}
return false;
}
template <typename T>
bool chmax(T &x, const T &y) {
if (x < y) {
x = y;
return true;
}
return false;
}
#ifdef INT128
using u128 = __uint128_t;
using i128 = __int128_t;
istream &operator>>(istream &is, i128 &x) {
i64 v;
is >> v;
x = v;
return is;
}
ostream &operator<<(ostream &os, i128 x) {
os << (i64)x;
return os;
}
istream &operator>>(istream &is, u128 &x) {
u64 v;
is >> v;
x = v;
return is;
}
ostream &operator<<(ostream &os, u128 x) {
os << (u64)x;
return os;
}
#endif
[[maybe_unused]] constexpr i32 INF = 1000000100;
[[maybe_unused]] constexpr i64 INF64 = 3000000000000000100;
struct SetUpIO {
SetUpIO() {
#ifdef FAST_IO
ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif
cout << fixed << setprecision(15);
}
} set_up_io;
// ============
#ifdef DEBUGF
#else
#define DBG(x) (void)0
#endif
// ============
// ============
// ============
#include <algorithm>
#include <iostream>
#include <atcoder/convolution>
namespace poly {
using Mint = atcoder::modint998244353;
using Poly = std::vector<Mint>;
Poly add(Poly f, Poly g) {
if (f.size() < g.size()) {
std::swap(f, g);
}
for (int i = 0; i < (int)g.size(); ++i) {
f[i] += g[i];
}
return f;
}
Poly sub(Poly f, Poly g) {
if (f.size() < g.size()) {
std::swap(f, g);
}
for (int i = 0; i < (int)g.size(); ++i) {
f[i] -= g[i];
}
return f;
}
Poly mul(const Poly &f, const Poly &g) {
return atcoder::convolution(f, g);
}
void dft(Poly &f) {
atcoder::internal::butterfly(f);
}
void idft(Poly &f) {
atcoder::internal::butterfly_inv(f);
Mint inv = Mint::raw(f.size()).inv();
for (Mint &cf : f) {
cf *= inv;
}
}
} // namespace poly
// ============
namespace poly {
class Factorial {
std::vector<Mint> fac;
std::vector<Mint> ifac;
public:
Factorial() : fac(1, Mint::raw(1)), ifac(1, Mint::raw(1)) {}
void reserve(int n) {
int m = (int)fac.size() - 1;
if (n <= m) {
return;
}
fac.resize(n + 1);
for (int i = m + 1; i <= n; ++i) {
fac[i] = fac[i - 1] * Mint::raw(i);
}
ifac.resize(n + 1);
ifac[n] = fac[n].inv();
for (int i = n - 1; i >= m; --i) {
ifac[i] = ifac[i + 1] * Mint::raw(i + 1);
}
}
Mint fact(int n) const {
return fac[n];
}
Mint inv_fact(int n) const {
return ifac[n];
}
Mint inv_n(int n) const {
return ifac[n] * fac[n - 1];
}
Mint binom(int n, int r) const {
return fac[n] * ifac[r] * ifac[n - r];
}
} factorial;
} // namespace poly
// ============
namespace poly {
std::vector<Mint> shift_of_sampling_points(std::vector<Mint> f, Mint c, int m) {
int n = (int)f.size();
factorial.reserve(std::max(n, m));
{
for (int i = 0; i < n; ++i) {
f[i] *= factorial.inv_fact(i);
}
Poly g(n);
for (int i = 0; i < n; ++i) {
g[i] = factorial.inv_fact(i);
if (i % 2 == 1) {
g[i] = -g[i];
}
}
f = mul(f, g);
f.resize(n);
}
{
for (int i = 0; i < n; ++i) {
f[i] *= factorial.fact(i);
}
std::reverse(f.begin(), f.end());
Mint pw(1);
Poly g(n);
for (int i = 0; i < n; ++i) {
g[i] = pw * factorial.inv_fact(i);
pw *= c - Mint::raw(i);
}
f = mul(f, g);
f.resize(n);
std::reverse(f.begin(), f.end());
for (int i = 0; i < n; ++i) {
f[i] *= factorial.inv_fact(i);
}
}
if (m <= n) {
f.resize(m);
}
{
Poly g(m);
for (int i = 0; i < m; ++i) {
g[i] = factorial.inv_fact(i);
}
f = mul(f, g);
f.resize(m);
for (int i = 0; i < m; ++i) {
f[i] *= factorial.fact(i);
}
}
return f;
}
} // namespace poly
// ============
int main() {
using poly::Mint;
using poly::shift_of_sampling_points;
using poly::factorial;
i32 n;
cin >> n;
Vec<Mint> a(n);
REP(i, n) {
u32 v;
cin >> v;
a[i] = Mint::raw(v);
}
string s;
cin >> s;
factorial.reserve(n);
Vec<Mint> b(n);
REP(i, n - 1) {
if (s[i] == '+') {
b[i] = -Mint::raw(i);
} else {
b[i] = -Mint::raw(i + 2);
}
}
Vec<Mint> c(n, Mint::raw(1));
const auto rec = [&](const auto &rec, i32 l, i32 r) -> Vec<Mint> {
if (r - l == 1) {
Vec<Mint> ret(2);
ret[0] = Mint::raw(l) + b[l];
ret[1] = Mint::raw(l + 1) + b[l];
return ret;
}
i32 m = (l + r) / 2;
Vec<Mint> pl = rec(rec, l, m);
Vec<Mint> pr = rec(rec, m, r);
Vec<Mint> nl = shift_of_sampling_points(pr, -Mint::raw(m - l), m - l);
Vec<Mint> nr = shift_of_sampling_points(pl, Mint::raw(m - l), r - m + 1);
REP(i, r - m) {
c[m + i] *= nr[i];
}
Vec<Mint> ret(r - l + 1);
REP(i, m - l) {
ret[i] = pl[i] * nl[i];
}
REP(i, r - m + 1) {
ret[m - l + i] = pr[i] * nr[i];
}
return ret;
};
rec(rec, 0, n);
Mint ans;
REP(i, n) {
ans += a[i] * c[i] * factorial.inv_fact(i) * factorial.fact(n - 1);
}
cout << ans.val() << '\n';
}
詳細信息
answer.code:117:10: fatal error: atcoder/convolution: No such file or directory 117 | #include <atcoder/convolution> | ^~~~~~~~~~~~~~~~~~~~~ compilation terminated.