Please sign in first.
Submission #55476144
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define K 20
#define M 1000000007
#define LL long long
vector<int> S;
LL ret = 1;
int n;
int main() {
scanf("%d", &n);
string x; cin >> x;
int cnt = 0;
FOE(i, 1, n - 1) {
int diff = (x[i] != x[i - 1]);
if (!diff) {
int sub = (cnt / 2 + 1);
ret = (ret * sub) % M;
cnt = 0;
} else cnt++;
}
ret = ret * (cnt / 2 + 1) % M;
printf("%lld\n", ret);
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - ABA and BAB |
| User | Theogry |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 504 Byte |
| Status | AC |
| Exec Time | 5 ms |
| Memory | 4080 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
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 | 3820 KiB |
| 00-sample-002.txt | AC | 1 ms | 3700 KiB |
| 00-sample-003.txt | AC | 1 ms | 3676 KiB |
| 00-sample-004.txt | AC | 1 ms | 3840 KiB |
| 01-001.txt | AC | 1 ms | 3688 KiB |
| 01-002.txt | AC | 1 ms | 3688 KiB |
| 01-003.txt | AC | 1 ms | 3672 KiB |
| 01-004.txt | AC | 1 ms | 3844 KiB |
| 01-005.txt | AC | 4 ms | 4052 KiB |
| 01-006.txt | AC | 4 ms | 4052 KiB |
| 01-007.txt | AC | 4 ms | 3980 KiB |
| 01-008.txt | AC | 5 ms | 4080 KiB |
| 01-009.txt | AC | 4 ms | 4080 KiB |
| 01-010.txt | AC | 4 ms | 3988 KiB |
| 01-011.txt | AC | 4 ms | 3968 KiB |
| 01-012.txt | AC | 4 ms | 3848 KiB |
| 01-013.txt | AC | 4 ms | 3968 KiB |
| 01-014.txt | AC | 4 ms | 3928 KiB |
| 01-015.txt | AC | 4 ms | 3996 KiB |
| 01-016.txt | AC | 4 ms | 3996 KiB |
| 01-017.txt | AC | 5 ms | 3968 KiB |
| 01-018.txt | AC | 5 ms | 4040 KiB |