| Task: | Lista |
| Sender: | okkokko |
| Submission time: | 2022-01-22 14:48:05 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| #2 | RUNTIME ERROR | 0 |
| #3 | RUNTIME ERROR | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #2 | RUNTIME ERROR | 0.07 s | 2, 3 | details |
| #3 | RUNTIME ERROR | 0.07 s | 3 | details |
| #4 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #5 | RUNTIME ERROR | 0.06 s | 1, 2, 3 | details |
| #6 | RUNTIME ERROR | 0.06 s | 1, 2, 3 | details |
| #7 | ACCEPTED | 0.04 s | 1, 2, 3 | details |
| #8 | ACCEPTED | 0.12 s | 3 | details |
| #9 | RUNTIME ERROR | 0.06 s | 3 | details |
| #10 | ACCEPTED | 0.12 s | 3 | details |
Code
def smallestPossible(num: "list[str]"):
"do not use at the start"
return [0 if i == "?" else int(i) for i in num]
def lowestLarger(prev: "list[int]", num: "list[str]", eka=False):
if (not prev) and (not num):
return []
if eka and len(prev) < len(num):
return [1 if num[0] == "?" else int(num[0])] + [0 if i == "?" else int(i) for i in num[1:]]
# both have the same length
if num[0] == "?":
a = lowestLarger(prev[1:], num[1:])
if a is None:
if prev[0] + 1 < 10:
return [prev[0] + 1] + smallestPossible(num[1:])
else:
return None
else:
if a: # if the length is not 0
return [prev[0]] + a
elif prev[0] + 1 < 10:
return [prev[0] + 1]
else:
return None
else:
first = int(num[0])
if first < prev[0]:
return None
elif first == prev[0]:
a = lowestLarger(prev[1:], num[1:])
if a is not None:
if a:
return [first] + a
else:
return None
else:
return [first] + smallestPossible(num[1:])
raise
def main():
n = int(input())
L = [[0]]
for _ in range(n):
num = list(input())
L.append(lowestLarger(L[-1], num, True))
if L[-1] is None:
print("IMPOSSIBLE")
break
else:
for i in L[1:]:
print(*i, sep="")
if __name__ == "__main__":
main()
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: RUNTIME ERROR
| input |
|---|
| 1000 8?? ??8? ???? ???? ... |
| correct output |
|---|
| 800 1080 1081 1082 1083 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 60, in <module>
main()...Test 3
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 ?????? ?????9? ??98??? ?????5? ... |
| correct output |
|---|
| 100000 1000090 1098000 1098050 4100001 ... |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 60, in <module>
main()...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: RUNTIME ERROR
| input |
|---|
| 2 ??? ?? |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 60, in <module>
main()...Test 6
Group: 1, 2, 3
Verdict: RUNTIME ERROR
| input |
|---|
| 3 123 ??? 124 |
| correct output |
|---|
| IMPOSSIBLE |
| user output |
|---|
| (empty) |
Error:
Traceback (most recent call last):
File "input/code.py", line 60, in <module>
main()...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: RUNTIME ERROR
| 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 60, in <module>
main()...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 |
