結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー 👑 p-adicp-adic
提出日時 2022-12-09 19:36:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,339 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 72,388 KB
最終ジャッジ日時 2024-04-22 19:15:30
合計ジャッジ時間 1,725 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/locale_classes.h:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/ios_base.h:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ios:44,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ostream:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/iostream:41,
                 from main.cpp:3:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h: In destructor 'std::_Vector_base<std::vector<int>, std::allocator<std::vector<int> > >::_Vector_impl::~_Vector_impl()':
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::vector<int>]': target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/vector:66,
                 from main.cpp:8:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~

ソースコード

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