結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー | shotoyoo |
提出日時 | 2022-09-16 21:46:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 1,102 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 82,400 KB |
実行使用メモリ | 122,668 KB |
最終ジャッジ日時 | 2024-12-21 18:56:44 |
合計ジャッジ時間 | 4,741 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 37 |
ソースコード
import sys, random input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x)) debug = lambda x: sys.stderr.write(x+"\n") YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18 LI = lambda : list(map(int, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()] def debug(_l_): for s in _l_.split(): print(f"{s}={eval(s)}", end=" ") print() def dlist(*l, fill=0): if len(l)==1: return [fill]*l[0] ll = l[1:] return [dlist(*ll, fill=fill) for _ in range(l[0])] n = int(input()) s = SI() l = [[],[],[]] for i in range(3*n): l[i%3].append(s[i]) from collections import Counter C = ord("c")-ord("a") O = ord("o")-ord("a") N = ord("n")-ord("a") cs = [Counter(item) for item in l] ans = 0 val = min(cs[0][C], cs[1][O], cs[2][N]) val2 = min(cs[1][C], cs[2][O], cs[0][N]) if val2==n: val2 = n-1 val3 = min(cs[2][C], cs[0][O], cs[1][N]) if val3==n: val3 = n-1 ans = val + val2 + val3 if ans==n and val!=n: ans = n-1 print(ans)