結果

問題 No.2073 Concon Substrings (Swap Version)
コンテスト
ユーザー 👑 Kazun
提出日時 2022-09-16 23:45:31
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 70 ms / 2,000 ms
+ 843µs
コード長 440 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 80 ms
コンパイル使用メモリ 64,088 KB
実行使用メモリ 60,728 KB
最終ジャッジ日時 2026-10-20 06:55:47
合計ジャッジ時間 4,630 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

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