結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー qwewe
提出日時 2025-04-24 12:26:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 560 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,108 KB
実行使用メモリ 77,368 KB
最終ジャッジ日時 2025-04-24 12:27:42
合計ジャッジ時間 3,806 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 25 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input().strip()

from collections import defaultdict

groups = [defaultdict(int) for _ in range(3)]
for i in range(len(s)):
    g = i % 3
    c = s[i]
    groups[g][c] += 1

c0 = groups[0].get('c', 0)
o0 = groups[0].get('o', 0)
n0 = groups[0].get('n', 0)

o1 = groups[1].get('o', 0)
n2 = groups[2].get('n', 0)

c1 = groups[1].get('c', 0)
o2 = groups[2].get('o', 0)

c2 = groups[2].get('c', 0)
n1 = groups[1].get('n', 0)

term0 = min(c0, o1, n2, n)
term1 = min(c1, o2, n0, n - 1)
term2 = min(c2, o0, n1, n - 1)

print(term0 + term1 + term2)
0