結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー lilictaka
提出日時 2022-09-18 23:18:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 104,820 KB
最終ジャッジ日時 2024-12-22 01:49:08
合計ジャッジ時間 5,649 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 25 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(input())
S = list(input())
cnt = [defaultdict(int) for _ in range(3)]
for i,s in enumerate(S):
    cnt[i%3][s] +=1
a = min(cnt[0]['c'],cnt[1]['o'],cnt[2]['n'])
b = min(cnt[0]['o'],cnt[1]['n'],cnt[2]['c'])
c = min(cnt[0]['n'],cnt[1]['c'],cnt[2]['o'])
if a > 0 and b > 0 and c > 0:
    ans = min(a+b+c,N-2)
elif a > 0 and b > 0:
    ans = min(a+b,N-1)
elif a > 0 and c > 0:
    ans = min(a+c,N-1)
elif b > 0 and c > 0:
    ans =min(b+c,N-2)
elif a:
    ans = a
elif b:
    ans = min(b,N-1)
elif c:
    ans= min(c,N-1)
else:
    ans = 0
print(ans)
0