結果
問題 | No.2983 Christmas Color Grid (Advent Calender ver.) |
ユーザー | KumaTachiRen |
提出日時 | 2024-12-08 12:21:31 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,584 bytes |
コンパイル時間 | 2,998 ms |
コンパイル使用メモリ | 254,804 KB |
実行使用メモリ | 7,416 KB |
最終ジャッジ日時 | 2024-12-08 12:21:37 |
合計ジャッジ時間 | 5,833 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | WA | - |
testcase_03 | AC | 4 ms
5,248 KB |
testcase_04 | AC | 1 ms
5,248 KB |
testcase_05 | AC | 2 ms
5,248 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,248 KB |
testcase_08 | AC | 1 ms
5,248 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 10 ms
5,248 KB |
testcase_12 | AC | 2 ms
5,248 KB |
testcase_13 | AC | 4 ms
5,248 KB |
testcase_14 | AC | 6 ms
5,248 KB |
testcase_15 | AC | 10 ms
5,248 KB |
testcase_16 | AC | 18 ms
5,248 KB |
testcase_17 | AC | 33 ms
5,248 KB |
testcase_18 | AC | 64 ms
7,276 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 4 ms
5,248 KB |
testcase_35 | AC | 5 ms
5,248 KB |
testcase_36 | AC | 9 ms
5,248 KB |
testcase_37 | AC | 18 ms
5,248 KB |
testcase_38 | AC | 34 ms
5,248 KB |
testcase_39 | AC | 67 ms
7,296 KB |
testcase_40 | AC | 2 ms
5,248 KB |
testcase_41 | AC | 2 ms
5,248 KB |
testcase_42 | AC | 1 ms
5,248 KB |
testcase_43 | AC | 1 ms
5,248 KB |
testcase_44 | AC | 2 ms
5,248 KB |
testcase_45 | AC | 2 ms
5,248 KB |
testcase_46 | AC | 2 ms
5,248 KB |
testcase_47 | AC | 2 ms
5,248 KB |
testcase_48 | AC | 1 ms
5,248 KB |
testcase_49 | AC | 2 ms
5,248 KB |
testcase_50 | AC | 1 ms
5,248 KB |
testcase_51 | AC | 2 ms
5,248 KB |
testcase_52 | AC | 2 ms
5,248 KB |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | AC | 2 ms
5,248 KB |
testcase_56 | AC | 2 ms
5,248 KB |
testcase_57 | WA | - |
testcase_58 | AC | 2 ms
5,248 KB |
testcase_59 | WA | - |
testcase_60 | AC | 2 ms
5,248 KB |
testcase_61 | WA | - |
testcase_62 | AC | 2 ms
5,248 KB |
testcase_63 | AC | 2 ms
5,248 KB |
testcase_64 | AC | 2 ms
5,248 KB |
testcase_65 | AC | 2 ms
5,248 KB |
testcase_66 | AC | 1 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/modint> using namespace atcoder; using mint = modint998244353; using vm = vector<mint>; using vvm = vector<vm>; inline ostream &operator<<(ostream &os, const mint x) { return os << x.val(); }; inline istream &operator>>(istream &is, mint &x) { long long v; is >> v; x = v; return is; }; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define all(a) (a).begin(), (a).end() #define contains(a, x) ((a).find(x) != (a).end()) #define rep(i, a, b) for (int i = (a); i < (int)(b); i++) #define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (a); i--) #define YN(b) cout << ((b) ? "YES" : "NO") << "\n"; #define Yn(b) cout << ((b) ? "Yes" : "No") << "\n"; #define yn(b) cout << ((b) ? "yes" : "no") << "\n"; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } using ll = long long; using vb = vector<bool>; using vvb = vector<vb>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> &p) { os << "(" << p.first << "," << p.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) { for (int i = 0; i < (int)vec.size(); i++) { os << vec[i] << (i + 1 == (int)vec.size() ? "" : " "); } return os; } template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (int i = 0; i < (int)vec.size(); i++) is >> vec[i]; return is; } ll floor(ll a, ll b) { return a >= 0 ? a / b : (a + 1) / b - 1; } ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; } int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; void solve() { int h, w, m; ll k; cin >> h >> w >> k >> m; if (h < w) swap(h, w); using mint = dynamic_modint<0>; mint::set_mod(m); vector<int> rev(1 << w, 0); rep(v, 0, 1 << w) rep(i, 0, w) rev[v] |= ((v >> i) & 1) << (w - 1 - i); int mask = (1 << w) - 1; int mask1 = 0; rep(i, 0, h) mask1 |= 1 << (w * i); int mask_all = (1 << (h * w)) - 1; auto gd = [&](int bit) { return (bit >> w) | ((bit << w) & mask_all) | ((bit & ~mask1) >> 1) | ((bit << 1) & ~(mask1 << w)); }; vector<bool> ok(1 << (h * w), false); auto dfs = [&](auto dfs, int f) { ok[f] = true; rep(i, 0, h) rep(j, 0, w) { if ((f >> (w * i + j)) & 1) continue; if (!((gd(f) >> (w * i + j)) & 1)) continue; int nf = f | (1 << (w * i + j)); if (ok[nf]) return; ok[nf] = true; dfs(dfs, nf); } }; rep(i, 0, h * w) dfs(dfs, 1 << i); vector<mint> cnt(h * w + 1, 0); rep(bit, 1, 1 << (h * w)) { if (!ok[bit]) continue; int pc = __builtin_popcount(bit); int nbit = gd(bit); int c = __builtin_popcount((~bit) & nbit); cnt[pc] += 1 << (h * w - pc - c); } mint ans = 0; rep(i, 0, h * w + 1) ans += mint(i).pow(k) * cnt[i]; mint p = 0; rep(i, 1, h * w + 1) p += mint(i).inv(); ans *= p; ans *= mint(2).inv().pow(h * w); cout << ans.val() << "\n"; } int main() { int t = 1; // cin >> t; while (t--) solve(); }