結果
| 問題 | No.3584 Camouflage Mole |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-10 21:23:25 |
| 言語 | C++23(gnu拡張gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 13,296 bytes |
| 記録 | |
| コンパイル時間 | 3,471 ms |
| コンパイル使用メモリ | 358,140 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-10 21:23:35 |
| 合計ジャッジ時間 | 5,199 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#line 2 "/Users/baluteshih/coding/cplibrary/default_code.hpp"
#line 2 "/Users/baluteshih/coding/cplibrary/assumption.hpp"
#include <cassert>
#include <bits/stdc++.h>
#line 4 "/Users/baluteshih/coding/cplibrary/default_code.hpp"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
template <typename T>
concept PrintableContainer = requires(T& a) {
a.begin();
a.end();
} && !std::convertible_to<std::remove_cvref_t<T>, std::string_view>;
template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &a);
template <PrintableContainer T>
std::ostream& operator<<(std::ostream& os, const T& a);
template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &a) {
os << "(" << a.first << ", " << a.second << ")";
return os;
}
template <PrintableContainer T>
std::ostream& operator<<(std::ostream& os, const T& a) {
os << "[ ";
bool first = true;
for (const auto& item : a) {
if (!first) os << ", ";
os << item;
first = false;
}
return os << " ]";
}
#ifdef bbq
#include <experimental/iterator>
#define safe cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define sepline sepline_()
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
void orange_(auto s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
using namespace experimental;
copy(L, R, make_ostream_joiner(cerr, ", "));
cerr << " ]\e[0m\n";
}
void sepline_(int length = 50) {
cerr << "\e[1;35m";
cerr << string(length, '=');
cerr << "\e[0m\n";
}
#else
#define safe ((void)0)
#define sepline safe
#define debug(...) safe
#define orange(...) safe
#endif
void chmax(auto &x, auto val) { x = max(x, val); }
void chmin(auto &x, auto val) { x = min(x, val); }
auto floor_div(auto a, auto b) { return a / b - (a % b && (a < 0) ^ (b < 0)); }
auto ceil_div(auto a, auto b) { return a / b + (a % b && (a < 0) ^ (b > 0)); }
string bitstring(auto x, int width = -1) {
string res;
while (x) res.push_back((x & 1) + '0'), x >>= 1;
if (res.empty()) res = "0";
if (width != -1) res.resize(width, '0');
ranges::reverse(res);
return res;
}
vector<int> count_array(const auto &container, int sz = -1) {
if (sz == -1) sz = *ranges::max_element(container) + 1;
vector<int> res(sz);
for (auto x : container) ++res[x];
return res;
}
#line 2 "A.cpp"
#line 2 "/Users/baluteshih/coding/cplibrary/Numeric/Modint.hpp"
// Reference: Atcoder Library https://github.com/atcoder/ac-library
#line 2 "/Users/baluteshih/coding/cplibrary/Numeric/internal_math.hpp"
// Reference: Atcoder Library https://github.com/atcoder/ac-library
#ifdef _MSC_VER
#include <intrin.h>
#endif
namespace internal {
constexpr long long safe_mod(long long x, long long m) {
x %= m;
if (x < 0) x += m;
return x;
}
constexpr long long pow_mod_constexpr(long long x, long long n, int m) {
if (m == 1) return 0;
unsigned int _m = (unsigned int)(m);
unsigned long long r = 1;
unsigned long long y = safe_mod(x, m);
while (n) {
if (n & 1) r = (r * y) % _m;
y = (y * y) % _m;
n >>= 1;
}
return r;
}
constexpr bool is_prime_constexpr(int n) {
if (n <= 1) return false;
if (n == 2 || n == 7 || n == 61) return true;
if (n % 2 == 0) return false;
long long d = n - 1;
while (d % 2 == 0) d /= 2;
constexpr long long bases[3] = {2, 7, 61};
for (long long a : bases) {
long long t = d;
long long y = pow_mod_constexpr(a, t, n);
while (t != n - 1 && y != 1 && y != n - 1)
y = y * y % n, t <<= 1;
if (y != n - 1 && t % 2 == 0)
return false;
}
return true;
}
template <int n> constexpr bool is_prime = is_prime_constexpr(n);
constexpr std::pair<long long, long long> inv_gcd(long long a, long long b) {
a = safe_mod(a, b);
if (a == 0) return {b, 0};
long long s = b, t = a, m0 = 0, m1 = 1;
while (t) {
long long u = s / t;
s -= t * u, m0 -= m1 * u;
auto tmp = s;
s = t, t = tmp, tmp = m0, m0 = m1, m1 = tmp;
}
if (m0 < 0) m0 += b / s;
return {s, m0};
}
} // namespace internal
namespace internal {
#ifndef _MSC_VER
template <class T>
using is_signed_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value ||
std::is_same<T, __int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int128 =
typename std::conditional<std::is_same<T, __uint128_t>::value ||
std::is_same<T, unsigned __int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using make_unsigned_int128 =
typename std::conditional<std::is_same<T, __int128_t>::value,
__uint128_t,
unsigned __int128>;
template <class T>
using is_integral = typename std::conditional<std::is_integral<T>::value ||
is_signed_int128<T>::value ||
is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_signed_int = typename std::conditional<(is_integral<T>::value &&
std::is_signed<T>::value) ||
is_signed_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<(is_integral<T>::value &&
std::is_unsigned<T>::value) ||
is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<
is_signed_int128<T>::value,
make_unsigned_int128<T>,
typename std::conditional<std::is_signed<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type>::type;
#else
template <class T> using is_integral = typename std::is_integral<T>;
template <class T>
using is_signed_int =
typename std::conditional<is_integral<T>::value && std::is_signed<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<is_integral<T>::value &&
std::is_unsigned<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<is_signed_int<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type;
#endif
template <class T> using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
template <class T> using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
template <class T> using to_unsigned_t = typename to_unsigned<T>::type;
struct modint_base {};
struct static_modint_base : modint_base {};
template <class T> using is_modint = std::is_base_of<modint_base, T>;
template <class T> using is_modint_t = std::enable_if_t<is_modint<T>::value>;
} // namespace internal
#line 5 "/Users/baluteshih/coding/cplibrary/Numeric/Modint.hpp"
template <int m, std::enable_if_t<(1 <= m)>* = nullptr>
struct static_modint : internal::static_modint_base {
using mint = static_modint;
public:
static constexpr int mod() { return m; }
static mint raw(int v) {
mint x;
x._v = v;
return x;
}
static_modint() : _v(0) {}
template <class T, internal::is_signed_int_t<T>* = nullptr>
static_modint(T v) {
long long x = (long long)(v % (long long)(umod()));
if (x < 0) x += umod();
_v = (unsigned int)(x);
}
template <class T, internal::is_unsigned_int_t<T>* = nullptr>
static_modint(T v) {
_v = (unsigned int)(v % umod());
}
unsigned int val() const { return _v; }
mint& operator++() {
_v++;
if (_v == umod()) _v = 0;
return *this;
}
mint& operator--() {
if (_v == 0) _v = umod();
_v--;
return *this;
}
mint operator++(int) {
mint result = *this;
++*this;
return result;
}
mint operator--(int) {
mint result = *this;
--*this;
return result;
}
mint& operator+=(const mint& rhs) {
_v += rhs._v;
if (_v >= umod()) _v -= umod();
return *this;
}
mint& operator-=(const mint& rhs) {
_v -= rhs._v;
if (_v >= umod()) _v += umod();
return *this;
}
mint& operator*=(const mint& rhs) {
unsigned long long z = _v;
z *= rhs._v;
_v = (unsigned int)(z % umod());
return *this;
}
mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }
mint operator+() const { return *this; }
mint operator-() const { return mint() - *this; }
mint pow(long long n) const {
assert(0 <= n);
mint x = *this, r = 1;
while (n) {
if (n & 1) r *= x;
x *= x;
n >>= 1;
}
return r;
}
mint inv() const {
if (prime) {
assert(_v);
return pow(umod() - 2);
} else {
auto eg = internal::inv_gcd(_v, m);
assert(eg.first == 1);
return eg.second;
}
}
friend mint operator+(const mint& lhs, const mint& rhs) {
return mint(lhs) += rhs;
}
friend mint operator-(const mint& lhs, const mint& rhs) {
return mint(lhs) -= rhs;
}
friend mint operator*(const mint& lhs, const mint& rhs) {
return mint(lhs) *= rhs;
}
friend mint operator/(const mint& lhs, const mint& rhs) {
return mint(lhs) /= rhs;
}
friend bool operator==(const mint& lhs, const mint& rhs) {
return lhs._v == rhs._v;
}
friend bool operator!=(const mint& lhs, const mint& rhs) {
return lhs._v != rhs._v;
}
friend std::strong_ordering operator<=>(const mint& lhs, const mint& rhs) {
return lhs._v <=> rhs._v;
}
friend std::ostream& operator<<(std::ostream& os, const mint& v) {
os << v._v;
return os;
}
friend std::istream& operator>>(std::istream& is, mint& v) {
long long x;
is >> x;
x %= (long long)(umod());
if (x < 0) x += umod();
v._v = (unsigned int)(x);
return is;
}
private:
unsigned int _v;
static constexpr unsigned int umod() { return m; }
static constexpr bool prime = internal::is_prime<m>;
};
using modint998244353 = static_modint<998244353>;
using modint1000000007 = static_modint<1000000007>;
#line 2 "/Users/baluteshih/coding/cplibrary/Numeric/Combination.hpp"
#line 4 "/Users/baluteshih/coding/cplibrary/Numeric/Combination.hpp"
template<class T>
requires std::derived_from<T, internal::modint_base>
class Combination {
inline static int N = 1;
public:
inline static std::vector<T> fac = {T(1)};
inline static std::vector<T> ifac = {T(1)};
Combination(int n) { ensure_upper_bound(n); }
Combination(int n, T v) {
N = 1;
std::vector<T>(n, v.raw(1)).swap(fac);
std::vector<T>(n, v.raw(1)).swap(ifac);
ensure_upper_bound(n);
}
T C(int n, int m) {
if (n < m || m < 0) return 0;
return fac[n] * ifac[m] * ifac[n - m];
}
T invC(int n, int m) {
assert(n >= m && m >= 0);
return ifac[n] * fac[m] * fac[n - m];
}
T P(int n, int m) {
if (n < m) return 0;
return fac[n] * ifac[n - m];
}
T H(int n, int m) {
return C(n + m - 1, m);
}
// a - b <= k and all non-empty proper prefix have a - b < k
T extend_catalan(int a, int b, int k) {
if (a - b == k) return C(a + b - 1, a - 1) - C(a + b - 1, b + k);
return C(a + b, a) - C(a + b, b + k);
}
void ensure_upper_bound(int n) {
if (N >= n) return;
fac.resize(n), ifac.resize(n);
for (int i = N; i < n; ++i)
fac[i] = fac[i - 1] * i;
ifac.back() = fac.back().inv();
for (int i = n - 2; i >= N; --i)
ifac[i] = ifac[i + 1] * (i + 1);
N = n;
}
};
namespace CombFunc {
template<class T>
std::vector<T> power(T base, int n) {
std::vector<T> res(n + 1, 1);
for (int i = 1; i <= n; ++i)
res[i] = res[i - 1] * base;
return res;
}
template<class T>
std::vector<T> ipower(T base, int n) {
return power(base.inv(), n);
}
template<class T>
std::vector<T> linear_inverse(int n) {
std::vector<T> res(n + 1, 1);
int MOD = T().mod();
for (int i = 2; i <= n; ++i) {
res[i] = res[MOD % i] * (MOD - MOD / i);
}
return res;
}
}
#line 5 "A.cpp"
using mint = modint998244353;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
auto pw = CombFunc::power<mint>(26, n + 1);
Combination<mint> comb(n + 1);
cout << comb.C(n, 4) * pw[n - 4] << "\n";
}