結果

問題 No.2541 Divide 01 String
ユーザー mkreemmkreem
提出日時 2024-01-20 04:13:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 2,087 bytes
コンパイル時間 2,926 ms
コンパイル使用メモリ 249,052 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-20 04:13:29
合計ジャッジ時間 4,396 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 5 ms
6,676 KB
testcase_05 AC 8 ms
6,676 KB
testcase_06 AC 5 ms
6,676 KB
testcase_07 AC 8 ms
6,676 KB
testcase_08 AC 8 ms
6,676 KB
testcase_09 AC 9 ms
6,676 KB
testcase_10 AC 6 ms
6,676 KB
testcase_11 AC 7 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 5 ms
6,676 KB
testcase_19 AC 5 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 4 ms
6,676 KB
testcase_22 AC 4 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef INCLUDED_main
#define INCLUDED_main

#include __FILE__

const ll mod = 998244353; using mint = atcoder::modint998244353;
//const ll mod = 1000000007; using mint = atcoder::modint1000000007;





int main(){

  int n; cin >> n;
  string s; cin >> s;

  vector<int> a;
  rep(i, 0, n){
    if(s[i] == '1'){
      a.emplace_back(i);
    }
  }

  int as = a.size();
  if(as == 0){
    cout << 0 << endl;
    return 0;
  }
  if(as == 1){
    cout << 1 << endl;
    return 0;
  }

  mint ans = 1;
  rep(i, 0, as-1){
    ans *= a[i+1]-a[i]+1;
  }

  cout << ans.val() << endl;

}

#else 

#include <bits/stdc++.h>
#include <atcoder/modint>

using ll = long long;
using ld = long double;
using Graph = std::vector<std::vector<int>>;
#define endl '\n'
#define INF 1000000039
#define LLINF 393939393939393939
#define fore(i, a) for(auto &i : a)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define erep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define part(x, a, b) x.begin()+a, x.begin()+b+1
#define rpart(x, a, b) x.rbegin()+a, x.rbegin()+b+1
#define pcnt(x) __builtin_popcount(x)
#define llpcnt(x) __builtin_popcountll(x)
template<typename T>
using pq = std::priority_queue<T>;
template<typename T>
using pqg = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
bool chmax(T &a, const T &b){
  if(a < b){ a = b; return 1; }
  else return 0;
}
template<typename T>
bool chmin(T &a, const T &b){
  if(a > b){ a = b; return 1; }
  else return 0;
}
// 多次元配列の生成
template<size_t Dimention, typename T>
class Mvector : public std::vector<Mvector<Dimention-1, T>>{
public:
  template<typename N, typename... Sizes>
  Mvector(T init, N n, Sizes... sizes) : std::vector<Mvector<Dimention-1, T> >(n, Mvector<Dimention-1, T>(init, sizes...))
  { }
};
template<typename T>
class Mvector<1, T> : public std::vector<T>{
public:
  template<typename N>
  Mvector(T init, N n) : std::vector<T>(n, init)
  { }
};


using namespace std;

#endif
0