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
N=int(input())
necklace=input()
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
print(c_count)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
2908 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |