← Back to Forum
CCC 2019 J3 - Cold Compress Solution
#Morgan Su, BayviewSS N=int(input()) array=[] #Store all input lines posCount=0 #character index tracker for current line mul=1 #Counter for consecutive characters Symb=[] #List to keep track of characters in current line length=0 #length for i in range(N): array+=[input()] for l in range(N): line=array[l] length=len(line) mul=1 #Reset consecutive count Symb.clear() #Clear previous line's symbol array for j in range(length): if posCount==0: Symb+=line[j] #Add first character of line to Symb else: Symb+=line[j] #Add current character if Symb[j]==Symb[j-1]: #If previous == current, add 1 to counter mul+=1 else: print(mul, end=" ") #If different character encountered, print counter and prev. char print(Symb[j-1], end=" ") mul=1 #For last character, print counter and char. if posCount==(length-1): print(mul, end=" ") print(Symb[j], end=" ") mul=1 posCount+=1 posCount=0 #reset position counter for next line print("") #create new line
By msu7 on 8/7/2025
0