- Translate each rule into one explicit state update.
- Maintain the invariant after every processed item.
- Return the accumulated state once all relevant input has been handled.
Code notes
- 51 lines of C++ from the credited upstream file yosupo-multipoint-evaluation-chirp-z.test.cpp.
- The implementation keeps its working state in language-native values and containers.
- 1 loop block detected.
Complexity
Count the number and nesting of passes over the input, then include the maintained containers in the memory estimate.
Check the problem constraints before deciding whether this complexity will pass.
Use this to learn the idea, then write your own version.
1#define PROBLEM "https://judge.yosupo.jp/problem/multipoint_evaluation_on_geometric_sequence"23#include "../../template/template.hpp"45#include "../../misc/rng.hpp"67#include "../../ntt/chirp-z.hpp"89#include "../../fps/ntt-friendly-fps.hpp"10#include "../../modint/montgomery-modint.hpp"11#include "../../modulo/binomial.hpp"1213using namespace Nyaan;14using mint = LazyMontgomeryModInt<998244353>;15Binomial<mint> C;16using fps = FormalPowerSeries<mint>;17 18void test() {19 rep(N, 50) rep(fdeg, 50) rep(W, 3) rep(A, 3) {20 fps f(fdeg);21 each(x, f) x = rng(0, 998244352);22 fps ys1 = ChirpZ(f, W, N, A);23 fps ys2(N);24 rep(i, N) ys2[i] = f.eval(mint{W}.pow(i) * A);25 if (ys1 != ys2) {26 trc(N, fdeg, W, A);27 trc(f);28 trc(ys1);29 trc(ys2);30 }31 assert(ys1 == ys2);32 }33 cerr << "OK" << endl;34}35 36void q() {37 test();38 int N, M, A, R, x;39 in(N, M, A, R);40 fps c(N);41 rep(i, N) in(x), c[i] = x;42 auto ps = ChirpZ(c, R, M, A);43 out(ps);44}45 46void Nyaan::solve() {47 int t = 1;48 49 while (t--) q();50}51