답안 #712781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
712781 2023-03-19T23:37:18 Z Proximitynow Type Printer (IOI08_printer) Python 3
10 / 100
1000 ms 12020 KB
from itertools import permutations

n = int(input())
words = [input() for _ in range(n)]

best = []

for per in permutations(words):
    m = []

    printer = ''

    for i in per:
        r = len(printer)
        for j in range(len(printer)):
            if j > len(i) or printer[j] != i[j]:
                r = len(printer) - j
                break
        m.extend(['-'] * r)
        m.extend([j for j in i[-(len(i) - (len(printer) - r)):]])
        printer = i
        m.append('P')

    if len(best) == 0 or len(m) < len(best):
        best = m

print(len(best))
for i in best:
    print(i)
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2900 KB Output is correct
2 Correct 15 ms 2916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 823 ms 2916 KB Output is correct
2 Execution timed out 1087 ms 2900 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 907 ms 2900 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 2920 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 ms 2900 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 3256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 4288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 4260 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 12020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 5708 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -