結果
| 問題 |
No.2867 NOT FOUND 404 Again
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2024-08-30 23:17:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 3,000 ms |
| コード長 | 1,948 bytes |
| コンパイル時間 | 802 ms |
| コンパイル使用メモリ | 73,356 KB |
| 最終ジャッジ日時 | 2025-02-24 03:23:40 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#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;
}
Nachia