CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:MojoLake
Submission time:2023-01-18 07:05:57 +0200
Language:C++ (C++17)
Status:READY
Result:39
Feedback
groupverdictscore
#1ACCEPTED13
#2ACCEPTED26
#30
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#2ACCEPTED0.00 s2, 3details
#3ACCEPTED0.01 s3details
#4ACCEPTED0.00 s1, 2, 3details
#5ACCEPTED0.00 s1, 2, 3details
#6ACCEPTED0.00 s1, 2, 3details
#7ACCEPTED0.00 s1, 2, 3details
#80.00 s3details
#9ACCEPTED0.01 s3details
#10ACCEPTED0.01 s3details

Code

#include <bits/stdc++.h>

using namespace std;

vector<string> nums;



int main(){

    int n;
    cin >> n;
    vector<string> nums(n);
    for(string&s:nums)cin>>s;
    string p;

    for(string& s : nums){

        int ss = (int)s.size();
        int ps = (int)p.size();

        if(ps > ss){
            cout << "IMPOSSIBLE\n";
            return 0;
        }

        if(ps < ss){
            for(int i = 0; i < ss; ++i){
                if(s[i]=='?')s[i] = '0' + (i==0);
            }
        }
        else{

            bool found = 0;

            for(int i = 0; i < ss; ++i){
                if(s[i] != '?')continue;

                for(int d = (i==0); d <= 9; ++d){
                    s[i] = '0' + d;
                    string temp = s;
                    for(int j = i + 1; j < ss; ++j){
                        if(temp[j]=='?')temp[j]='9';
                    }
                    if(temp > p){
                        found = 1;
                        break;
                    }
                }
            }

            if(!found){
                cout << "IMPOSSIBLE\n";
                return 0;
            }
        }

        // if(ps == ss && s <= p){
            // cout << "IMPOSSIBLE\n";
            // return 0;
        // }

        p = s;
    }

    for(string x : nums)cout << x << "\n";

}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

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

correct output
10
11
12
13
20
...

user output
10
11
12
13
20
...
Truncated

Test 2

Group: 2, 3

Verdict: ACCEPTED

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

correct output
800
1080
1081
1082
1083
...

user output
800
1080
1081
1082
1083
...
Truncated

Test 3

Group: 3

Verdict: ACCEPTED

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

correct output
100000
1000090
1098000
1098050
4100001
...

user output
100000
1000090
1098000
1098050
4100001
...
Truncated

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
100
?
?
?
?
...

correct output
1
2
3
4
5
...

user output
1
2
3
4
5
...
Truncated

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
2
???
??

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

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: ACCEPTED

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

correct output
100000000
101000000
102000000
103000000
104000000
...

user output
100000000
101000000
102000000
103000000
104000000
...
Truncated

Test 10

Group: 3

Verdict: ACCEPTED

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

correct output
100100000
101000000
101100000
102000000
102100000
...

user output
100100000
101000000
101100000
102000000
102100000
...
Truncated