結果
問題 |
No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
|
ユーザー |
|
提出日時 | 2022-12-09 01:23:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,095 bytes |
コンパイル時間 | 2,098 ms |
コンパイル使用メモリ | 194,808 KB |
最終ジャッジ日時 | 2025-02-09 06:45:26 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 TLE * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i=0; i<n; i++) #define pb push_back typedef long long ll; int main() { cin.tie(0); ios::sync_with_stdio(false); int N = 19; ll dp[1<<N][2]; rep(S, 1<<N) rep(i, 2) dp[S][i] = 0ll; dp[0][0] = 1ll; int inv[1<<N][N]; rep(S, 1<<N) rep(i, N) inv[S][i] = 0; rep(S, 1<<N) { int cnt[N]; fill(cnt, cnt+N, 0); rep(i, N) if ((S>>i)&1) cnt[i] = 1; for (int i=1; i<N; i++) cnt[i] += cnt[i-1]; rep(i, N) inv[S][i] = N-cnt[i]; } rep(t, N) { ll ndp[1<<N][2]; rep(S, 1<<N) rep(i, 2) ndp[S][i] = 0ll; int L; cin >> L; while (L--) { int A; cin >> A; A--; rep(S, 1<<N) { if ((S>>A)&1) continue; ndp[S|(1<<A)][inv[S][A]%2] += dp[S][0]; ndp[S|(1<<A)][(inv[S][A]%2+1)%2] += dp[S][1]; } } rep(S, 1<<N) rep(i, 2) dp[S][i] = ndp[S][i]; } cout << dp[(1<<N)-1][0] << " " << dp[(1<<N)-1][1] << endl; }