CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:tonero
Submission time:2022-01-22 15:17:27 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.01 s1, 2, 3details
#20.01 s2, 3details
#30.01 s3details
#40.01 s1, 2, 3details
#50.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#80.01 s3details
#90.01 s3details
#100.01 s3details

Code

#include <bits/stdc++.h>

using namespace std;

#define ull unsigned long long
#define ll long long

int ans[1001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> noskipws;
    int n;
    cin >> n;
    cin.ignore(1);

    ll prev = 0;
    char digP[10] = {};

    vector<ll> ans;
    ans.reserve(n);

    for (int i = 0; i < n; ++i){
        ll num = 0;
        vector<char> numstck;
        vector<pair<int,int>> qIn;
        char u = 0;
        char c;
        cin >> c;
        while(c != '\n'){
            numstck.emplace_back(c);
            ++u;
            cin >> c;
        }

        char qdig[10];

        int y = 0;
        for (auto j = numstck.rbegin(); j != numstck.rend(); ++j, ++y) {
            if(*j == '?'){
                qIn.emplace_back(y, 0);
                qdig[y] = 0;
            }else{
                num += pow(10, (y))*(*j-'0');
                qdig[y] = *j-'0';
            }
        }
        if(*numstck.begin() == '?'){
            num += pow(10, y-1);
            qIn.pop_back();
            qIn.emplace_back(y, 1);
        }

        ll n2 = prev;
        int in = 0;

        if(num > prev){
            goto suc;
        }

        while (n2 >= 10) {
            if((char) (n2 % 10) > qdig[in]){
                num += pow(10, in)*(((char) (n2 % 10))-qdig[in]);
                qdig[in] = (char) (n2 % 10);
            }
            n2 /= 10;
            ++in;
        }


        for (const auto &item : qIn){
            while(qdig[item.first] < 9){
                ++qdig[item.first];
                num += pow(10, item.first);
                if(num > prev){
                    goto suc;
                }
            }

        }

        if(num > prev){
            goto suc;
        }

        cout << "IMPOSSIBLE";
        flush(std::cout);
        return 0;
        suc:
        prev = num;

        fill(digP, digP+numstck.size(), 0);
        n2 = num;

        in = numstck.size()-1;
        while (n2 != 0) {
            digP[in] = (n2 % 10);
            n2 /= 10;
            --in;
        }

        ans.emplace_back(num);
    }

    for (const auto &item : ans){
        cout << item << "\n";
    }

    flush(std::cout);
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
100
??
??
??
??
...

correct output
10
11
12
13
20
...

user output
IMPOSSIBLE

Test 2

Group: 2, 3

Verdict:

input
1000
8??
??8?
????
????
...

correct output
800
1080
1081
1082
1083
...

user output
IMPOSSIBLE

Test 3

Group: 3

Verdict:

input
1000
??????
?????9?
??98???
?????5?
...

correct output
100000
1000090
1098000
1098050
4100001
...

user output
IMPOSSIBLE

Test 4

Group: 1, 2, 3

Verdict:

input
100
?
?
?
?
...

correct output
1
2
3
4
5
...

user output
IMPOSSIBLE

Test 5

Group: 1, 2, 3

Verdict:

input
2
???
??

correct output
IMPOSSIBLE

user output
100
119

Test 6

Group: 1, 2, 3

Verdict: ACCEPTED

input
3
123
???
124

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
5
1??
???
2??
???
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 8

Group: 3

Verdict:

input
1000
?????????
?????????
?????????
?????????
...

correct output
100000000
100000001
100000002
100000003
100000004
...

user output
IMPOSSIBLE

Test 9

Group: 3

Verdict:

input
900
???000000
???000000
???000000
???000000
...

correct output
100000000
101000000
102000000
103000000
104000000
...

user output
IMPOSSIBLE

Test 10

Group: 3

Verdict:

input
1000
???1?????
???0?????
???1?????
???0?????
...

correct output
100100000
101000000
101100000
102000000
102100000
...

user output
IMPOSSIBLE