結果
| 問題 | No.2152 [Cherry Anniversary 2] 19 Petals of Cherry |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-09 01:15:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 904 bytes |
| 記録 | |
| コンパイル時間 | 2,114 ms |
| コンパイル使用メモリ | 193,024 KB |
| 最終ジャッジ日時 | 2025-02-09 06:42:49 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 45 TLE * 4 |
ソースコード
#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;
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;
int inv = 0;
for (int i=A+1; i<N; i++) if ((S>>i)&1) inv++;
ndp[S|(1<<A)][inv%2] += dp[S][0];
ndp[S|(1<<A)][(inv%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;
}