結果

問題 No.2055 12x34...
ユーザー CAT_CATCAT_CAT
提出日時 2022-08-21 13:56:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 882 bytes
コンパイル時間 4,761 ms
コンパイル使用メモリ 263,948 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-04-18 12:56:27
合計ジャッジ時間 9,334 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 26 ms
6,016 KB
testcase_03 AC 57 ms
8,960 KB
testcase_04 AC 79 ms
11,136 KB
testcase_05 AC 84 ms
11,860 KB
testcase_06 AC 74 ms
11,008 KB
testcase_07 AC 60 ms
9,328 KB
testcase_08 AC 43 ms
7,424 KB
testcase_09 AC 90 ms
12,672 KB
testcase_10 AC 98 ms
13,568 KB
testcase_11 AC 40 ms
7,296 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<atcoder/all>
#define double long double
using namespace std;
int size(int number){
    string numstr=to_string(number);
    return numstr.size();
}
constexpr int MOD=998244353;
signed main(void){
    int N;
    cin>>N;
    vector<int>A(N);
    for(int i=0;i<N;++i){
        cin>>A.at(i);
    }
    vector<map<int,int>>dp(N);
    dp.at(0)[A.at(0)]=1;
    for(int i=1;i<N;++i){
        dp.at(i)=dp.at(i-1);
        if(dp.at(i-1).find(A.at(i)-1)!=dp.at(i-1).end()){
            dp.at(i)[A.at(i)]+=dp.at(i-1)[A.at(i)-1]+1;
            dp.at(i)[A.at(i)]%=MOD;
        }else{
            dp.at(i)[A.at(i)]+=1;
            dp.at(i)[A.at(i)]%=MOD;
        }
        if(i>=2){
            dp.at(i-2).clear();
        }
    }
    int ans=0;
    for(auto e:dp.at(N-1)){
        ans+=e.second;
        ans%=MOD;
    }
    cout<<(ans-A.size())%MOD<<endl;

}

 
0