22#define PROBLEM " https://judge.yosupo.jp/problem/many_factorials"
33#pragma GCC optimize("Ofast,unroll-loops")
44#include < bits/stdc++.h>
5+ #define CP_ALGO_CHECKPOINT
6+ #include " cp-algo/util/checkpoint.hpp"
57#include " blazingio/blazingio.min.hpp"
68#include " cp-algo/util/simd.hpp"
79#include " cp-algo/math/common.hpp"
@@ -25,6 +27,7 @@ void facts_inplace(vector<int> &args) {
2527 args_per_block[(mod - x - 1 ) / block].push_back (i);
2628 }
2729 }
30+ cp_algo::checkpoint (" init" );
2831 uint32_t b2x32 = (1ULL << 32 ) % mod;
2932 uint64_t fact = 1 ;
3033 const int accum = 4 ;
@@ -49,6 +52,7 @@ void facts_inplace(vector<int> &args) {
4952 prods[z][i] = montgomery_mul (prods[z][i - 1 ], cur[z], mod, imod);
5053 }
5154 }
55+ cp_algo::checkpoint (" inner loop" );
5256 for (int z = 0 ; z < accum; z++) {
5357 uint64_t bl = b + z * block;
5458 for (auto i: args_per_block[bl / block]) {
@@ -75,6 +79,7 @@ void facts_inplace(vector<int> &args) {
7579 fact = fact * prods[z].back ()[j] % mod;
7680 }
7781 }
82+ cp_algo::checkpoint (" write ans" );
7883 }
7984}
8085
@@ -83,8 +88,11 @@ void solve() {
8388 cin >> n;
8489 vector<int > args (n);
8590 for (auto &x : args) {cin >> x;}
91+ cp_algo::checkpoint (" input read" );
8692 facts_inplace (args);
8793 for (auto it: args) {cout << it << " \n " ;}
94+ cp_algo::checkpoint (" output written" );
95+ cp_algo::checkpoint<1 >();
8896}
8997
9098signed main () {
0 commit comments