結果
問題 | No.2131 Concon Substrings (COuNt Version) |
ユーザー | 👑 p-adic |
提出日時 | 2022-10-25 09:29:51 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 1,460 bytes |
コンパイル時間 | 2,081 ms |
コンパイル使用メモリ | 202,492 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-03 10:21:42 |
合計ジャッジ時間 | 2,805 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type #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 FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ ) #define QUIT return 0 #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT #define CHECK_REDUNDANT_INPUT string VARIABLE_FOR_CHECK_REDUNDANT_INPUT = ""; cin >> VARIABLE_FOR_CHECK_REDUNDANT_INPUT; assert( VARIABLE_FOR_CHECK_REDUNDANT_INPUT == "" ); assert( ! cin ); int main() { constexpr const int bound_N = 3000; CIN_ASSERT( N , 3 , bound_N ); CHECK_REDUNDANT_INPUT; ll count[2][bound_N + 1] = {}; int i_prev = 0; int i_curr = 1; count[i_prev][1] = 1; N++; constexpr const ll P = 998244353; FOREQ( total_length_plus , 2 , N ){ ll ( &count_prev )[bound_N + 1] = count[i_prev]; ll ( &count_curr )[bound_N + 1] = count[i_curr]; FOREQ( length_plus , 1 , total_length_plus ){ count_curr[length_plus] = ( count_prev[length_plus] * 25 + count_prev[length_plus - 1] ) % P; } swap( i_prev , i_curr ); } ll ( &count_last )[bound_N + 1] = count[i_prev]; ll answer = 0; while( --N > 0 ){ answer += count_last[N+1] * ( N / 3 ); } RETURN( answer % P ); }