CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:Juho
Submission time:2022-01-22 14:49:18 +0200
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED13
#2ACCEPTED26
#3ACCEPTED61
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s2, 3details
#3ACCEPTED0.01 s3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.01 s3details
#9ACCEPTED0.01 s3details
#10ACCEPTED0.01 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:56:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=1;i<s.size();i++){
                     ~^~~~~~~~~

Code

#include <bits/stdc++.h>
using namespace std;

int n, a, b, potenssi;
bool possible;
string s;
vector<string> v;
vector<int> vas;

int main(){
    cin>>n;
    possible =true;
    for(int i=0;i<n;i++){
        cin>>s;
        v.push_back(s);
    }
    s=v.back();
    potenssi=1;
    
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='?'){
            a+=potenssi*9;
        }else{
            a+=potenssi*(s[i]-'0');
        }
        potenssi *=10;
    }
    v.pop_back();
    vas.push_back(a);
    
    while(v.size()>0){
        b=a;
        potenssi=1;
        s=v.back();
        a=0;
        for(int i=s.size()-1;i>=0;i--){
            if(s[i]!='?'){
                a+= potenssi*(s[i]-'0');
            }
            potenssi *=10;
        }
        
        potenssi/=10;
        
        if(s[0]=='?'){
            a+= potenssi;
            for(int j=2;j<10;j++){
                if(a+potenssi<b){
                    a+=potenssi;
                }
            }
        }
        if(a>=b){
            possible = false;
        }
        for(int i=1;i<s.size();i++){
            potenssi /= 10;
            if(s[i]=='?'){
                for(int j=1;j<10;j++){
                    if(a+potenssi<b){
                        a+=potenssi;
                    }
                }
            }
        }
        v.pop_back();
        vas.push_back(a);
    }
    if(possible){
        for(int i=n-1;i>=0;i--){
            cout<<vas[i]<<"\n";
        }
    }else{
        cout<<"IMPOSSIBLE";
    }
    
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

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

correct output
10
11
12
13
20
...

user output
86
87
88
89
90
...

Test 2

Group: 2, 3

Verdict: ACCEPTED

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

correct output
800
1080
1081
1082
1083
...

user output
899
9989
9995
9996
9997
...

Test 3

Group: 3

Verdict: ACCEPTED

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

correct output
100000
1000090
1098000
1098050
4100001
...

user output
999999
4198998
4198999
4199959
4199991
...

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
100
?
?
?
?
...

correct output
1
2
3
4
5
...

user output
1
2
3
4
5
...

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

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

correct output
100000000
100000001
100000002
100000003
100000004
...

user output
100000000
100000001
100000002
100000003
100000004
...

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
...

Test 10

Group: 3

Verdict: ACCEPTED

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

correct output
100100000
101000000
101100000
102000000
102100000
...

user output
499199999
500099999
500199999
501099999
501199999
...