結果
| 問題 | 
                            No.2131 Concon Substrings (COuNt Version)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-03-29 15:52:55 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 29 ms / 2,000 ms | 
| コード長 | 2,163 bytes | 
| コンパイル時間 | 851 ms | 
| コンパイル使用メモリ | 86,808 KB | 
| 最終ジャッジ日時 | 2025-02-11 18:59:58 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
            
            ソースコード
#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;
}