Task: | Ositus |
Sender: | ToukoP |
Submission time: | 2021-10-05 23:18:33 +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.21 s | 3 | details |
Compiler report
input/code.cpp: In function 'bool isValid(std::__cxx11::string)': input/code.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 0; i < value.length(); i++) { ~~^~~~~~~~~~~~~~~~ input/code.cpp:9:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int j = i; j < value.length(); j++) { ~~^~~~~~~~~~~~~~~~ input/code.cpp: In function 'long int solve(std::__cxx11::string)': input/code.cpp:30:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i = 1; i < value.length(); i++) { ~~^~~~~~~~~~~~~~~~ input/code.cpp:24:9: warning: unused variable 'duplicates' [-Wunused-variable] int duplicates = 0; ^~~~~~~~~~ input/code.cpp:25:9: warning: unused variable 'lastDuplicate' [-Wunused-variable] int lastDuplicate = 0; ^~~~~~~~~~~~~ input/code.cp...
Code
#include <iostream> #include <string> #include <math.h> using namespace std; bool isValid(string value) { for (int i = 0; i < value.length(); i++) { for (int j = i; j < value.length(); j++) { if (value[i] == value[j] && i != j) { return false; } } } return true; } long all(long len) { return pow(2, max(len - 1, (long) 0)); } long solve(string value) { int duplicates = 0; int lastDuplicate = 0; long res = 1; bool b = false; for (int i = 1; i < value.length(); i++) { bool isDup = false; long pos = -1; for (int j = i; j >= 0; j--) { if (value[i] == value[j] && i != j) { isDup = true; pos = j; break; } } if (isDup) { res += all(pos + 1) * (all(i - pos) - 1);//+ (pos == 0 ? 0 : 1); //cout << value[i] << " i: " << i << " res: " << res << ", pos: " << pos << ", all(pos): " << all(pos + 1) << ", all(i - pos): " << all(i - pos)-1 << "\n"; } else { res *= 2; //cout << value[i] << ": " << res << "\n"; } } return res; } int main() { string str; cin >> str; cout << (solve(str) % 1000000007); return 0; }
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 |
---|
321 |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
aaxxxxxxaa |
correct output |
---|
4 |
user output |
---|
128 |
Test 5
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
mfyzvoxmppoxcvktmcjkryyocfweub... |
correct output |
---|
643221148 |
user output |
---|
355523294 |
Test 6
Group: 3
Verdict: WRONG ANSWER
input |
---|
weinscqmmpgbrlboocvtbptgbahmwv... |
correct output |
---|
831644159 |
user output |
---|
-59752902 |
Test 7
Group: 3
Verdict: WRONG ANSWER
input |
---|
sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
correct output |
---|
816016015 |
user output |
---|
-377817714 |