結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
19,840 KB
testcase_01 AC 347 ms
19,712 KB
testcase_02 AC 36 ms
19,968 KB
testcase_03 AC 802 ms
19,968 KB
testcase_04 AC 617 ms
19,840 KB
testcase_05 AC 612 ms
19,840 KB
testcase_06 AC 612 ms
19,712 KB
testcase_07 AC 567 ms
19,712 KB
testcase_08 AC 584 ms
19,712 KB
testcase_09 AC 507 ms
19,840 KB
testcase_10 AC 605 ms
19,712 KB
testcase_11 AC 659 ms
19,840 KB
testcase_12 AC 465 ms
19,840 KB
testcase_13 AC 470 ms
19,712 KB
testcase_14 AC 601 ms
19,840 KB
testcase_15 AC 638 ms
19,840 KB
testcase_16 AC 679 ms
19,840 KB
testcase_17 AC 766 ms
19,840 KB
testcase_18 AC 778 ms
19,840 KB
testcase_19 AC 619 ms
19,840 KB
testcase_20 AC 363 ms
19,840 KB
testcase_21 AC 522 ms
19,840 KB
testcase_22 AC 556 ms
19,840 KB
testcase_23 AC 489 ms
19,840 KB
testcase_24 AC 739 ms
19,968 KB
testcase_25 AC 523 ms
19,712 KB
testcase_26 AC 639 ms
19,712 KB
testcase_27 AC 545 ms
19,712 KB
testcase_28 AC 92 ms
19,968 KB
testcase_29 AC 151 ms
19,840 KB
testcase_30 AC 204 ms
19,968 KB
testcase_31 AC 262 ms
19,712 KB
testcase_32 AC 338 ms
19,840 KB
testcase_33 AC 381 ms
19,712 KB
testcase_34 AC 434 ms
19,840 KB
testcase_35 AC 494 ms
19,840 KB
testcase_36 AC 552 ms
19,840 KB
testcase_37 AC 624 ms
19,712 KB
testcase_38 AC 685 ms
19,840 KB
testcase_39 AC 737 ms
19,840 KB
testcase_40 AC 783 ms
19,840 KB
testcase_41 AC 838 ms
19,840 KB
testcase_42 AC 916 ms
19,840 KB
testcase_43 AC 965 ms
19,840 KB
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 AC 37 ms
19,840 KB
testcase_48 AC 700 ms
19,840 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;
    
    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;
}
0