結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー roarisroaris
提出日時 2022-12-09 01:23:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,095 bytes
コンパイル時間 2,254 ms
コンパイル使用メモリ 197,332 KB
実行使用メモリ 58,904 KB
最終ジャッジ日時 2024-04-22 18:55:03
合計ジャッジ時間 39,512 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
58,656 KB
testcase_01 AC 467 ms
58,752 KB
testcase_02 AC 84 ms
58,772 KB
testcase_03 TLE -
testcase_04 AC 791 ms
58,624 KB
testcase_05 AC 786 ms
58,788 KB
testcase_06 AC 802 ms
58,676 KB
testcase_07 AC 761 ms
58,624 KB
testcase_08 AC 779 ms
58,636 KB
testcase_09 AC 638 ms
58,776 KB
testcase_10 AC 779 ms
58,752 KB
testcase_11 AC 772 ms
58,724 KB
testcase_12 AC 591 ms
58,720 KB
testcase_13 AC 622 ms
58,624 KB
testcase_14 AC 770 ms
58,624 KB
testcase_15 AC 831 ms
58,624 KB
testcase_16 AC 664 ms
58,704 KB
testcase_17 AC 754 ms
58,712 KB
testcase_18 AC 828 ms
58,880 KB
testcase_19 AC 803 ms
58,752 KB
testcase_20 AC 497 ms
58,664 KB
testcase_21 AC 705 ms
58,736 KB
testcase_22 AC 731 ms
58,880 KB
testcase_23 AC 637 ms
58,720 KB
testcase_24 AC 963 ms
58,624 KB
testcase_25 AC 695 ms
58,656 KB
testcase_26 AC 846 ms
58,880 KB
testcase_27 AC 709 ms
58,752 KB
testcase_28 AC 162 ms
58,624 KB
testcase_29 AC 229 ms
58,656 KB
testcase_30 AC 286 ms
58,752 KB
testcase_31 AC 361 ms
58,624 KB
testcase_32 AC 436 ms
58,624 KB
testcase_33 AC 497 ms
58,752 KB
testcase_34 AC 583 ms
58,752 KB
testcase_35 AC 643 ms
58,600 KB
testcase_36 AC 712 ms
58,880 KB
testcase_37 AC 774 ms
58,624 KB
testcase_38 AC 851 ms
58,880 KB
testcase_39 AC 927 ms
58,764 KB
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 AC 87 ms
58,632 KB
testcase_48 AC 897 ms
58,744 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) {
        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;
}
0