結果

問題 No.2867 NOT FOUND 404 Again
ユーザー NachiaNachia
提出日時 2024-08-30 23:17:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 3,000 ms
コード長 1,948 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 75,212 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-08-30 23:17:10
合計ジャッジ時間 2,076 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <sys/mman.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;

int main(){
    char *S = (char *)mmap(NULL, 1000010, PROT_READ, MAP_PRIVATE, 0, 0);
    i64 dp0 = 0, dp1 = 0, dp2 = 0;
    int ex = 0;
    bool beg = true;
    for(int i=0; S[i]!='\n'; i++){
        i64 d = S[i] - '0';
        if(beg){
            rep(e,d) if(e != 0){
                if(e == 4) dp1 += 1; else dp0 += 1;
            }
            beg = false;
        } else {
            i64 nx0 = ((dp0 + dp1 + dp2) * 9 - dp1) % 998244353;
            i64 nx1 = dp0 + dp1;
            i64 nx2 = dp1;
            if(4 < d){
                if(ex == 0){
                    nx0 += d-1;
                    nx1 += 1;
                } else if(ex == 1){
                    nx0 += d-2;
                    nx1 += 1;
                    nx2 += 1;
                } else if(ex == 2){
                    nx0 += d-1;
                }
            } else if(0 < d){
                if(ex == 0){
                    nx0 += d;
                } else if(ex == 1){
                    nx0 += d-1;
                    nx2 += 1;
                } else if(ex == 2){
                    nx0 += d;
                }
            }
            nx1 += 1;
            nx0 += 8;
            dp0 = nx0; dp1 = nx1; dp2 = nx2;
        }
        if(ex < 3){
            if(d == 4){
                if(ex == 2) ex = 3; else ex = 1;
            } else if(d == 0){
                if(ex == 1) ex = 2; else ex = 0;
            } else ex = 0;
        }
    }
    i64 ans = dp0 + dp1 + dp2;
    if(ex < 3) ans += 1;
    ans %= 998244353;
    cout << ans << '\n';
    return 0;
}
0