Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
88530443 Practice:
strategy
1389C - 13 Python 3 Time limit exceeded on test 2 2000 ms 6772 KB 2020-07-30 21:01:26 2020-07-30 21:01:26
→ Source
def repeat(a,n,l,r):
    rep=0
    flag=0
    for i in range(n):
        if flag==0 and int(a[i])==l:
            rep+=1
            flag=1
        elif flag==1 and int(a[i])==r:
            rep+=1
            flag=0
    if flag==1 and l!=r:        
        return rep-1
    else:
        return rep          

test=int(input())
for t in range(test):
    a=input()
    n=len(a)
    rep=0
    for i in range(10):
        for j in range(10):
            x=repeat(a,n,int(i),int(j))
            if i!=j and x>rep:
                rep=x
    if rep>2:
        print(n-rep)
    else:    
        print(n-2)
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details