結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー roarisroaris
提出日時 2022-12-09 01:18:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 989 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 194,988 KB
実行使用メモリ 63,872 KB
最終ジャッジ日時 2024-04-22 18:53:45
合計ジャッジ時間 44,021 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 296 ms
58,752 KB
testcase_01 AC 572 ms
58,624 KB
testcase_02 AC 201 ms
58,880 KB
testcase_03 TLE -
testcase_04 AC 895 ms
58,624 KB
testcase_05 AC 882 ms
58,624 KB
testcase_06 AC 890 ms
58,880 KB
testcase_07 AC 828 ms
58,624 KB
testcase_08 AC 858 ms
58,752 KB
testcase_09 AC 770 ms
58,624 KB
testcase_10 AC 872 ms
58,752 KB
testcase_11 AC 857 ms
58,880 KB
testcase_12 AC 709 ms
58,752 KB
testcase_13 AC 725 ms
58,752 KB
testcase_14 AC 864 ms
58,752 KB
testcase_15 AC 904 ms
58,752 KB
testcase_16 AC 767 ms
58,880 KB
testcase_17 AC 861 ms
58,880 KB
testcase_18 AC 930 ms
58,880 KB
testcase_19 AC 916 ms
58,752 KB
testcase_20 AC 602 ms
58,624 KB
testcase_21 AC 811 ms
58,752 KB
testcase_22 AC 827 ms
58,752 KB
testcase_23 AC 761 ms
58,752 KB
testcase_24 TLE -
testcase_25 AC 795 ms
58,880 KB
testcase_26 AC 943 ms
58,752 KB
testcase_27 AC 810 ms
58,624 KB
testcase_28 AC 276 ms
58,752 KB
testcase_29 AC 343 ms
58,752 KB
testcase_30 AC 408 ms
58,752 KB
testcase_31 AC 474 ms
58,752 KB
testcase_32 AC 548 ms
58,880 KB
testcase_33 AC 612 ms
58,752 KB
testcase_34 AC 683 ms
58,624 KB
testcase_35 AC 753 ms
58,752 KB
testcase_36 AC 826 ms
58,624 KB
testcase_37 AC 887 ms
58,752 KB
testcase_38 AC 968 ms
58,752 KB
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 AC 200 ms
58,624 KB
testcase_48 AC 987 ms
58,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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) rep(i, N) {
        for (int j=i+1; j<N; j++) if ((S>>j)&1) inv[S][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;
}
0