結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー dn6049949dn6049949
提出日時 2022-09-16 22:29:14
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 244 ms
使用メモリ 83,052 KB
最終ジャッジ日時 2023-01-11 07:43:07
合計ジャッジ時間 6,774 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 97 ms
76,704 KB
testcase_01 AC 97 ms
76,668 KB
testcase_02 AC 97 ms
76,448 KB
testcase_03 AC 98 ms
76,660 KB
testcase_04 AC 97 ms
76,436 KB
testcase_05 AC 116 ms
82,872 KB
testcase_06 AC 121 ms
82,660 KB
testcase_07 AC 97 ms
76,656 KB
testcase_08 AC 110 ms
82,128 KB
testcase_09 AC 111 ms
82,596 KB
testcase_10 AC 127 ms
82,988 KB
testcase_11 AC 127 ms
83,052 KB
testcase_12 AC 99 ms
76,436 KB
testcase_13 AC 110 ms
81,360 KB
testcase_14 AC 123 ms
82,696 KB
testcase_15 AC 113 ms
81,768 KB
testcase_16 AC 118 ms
82,772 KB
testcase_17 AC 97 ms
76,420 KB
testcase_18 AC 107 ms
81,356 KB
testcase_19 AC 115 ms
82,460 KB
testcase_20 AC 113 ms
82,224 KB
testcase_21 AC 112 ms
82,144 KB
testcase_22 AC 115 ms
82,780 KB
testcase_23 AC 99 ms
76,584 KB
testcase_24 AC 106 ms
81,288 KB
testcase_25 AC 114 ms
82,168 KB
testcase_26 AC 118 ms
82,832 KB
testcase_27 AC 99 ms
76,648 KB
testcase_28 AC 115 ms
82,404 KB
testcase_29 AC 111 ms
81,708 KB
testcase_30 AC 115 ms
82,044 KB
testcase_31 AC 110 ms
81,744 KB
testcase_32 AC 106 ms
81,344 KB
testcase_33 AC 109 ms
81,444 KB
testcase_34 AC 109 ms
81,408 KB
testcase_35 AC 113 ms
81,756 KB
testcase_36 AC 109 ms
81,436 KB
testcase_37 AC 113 ms
81,720 KB
testcase_38 AC 108 ms
81,412 KB
testcase_39 AC 113 ms
82,008 KB
testcase_40 AC 111 ms
82,084 KB
testcase_41 AC 113 ms
82,232 KB
権限があれば一括ダウンロードができます

ソースコード

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])
        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()
0