Submission #67464526


Source Code Expand

#ifndef HIDDEN_IN_VS // 折りたたみ用

// 警告の抑制
#define _CRT_SECURE_NO_WARNINGS

// ライブラリの読み込み
#include <bits/stdc++.h>
using namespace std;

// 型名の短縮
using ll = long long; using ull = unsigned long long; // -2^63 ~ 2^63 = 9e18(int は -2^31 ~ 2^31 = 2e9)
using pii = pair<int, int>;	using pll = pair<ll, ll>;	using pil = pair<int, ll>;	using pli = pair<ll, int>;
using vi = vector<int>;		using vvi = vector<vi>;		using vvvi = vector<vvi>;	using vvvvi = vector<vvvi>;
using vl = vector<ll>;		using vvl = vector<vl>;		using vvvl = vector<vvl>;	using vvvvl = vector<vvvl>;
using vb = vector<bool>;	using vvb = vector<vb>;		using vvvb = vector<vvb>;
using vc = vector<char>;	using vvc = vector<vc>;		using vvvc = vector<vvc>;
using vd = vector<double>;	using vvd = vector<vd>;		using vvvd = vector<vvd>;
template <class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
using Graph = vvi;

// 定数の定義
const double PI = acos(-1);
int DX[4] = { 1, 0, -1, 0 }; // 4 近傍(下,右,上,左)
int DY[4] = { 0, 1, 0, -1 };
int INF = 1001001001; ll INFL = 4004004003094073385LL; // (int)INFL = INF, (int)(-INFL) = -INF;

// 入出力高速化
struct fast_io { fast_io() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } fastIOtmp;

// 汎用マクロの定義
#define all(a) (a).begin(), (a).end()
#define sz(x) ((int)(x).size())
#define lbpos(a, x) (int)distance((a).begin(), std::lower_bound(all(a), (x)))
#define ubpos(a, x) (int)distance((a).begin(), std::upper_bound(all(a), (x)))
#define Yes(b) {cout << ((b) ? "Yes\n" : "No\n");}
#define rep(i, n) for(int i = 0, i##_len = int(n); i < i##_len; ++i) // 0 から n-1 まで昇順
#define repi(i, s, t) for(int i = int(s), i##_end = int(t); i <= i##_end; ++i) // s から t まで昇順
#define repir(i, s, t) for(int i = int(s), i##_end = int(t); i >= i##_end; --i) // s から t まで降順
#define repe(v, a) for(const auto& v : (a)) // a の全要素(変更不可能)
#define repea(v, a) for(auto& v : (a)) // a の全要素(変更可能)
#define repb(set, d) for(int set = 0, set##_ub = 1 << int(d); set < set##_ub; ++set) // d ビット全探索(昇順)
#define repis(i, set) for(int i = lsb(set), bset##i = set; i < 32; bset##i -= 1 << i, i = lsb(bset##i)) // set の全要素(昇順)
#define repp(a) sort(all(a)); for(bool a##_perm = true; a##_perm; a##_perm = next_permutation(all(a))) // a の順列全て(昇順)
#define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());} // 重複除去
#define EXIT(a) {cout << (a) << endl; exit(0);} // 強制終了
#define inQ(x, y, u, l, d, r) ((u) <= (x) && (l) <= (y) && (x) < (d) && (y) < (r)) // 半開矩形内判定

// 汎用関数の定義
template <class T> inline ll powi(T n, int k) { ll v = 1; rep(i, k) v *= n; return v; }
template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; } // 最大値を更新(更新されたら true を返す)
template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; } // 最小値を更新(更新されたら true を返す)
template <class T> inline T getb(T set, int i) { return (set >> i) & T(1); }
template <class T> inline T smod(T n, T m) { n %= m; if (n < 0) n += m; return n; } // 非負mod

// 演算子オーバーロード
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template <class T> inline istream& operator>>(istream& is, vector<T>& v) { repea(x, v) is >> x; return is; }
template <class T> inline vector<T>& operator--(vector<T>& v) { repea(x, v) --x; return v; }
template <class T> inline vector<T>& operator++(vector<T>& v) { repea(x, v) ++x; return v; }

#endif // 折りたたみ用


#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;

#ifdef _MSC_VER
#include "localACL.hpp"
#endif

using mint = modint998244353;
//using mint = static_modint<(int)1e9+7>;
//using mint = modint; // mint::set_mod(m);

using vm = vector<mint>; using vvm = vector<vm>; using vvvm = vector<vvm>; using vvvvm = vector<vvvm>; using pim = pair<int, mint>;
#endif


#ifdef _MSC_VER // 手元環境(Visual Studio)
#include "local.hpp"
#else // 提出用(gcc)
int mute_dump = 0;
int frac_print = 0;
#if __has_include(<atcoder/all>)
namespace atcoder {
	inline istream& operator>>(istream& is, mint& x) { ll x_; is >> x_; x = x_; return is; }
	inline ostream& operator<<(ostream& os, const mint& x) { os << x.val(); return os; }
}
#endif
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(ll n) { return __builtin_popcountll(n); }
inline int lsb(int n) { return n != 0 ? __builtin_ctz(n) : 32; }
inline int lsb(ll n) { return n != 0 ? __builtin_ctzll(n) : 64; }
inline int msb(int n) { return n != 0 ? (31 - __builtin_clz(n)) : -1; }
inline int msb(ll n) { return n != 0 ? (63 - __builtin_clzll(n)) : -1; }
#define dump(...)
#define dumpel(v)
#define dump_math(v)
#define input_from_file(f)
#define output_to_file(f)
#define Assert(b) { if (!(b)) { vc MLE(1<<30); EXIT(MLE.back()); } } // RE の代わりに MLE を出す
#endif


/*
* Solve[] でループのある漸化式をほぐし,
* 解を貼ってメモ化再帰をお手軽実装し,
* P-recursive チェッカーにぶち込んでコードを自動生成する.
* もはや C++ でコードを書く必要はない.
* 
* なお L2 ノルムは 10^10 程度に大きくなるが,
* LLL に頼る必要もないほど簡単に項数を稼げるので問題ない.
*/


int main() {
//	input_from_file("input.txt");
//	output_to_file("output.txt");

	int n;
	cin >> n;

	{
		vm dp{ -1, 0, 332748118, 174692763, 608453703, 372360992, 859635320, 429809353, \
858142222, 200768582, 509205977, 897311825, 408450400, 41554758, \
257336643, 406471642, 414423603, 723884068, 251145641, 157803499, \
529080914, 169032157, 566008154, 110382875, 509006948, 88011973, \
45695750, 17762602, 74721785, 306099118, 214079195, 972444611, \
416665564, 25951134, 110570941, 616399451, 628652036, 481234433, \
615762675, 746144262, 471853190 };
		dp.resize(n + 1);
		
		auto dpsub = [&](const mint& x) { return dp[x.val()]; };
		auto Power = [&](const mint& x, int n) { mint res = 1; rep(hoge, n) res *= x; return res; };

		repi(i, 6, n) {
			mint nn = i;
			dp[i] = (4 * (-4 + nn) * (-3 + nn) * (-11 + 2 * nn) * (-33690471 + 3861578 * nn) * dpsub(-5 + nn) +
				(-3 + nn) * (-9 + 2 * nn) * (1953625121 + nn * (-924962047 + 219465870 * nn)) * dpsub(-4 + nn) -
				128537183656 * dpsub(-3 + nn) + 6457125105 * dpsub(-2 + nn) + 72762944250 * dpsub(-1 + nn) +
				nn * ((82981283591 + nn * (-8991808051 + 4 * nn * (-737833091 + 124599275 * nn))) * dpsub(-3 + nn) +
					(95195226968 + nn * (-90156295269 + 4 * (6726850184 - 648937495 * nn) * nn)) * dpsub(-2 + nn) +
					(-123231155213 + nn * (74705435283 + 4 * nn * (-4818197491 + 446529645 * nn))) * dpsub(-1 + nn))) /
				(2 * (-1 + nn) * (-3 + 2 * nn) * (-1 + 2 * nn) * (-79818139 + 19823758 * nn));
		}

		cout << dp[n] << " ";
	}

	{
		vm dp{ -1, 0, 665496236, 324429416, 722538772, 542696338, 238433477, 19400617, \
796091291, 537219224, 754444632, 193230540, 781232181, 831332892, \
759484239, 682979304, 614558160, 182238240, 473396956, 107869289, \
381044771, 537038725, 553968715, 561379858, 929795644, 412496375, \
834200900, 972764255, 508827096, 833064556, 964365986, 677854630, \
836049107, 797983831, 42585687, 833107418, 491492842, 170903405, \
809428670, 7273237, 96114635, 676166043, 816583639, 464177453, \
977599237, 31987612, 847701229, 675385564, 896087230, 422427405, \
904385543, 308786564, 624133877, 539591560, 464166198, 160272887, \
613314433, 613945823, 909439768, 771274713, 15363680 };
		dp.resize(n + 1);

		auto dpsub = [&](const mint& x) { return dp[x.val()]; };
		auto Power = [&](const mint& x, int n) { mint res = 1; rep(hoge, n) res *= x; return res; };

		repi(i, 6, n) {
			mint nn = i;
			dp[i] = (4 * (-4 + nn) * (-3 + nn) * (-11 + 2 * nn) * (-41668371 + 16645153 * nn) * dpsub(-5 + nn) +
				(-3 + nn) * (-9 + 2 * nn) * (2047580971 + nn * (-1279719797 + 207137370 * nn)) * dpsub(-4 + nn) -
				185581519256 * dpsub(-3 + nn) + 97358324355 * dpsub(-2 + nn) + 30884664750 * dpsub(-1 + nn) +
				nn * ((197877805741 + nn * (-74653156601 + 4 * (2946886409 - 163066475 * nn) * nn)) * dpsub(-3 + nn) +
					(-66499228232 + nn * (6337473681 + 4 * (802929184 - 133776245 * nn) * nn)) * dpsub(-2 + nn) +
					(-51718493263 + nn * (30876347733 - 7805400464 * nn + 704102580 * Power(nn, 2))) * dpsub(-1 + nn))) /
				(2 * (-1 + nn) * (-3 + 2 * nn) * (-1 + 2 * nn) * (-34749689 + 8020958 * nn));
		}

		cout << dp[n] << "\n";
	}
}

Submission Info

Submission Time
Task C - Catastrophic Roulette
User ecottea
Language C++ 23 (gcc 12.2)
Score 500
Code Size 8987 Byte
Status AC
Exec Time 297 ms
Memory 7376 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:135:22: warning: variable ‘Power’ set but not used [-Wunused-but-set-variable]
  135 |                 auto Power = [&](const mint& x, int n) { mint res = 1; rep(hoge, n) res *= x; return res; };
      |                      ^~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 3492 KiB
sample_02.txt AC 1 ms 3480 KiB
sample_03.txt AC 1 ms 3452 KiB
test_01.txt AC 297 ms 7376 KiB
test_02.txt AC 297 ms 7316 KiB
test_03.txt AC 1 ms 3684 KiB
test_04.txt AC 1 ms 3544 KiB
test_05.txt AC 1 ms 3556 KiB
test_06.txt AC 34 ms 3864 KiB
test_07.txt AC 163 ms 5672 KiB
test_08.txt AC 11 ms 3676 KiB
test_09.txt AC 171 ms 5716 KiB
test_10.txt AC 183 ms 5952 KiB
test_11.txt AC 210 ms 6204 KiB
test_12.txt AC 252 ms 6872 KiB
test_13.txt AC 141 ms 5320 KiB
test_14.txt AC 155 ms 5640 KiB
test_15.txt AC 163 ms 5696 KiB
test_16.txt AC 207 ms 6200 KiB
test_17.txt AC 45 ms 4056 KiB