CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:kpop
Submission time:2021-10-07 10:25:45 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.01 s1, 2, 3details
#30.01 s1, 2, 3details
#40.01 s1, 2, 3details
#50.01 s2, 3details
#60.09 s3details
#7--3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:16:13: warning: unused variable 'ai' [-Wunused-variable]
         int ai = str.rbegin()-ita-1;
             ^~

Code

#include <bits/stdc++.h>

using namespace std;

int main() {
    string str; cin >> str;
    vector<int> points(str.length(), 0);
    unordered_set<char> seen;

    auto ita = str.rbegin();
    auto itb = ita+1;

    seen.insert(*ita);

    while (ita != str.rend()) {
        int ai = str.rbegin()-ita-1;
        int bi = str.rend()-itb-1;

        if (seen.find(*itb) == seen.end() && itb != str.rend()) {
            seen.insert(*itb);
            points[bi] += 1;
            ++itb;
        } else {
            ++ita;
            itb = ita+1;
            seen.clear();
        }
    }

    for (int i = points.size()-1; i >= 0; --i) {
        points[i] += points[i+1];
    }

    points[points.size()-1] = 1;

    int result = 0;

    auto itc = str.begin();
    auto itd = itc+1;

    seen.clear();
    seen.insert(*itc);

    while (itc != str.end()) {
        int di = itd-str.begin()-1;

        cout << *itc << " and " << *itd << endl;

        if (seen.find(*itd) == seen.end() && itd != str.end()) {
            cout << "YES!" << endl;
            seen.insert(*itd);
            result += points[di+1];
            ++itd;
        } else {
            cout << "fail." << endl;
            ++itc;
            itd = itc+1;
            seen.clear();
        }
    }

    cout << result%1000000007 << endl;
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
a

correct output
1

user output
a and 
fail.
0

Test 2

Group: 1, 2, 3

Verdict:

input
abcdefghij

correct output
512

user output
a and b
YES!
a and c
YES!
a and d
...
Truncated

Test 3

Group: 1, 2, 3

Verdict:

input
abcabaacbc

correct output
120

user output
a and b
YES!
a and c
YES!
a and a
...
Truncated

Test 4

Group: 1, 2, 3

Verdict:

input
aaxxxxxxaa

correct output
4

user output
a and a
fail.
a and x
YES!
a and x
...
Truncated

Test 5

Group: 2, 3

Verdict:

input
mfyzvoxmppoxcvktmcjkryyocfweub...

correct output
643221148

user output
m and f
YES!
m and y
YES!
m and z
...
Truncated

Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
w and e
YES!
w and i
YES!
w and n
...
Truncated

Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)