結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー dn6049949
提出日時 2022-09-16 22:27:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 997 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 77,280 KB
最終ジャッジ日時 2024-12-21 21:42:02
合計ジャッジ時間 4,291 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 25 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
        if m == n and i != 0:
            m = n-1
        ans += m
    print(ans)
    return


if __name__ == "__main__":
    main()
0