結果
問題 |
No.2541 Divide 01 String
|
ユーザー |
|
提出日時 | 2023-11-24 22:06:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 674 bytes |
コンパイル時間 | 1,796 ms |
コンパイル使用メモリ | 171,776 KB |
実行使用メモリ | 10,784 KB |
最終ジャッジ日時 | 2024-09-26 09:23:08 |
合計ジャッジ時間 | 5,148 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; #define REP(i,n) for(ll i=0;i<ll(n);i++) const ll MOD=998244353; int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll i,j; ll N; string S; cin >> N >> S; vector<ll> v; REP(i,N) if(S[i]=='1') v.push_back(i); ll n=v.size(); if(n==0 || n==1){ cout << n << endl; return 0; } vector<ll> u; for(i=1;i<n;i++){ u.push_back(v[i]-v[i-1]); } ll m=u.size(); ll ans=1; for(i=1;i<(1LL<<m);i++){ ll c=1; for(j=0;j<m;j++){ if(i & (1LL<<j)){ c*=u[j]; c%=MOD; } } ans+=c; ans%=MOD; } cout << ans << endl; return 0; }