結果
| 問題 |
No.2541 Divide 01 String
|
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2023-11-24 22:06:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 857 bytes |
| コンパイル時間 | 2,168 ms |
| コンパイル使用メモリ | 195,100 KB |
| 最終ジャッジ日時 | 2025-02-18 00:09:37 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
string s;
cin >> n >> s;
vector<ll> dp(n+2,0);
dp[1] = 1;
int now = 0, r = n-1;
while(r>=0 && s[r]=='0') r--;
for(int i=0;i<=r;i++){
if(s[i]=='1') now = i+1;
dp[i+2] = (dp[i+1] + dp[now]) % MOD;
}
cout << dp[r+1] << '\n';
return 0;
}
houren