結果

問題 No.2073 Concon Substrings (Swap Version)
コンテスト
ユーザー 👑 Kazun
提出日時 2022-09-16 23:45:31
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 440 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 152 ms
コンパイル使用メモリ 84,992 KB
実行使用メモリ 82,048 KB
最終ジャッジ日時 2026-05-28 11:02:42
合計ジャッジ時間 3,596 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict

def solve():
    N=int(input())
    S=input()

    A=[defaultdict(int), defaultdict(int), defaultdict(int)]

    for i in range(3*N):
        if S[i]=="c" or S[i]=="o" or S[i]=="n":
            A[i%3][S[i]]+=1

    ans=0
    p,q,r="con"
    for _ in range(3):
        ans+=min(A[0][p], A[1][q], A[2][r])
        p,q,r=q,r,p

    if ans==N and A[0]["c"]<N:
        ans-=1

    return ans

print(solve())
0