結果
| 問題 | No.2152 [Cherry Anniversary 2] 19 Petals of Cherry |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-09 01:15:16 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 669 ms / 1,000 ms |
| コード長 | 904 bytes |
| 記録 | |
| コンパイル時間 | 1,273 ms |
| コンパイル使用メモリ | 210,296 KB |
| 実行使用メモリ | 19,968 KB |
| 最終ジャッジ日時 | 2026-06-28 19:15:18 |
| 合計ジャッジ時間 | 20,472 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 |
ソースコード
#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;
}