提出 #55014589
ソースコード 拡げる
// I hate it here so I will go to secret gardens in my mind
// People need a key to get to, the only one is mine
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;
void upd(int& a, int b) { a = (a + b) % mod; }
int add(int a, int b) { return (a + b) % mod; }
int mul(int a, int b) { return (a * 1ll * b) % mod; }
int pwr(int a, int b = mod - 2)
{
if (!b) return 1;
int h = pwr(a, b >> 1);
h = mul(h, h);
if (b & 1) h = mul(h, a);
return h;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
string s;
cin >> s;
int ans = 1;
int d = 0;
for (int i = 0; i < n; i++)
{
if (i && s[i] == s[i - 1])
{
ans = mul(ans, (d + 1) / 2);
d = 0;
}
d++;
}
ans = mul(ans, (d + 1) / 2);
cout << ans << "\n";
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | A - ABA and BAB |
| ユーザ | prvocislo |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 400 |
| コード長 | 1206 Byte |
| 結果 | AC |
| 実行時間 | 3 ms |
| メモリ | 3728 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt |
| All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 00-sample-004.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00-sample-001.txt | AC | 1 ms | 3388 KiB |
| 00-sample-002.txt | AC | 1 ms | 3408 KiB |
| 00-sample-003.txt | AC | 1 ms | 3476 KiB |
| 00-sample-004.txt | AC | 1 ms | 3316 KiB |
| 01-001.txt | AC | 1 ms | 3436 KiB |
| 01-002.txt | AC | 1 ms | 3452 KiB |
| 01-003.txt | AC | 1 ms | 3464 KiB |
| 01-004.txt | AC | 1 ms | 3512 KiB |
| 01-005.txt | AC | 2 ms | 3728 KiB |
| 01-006.txt | AC | 2 ms | 3504 KiB |
| 01-007.txt | AC | 3 ms | 3600 KiB |
| 01-008.txt | AC | 3 ms | 3592 KiB |
| 01-009.txt | AC | 2 ms | 3716 KiB |
| 01-010.txt | AC | 2 ms | 3552 KiB |
| 01-011.txt | AC | 2 ms | 3600 KiB |
| 01-012.txt | AC | 2 ms | 3636 KiB |
| 01-013.txt | AC | 2 ms | 3588 KiB |
| 01-014.txt | AC | 2 ms | 3568 KiB |
| 01-015.txt | AC | 2 ms | 3572 KiB |
| 01-016.txt | AC | 2 ms | 3536 KiB |
| 01-017.txt | AC | 3 ms | 3644 KiB |
| 01-018.txt | AC | 2 ms | 3572 KiB |