結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー mkawa2mkawa2
提出日時 2022-09-16 22:39:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 1,160 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 77,812 KB
最終ジャッジ日時 2023-08-23 16:14:40
合計ジャッジ時間 5,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,200 KB
testcase_01 AC 71 ms
71,352 KB
testcase_02 AC 71 ms
71,128 KB
testcase_03 AC 71 ms
71,232 KB
testcase_04 AC 71 ms
71,516 KB
testcase_05 AC 86 ms
77,632 KB
testcase_06 AC 86 ms
77,812 KB
testcase_07 AC 70 ms
71,156 KB
testcase_08 AC 82 ms
76,756 KB
testcase_09 AC 85 ms
77,200 KB
testcase_10 AC 94 ms
77,600 KB
testcase_11 AC 93 ms
77,700 KB
testcase_12 AC 70 ms
71,488 KB
testcase_13 AC 78 ms
76,092 KB
testcase_14 AC 90 ms
77,276 KB
testcase_15 AC 83 ms
76,412 KB
testcase_16 AC 86 ms
77,512 KB
testcase_17 AC 72 ms
71,232 KB
testcase_18 AC 77 ms
76,000 KB
testcase_19 AC 84 ms
77,344 KB
testcase_20 AC 82 ms
77,124 KB
testcase_21 AC 82 ms
76,968 KB
testcase_22 AC 84 ms
77,628 KB
testcase_23 AC 71 ms
71,428 KB
testcase_24 AC 78 ms
75,976 KB
testcase_25 AC 82 ms
77,004 KB
testcase_26 AC 84 ms
77,672 KB
testcase_27 AC 69 ms
71,420 KB
testcase_28 AC 83 ms
77,308 KB
testcase_29 AC 78 ms
76,428 KB
testcase_30 AC 84 ms
76,764 KB
testcase_31 AC 79 ms
76,576 KB
testcase_32 AC 79 ms
76,148 KB
testcase_33 AC 80 ms
76,196 KB
testcase_34 AC 80 ms
76,076 KB
testcase_35 AC 82 ms
76,860 KB
testcase_36 AC 80 ms
76,244 KB
testcase_37 AC 82 ms
76,788 KB
testcase_38 AC 79 ms
76,196 KB
testcase_39 AC 82 ms
76,832 KB
testcase_40 AC 82 ms
76,632 KB
testcase_41 AC 83 ms
76,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

n = II()
s = SI()
t = "con"

cnt = [[0]*3 for _ in range(3)]
for si in range(3):
    for i in range(si, 3*n, 3):
        c = t.find(s[i])
        if c == -1: continue
        cnt[si][c] += 1
# p2D(cnt)

ans = 0
aa = []
for si in range(3):
    cur = n-1 if si else n
    for j in range(3):
        i = (si+j)%3
        cur = min(cur, cnt[i][j])
    aa.append(cur)

if aa[0] == n:
    ans = n
else:
    ans = min(n-1, sum(aa))

print(ans)
0