結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー buey_tbuey_t
提出日時 2023-03-15 17:30:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 2,521 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 117,828 KB
最終ジャッジ日時 2023-10-18 12:28:31
合計ジャッジ時間 8,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
84,100 KB
testcase_01 AC 132 ms
84,100 KB
testcase_02 AC 129 ms
84,100 KB
testcase_03 AC 132 ms
84,104 KB
testcase_04 AC 132 ms
84,108 KB
testcase_05 AC 204 ms
117,828 KB
testcase_06 AC 204 ms
117,828 KB
testcase_07 AC 132 ms
84,108 KB
testcase_08 AC 173 ms
94,824 KB
testcase_09 AC 194 ms
111,032 KB
testcase_10 AC 218 ms
117,828 KB
testcase_11 AC 220 ms
117,828 KB
testcase_12 AC 132 ms
84,104 KB
testcase_13 AC 169 ms
89,060 KB
testcase_14 AC 213 ms
113,408 KB
testcase_15 AC 176 ms
91,856 KB
testcase_16 AC 167 ms
99,112 KB
testcase_17 AC 133 ms
84,100 KB
testcase_18 AC 151 ms
88,928 KB
testcase_19 AC 171 ms
98,684 KB
testcase_20 AC 163 ms
95,708 KB
testcase_21 AC 159 ms
94,432 KB
testcase_22 AC 168 ms
99,116 KB
testcase_23 AC 132 ms
84,108 KB
testcase_24 AC 150 ms
88,560 KB
testcase_25 AC 161 ms
94,912 KB
testcase_26 AC 168 ms
99,116 KB
testcase_27 AC 135 ms
84,104 KB
testcase_28 AC 168 ms
97,124 KB
testcase_29 AC 159 ms
90,964 KB
testcase_30 AC 187 ms
107,404 KB
testcase_31 AC 165 ms
91,528 KB
testcase_32 AC 160 ms
89,152 KB
testcase_33 AC 160 ms
90,232 KB
testcase_34 AC 159 ms
89,984 KB
testcase_35 AC 168 ms
93,588 KB
testcase_36 AC 161 ms
90,416 KB
testcase_37 AC 166 ms
93,336 KB
testcase_38 AC 160 ms
89,996 KB
testcase_39 AC 183 ms
104,500 KB
testcase_40 AC 171 ms
93,400 KB
testcase_41 AC 183 ms
104,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    try:
        import pypyjit
        pypyjit.set_param('max_unroll_recursion=-1')
    except:
        pass
    try:
        import sys
        sys.setrecursionlimit(10**7)
    except:
        pass
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    
    
    '''
    これもスワップか
    3で割った余りみたいなのが大事そう
    回数の最小値はいらないから
    %3 = 0
    %3 = 1
    %3 = 2
    でc,o,nの数数えて
    それの最小のやつ
    
    concononc で落ちる
    猶予がないとダメって感じか
    '''
    
    N = int(input())
    S = list(input())
    
    c0 = 0
    o0 = 0
    n0 = 0
    for i in range(0,3*N,3):
        if S[i] == 'c':
            c0 += 1
        elif S[i] == 'o':
            o0 += 1
        elif S[i] == 'n':
            n0 += 1
    
    c1 = 0
    o1 = 0
    n1 = 0
    for i in range(1,3*N,3):
        if S[i] == 'c':
            c1 += 1
        elif S[i] == 'o':
            o1 += 1
        elif S[i] == 'n':
            n1 += 1
    
    c2 = 0
    o2 = 0
    n2 = 0
    for i in range(2,3*N,3):
        if S[i] == 'c':
            c2 += 1
        elif S[i] == 'o':
            o2 += 1
        elif S[i] == 'n':
            n2 += 1
    
    a = min(c0,o1,n2)
    b = min(o0,n1,c2)
    c = min(n0,c1,o2)
    
    if a>0 and (b==c==0):
        print(a)
    elif b>0 and (c==a==0):
        if b*3+2 > 3*N:
            print(b-1)
        else:
            print(b)
    elif c>0 and (a==b==0):
        if c*3+1>3*N:
            print(c-1)
        else:
            print(c)
    else:
        if (a+b+c)*3+2 > 3*N:
            print(a+b+c-1)
        else:
            print(a+b+c)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0