結果
| 問題 | 
                            No.2055 12x34...
                             | 
                    
| コンテスト | |
| ユーザー | 
                             CAT_CAT
                         | 
                    
| 提出日時 | 2022-08-21 14:00:56 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 840 bytes | 
| コンパイル時間 | 4,299 ms | 
| コンパイル使用メモリ | 262,400 KB | 
| 最終ジャッジ日時 | 2025-01-31 02:28:35 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 11 TLE * 30 | 
ソースコード
#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){
        auto back=dp.at(i-1);
        dp.at(i)=move(dp.at(i-1));
        if(back.find(A.at(i)-1)!=back.end()){
            dp.at(i)[A.at(i)]+=back[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;
        }
    }
    int ans=0;
    for(auto e:dp.at(N-1)){
        ans+=e.second;
        ans%=MOD;
    }
    cout<<(ans-A.size())%MOD<<endl;
}
 
            
            
            
        
            
CAT_CAT