제출 #920585

#제출 시각아이디문제언어결과실행 시간메모리
920585zeroday1934구슬과 끈 (APIO14_beads)Cpython 3
0 / 100
11 ms2908 KiB
""" ID: asp.5611 LANG: PYTHON3 TASK: beads """ def break_and_join(inp, idx): pp = inp[:idx] sp = inp[idx:] r = sp + pp return r def count(string): c=0 for j in range(len(string)): if(string[j]=='w'): c+=1 else: ch=string[j] for i in range(j,len(string)): if(string[i]==ch or string[i]=='w'): c+=1 else: break break for k in range(len(string)-1,-1,-1): if(string[k]=='w'): c+=1 else: ch=string[k] for i in range(k,i>=0,-1): if(string[i]==ch or string[i]=='w'): c+=1 else: break break if(c>len(string)): c=len(string) return c with open('beads.in','r') as f: N=int(f.readline()) necklace=f.readline() f.close() counter=0 for i in range(N): res=break_and_join(necklace,i) c_count=count(res) if(c_count>counter): counter=c_count with open('beads.out','w') as fout: fout.write(str(counter) + '\n') fout.close()
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...