結果
問題 | No.2772 Appearing Even Times |
ユーザー |
![]() |
提出日時 | 2024-05-31 23:15:39 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,323 ms / 4,000 ms |
コード長 | 1,398 bytes |
コンパイル時間 | 3,484 ms |
コンパイル使用メモリ | 247,720 KB |
実行使用メモリ | 163,724 KB |
最終ジャッジ日時 | 2024-12-21 01:34:00 |
合計ジャッジ時間 | 20,852 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll=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 all(v) v.begin(),v.end()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[10010][2][2][1<<10];int main(){ios::sync_with_stdio(false);cin.tie(nullptr);string s;cin >> s;ll n=(ll)s.size();dp[0][0][0][0]=1;rep(i,n){rep(j,1<<10){rep(k,10){rep(l,2){ll x=l|(k!=0),y=j;if(x==1) y^=1<<k;if(k<s[i]-'0'){dp[i+1][1][x][y]+=dp[i][0][l][j];dp[i+1][1][x][y]+=dp[i][1][l][j];}else if(k==s[i]-'0'){dp[i+1][0][x][y]+=dp[i][0][l][j];dp[i+1][1][x][y]+=dp[i][1][l][j];}else{dp[i+1][1][x][y]+=dp[i][1][l][j];}}}}}cout << (dp[n][0][1][0]+dp[n][1][1][0]).val() << '\n';}