제출 #1161443

#제출 시각아이디문제언어결과실행 시간메모리
1161443browhattType Printer (IOI08_printer)Pypy 3
10 / 100
218 ms77452 KiB
def get_operations(prev, curr): """Calculate operations needed to transform prev to curr""" i = 0 min_len = min(len(prev), len(curr)) # Find common prefix length while i < min_len and prev[i] == curr[i]: i += 1 # Generate operations ops = [] # Backspace operations ops.extend(['-'] * (len(prev) - i)) # Add new characters ops.extend(list(curr[i:])) # Print operation ops.append('P') return ops def solve(words): n = len(words) if n == 1: return list(words[0]) + ['P'] # Sort words to maximize prefix sharing words.sort() # Generate operations operations = [] current = "" for word in words: operations.extend(get_operations(current, word)) current = word return operations # Read input n = int(input()) words = [input().strip() for _ in range(n)] # Get solution operations = solve(words) # Print output print(len(operations)) for op in operations: print(op)

컴파일 시 표준 출력 (stdout) 메시지

Compiling 'printer.py'...

=======
  adding: __main__.pyc (deflated 38%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...