結果
| 問題 | No.3500 01 String |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-17 23:22:51 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 655 bytes |
| 記録 | |
| コンパイル時間 | 3,375 ms |
| コンパイル使用メモリ | 330,932 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-17 23:23:10 |
| 合計ジャッジ時間 | 4,799 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
string A;
cin >> A;
long long count = 0;
long long ans = 1;
bool flag = false;
char ibit;
for(int i = 0; i < N; i++){
ibit = A.at(i);
if(!flag){
if(ibit == '0'){
flag = true;
count++;
}
}
else{
if(A.at(i) == '0' && A.at(i-1) == '1'){
ans *= count+1;
ans = ans % 998244353;
count = 1;
}
else{
count++;
}
}
if(i == N-1){
if(ibit == '1'){
ans *= count+1;
ans = ans % 998244353;
}
}
}
cout << ans << endl;
return 0;
}