結果
問題 | No.2445 奇行列式 |
ユーザー | 👑 p-adic |
提出日時 | 2023-07-01 02:45:40 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 349 ms / 3,000 ms |
コード長 | 2,017 bytes |
コンパイル時間 | 2,976 ms |
コンパイル使用メモリ | 217,948 KB |
実行使用メモリ | 19,840 KB |
最終ジャッジ日時 | 2024-07-07 13:56:52 |
合計ジャッジ時間 | 6,592 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
19,832 KB |
testcase_01 | AC | 6 ms
19,712 KB |
testcase_02 | AC | 6 ms
19,712 KB |
testcase_03 | AC | 7 ms
19,712 KB |
testcase_04 | AC | 8 ms
19,712 KB |
testcase_05 | AC | 7 ms
19,712 KB |
testcase_06 | AC | 7 ms
19,840 KB |
testcase_07 | AC | 7 ms
19,712 KB |
testcase_08 | AC | 7 ms
19,840 KB |
testcase_09 | AC | 7 ms
19,708 KB |
testcase_10 | AC | 7 ms
19,584 KB |
testcase_11 | AC | 14 ms
19,840 KB |
testcase_12 | AC | 40 ms
19,760 KB |
testcase_13 | AC | 174 ms
19,712 KB |
testcase_14 | AC | 349 ms
19,688 KB |
testcase_15 | AC | 349 ms
19,712 KB |
testcase_16 | AC | 349 ms
19,840 KB |
testcase_17 | AC | 349 ms
19,712 KB |
testcase_18 | AC | 348 ms
19,840 KB |
testcase_19 | AC | 343 ms
19,712 KB |
ソースコード
#pragma GCC optimize ( "O3" ) #pragma GCC optimize( "unroll-loops" ) #pragma GCC target ( "sse4.2,fma,avx2,popcnt,lzcnt,bmi2" ) #include <bits/stdc++.h> using namespace std; using ll = long long; #define TYPE_OF( VAR ) decay_t<decltype( VAR )> #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 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; } } CEXPR( uint , bound_power_N , 1 << bound_N ); uint power_N = 1 << N; 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; FOR( d , 1 , power_N ){ ll& ed = e[d] = 0; ll& od = o[d] = 0; int n = 0; uint d_copy = d; while( d_copy != 0 ){ d_copy ^= d_copy & -d_copy; n++; } d_copy = d; ll ( &Ai )[bound_N] = A[N - n]; bool even = true; FOR( j , 0 , N ){ uint digit = 1 << j; if( ( d & digit ) != 0 ){ uint d_sub = d ^ digit; ll& Aij = Ai[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] ); }