結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー 👑 p-adicp-adic
提出日時 2024-04-22 21:26:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 307 ms / 1,000 ms
コード長 2,341 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 83,772 KB
実行使用メモリ 63,300 KB
最終ジャッジ日時 2024-04-22 21:27:11
合計ジャッジ時間 16,065 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 258 ms
62,940 KB
testcase_01 AC 260 ms
62,752 KB
testcase_02 AC 238 ms
61,536 KB
testcase_03 AC 269 ms
62,936 KB
testcase_04 AC 290 ms
63,144 KB
testcase_05 AC 273 ms
62,828 KB
testcase_06 AC 263 ms
62,504 KB
testcase_07 AC 275 ms
61,568 KB
testcase_08 AC 272 ms
61,528 KB
testcase_09 AC 256 ms
63,048 KB
testcase_10 AC 258 ms
61,664 KB
testcase_11 AC 291 ms
61,456 KB
testcase_12 AC 269 ms
62,736 KB
testcase_13 AC 263 ms
62,244 KB
testcase_14 AC 275 ms
62,028 KB
testcase_15 AC 268 ms
63,076 KB
testcase_16 AC 263 ms
63,148 KB
testcase_17 AC 275 ms
62,232 KB
testcase_18 AC 307 ms
62,016 KB
testcase_19 AC 274 ms
62,028 KB
testcase_20 AC 257 ms
63,300 KB
testcase_21 AC 262 ms
63,220 KB
testcase_22 AC 266 ms
61,928 KB
testcase_23 AC 263 ms
62,984 KB
testcase_24 AC 274 ms
62,036 KB
testcase_25 AC 296 ms
62,548 KB
testcase_26 AC 277 ms
62,964 KB
testcase_27 AC 264 ms
62,484 KB
testcase_28 AC 249 ms
62,988 KB
testcase_29 AC 264 ms
61,656 KB
testcase_30 AC 249 ms
62,324 KB
testcase_31 AC 251 ms
62,432 KB
testcase_32 AC 252 ms
62,468 KB
testcase_33 AC 259 ms
61,400 KB
testcase_34 AC 261 ms
61,400 KB
testcase_35 AC 289 ms
63,200 KB
testcase_36 AC 262 ms
62,196 KB
testcase_37 AC 268 ms
62,348 KB
testcase_38 AC 267 ms
61,532 KB
testcase_39 AC 272 ms
62,768 KB
testcase_40 AC 293 ms
62,072 KB
testcase_41 AC 276 ms
63,216 KB
testcase_42 AC 283 ms
61,528 KB
testcase_43 AC 273 ms
62,456 KB
testcase_44 AC 279 ms
61,868 KB
testcase_45 AC 306 ms
61,984 KB
testcase_46 AC 286 ms
63,176 KB
testcase_47 AC 243 ms
63,220 KB
testcase_48 AC 272 ms
62,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ( "O3" )
//#pragma GCC target ( "avx" )
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdint.h>
#include <cassert>
#include <vector>
using namespace std;

using ll = long long;

#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) 
#define CEXPR( LL , BOUND , VALUE ) constexpr const LL BOUND = VALUE 
#define CIN( LL , A ) LL A; cin >> A 
#define ASSERT( A , MIN , MAX ) assert( MIN <= A && A <= MAX ) 
#define CIN_ASSERT( A , MIN , MAX ) CIN( TYPE_OF( MAX ) , A ); ASSERT( A , MIN , MAX ) 
#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( TYPE_OF( FINAL_PLUS_ONE ) VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) 
#define FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) 
#define QUIT return 0 


int main()
{
  UNTIE;
  CEXPR( int , N , 19 );
  bool M[N][N] = {};
  int Aij_min;
  FOR( i , 0 , N ){
    CIN_ASSERT( Li , 0 , N );
    bool ( &Mi )[N] = M[i];
    Aij_min = 1;
    FOR( j , 0 , Li ){
      CIN_ASSERT( Aij , Aij_min , N );
      Mi[Aij - 1] = true;
      Aij_min = Aij + 1;
    }
  }
  vector<vector<int> > S[N+1]{};
  vector<int> S_int[N+1]{};
  CEXPR( int , PN , 1 << 19 );
  int s_copy , size;
  FOR( s , 0 , PN ){
    s_copy = s;
    vector<int> I{};
    FOR( i , 0 , N ){
      if( s_copy % 2 == 1 ){
	I.push_back( i );
      }
      s_copy /= 2;
      if( s_copy == 0 ){
	break;
      }
    }
    size = I.size();
    S[size].push_back( move( I ) );
    S_int[size].push_back( s );
  }
  static ll det[2][PN] = {};
  ll ( &det0 )[PN] = det[0];
  ll ( &det1 )[PN] = det[1];
  det0[0] = 1;
  det1[0] = 0;
  int i_r , I_j , s , s_sub;
  FOREQ( c , 1 , N ){
    vector<vector<int> >& Sc = S[c];
    vector<int>& Sc_int = S_int[c];
    size = Sc.size();
    FOR( k , 0 , size ){
      vector<int>& I = Sc[k];
      s = Sc_int[k];
      ll& det0s = ( det0[s] = 0 );
      ll& det1s = ( det1[s] = 0 );
      bool ( &Mi )[N] = M[N - c];
      FOR( j , 0 , c ){
	I_j = I[j];
	if( Mi[I_j] ){
	  s_sub = s - ( 1 << I_j );
	  i_r = j % 2;
	  det0s += det[i_r][s_sub];
	  det1s += det[1-i_r][s_sub];
	}
      }
    }
  }
  ll& det0_total = det0[PN-1];
  ll& det1_total = det1[PN-1];
  cout << det0_total << " " << det1_total << "\n";
  QUIT;
}
0