이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
"""
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |