| Task: | Ositus |
| Sender: | ToukoP |
| Submission time: | 2021-10-06 00:19:14 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #2 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #3 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
| #4 | ACCEPTED | 0.01 s | 1, 2, 3 | details |
| #5 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
| #6 | TIME LIMIT EXCEEDED | -- | 3 | details |
| #7 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
long all(long len) {
return pow(2, max(len - 1, (long) 0));
}
long solve(string value, bool debug = false, bool fixUnique = false) {
long res = 1;
for (int i = 1; (unsigned) i < value.length(); i++) {
bool isDup = false;
long pos = -1;
for (int j = i; j >= 0; j--) {
if (value[i] == value[j] && i != j) {
fixUnique = false;
isDup = true;
pos = j;
break;
}
}
if (isDup) {
long start = solve(value.substr(0, pos + 1), false, false); // /*/ all(pos + 1) /**/
long end = solve(value.substr(pos, i - pos), false, true); // /*/ (all(i - pos) -1) /**/
res += start * end;
if (debug) cout << value[i] << " i: " << i << " res: " << res << ", pos: " << pos << ", start: " << start << ", end: " << end << "\n";
} else {
res *= 2;
if (debug) cout << value[i] << ": " << res << "\n";
}
}
if (fixUnique) res--;
return res;
}
int main() {
string str;
cin >> str;
cout << (solve(str, false) % (long) (pow((long) 10, (long) 9) + 7)) << "\n";
}Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| a |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 2
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| abcdefghij |
| correct output |
|---|
| 512 |
| user output |
|---|
| 512 |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| abcabaacbc |
| correct output |
|---|
| 120 |
| user output |
|---|
| 140 |
Test 4
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| aaxxxxxxaa |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Test 5
Group: 2, 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| mfyzvoxmppoxcvktmcjkryyocfweub... |
| correct output |
|---|
| 643221148 |
| user output |
|---|
| (empty) |
Test 6
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| weinscqmmpgbrlboocvtbptgbahmwv... |
| correct output |
|---|
| 831644159 |
| user output |
|---|
| (empty) |
Test 7
Group: 3
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
| correct output |
|---|
| 816016015 |
| user output |
|---|
| (empty) |
