CSES - Datatähti 2022 alku - Results
Submission details
Task:Ositus
Sender:motsgar
Submission time:2021-10-06 23:31:02 +0300
Language:C++ (C++17)
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.02 s3details
#7--3details

Compiler report

input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:67:13: warning: unused variable 'mys' [-Wunused-variable]
         int mys = 0;
             ^~~
input/code.cpp:25:8: warning: unused variable 'removed' [-Wunused-variable]
     ll removed = 0;
        ^~~~~~~

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(int argc, char **argv)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string in;
    cin >> in;

    ll length = 1;

    unsigned int biggestPos = 0;

    bool rem = false;

    int skip = 0;

    ll lastRem = 0;

    ll removed = 0;

    for (unsigned int i = 0; i < in.size(); i++)
    {
        vector<ll> v(122, -1);
        unsigned int pos = i + 1;
        v[in[i]] = i;

        while (pos < in.size())
        {
            if (v[in[pos]] != -1)
            {
                break;
            }
            v[in[pos]] = pos;
            pos++;
        }
        cout << "a: " << pos << " " << biggestPos << " " << i << endl;

        if (pos == i + 1)
        {
            cout << "mui" << endl;
            rem = false;
            lastRem = 0;
            continue;
        }

        if (pos == biggestPos)
        {
            skip++;
            continue;
        }

        int slength = pos - biggestPos;
        if (!rem)
            slength--;
        ll thing = 1 << slength;
        ll tmp = length * thing;

        cout << "b: " << slength << " " << thing << endl;
        cout << "skip: " << skip << endl;

        int mys = 0;

        if (rem)
        {
            cout << "remove: " << lastRem << endl;
            ll toRem = (1 << (slength - 1)) * ((1 << (skip + lastRem)) - lastRem);
            tmp -= toRem;
            lastRem = slength + skip + lastRem;
        }

        length = (tmp) % 1000000007;

        biggestPos = pos;
        rem = true;
        skip = 0;
    }

    cout << length << "\n";
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
a

correct output
1

user output
a: 1 0 0
mui
1

Test 2

Group: 1, 2, 3

Verdict:

input
abcdefghij

correct output
512

user output
a: 10 0 0
b: 9 512
skip: 0
a: 10 10 1
a: 10 10 2
...
Truncated

Test 3

Group: 1, 2, 3

Verdict:

input
abcabaacbc

correct output
120

user output
a: 3 0 0
b: 2 4
skip: 0
a: 4 3 1
b: 1 2
...
Truncated

Test 4

Group: 1, 2, 3

Verdict:

input
aaxxxxxxaa

correct output
4

user output
a: 1 0 0
mui
a: 3 0 1
b: 2 4
skip: 0
...
Truncated

Test 5

Group: 2, 3

Verdict:

input
mfyzvoxmppoxcvktmcjkryyocfweub...

correct output
643221148

user output
a: 3 0 0
b: 2 4
skip: 0
a: 3 3 1
a: 3 3 2
...
Truncated

Test 6

Group: 3

Verdict:

input
weinscqmmpgbrlboocvtbptgbahmwv...

correct output
831644159

user output
a: 8 0 0
b: 7 128
skip: 0
a: 8 8 1
a: 8 8 2
...
Truncated

Test 7

Group: 3

Verdict:

input
sxaoxcyrjoeieyinaqxwukgzdnhhsw...

correct output
816016015

user output
(empty)