Task: | Ositus |
Sender: | ToukoP |
Submission time: | 2021-10-06 22:52:44 +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 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#5 | WRONG ANSWER | 0.01 s | 2, 3 | details |
#6 | WRONG ANSWER | 0.01 s | 3 | details |
#7 | WRONG ANSWER | 0.10 s | 3 | details |
Code
#include <iostream> #include <math.h> #include <vector> #include <algorithm> using namespace std; const int charCount = 26; int toInt(char c) { return (int) c - 97; } long all(long len) { return pow(2, max(len - 1, (long) 0)); } long solve(string value) { long res = 1; long history[value.length()]; int chars [charCount]; fill_n(chars, charCount, -1); for (long i = 0; (unsigned) i < value.length(); i++) { int c = toInt(value[i]); if (chars[c] != -1) { long start = history[chars[c]]; long end = all(i - chars[c]) - 1; //cout <<"| "<< value[i] <<" res: "<< res <<" i: "<< i <<", last: "<< chars[c] <<", start: "<< start <<", end: "<< end <<endl; res += start * end; } else if (i != 0) { res *= 2; } //cout << value.substr(0, i + 1) <<" = "<< res << endl; history[i] = res; chars[c] = i; } return res; } int main() { string str; cin >> str; cout << (solve(str) % (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 |
---|
251 |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
aaxxxxxxaa |
correct output |
---|
4 |
user output |
---|
65 |
Test 5
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
mfyzvoxmppoxcvktmcjkryyocfweub... |
correct output |
---|
643221148 |
user output |
---|
532560796 |
Test 6
Group: 3
Verdict: WRONG ANSWER
input |
---|
weinscqmmpgbrlboocvtbptgbahmwv... |
correct output |
---|
831644159 |
user output |
---|
374024565 |
Test 7
Group: 3
Verdict: WRONG ANSWER
input |
---|
sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
correct output |
---|
816016015 |
user output |
---|
954886556 |