結果
問題 | No.2445 奇行列式 |
ユーザー | 👑 p-adic |
提出日時 | 2023-07-01 02:46:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 376 ms / 3,000 ms |
コード長 | 2,183 bytes |
コンパイル時間 | 2,912 ms |
コンパイル使用メモリ | 217,184 KB |
実行使用メモリ | 19,952 KB |
最終ジャッジ日時 | 2024-07-07 13:58:28 |
合計ジャッジ時間 | 6,437 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
19,680 KB |
testcase_01 | AC | 6 ms
19,788 KB |
testcase_02 | AC | 5 ms
19,888 KB |
testcase_03 | AC | 5 ms
19,816 KB |
testcase_04 | AC | 5 ms
19,696 KB |
testcase_05 | AC | 5 ms
19,872 KB |
testcase_06 | AC | 5 ms
19,756 KB |
testcase_07 | AC | 6 ms
19,836 KB |
testcase_08 | AC | 6 ms
19,896 KB |
testcase_09 | AC | 6 ms
19,740 KB |
testcase_10 | AC | 5 ms
19,860 KB |
testcase_11 | AC | 14 ms
19,832 KB |
testcase_12 | AC | 40 ms
19,940 KB |
testcase_13 | AC | 181 ms
19,872 KB |
testcase_14 | AC | 376 ms
19,920 KB |
testcase_15 | AC | 367 ms
19,864 KB |
testcase_16 | AC | 361 ms
19,816 KB |
testcase_17 | AC | 358 ms
19,952 KB |
testcase_18 | AC | 368 ms
19,788 KB |
testcase_19 | AC | 350 ms
19,840 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; // map<uint,int> digit{}; // FOR( d , 0 , N ){ // digit[1 << d] = 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; 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; while( d_copy != 0 ){ uint j = d_copy & -d_copy; d_copy ^= j; int digit = 0; while( j >> digit != 1 ){ digit++; } ll& Aij = Ai[digit]; uint d_sub = d ^ 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] ); }