結果
問題 |
No.2772 Appearing Even Times
|
ユーザー |
![]() |
提出日時 | 2024-06-02 12:24:35 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,044 ms / 4,000 ms |
コード長 | 1,236 bytes |
コンパイル時間 | 3,537 ms |
コンパイル使用メモリ | 246,468 KB |
実行使用メモリ | 163,536 KB |
最終ジャッジ日時 | 2024-12-23 09:56:43 |
合計ジャッジ時間 | 14,935 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define replr(i,l,r) for (ll i=(ll)(l);i<(ll)(r);i++) #define all(v) v.begin(),v.end() #define len(v) ((ll)v.size()) template<class T> inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template<class T> inline bool chmax(T &a,T b){ if(a<b){ a=b; return true; } return false; } #include<atcoder/modint> using mint=atcoder::modint998244353; mint dp[10002][2][2][1<<10]; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; ll n=len(s); dp[0][0][0][0]=1; rep(i,n){ rep(j,2){ rep(k,2){ rep(l,1<<10){ rep(m,j==0?s[i]-'0'+1:10){ if(dp[i][j][k][l]==0) continue; dp[i+1][j|(m<s[i]-'0')][k|(m!=0)][(l^((1<<m)*(k|(m!=0))))]+=dp[i][j][k][l]; } } } } } cout << (dp[n][0][1][0]+dp[n][1][1][0]).val() << '\n'; }