CSES - Datatähti 2022 loppu - Results
Submission details
Task:Lista
Sender:Kirill_Akimov
Submission time:2022-01-22 16:59:58 +0200
Language:Python3 (PyPy3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.04 s1, 2, 3details
#20.08 s2, 3details
#30.08 s3details
#4ACCEPTED0.04 s1, 2, 3details
#5ACCEPTED0.04 s1, 2, 3details
#6ACCEPTED0.04 s1, 2, 3details
#70.04 s1, 2, 3details
#80.07 s3details
#90.07 s3details
#100.07 s3details

Code

from array import array
a = []

n = int(input())
c = 0

s = input()
if '?' in s:
    s = bytearray(s, 'ascii')
    if s[0] == 63:
        s[0] = 49
    for i in range(1, len(s)):
        if s[i] == 63:
            s[i] == 48

    a.append(s)
else:
    a.append(bytearray(s, 'ascii'))
    
b = len(s)

for k in range(1, n):
    s = input()
    l = len(s)
    
    if l < b:
        print('IMPOSSIBLE')
        break
    elif l == b:
        if '?' not in s:
            if int(s) <= int(a[k-1].decode()):
                print('IMPOSSIBLE')
                break
            else:
                a.append(bytearray(s, 'ascii'))
                b = l
                continue
        
        if '?' in s:
            s = bytearray(s, 'ascii')
            needed = True
            for i in range(len(s)-1, -1, -1):
                if s[i] == 63:
                    if needed:
                        if a[k-1][i] == 57:
                            s[i] = 48
                        else:
                            s[i] = a[k-1][i] + 1
                            needed = False
                    else:
                        s[i] = a[k-1][i]
                else:
                    if s[i] > a[k-1][i]:
                        needed = False
            if needed:
                print('IMPOSSIBLE')
                break
            a.append(s)
            b = l            
    else:
        if '?' in s:
            s = bytearray(s, 'ascii')
            if s[0] == 63:
                s[0] = 49
            for i in range(1, len(s)):
                if s[i] == 63:
                    s[i] = 48
            a.append(s)

        else:
            a.append(bytearray(s, 'ascii'))
        b = l
else:
    for e in a:
        print(e.decode())

Test details

Test 1

Group: 1, 2, 3

Verdict:

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

correct output
10
11
12
13
20
...

user output
1?
1@
1A
1B
20
...
Truncated

Test 2

Group: 2, 3

Verdict:

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

correct output
800
1080
1081
1082
1083
...

user output
8??
1080
1081
1082
1083
...
Truncated

Test 3

Group: 3

Verdict:

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

correct output
100000
1000090
1098000
1098050
4100001
...

user output
1?????
1000090
1098091
1098052
4198061
...
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:

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

correct output
IMPOSSIBLE

user output
1??
1?@
2?A
2?B
1?C

Test 8

Group: 3

Verdict:

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

correct output
100000000
100000001
100000002
100000003
100000004
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 48, in <module>
    s[i] =...

Test 9

Group: 3

Verdict:

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

correct output
100000000
101000000
102000000
103000000
104000000
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 48, in <module>
    s[i] =...

Test 10

Group: 3

Verdict:

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

correct output
100100000
101000000
101100000
102000000
102100000
...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 48, in <module>
    s[i] =...