結果
| 問題 |
No.2136 Dice Calendar?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-21 23:49:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 950 ms / 5,000 ms |
| コード長 | 1,345 bytes |
| コンパイル時間 | 2,101 ms |
| コンパイル使用メモリ | 198,252 KB |
| 最終ジャッジ日時 | 2025-02-08 10:35:08 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll fact[21];
struct ms
{
int mulset;
ll part;
ms()
{
mulset = 511;
part = 9043225708576ll;
}
ms(int mulset_, ll part_) : mulset(mulset_), part(part_) {}
int getpart(int ind)
{
if (ind == -1)
return -1;
return part >> (5 * ind) & (31);
}
ll count()
{
ll ret = fact[getpart(8) - 8];
for (int i = 0; i < 9; i++)
ret /= fact[getpart(i) - getpart(i - 1) - 1];
return ret;
}
};
int main()
{
int n;
cin >> n;
fact[0] = 1;
for (int i = 1; i <= 20; i++)
fact[i] = fact[i - 1] * i;
vector<ms> dp(1, ms()), ndp;
ndp.reserve(3200000);
bitset<1 << 29> st(0);
int S[6];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 6; j++)
cin >> S[j], --S[j];
for (auto &v : dp)
{
for (int j = 0; j < 6; j++)
{
int mask = (1 << v.getpart(S[j])) - 1;
int nms = (v.mulset & ~mask) << 1 | (v.mulset & mask);
if (st[nms])
continue;
st.set(nms);
ll np = v.part + (1134979744801ll & ~((1ll << (5 * S[j])) - 1));
ndp.push_back(ms(nms, np));
}
}
swap(dp, ndp);
ndp.clear();
ndp.reserve(3200000);
}
ll ans = 0;
for (auto &tmp : dp)
{
ans = (ans + tmp.count()) % 998244353;
}
cout << ans << endl;
}