Result

AC

Duration

1009ms

Code [DL]

main=interact$unlines.f.s.lines
f(a:b)=zipWith min(scanl1 max$b!!0)(s a):b
s(a:b)=a:scanr1 max b

stdin

                           T                      
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                      K                           

stdout

                      KKKKKK                      
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           
                      K                           

stderr

strace