結果
| 問題 | No.3500 01 String |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2026-04-20 10:36:31 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 648 bytes |
| 記録 | |
| コンパイル時間 | 446 ms |
| コンパイル使用メモリ | 52,688 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-20 10:36:37 |
| 合計ジャッジ時間 | 1,567 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 3500.cc: No.3500 01 String - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 500000;
const int MOD = 998244353;
/* typedef */
using ll = long long;
/* global variables */
char s[MAX_N + 8];
int cs[MAX_N + 1];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d%s", &n, s + 1);
s[0] = '1', s[n + 1] = '0';
int k = 0;
for (int i = 0; i <= n; i++)
if (s[i] == '1' && s[i + 1] == '0') cs[k++] = i;
ll p = 1;
for (int i = 0; i + 1 < k; i++)
p = p * (cs[i + 1] - cs[i] + 1) % MOD;
printf("%lld\n", p);
return 0;
}
tnakao0123