結果

問題 No.2131 Concon Substrings (COuNt Version)
ユーザー lddlinanlddlinan
提出日時 2023-03-29 15:52:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 2,163 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 86,452 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 07:05:45
合計ジャッジ時間 2,690 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};


#define MOD 998244353
typedef struct { int c, m, n; } QNode;
QNode q1[3000*3];
int dp[3][1004];
int main() {
    int n, i, s, m, k, r, j;
    LL nn, nm, nc;
    int c;
    LL t;
    scanf("%d", &n);
    c=0; q1[c].c=0; q1[c].m=0; q1[c].n=1; c++;
    for (i=0; i<n; i++) {
        // clear dp
        memset(dp, 0, sizeof(dp));
        for (j=0; j<c; j++) {
            if (q1[j].m==0) {
                nc=q1[j].c;
                // not c...
                nn=25; nn*=q1[j].n; nn%=MOD;
                nm=0; dp[nm][nc]+=nn;
                dp[nm][nc]%=MOD;
                // c...
                nn = q1[j].n; nm=1;
                dp[nm][nc]+=nn;
                dp[nm][nc]%=MOD;
            } else if (q1[j].m==1) {
                nc=q1[j].c;
                // not o...
                nn=25; nn*=q1[j].n; nn%=MOD;
                nm=1; dp[nm][nc]+=nn;
                dp[nm][nc]%=MOD;
                // o..
                nn=q1[j].n; nm=2;
                dp[nm][nc]+=nn;
                dp[nm][nc]%=MOD;
            } else {
                nc=q1[j].c;
                // not n;
                nn=25; nn*=q1[j].n; nn%=MOD;
                nm=2; dp[nm][nc]+=nn;
                dp[nm][nc]%=MOD;
                // n
                nn=q1[j].n;
                nc++; nm=0;
                dp[nm][nc]+=nn;
                dp[nm][nc]%=MOD;
            }
        }
        c=0;
        for (nm=0; nm<3; nm++) for (nc=0; nc<=n/3; nc++) if (dp[nm][nc]) {
            q1[c].c=nc; q1[c].m=nm; q1[c].n=dp[nm][nc]; c++;
        }
    }
    s=0;
    for (nm=0; nm<3; nm++) for (nc=0; nc<=n/3; nc++) if (dp[nm][nc]) {
        t=dp[nm][nc]; t*=nc; t%=MOD; s+=t; s%=MOD;
    }

    printf("%d\n", s);
    return 0;
}
0