結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー 👑 p-adicp-adic
提出日時 2022-10-25 09:31:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,514 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 199,164 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 09:01:05
合計ジャッジ時間 3,019 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 11 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 11 ms
4,376 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  constexpr const int bound_length = bound_N + 2;
  ll count[2][bound_length] = {};
  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_length] = count[i_prev];
    ll ( &count_curr )[bound_length] = 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_length] = count[i_prev];
  ll answer = 0;
  while( --N > 0 ){
    answer += count_last[N+1] * ( N / 3 );
  }
  RETURN( answer % P );
}

0