結果
問題 | No.2136 Dice Calendar? |
ユーザー | srtubaki |
提出日時 | 2022-10-20 18:33:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 6,088 bytes |
コンパイル時間 | 2,512 ms |
コンパイル使用メモリ | 219,856 KB |
実行使用メモリ | 301,364 KB |
最終ジャッジ日時 | 2024-06-30 10:19:48 |
合計ジャッジ時間 | 28,199 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 15 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 3 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 3 ms
6,944 KB |
testcase_08 | AC | 5 ms
6,940 KB |
testcase_09 | AC | 10 ms
6,940 KB |
testcase_10 | AC | 15 ms
6,944 KB |
testcase_11 | AC | 57 ms
9,676 KB |
testcase_12 | AC | 82 ms
12,856 KB |
testcase_13 | AC | 57 ms
9,732 KB |
testcase_14 | AC | 109 ms
14,692 KB |
testcase_15 | AC | 715 ms
56,044 KB |
testcase_16 | AC | 947 ms
70,380 KB |
testcase_17 | AC | 589 ms
55,596 KB |
testcase_18 | AC | 2,740 ms
162,748 KB |
testcase_19 | AC | 3,587 ms
205,796 KB |
testcase_20 | AC | 4,369 ms
236,616 KB |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
#pragma region template #include <bits/stdc++.h> #include <atcoder/modint.hpp> using namespace std; using namespace atcoder; using mint = static_modint<998244353>; using vm = vector<mint>; using vvm = vector<vm>; ostream& operator<<(ostream& os, const mint& v) { os << v.val(); return os; } // clang-format off using ll = long long; using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>; using ld = long double; using vld = vector<ld>; using vvld = vector<vld>; using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>; using vi = vector<int>; using vvi = vector<vi>; using vb = vector<bool>; using vvb = vector<vb>; using mll = map<ll, ll>; using vs = vector<string>; template <class T> using max_heap = priority_queue<T>; template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; constexpr ll inf = 3001001000100100100LL; #define endl '\n' #define _overload(_1, _2, _3, name, ...) name #define rep(...) _overload(__VA_ARGS__, _rep, _rep2,)(__VA_ARGS__) #define repc(...) _overload(__VA_ARGS__, _repc, _repc2,)(__VA_ARGS__) #define repr(...) _overload(__VA_ARGS__, _repr, _repr2,)(__VA_ARGS__) #define reprc(...) _overload(__VA_ARGS__, _reprc, _reprc2,)(__VA_ARGS__) #define _rep(i,k,n) for(ll i=(k) , i##_xxxx=(n); i < i##_xxxx; ++i) #define _repc(i,k,n) for(ll i=(k) , i##_xxxx=(n); i <=i##_xxxx; ++i) #define _repr(i,k,n) for(ll i=(n)-1, i##_xxxx=(k); i >=i##_xxxx; --i) #define _reprc(i,k,n) for(ll i=(n) , i##_xxxx=(k); i >=i##_xxxx; --i) #define _rep2(i,n) _rep(i,0,n) #define _repc2(i,n) _repc(i,1,n) #define _repr2(i,n) _repr(i,0,n) #define _reprc2(i,n) _reprc(i,1,n) #define rall(o) rbegin(o), rend(o) #define all(o) begin(o), end(o) template <class C> ll sz(const C& c) { return static_cast<ll>(c.size()); } template <class T, class U> common_type_t<T, U> min(const T& a, const U& b){ return std::min<common_type_t<T, U>>(a,b); } template <class T, class U> common_type_t<T, U> max(const T& a, const U& b){ return std::max<common_type_t<T, U>>(a,b); } template <class T, class U> bool chmax(T& m, const U& v){ if (m < v){ m = v; return true; } return false; } template <class T, class U> bool chmin(T& m, const U& v){ if (v < m){ m = v; return true; } return false; } template <class T, class U> common_type_t<T, U> cdiv(const T& a, const U& b){ return (a + b - 1) / b; } template <class T, class U> common_type_t<T, U> rdiv(const T& a, const T& b){ return (a + b / 2) / b; } template <class T, class S> string join(const T& v, const S& sep ){ stringstream ss; bool f = false; for (const auto& e : v){ if (f) ss << sep; f = true; ss << e;} return ss.str(); } template <class T, class S, class... U> string join(const T& v, const S& sep, const U& ...args){ stringstream ss; bool f = false; for (const auto& c : v){ if (f) ss << sep; f = true; ss << join(c, args...); } return ss.str(); } template <class T> ostream& operator<<(ostream& os, const vector<T>& seq){ os << '[' << join(seq, ",") << ']'; return os; } template <class T> ostream& operator<<(ostream& os, const vector<vector<T>>& seq){ os << '[' << join(seq, ",\n ") << ']'; return os; } template <class T> ostream& operator<<(ostream& os, const deque<T>& seq){ os << '[' << join(seq, ",") << ']'; return os; } template <class T> ostream& operator<<(ostream& os, const set<T>& seq){ os << '{' << join(seq, ",") << '}'; return os; } template <class T , class TH> ostream& operator<<(ostream& os, const unordered_set<T, TH>& seq){ os << '{' << join(seq, ",") << '}'; return os; } template <class TK, class TV> ostream& operator<<(ostream& os, const map<TK, TV>& seq){ os << '{'; bool f = false; for (const auto& e : seq){ if (f) os << ','; f = true; os << e.first << ":" << e.second; } os << '}'; return os; } template <class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& pa){ os << '(' << pa.first << ',' << pa.second << ')'; return os; } #if LOCAL #define debug(...) _debug(__VA_ARGS__, __LINE__) #else #define debug(...) #endif void print() { std::cout << '\n'; } template <class S> void print(const S& a){ std::cout << a << '\n'; } template <class S> void _debug(const S& a){ std::cerr << "(L:" << std::setw(3) << a << ")\n"; } template <class S, class... T> void print(const S& a, const T&... args){ std::cout << a << ' '; print(args...); } template <class S, class... T> void _debug(const S& a, const T&... args){ std::cerr << a << ' '; _debug(args...); } struct setup_main { setup_main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << fixed << setprecision(15); } } setup_main_; // clang-format on #pragma endregion // 階乗 mint factorial(ll n) { if (n < 0) return 0; static vector<mint> fact = {1, 1}; while (sz(fact) <= n) fact.push_back(fact.back() * fact.size()); return fact[n]; } mint factorial_inv(ll n) { if (n < 0) return 0; static vector<mint> fact_inv; while (sz(fact_inv) <= n) fact_inv.push_back(1 / factorial(fact_inv.size())); return fact_inv[n]; } // 組み合わせ mint combination(ll n, ll k) { if (k > n or k < 0) return 0; return factorial(n) * factorial_inv(n - k) * factorial_inv(k); } // 順列 mint permutation(ll n, ll k) { if (k > n or k < 0) return 0; return factorial(n) * factorial_inv(n - k); } mint solve(ll N, vvl S) { mint ans = 0; vector<unordered_set<ll>> seen(N + 1); seen[0].insert(0); rep(i, N) { for (ll v : seen[i]) { rep(j, 6) { seen[i + 1].insert(v + (1LL << 5 * S[i][j])); } } } for (ll v : seen[N]) { mint a = factorial(N); rep(i, 9) a *= factorial_inv((v >> i * 5) & 0b11111); ans += a; } return ans; } int main() { ll N; cin >> N; vvl S(N, vl(6)); rep(i, N) rep(j, 6) { cin >> S[i][j]; S[i][j]--; } print(solve(N, S)); }