Task: | Ositus |
Sender: | kpop |
Submission time: | 2021-10-09 09:09:13 +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 | WRONG ANSWER | 0.01 s | 1, 2, 3 | details |
#2 | WRONG ANSWER | 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.87 s | 3 | details |
Code
#include <bits/stdc++.h> using namespace std; int main() { int result = 0; string s; cin >> s; int n = s.length(); vector<int> points(n, 0); unordered_set<char> seen; auto left = s.begin(); auto right = left+1; while (left < s.end()) { int i = distance(s.begin(), right); if (seen.count(*right) == 0 && right != s.end()) { seen.insert(*right); ++points[i]; ++right; } else { if (!seen.empty()) seen.clear(); ++left; seen.insert(*left); right = left+1; } } for (int i = 1; i < n; ++i) points[i]+=points[i-1]; // cumulative sum seen.clear(); left = s.begin(); right = left+1; vector<int> finals(n, 0); while (left < s.end()) { int i = distance(s.begin(), left); int j = distance(s.begin(), right); if (seen.count(*right) == 0 && right != s.end()) { int p = 1; if (i>1) { p = points[i-1]; } seen.insert(*right); finals[j] += p; ++right; } else { if (!seen.empty()) seen.clear(); ++left; right = left+1; seen.insert(*left); } } for (int i = 1; i < n; ++i) finals[i]+=finals[i-1]; seen.clear(); for (int i = n-1; i > 0; --i) { char val = s[i]; if (seen.count(val) != 0) break; int p = finals[i-1]+1; cout << val << " -> " << p << endl; result += p+1; seen.insert(val); } cout << result << endl; }
Test details
Test 1
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
a |
correct output |
---|
1 |
user output |
---|
0 |
Test 2
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
abcdefghij |
correct output |
---|
512 |
user output |
---|
j -> 142 i -> 84 h -> 47 g -> 25 f -> 13 ... |
Test 3
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
abcabaacbc |
correct output |
---|
120 |
user output |
---|
c -> 44 b -> 26 72 |
Test 4
Group: 1, 2, 3
Verdict: WRONG ANSWER
input |
---|
aaxxxxxxaa |
correct output |
---|
4 |
user output |
---|
a -> 7 8 |
Test 5
Group: 2, 3
Verdict: WRONG ANSWER
input |
---|
mfyzvoxmppoxcvktmcjkryyocfweub... |
correct output |
---|
643221148 |
user output |
---|
t -> 118336 h -> 115409 m -> 112985 k -> 111060 a -> 107324 ... Truncated |
Test 6
Group: 3
Verdict: WRONG ANSWER
input |
---|
weinscqmmpgbrlboocvtbptgbahmwv... |
correct output |
---|
831644159 |
user output |
---|
p -> 321354270 i -> 321176787 g -> 321024670 x -> 320897914 f -> 320796515 ... Truncated |
Test 7
Group: 3
Verdict: WRONG ANSWER
input |
---|
sxaoxcyrjoeieyinaqxwukgzdnhhsw... |
correct output |
---|
816016015 |
user output |
---|
l -> -1640160611 a -> -1670677969 h -> -1696109094 y -> -1716453990 r -> -1731712660 ... Truncated |