結果
問題 |
No.2772 Appearing Even Times
|
ユーザー |
|
提出日時 | 2024-05-31 23:42:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,292 bytes |
コンパイル時間 | 2,350 ms |
コンパイル使用メモリ | 194,284 KB |
最終ジャッジ日時 | 2025-02-21 18:40:14 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 RE * 2 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; constexpr int MOD=998244353; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define replr(i,l,r) for(int i=(l);i<(int)(r);i++) ll memo[10000][1<<10][2][2]; string N; int len; void ch(ll &a,ll b){ a=(a+b)%MOD; } ll rec(int p,int s,int t,int led_0){ if(memo[p][s][t][led_0]!=-1)return memo[p][s][t][led_0]; if(p==len){ if(s==0&&led_0==0)return memo[p][s][t][led_0]=1; return memo[p][s][t][led_0]=0; } ll ret=0; if(t){ if(led_0){ replr(i,1,N[p]){ ch(ret,rec(p+1,s^(1<<i),0,0)); } ch(ret,rec(p+1,s,0,1)); ch(ret,rec(p+1,s^(1<<N[p]),1,0)); }else{ rep(i,N[p]){ ch(ret,rec(p+1,s^(1<<i),0,0)); } ch(ret,rec(p+1,s^(1<<N[p]),1,0)); } }else{ if(led_0){ rep(i,9){ ch(ret,rec(p+1,s^(1<<(i+1)),0,0)); } ch(ret,rec(p+1,s,0,1)); }else{ rep(i,10){ ch(ret,rec(p+1,s^(1<<i),0,0)); } } } return memo[p][s][t][led_0]=ret; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N; len=N.size(); rep(i,10000){ rep(j,1<<10){ rep(k,2){ rep(l,2){ memo[i][j][k][l]=-1; } } } } for(auto &i:N)i-='0'; cout<<rec(0,0,1,1)<<'\n'; }