Submission #1312599

#TimeUsernameProblemLanguageResultExecution timeMemory
1312599algoproclubType Printer (IOI08_printer)Pypy 3
90 / 100
976 ms279888 KiB
# UUID: 7f5bfc6f-d408-4850-9f8a-49e86f4b5c82 def dfshossz(hely): for i in graf[hely][1]: dfshossz(i[1]) graf[graf[hely][2]][0]=max(graf[graf[hely][2]][0],graf[hely][0]+1) graf[hely][1].sort(key= lambda x:graf[x[1]][0],reverse=False) def dfs(hely): for j in range(graf[hely][3]): ki.append("P") for i in graf[hely][1]: ki.append(i[0]) dfs(i[1]) ki.append("-") n=int(input()) l=[] for i in range(n): l.append(input()) #print(l) graf=[] graf=[[0,[],0,0]] for i in l: hely=0 for ch in i: talalt=False for j in graf[hely][1]: #print(j) if j[0]==ch: hely=j[1] talalt=True break if not talalt: graf[hely][1].append([ch,len(graf)]) graf.append([0,[],hely,0]) hely=len(graf)-1 graf[hely][3]+=1 dfshossz(0) #print(graf) ki=[] dfs(0) while True: if ki[-1]=="-": ki.pop() else: break #print(ki) print(len(ki)) for i in ki: print(i) """ ki=[] stack=[] for i in l: hely=0 for j in i: if len(stack)==hely: break elif stack[hely]!=j: break hely+=1 if len(stack)>hely: while True: kidob=len(stack) if kidob==hely: break ki.append("-") stack.pop() hely=0 for j in i: if len(stack)==hely: ki.append(j) stack.append(j) hely+=1 ki.append("P") print(len(ki)) for i in ki: print(i) """

Compilation message (stdout)

Compiling 'printer.py'...

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

=======
#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...