結果

問題 No.2136 Dice Calendar?
ユーザー 👑 hitonanodehitonanode
提出日時 2022-11-26 00:19:57
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,836 ms / 5,000 ms
コード長 2,224 bytes
コンパイル時間 2,650 ms
コンパイル使用メモリ 229,052 KB
実行使用メモリ 312,696 KB
最終ジャッジ日時 2024-04-10 05:06:05
合計ジャッジ時間 16,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 11 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 7 ms
6,940 KB
testcase_10 AC 8 ms
6,940 KB
testcase_11 AC 30 ms
7,820 KB
testcase_12 AC 38 ms
8,392 KB
testcase_13 AC 30 ms
7,776 KB
testcase_14 AC 53 ms
11,168 KB
testcase_15 AC 244 ms
35,904 KB
testcase_16 AC 301 ms
41,268 KB
testcase_17 AC 249 ms
36,076 KB
testcase_18 AC 718 ms
79,696 KB
testcase_19 AC 1,044 ms
137,020 KB
testcase_20 AC 1,318 ms
187,944 KB
testcase_21 AC 1,668 ms
204,664 KB
testcase_22 AC 2,007 ms
223,696 KB
testcase_23 AC 2,836 ms
312,696 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 66 ms
8,840 KB
testcase_26 AC 2,713 ms
288,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template <class T> std::vector<T> sort_unique(std::vector<T> vec) { sort(vec.begin(), vec.end()), vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec; }

using Array = lint;

int main() {
    int N;
    cin >> N;

    vector<lint> facs(21, 1);
    for (int i = 1; i < int(facs.size()); ++i) facs[i] = facs[i - 1] * i;

    vector<Array> states;
    {
        Array arr = 0;
        states.push_back(arr);
    }

    while (N--) {
        vector<Array> states_nxt;

        vector<int> S(6);
        for (auto &x : S) cin >> x;
        S = sort_unique(S);
        for (auto &x : S) --x;
        for (auto &v : states) {
            for (int x : S) {
                v += 1LL << (5 * x);
                states_nxt.push_back(v);
                v -= 1LL << (5 * x);
            }
        }

        states = sort_unique(states_nxt);
    }

    lint ret = 0;
    for (auto vec : states) {
        int len = 0;
        lint den = 1;
        while (vec) {
            int d = vec % 32;
            den *= facs[d];
            len += d;
            vec >>= 5;
        }
        ret += facs[len] / den;
        ret %= 998244353;
    }
    cout << ret << endl;
}
0