結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー shobonvipshobonvip
提出日時 2022-09-16 23:15:55
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 1,093 ms
使用メモリ 82,580 KB
最終ジャッジ日時 2023-01-11 08:27:27
合計ジャッジ時間 6,476 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 80 ms
75,580 KB
testcase_01 AC 76 ms
75,516 KB
testcase_02 AC 77 ms
75,292 KB
testcase_03 AC 77 ms
75,544 KB
testcase_04 AC 79 ms
75,844 KB
testcase_05 AC 108 ms
82,308 KB
testcase_06 AC 108 ms
82,360 KB
testcase_07 AC 77 ms
75,724 KB
testcase_08 AC 101 ms
82,028 KB
testcase_09 AC 104 ms
82,128 KB
testcase_10 AC 126 ms
82,580 KB
testcase_11 AC 124 ms
82,344 KB
testcase_12 AC 78 ms
75,888 KB
testcase_13 AC 90 ms
80,900 KB
testcase_14 AC 119 ms
82,116 KB
testcase_15 AC 96 ms
80,852 KB
testcase_16 AC 113 ms
82,380 KB
testcase_17 AC 78 ms
75,800 KB
testcase_18 AC 87 ms
80,384 KB
testcase_19 AC 112 ms
82,480 KB
testcase_20 AC 105 ms
81,520 KB
testcase_21 AC 103 ms
81,972 KB
testcase_22 AC 120 ms
82,396 KB
testcase_23 AC 77 ms
75,676 KB
testcase_24 AC 86 ms
80,716 KB
testcase_25 AC 108 ms
81,904 KB
testcase_26 AC 113 ms
82,236 KB
testcase_27 AC 77 ms
75,376 KB
testcase_28 AC 108 ms
81,560 KB
testcase_29 AC 92 ms
80,900 KB
testcase_30 AC 102 ms
82,036 KB
testcase_31 AC 94 ms
80,956 KB
testcase_32 AC 89 ms
80,780 KB
testcase_33 AC 90 ms
80,864 KB
testcase_34 AC 88 ms
80,364 KB
testcase_35 AC 100 ms
82,068 KB
testcase_36 AC 91 ms
80,792 KB
testcase_37 AC 98 ms
81,716 KB
testcase_38 AC 90 ms
81,088 KB
testcase_39 AC 102 ms
82,024 KB
testcase_40 AC 99 ms
81,868 KB
testcase_41 AC 103 ms
82,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
con = [[0] * 3 for i in range(3)]
dat = ["c", "o", "n"]



for i in range(3*n):
	for j in range(3):
		if s[i] == dat[j]:
			con[i%3][j] += 1

#無駄なスペースを取らない
ans = 99999999
for i in range(3):
	ans = min(ans, con[i][i])

v = [n] * 3
for i in range(3):
	for j in range(3):
		v[i] -= con[(i+j)%3][i]

#無駄なスペースを1つ分とる
for i in range(64):
	mode = 1
	for j in range(3):
		typ = (i // (4 ** j)) % 4
		if typ == 3:
			if v[j] == 0:
				mode = 0
		else:
			con[j][typ] -= 1
			if con[j][typ] < 0:
				mode = 0
	
	tmp = 0
	for k in range(3):
		r = 999999
		for l in range(3):
			r = min(r, con[(l+k)%3][l])
		tmp += r
	
	if mode:
		ans = max(tmp, ans)
	
	for j in range(3):
		typ = (i // (4 ** j)) % 4
		if typ < 3:
			con[j][typ] += 1

print(ans)
0