結果
問題 | No.2445 奇行列式 |
ユーザー | 👑 p-adic |
提出日時 | 2023-03-25 22:00:03 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 772 ms / 3,000 ms |
コード長 | 2,705 bytes |
コンパイル時間 | 1,110 ms |
コンパイル使用メモリ | 80,888 KB |
実行使用メモリ | 122,072 KB |
最終ジャッジ日時 | 2024-11-15 03:39:17 |
合計ジャッジ時間 | 7,724 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
44,416 KB |
testcase_01 | AC | 17 ms
44,288 KB |
testcase_02 | AC | 17 ms
44,416 KB |
testcase_03 | AC | 17 ms
44,416 KB |
testcase_04 | AC | 17 ms
44,288 KB |
testcase_05 | AC | 17 ms
44,416 KB |
testcase_06 | AC | 17 ms
44,288 KB |
testcase_07 | AC | 17 ms
44,416 KB |
testcase_08 | AC | 18 ms
44,416 KB |
testcase_09 | AC | 17 ms
44,416 KB |
testcase_10 | AC | 16 ms
44,416 KB |
testcase_11 | AC | 35 ms
46,336 KB |
testcase_12 | AC | 97 ms
52,936 KB |
testcase_13 | AC | 362 ms
81,904 KB |
testcase_14 | AC | 763 ms
122,072 KB |
testcase_15 | AC | 765 ms
121,980 KB |
testcase_16 | AC | 772 ms
121,960 KB |
testcase_17 | AC | 764 ms
122,068 KB |
testcase_18 | AC | 757 ms
122,068 KB |
testcase_19 | AC | 762 ms
121,832 KB |
ソースコード
#pragma GCC optimize ( "O3" ) #pragma GCC optimize( "unroll-loops" ) #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) #include <iostream> #include <stdio.h> #include <stdint.h> #include <cassert> #include <vector> using namespace std; using ll = long long; #define MAIN main #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 GETLINE( S ) string S; getline( cin , S ) #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 FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) #define QUIT return 0 #define COUT( ANSWER ) cout << ( ANSWER ) << "\n" #define RETURN( ANSWER ) COUT( ANSWER ); QUIT int MAIN() { UNTIE; CEXPR( int , bound_N , 20 ); CIN_ASSERT( N , 1 , bound_N ); CEXPR( ll , bound_B , 1000000000 ); CIN_ASSERT( B , 1 , bound_B ); CEXPR( ll , bound_Aij , 1000000000000000000 ); ll A[bound_N][bound_N]; FOR( i , 0 , N ){ ll ( &Ai )[bound_N] = A[i]; FOR( j , 0 , N ){ CIN_ASSERT( Aij , 0 , bound_Aij ); Ai[j] = Aij %= B; } } vector<int> D[bound_N+1] = {}; CEXPR( int , bound_power_N , 1 << bound_N ); vector<int> S[bound_power_N] = {}; int power_N = 1 << N; FOR( d , 0 , power_N ){ int d_copy = d; vector<int>& Sd = S[d]; FOR( j , 0 , N ){ if( d_copy % 2 == 1 ){ Sd.push_back( j ); } d_copy /= 2; if( d_copy == 0 ){ break; } } D[Sd.size()].push_back( d ); } ll det[2][bound_power_N] = {}; ll ( &e )[bound_power_N] = det[0]; ll ( &o )[bound_power_N] = det[1]; e[0] = 1; o[0] = 0; FOREQ( n , 1 , N ){ vector<int>& Dn = D[n]; FOR_ITR( Dn , itr_Dn , end_Dn ){ int& d = *itr_Dn; vector<int>& Sd = S[d]; ll& ed = e[d] = 0; ll& od = o[d] = 0; ll ( &Ai )[bound_N] = A[N - n]; bool even = true; FOR_ITR( Sd , itr_Sd , end_Sd ){ int& j = *itr_Sd; ll& Aij = Ai[j]; int d_sub = d - ( 1 << j ); if( even ){ ( ed += Aij * e[d_sub] ) %= B; ( od += Aij * o[d_sub] ) %= B; } else { ( ed += Aij * o[d_sub] ) %= B; ( od += Aij * e[d_sub] ) %= B; } even = ! even; } } } RETURN( o[power_N - 1] ); }