| Task: | Text Alignment |
| Sender: | Dereden |
| Submission time: | 2025-11-26 16:54:16 +0200 |
| Language: | Python3 (PyPy3) |
| Status: | READY |
| Result: | RUNTIME ERROR |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | ACCEPTED | 0.04 s | details |
| #3 | ACCEPTED | 0.04 s | details |
| #4 | ACCEPTED | 0.04 s | details |
| #5 | ACCEPTED | 0.04 s | details |
| #6 | RUNTIME ERROR | 0.06 s | details |
| #7 | ACCEPTED | 0.04 s | details |
| #8 | ACCEPTED | 0.04 s | details |
| #9 | ACCEPTED | 0.04 s | details |
| #10 | ACCEPTED | 0.04 s | details |
| #11 | ACCEPTED | 0.05 s | details |
| #12 | ACCEPTED | 0.05 s | details |
| #13 | ACCEPTED | 0.06 s | details |
Code
text = input()
splitText = text.split()
wordLens = [len(word) for word in splitText]
lines = []
currentLine = []
currentLength = 0
i = 0
for word, length in zip(splitText, wordLens):
if currentLength + length + len(currentLine) + (0 if i == 0 else 1) <= 50:
currentLine.append(word)
currentLength += length
i += 1
else:
lines.append(currentLine)
currentLine = [word]
currentLength = length
if currentLine:
lines.append(currentLine)
for line in lines:
totalLength = sum(len(word) for word in line)
spacesNeeded = 50 - totalLength
spaceSlots = len(line) - 1
baseSpaces = spacesNeeded // spaceSlots
extraSpaces = spacesNeeded % spaceSlots
resultLine = ''
for i in range(len(line)):
resultLine += line[i]
if i < spaceSlots:
resultLine += ' ' * (baseSpaces + (1 if i < extraSpaces else 0))
print(resultLine)
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| zsyadhzdg ke irkyowki nflwfanr... |
| correct output |
|---|
| zsyadhzdg ... |
| user output |
|---|
| zsyadhzdg ke irkyowk... |
Test 2
Verdict: ACCEPTED
| input |
|---|
| eayoylmki efsqdhm qqvnrd npesu... |
| correct output |
|---|
| eayoylmki ... |
| user output |
|---|
| eayoylmki efsqdhm qq... |
Test 3
Verdict: ACCEPTED
| input |
|---|
| bsvhdnoxlxad f bclsa llq hjrmp... |
| correct output |
|---|
| bsvhdnoxlxad ... |
| user output |
|---|
| bsvhdnoxlxad f bclsa... |
Test 4
Verdict: ACCEPTED
| input |
|---|
| xoezwspspfdzfasgxlqu f wjzpekp... |
| correct output |
|---|
| xoezwspspfdzfasgxlqu ... |
| user output |
|---|
| xoezwspspfdzfasgxlqu f ... |
Test 5
Verdict: ACCEPTED
| input |
|---|
| bwvfj zmcpktjnmhzevcqtvlg twch... |
| correct output |
|---|
| bwvfj ... |
| user output |
|---|
| bwvfj zmcpktjnmhzevcqtvlg tw... |
Test 6
Verdict: RUNTIME ERROR
| input |
|---|
| yifvbbjczpcnpknimq lttkngpeqsz... |
| correct output |
|---|
| yifvbbjczpcnpknimq ... |
| user output |
|---|
| yifvbbjczpcnpknimq ... |
Error:
Traceback (most recent call last):
File "input/code.py", line 25, in <module>
baseSpaces = spacesNeeded // spaceSlots
ZeroDivisionError: integer division or modulo by zeroTest 7
Verdict: ACCEPTED
| input |
|---|
| fu lzslzio ncbkga nrwuijkbrh x... |
| correct output |
|---|
| fu ... |
| user output |
|---|
| fu lzslzio ncbkga nrwuijkbrh ... |
Test 8
Verdict: ACCEPTED
| input |
|---|
| azgwjnvgkapltkknwm odostksvqal... |
| correct output |
|---|
| azgwjnvgkapltkknwm ... |
| user output |
|---|
| azgwjnvgkapltkknwm odostksv... |
Test 9
Verdict: ACCEPTED
| input |
|---|
| j mmadidafwkd dckim iwjy bzsso... |
| correct output |
|---|
| j ... |
| user output |
|---|
| j mmadidafwkd dckim iw... |
Test 10
Verdict: ACCEPTED
| input |
|---|
| barm sykc faxmvycwxs cnxuwpetq... |
| correct output |
|---|
| barm ... |
| user output |
|---|
| barm sykc faxmvycwxs... |
Test 11
Verdict: ACCEPTED
| input |
|---|
| ltwg ns j axhacysdjhrpzymwxae ... |
| correct output |
|---|
| ltwg ... |
| user output |
|---|
| ltwg ns j axhacysdjhrpzymwx... |
Test 12
Verdict: ACCEPTED
| input |
|---|
| pgwvxzeztltppuuq siarhxbs mjmr... |
| correct output |
|---|
| pgwvxzeztltppuuq ... |
| user output |
|---|
| pgwvxzeztltppuuq siarhxbs ... |
Test 13
Verdict: ACCEPTED
| input |
|---|
| xurwjadifyf iijoofrunig zadrff... |
| correct output |
|---|
| xurwjadifyf ... |
| user output |
|---|
| xurwjadifyf iijoofruni... |
