結果

問題 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  
実行時間 197 ms / 1,000 ms
コード長 866 bytes
コンパイル時間 2,553 ms
コンパイル使用メモリ 197,096 KB
実行使用メモリ 118,016 KB
最終ジャッジ日時 2024-04-22 18:51:28
合計ジャッジ時間 12,372 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
93,952 KB
testcase_01 AC 187 ms
113,536 KB
testcase_02 AC 85 ms
44,416 KB
testcase_03 AC 184 ms
117,248 KB
testcase_04 AC 169 ms
111,232 KB
testcase_05 AC 181 ms
117,504 KB
testcase_06 AC 171 ms
114,176 KB
testcase_07 AC 181 ms
116,608 KB
testcase_08 AC 179 ms
114,816 KB
testcase_09 AC 172 ms
113,664 KB
testcase_10 AC 173 ms
117,504 KB
testcase_11 AC 176 ms
116,736 KB
testcase_12 AC 179 ms
115,840 KB
testcase_13 AC 171 ms
112,384 KB
testcase_14 AC 181 ms
114,304 KB
testcase_15 AC 178 ms
116,352 KB
testcase_16 AC 169 ms
115,456 KB
testcase_17 AC 177 ms
116,864 KB
testcase_18 AC 180 ms
112,768 KB
testcase_19 AC 181 ms
116,736 KB
testcase_20 AC 166 ms
111,744 KB
testcase_21 AC 170 ms
116,992 KB
testcase_22 AC 180 ms
115,072 KB
testcase_23 AC 174 ms
113,536 KB
testcase_24 AC 183 ms
117,888 KB
testcase_25 AC 174 ms
117,248 KB
testcase_26 AC 180 ms
116,608 KB
testcase_27 AC 166 ms
113,664 KB
testcase_28 AC 136 ms
90,496 KB
testcase_29 AC 154 ms
102,656 KB
testcase_30 AC 160 ms
108,928 KB
testcase_31 AC 160 ms
112,256 KB
testcase_32 AC 164 ms
114,176 KB
testcase_33 AC 169 ms
115,584 KB
testcase_34 AC 169 ms
116,608 KB
testcase_35 AC 171 ms
117,120 KB
testcase_36 AC 173 ms
117,504 KB
testcase_37 AC 172 ms
117,504 KB
testcase_38 AC 176 ms
117,632 KB
testcase_39 AC 177 ms
117,760 KB
testcase_40 AC 180 ms
117,888 KB
testcase_41 AC 182 ms
118,016 KB
testcase_42 AC 185 ms
117,760 KB
testcase_43 AC 190 ms
117,760 KB
testcase_44 AC 195 ms
117,760 KB
testcase_45 AC 197 ms
118,016 KB
testcase_46 AC 194 ms
117,760 KB
testcase_47 AC 84 ms
44,288 KB
testcase_48 AC 177 ms
117,248 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