結果

問題 No.1964 sum = length
ユーザー nyyanyya
提出日時 2022-06-03 23:10:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,167 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 169,064 KB
実行使用メモリ 398,160 KB
最終ジャッジ日時 2023-10-21 02:20:52
合計ジャッジ時間 12,770 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,432 KB
testcase_01 AC 7 ms
9,480 KB
testcase_02 AC 40 ms
40,732 KB
testcase_03 AC 7 ms
9,480 KB
testcase_04 AC 9 ms
11,432 KB
testcase_05 AC 11 ms
13,388 KB
testcase_06 AC 13 ms
15,340 KB
testcase_07 AC 15 ms
17,292 KB
testcase_08 AC 17 ms
19,248 KB
testcase_09 AC 19 ms
21,200 KB
testcase_10 AC 21 ms
23,152 KB
testcase_11 AC 23 ms
25,104 KB
testcase_12 AC 112 ms
89,560 KB
testcase_13 AC 154 ms
126,668 KB
testcase_14 AC 216 ms
169,636 KB
testcase_15 AC 244 ms
191,120 KB
testcase_16 AC 38 ms
38,776 KB
testcase_17 AC 121 ms
101,276 KB
testcase_18 AC 135 ms
112,996 KB
testcase_19 AC 90 ms
75,888 KB
testcase_20 AC 100 ms
81,748 KB
testcase_21 AC 36 ms
36,824 KB
testcase_22 AC 469 ms
364,944 KB
testcase_23 AC 456 ms
357,136 KB
testcase_24 AC 331 ms
263,388 KB
testcase_25 AC 353 ms
286,824 KB
testcase_26 WA -
testcase_27 AC 393 ms
316,120 KB
testcase_28 AC 346 ms
279,012 KB
testcase_29 AC 431 ms
339,560 KB
testcase_30 AC 360 ms
288,776 KB
testcase_31 WA -
testcase_32 AC 262 ms
210,652 KB
testcase_33 AC 255 ms
204,792 KB
testcase_34 AC 448 ms
355,184 KB
testcase_35 AC 291 ms
236,044 KB
testcase_36 AC 374 ms
300,496 KB
testcase_37 AC 418 ms
335,652 KB
testcase_38 WA -
testcase_39 AC 352 ms
282,920 KB
testcase_40 AC 359 ms
290,732 KB
testcase_41 AC 463 ms
368,856 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
bool chmin(ll& a,ll b){if(a>b){a=b; return 1;} return 0;}
bool chmax(ll& a,ll b){if(a<b){a=b; return 1;} return 0;}

int main(){
    int n;
    cin >> n;

    ll dp[n+2][500][500];

    rep(i,500){
        rep(j,500){
            rep(k,n+2){
                dp[k][i][j]=0;
            }
        }
    }

    dp[1][1][1]=1;
    dp[1][10][1]=-1;
    dp[1][10][2]=1;
    dp[1][100][2]=-1;
    dp[1][100][3]=1;

    //for(int i=1;i<500;i++){
    //    if(i<10) dp[1][i][1]=1;
    //    else if(i<100) dp[1][i][2]=1;
    //    else dp[1][i][3]=1;
    //}

    for(int k=1;k<=n;k++){
        for(int i=1;i<500;i++){
            for(int j=1;j<500;j++){
                dp[k][i][j]+=dp[k][i-1][j];

                if(i+1>=500 || j+2>=500) break;
                dp[k+1][i+1][j+2]+=dp[k][i][j];
                dp[k+1][i+1][j+2]%=998244353;

                if(i+10>=500 || j+2>=500) break;
                dp[k+1][i+10][j+2]+=998244353-dp[k][i][j];
                dp[k+1][i+10][j+2]%=998244353;

                if(i+10>=500 || j+3>=500) break;
                dp[k+1][i+10][j+3]+=dp[k][i][j];
                dp[k+1][i+10][j+3]%=998244353;

                if(i+100>=500 || j+3>=500) break;
                dp[k+1][i+100][j+3]+=998244353-dp[k][i][j];
                dp[k+1][i+100][j+3]%=998244353;

                if(i+100>=500 || j+4>=500) break;
                dp[k+1][i+100][j+4]+=dp[k][i][j];
                dp[k+1][i+100][j+4]%=998244353;


                //for(int add_a=1;add_a<500;add_a++){
                //    int add_l;
                //    if(add_a<10) add_l=2;
                //    else if(add_a<100) add_l=3;
                //    else add_l=4;
                //
                //    if(i+add_a>=500 || j+add_l>=500) break;
                //    dp[k+1][i+add_a][j+add_l]+=dp[k][i][j];
                //    dp[k+1][i+add_a][j+add_l]%=998244353;
                //}
            }
        }
    }

    ll ans=0;
    for(int i=1;i<500;i++){
        ans += dp[n][i][i];
        ans %=998244353;
    }

    cout << ans << endl;
    return 0;
}
0