CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:Anttono
Submission time:2022-01-24 08:34:50 +0200
Language:C++ (C++11)
Status:READY
Result:39
Feedback
groupverdictscore
#1ACCEPTED13
#2ACCEPTED26
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.04 s2, 3details
#3--3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s1, 2, 3details
#7ACCEPTED0.01 s1, 2, 3details
#8ACCEPTED0.82 s3details
#9--3details
#10--3details

Compiler report

input/code.cpp: In function 'bool eq(std::__cxx11::string, int)':
input/code.cpp:13:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.size();i++)
                 ~^~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:40:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(s.size()>dig(nxt)) nxt++;
               ~~~~~~~~^~~~~~~~~
input/code.cpp:41:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(!eq(s, nxt) && s.size()==dig(nxt)) nxt++;
                              ~~~~~~~~^~~~~~~~~~
input/code.cpp:42:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(s.size()<dig(nxt))
            ~~~~~~~~^~~~~~~~~

Code

#include <bits/stdc++.h>

using namespace std;

int n;
bool pos = true;
vector<int> r;

bool eq(string s, int x)
{
    bool res = true;
    reverse(s.begin(), s.end());
    for(int i=0;i<s.size();i++)
    {
        if(s[i] != '?' && s[i]-'0' != x%10) res = false;
        x /= 10;
    }
    return res;
}

int dig(int x)
{
    int res = 0;
    while(x>0)
    {
        res++;
        x /= 10;
    }
    return res;
}

int main()
{
    cin>>n;
    string s;
    int nxt = 1;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        while(s.size()>dig(nxt)) nxt++;
        while(!eq(s, nxt) && s.size()==dig(nxt)) nxt++;
        if(s.size()<dig(nxt))
        {
            pos = false;
            break;
        }
        r.push_back(nxt);
        nxt++;
    }

    if(pos) for(int i=0;i<n;i++)
    {
        cout<<r[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
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:

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

correct output
100000
1000090
1098000
1098050
4100001
...

user output
(empty)

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

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

correct output
100000000
100000001
100000002
100000003
100000004
...

user output
100000000
100000001
100000002
100000003
100000004
...
Truncated

Test 9

Group: 3

Verdict:

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

correct output
100000000
101000000
102000000
103000000
104000000
...

user output
(empty)

Test 10

Group: 3

Verdict:

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

correct output
100100000
101000000
101100000
102000000
102100000
...

user output
(empty)