結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー umezoumezo
提出日時 2022-12-09 00:56:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 1,000 ms
コード長 866 bytes
コンパイル時間 2,499 ms
コンパイル使用メモリ 201,176 KB
実行使用メモリ 118,016 KB
最終ジャッジ日時 2023-08-04 20:39:20
合計ジャッジ時間 10,438 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
93,828 KB
testcase_01 AC 140 ms
113,472 KB
testcase_02 AC 57 ms
44,300 KB
testcase_03 AC 136 ms
117,168 KB
testcase_04 AC 124 ms
113,364 KB
testcase_05 AC 133 ms
117,348 KB
testcase_06 AC 129 ms
114,148 KB
testcase_07 AC 133 ms
116,320 KB
testcase_08 AC 152 ms
114,732 KB
testcase_09 AC 131 ms
113,460 KB
testcase_10 AC 132 ms
117,388 KB
testcase_11 AC 130 ms
116,692 KB
testcase_12 AC 132 ms
115,704 KB
testcase_13 AC 127 ms
112,076 KB
testcase_14 AC 139 ms
114,416 KB
testcase_15 AC 136 ms
116,340 KB
testcase_16 AC 129 ms
115,336 KB
testcase_17 AC 134 ms
116,868 KB
testcase_18 AC 137 ms
112,604 KB
testcase_19 AC 136 ms
116,480 KB
testcase_20 AC 123 ms
111,620 KB
testcase_21 AC 128 ms
116,716 KB
testcase_22 AC 135 ms
114,876 KB
testcase_23 AC 128 ms
113,572 KB
testcase_24 AC 137 ms
117,564 KB
testcase_25 AC 133 ms
117,260 KB
testcase_26 AC 141 ms
116,668 KB
testcase_27 AC 125 ms
113,728 KB
testcase_28 AC 104 ms
90,564 KB
testcase_29 AC 113 ms
102,832 KB
testcase_30 AC 118 ms
108,760 KB
testcase_31 AC 127 ms
112,140 KB
testcase_32 AC 123 ms
114,376 KB
testcase_33 AC 127 ms
115,904 KB
testcase_34 AC 127 ms
116,484 KB
testcase_35 AC 127 ms
117,004 KB
testcase_36 AC 129 ms
117,456 KB
testcase_37 AC 130 ms
117,768 KB
testcase_38 AC 130 ms
117,684 KB
testcase_39 AC 131 ms
117,852 KB
testcase_40 AC 136 ms
117,744 KB
testcase_41 AC 137 ms
117,772 KB
testcase_42 AC 140 ms
117,940 KB
testcase_43 AC 144 ms
118,016 KB
testcase_44 AC 148 ms
117,832 KB
testcase_45 AC 152 ms
117,952 KB
testcase_46 AC 153 ms
117,800 KB
testcase_47 AC 56 ms
44,524 KB
testcase_48 AC 132 ms
117,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

ll dp[20][530000][2];
int B[1<<19][20];
int x=(1<<19)-1;
vector<int> A[20];
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  for(int i=0;i<(1<<19);i++){
    int cnt=0;
    for(int j=18;j>=0;j--){
      if(i&(1<<j)) cnt++;
      B[i][j]=cnt;
    }
  }
  
  rep(i,19){
    int l;
    cin>>l;
    rep(_,l){
      int a;
      cin>>a;
      a--;
      A[i+1].push_back(a);
    }
  }
  
  dp[0][0][0]=1;
  for(int i=1;i<=19;i++){
    rep(j,1<<19){
      if(__builtin_popcount(j)!=i-1) continue;
      for(auto a:A[i]){
        if(j&(1<<a)) continue;
        rep(k,2) dp[i][j|(1<<a)][(k+B[j][a+1])%2]+=dp[i-1][j][k];
      }
    }
  }
  cout<<dp[19][x][0]<<" "<<dp[19][x][1]<<endl;
  
  return 0;
}
0