結果
| 問題 | No.2073 Concon Substrings (Swap Version) | 
| コンテスト | |
| ユーザー | 👑  Kazun | 
| 提出日時 | 2022-09-16 23:45:31 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 115 ms / 2,000 ms | 
| コード長 | 440 bytes | 
| コンパイル時間 | 551 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 77,184 KB | 
| 最終ジャッジ日時 | 2024-12-21 23:25:37 | 
| 合計ジャッジ時間 | 4,914 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 37 | 
ソースコード
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())
            
            
            
        