結果
| 問題 | No.2073 Concon Substrings (Swap Version) | 
| コンテスト | |
| ユーザー |  dn6049949 | 
| 提出日時 | 2022-09-16 22:29:14 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 81 ms / 2,000 ms | 
| コード長 | 1,016 bytes | 
| コンパイル時間 | 192 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 77,184 KB | 
| 最終ジャッジ日時 | 2024-12-21 21:44:30 | 
| 合計ジャッジ時間 | 3,692 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 37 | 
ソースコード
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def main():
    n = I()
    s = input()
    count_c = [0]*3
    count_o = [0]*3
    count_n = [0]*3
    for i,si in enumerate(s):
        if si == "c":
            count_c[i%3] += 1
        elif si == "o":
            count_o[i%3] += 1
        elif si == "n":
            count_n[i%3] += 1
    c = [count_c, count_o, count_n]
    ans = 0
    for i in range(3):
        m = float("inf")
        for j in range(3):
            m = min(m, c[j][(i+j)%3])
        ans += m
    if ans == n and c != [[n,0,0],[0,n,0],[0,0,n]]:
        ans -= 1
    print(ans)
    return
if __name__ == "__main__":
    main()
            
            
            
        