結果
| 問題 |
No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-12-09 19:36:23 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 267 ms / 1,000 ms |
| コード長 | 2,339 bytes |
| コンパイル時間 | 3,379 ms |
| コンパイル使用メモリ | 106,292 KB |
| 最終ジャッジ日時 | 2025-02-09 06:54:21 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 |
ソースコード
#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;
}