Submission #7089000


Source Code Expand

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**7)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
mo=998244353
input=sys.stdin.readline
n=I()
s=input()+' '
b='ABXY'
com=[i+j for i in b for j in b]
ans=10**10
for l in com:
    for r in com:
        c=0
        i=0
        if l==r:
            continue
        while i<n:
            c+=1
            if s[i:i+2] in (l,r):
                i+=2
            else:
                i+=1
        ans=min(ans,c)
print(ans)

Submission Info

Submission Time
Task C - コマンド入力
User keroru
Language PyPy3 (2.4.0)
Score 100
Code Size 811 Byte
Status AC
Exec Time 196 ms
Memory 40688 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 45
Set Name Test Cases
All 00_retmax.txt, 00_retmin.txt, 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_twothree_00.txt, 02_twothree_01.txt, 02_twothree_02.txt, 02_twothree_03.txt, 02_twothree_04.txt, 02_twothree_05.txt, 02_twothree_06.txt, 02_twothree_07.txt, 02_twothree_08.txt, 02_twothree_09.txt, 02_twothree_10.txt, 02_twothree_11.txt, 02_twothree_12.txt, 02_twothree_13.txt, 02_twothree_14.txt, 02_twothree_15.txt, 02_twothree_16.txt, 02_twothree_17.txt, 02_twothree_18.txt, 02_twothree_19.txt
Case Name Status Exec Time Memory
00_retmax.txt AC 196 ms 40688 KB
00_retmin.txt AC 167 ms 38512 KB
00_sample_00.txt AC 166 ms 38512 KB
00_sample_01.txt AC 173 ms 38896 KB
00_sample_02.txt AC 170 ms 38896 KB
01_rnd_00.txt AC 185 ms 40048 KB
01_rnd_01.txt AC 187 ms 40176 KB
01_rnd_02.txt AC 184 ms 40048 KB
01_rnd_03.txt AC 185 ms 40048 KB
01_rnd_04.txt AC 186 ms 40048 KB
01_rnd_05.txt AC 186 ms 40048 KB
01_rnd_06.txt AC 185 ms 40048 KB
01_rnd_07.txt AC 186 ms 40048 KB
01_rnd_08.txt AC 187 ms 40048 KB
01_rnd_09.txt AC 186 ms 40048 KB
01_rnd_10.txt AC 189 ms 40048 KB
01_rnd_11.txt AC 186 ms 40048 KB
01_rnd_12.txt AC 190 ms 40176 KB
01_rnd_13.txt AC 188 ms 40048 KB
01_rnd_14.txt AC 185 ms 40176 KB
01_rnd_15.txt AC 186 ms 40048 KB
01_rnd_16.txt AC 186 ms 40048 KB
01_rnd_17.txt AC 187 ms 40176 KB
01_rnd_18.txt AC 186 ms 40176 KB
01_rnd_19.txt AC 188 ms 40176 KB
02_twothree_00.txt AC 187 ms 40304 KB
02_twothree_01.txt AC 185 ms 40048 KB
02_twothree_02.txt AC 185 ms 40048 KB
02_twothree_03.txt AC 184 ms 40048 KB
02_twothree_04.txt AC 188 ms 40048 KB
02_twothree_05.txt AC 184 ms 39920 KB
02_twothree_06.txt AC 183 ms 39920 KB
02_twothree_07.txt AC 183 ms 39920 KB
02_twothree_08.txt AC 183 ms 39920 KB
02_twothree_09.txt AC 184 ms 40048 KB
02_twothree_10.txt AC 185 ms 40048 KB
02_twothree_11.txt AC 186 ms 39920 KB
02_twothree_12.txt AC 185 ms 39920 KB
02_twothree_13.txt AC 184 ms 39920 KB
02_twothree_14.txt AC 184 ms 39920 KB
02_twothree_15.txt AC 185 ms 40044 KB
02_twothree_16.txt AC 183 ms 39920 KB
02_twothree_17.txt AC 187 ms 40048 KB
02_twothree_18.txt AC 186 ms 40048 KB
02_twothree_19.txt AC 183 ms 39920 KB