結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー sapphire__15sapphire__15
提出日時 2022-08-26 06:00:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,944 KB
実行使用メモリ 30,840 KB
最終ジャッジ日時 2023-08-23 14:07:34
合計ジャッジ時間 9,379 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
29,516 KB
testcase_01 AC 134 ms
29,584 KB
testcase_02 AC 134 ms
29,376 KB
testcase_03 AC 136 ms
29,536 KB
testcase_04 AC 137 ms
29,432 KB
testcase_05 AC 230 ms
30,840 KB
testcase_06 AC 234 ms
30,736 KB
testcase_07 AC 134 ms
29,388 KB
testcase_08 AC 196 ms
30,032 KB
testcase_09 AC 212 ms
30,788 KB
testcase_10 AC 233 ms
30,740 KB
testcase_11 AC 231 ms
30,720 KB
testcase_12 AC 137 ms
29,472 KB
testcase_13 AC 146 ms
29,664 KB
testcase_14 AC 218 ms
30,348 KB
testcase_15 AC 165 ms
29,744 KB
testcase_16 AC 230 ms
30,740 KB
testcase_17 AC 138 ms
29,404 KB
testcase_18 AC 147 ms
29,544 KB
testcase_19 AC 229 ms
30,492 KB
testcase_20 AC 204 ms
30,536 KB
testcase_21 AC 195 ms
30,044 KB
testcase_22 AC 233 ms
30,820 KB
testcase_23 AC 139 ms
29,532 KB
testcase_24 AC 141 ms
29,528 KB
testcase_25 AC 202 ms
29,864 KB
testcase_26 AC 235 ms
30,620 KB
testcase_27 AC 137 ms
29,452 KB
testcase_28 AC 214 ms
30,128 KB
testcase_29 AC 162 ms
29,852 KB
testcase_30 AC 199 ms
30,576 KB
testcase_31 AC 166 ms
30,032 KB
testcase_32 AC 148 ms
29,644 KB
testcase_33 AC 153 ms
29,832 KB
testcase_34 AC 153 ms
29,716 KB
testcase_35 AC 184 ms
30,156 KB
testcase_36 AC 157 ms
29,856 KB
testcase_37 AC 183 ms
30,216 KB
testcase_38 AC 153 ms
29,656 KB
testcase_39 AC 188 ms
30,320 KB
testcase_40 AC 183 ms
30,336 KB
testcase_41 AC 189 ms
30,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from functools import reduce
from numpy import roll


def main():
    N = int(input())
    S = input()
    CON = "con"

    buff = [defaultdict(lambda: 0) for _ in range(3)]

    for i, j in enumerate(S):
        buff[i%3][j] += 1
    
    cnt = [reduce(min,
                  map(lambda x, y: x[y],
                      roll(buff, i), CON))
           for i in range(3)]

    if cnt[0] == N:
        print(N)
    else:
        print(min(sum(cnt), N-1))

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