Submission #55014917
Source Code Expand
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
string s;
typedef long long LL;
LL MOD = 1e9 + 7;
int main() {
ios::sync_with_stdio(0);
int n;
cin >> n;
cin >> s;
LL ans = 1;
for (int i = 0, j = 0; i < n; i++)
if (i + 1 < n && s[i] == s[i + 1] || i == n-1) {
int m = i - j + 1;
if (m >= 3) {
m = (m + 1) / 2;
ans = ans * m % MOD;
}
j = i + 1;
}
cout << ans << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - ABA and BAB |
| User | yefllower |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 492 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 3564 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:18:23: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
18 | if (i + 1 < n && s[i] == s[i + 1] || i == n-1) {
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-001.txt | AC | 1 ms | 3420 KiB |
| 00-sample-002.txt | AC | 1 ms | 3384 KiB |
| 00-sample-003.txt | AC | 1 ms | 3388 KiB |
| 00-sample-004.txt | AC | 1 ms | 3376 KiB |
| 01-001.txt | AC | 1 ms | 3388 KiB |
| 01-002.txt | AC | 1 ms | 3332 KiB |
| 01-003.txt | AC | 1 ms | 3388 KiB |
| 01-004.txt | AC | 1 ms | 3396 KiB |
| 01-005.txt | AC | 2 ms | 3404 KiB |
| 01-006.txt | AC | 2 ms | 3564 KiB |
| 01-007.txt | AC | 2 ms | 3560 KiB |
| 01-008.txt | AC | 2 ms | 3348 KiB |
| 01-009.txt | AC | 1 ms | 3560 KiB |
| 01-010.txt | AC | 1 ms | 3508 KiB |
| 01-011.txt | AC | 1 ms | 3348 KiB |
| 01-012.txt | AC | 1 ms | 3508 KiB |
| 01-013.txt | AC | 2 ms | 3516 KiB |
| 01-014.txt | AC | 1 ms | 3508 KiB |
| 01-015.txt | AC | 1 ms | 3516 KiB |
| 01-016.txt | AC | 1 ms | 3512 KiB |
| 01-017.txt | AC | 1 ms | 3508 KiB |
| 01-018.txt | AC | 1 ms | 3408 KiB |