Submission #14872811


Source Code Expand

Copy
def readinput():
    s=input()
    return s

def find(s,it,ie):
    i=it
    while i+1<ie:
        if s[i]=='2':
            if s[i+1]=='5':
                return i
        i+=1
    return -1

def findToken(s):
    tokens=[]
    it=find(s,0,len(s))
    if (it<0):
        return tokens
    ie=it+2
    #print(it,ie)
    lens=len(s)
    while(ie+2<=lens):
        #if s[ie:ie+2]=='25':
        if s[ie]=='2' and s[ie+1]=='5':
            ie+=2
        else:
            #print(it,ie)
            tokens.append(ie-it)
            it=find(s,ie,lens)
            ie=it+2
    else:
        tokens.append(ie-it)
    return tokens      

def main(s):
    tokens=findToken(s)
    #print(tokens)
    sum=0
    for token in tokens:
        m=token//2
        sum+=m*(m+1)//2
    return sum

if __name__=='__main__':
    s=readinput()
    ans=main(s)
    print(ans)

Submission Info

Submission Time
Task B - ニコニコ文字列
User bokukko
Language PyPy3 (7.3.0)
Score 0
Code Size 903 Byte
Status
Exec Time 2210 ms
Memory 202856 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
Subtask1 0 / 30 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt
All 0 / 70 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask0_sample_04.txt, subtask0_sample_05.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt 64 ms 61524 KB
subtask0_sample_02.txt 55 ms 61636 KB
subtask0_sample_03.txt 49 ms 61648 KB
subtask0_sample_04.txt 54 ms 61620 KB
subtask0_sample_05.txt 51 ms 61656 KB
subtask1_01.txt 53 ms 62672 KB
subtask1_02.txt 57 ms 62444 KB
subtask1_03.txt 50 ms 62836 KB
subtask1_04.txt 2208 ms 201940 KB
subtask1_05.txt 2210 ms 202856 KB
subtask1_06.txt 2208 ms 202344 KB
subtask1_07.txt 64 ms 62408 KB
subtask1_08.txt 55 ms 62664 KB
subtask1_09.txt 53 ms 62692 KB
subtask1_10.txt 53 ms 61536 KB
subtask1_11.txt 53 ms 61348 KB
subtask1_12.txt 57 ms 62772 KB
subtask1_13.txt 55 ms 61488 KB
subtask2_01.txt 56 ms 63308 KB
subtask2_02.txt 56 ms 63040 KB
subtask2_03.txt 55 ms 63136 KB
subtask2_04.txt 2209 ms 201988 KB
subtask2_05.txt 2209 ms 202212 KB
subtask2_06.txt 2209 ms 202028 KB
subtask2_07.txt 65 ms 63440 KB
subtask2_08.txt 53 ms 63232 KB
subtask2_09.txt 56 ms 62964 KB
subtask2_10.txt 54 ms 62700 KB
subtask2_11.txt 46 ms 62676 KB
subtask2_12.txt 59 ms 65836 KB