結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー shobonvipshobonvip
提出日時 2022-09-16 23:15:55
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 78,568 KB
最終ジャッジ日時 2023-08-23 16:36:27
合計ジャッジ時間 5,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,528 KB
testcase_01 AC 72 ms
71,556 KB
testcase_02 AC 71 ms
71,096 KB
testcase_03 AC 71 ms
71,256 KB
testcase_04 AC 72 ms
71,296 KB
testcase_05 AC 103 ms
78,552 KB
testcase_06 AC 104 ms
78,216 KB
testcase_07 AC 69 ms
71,428 KB
testcase_08 AC 93 ms
77,776 KB
testcase_09 AC 99 ms
77,828 KB
testcase_10 AC 138 ms
78,568 KB
testcase_11 AC 125 ms
78,208 KB
testcase_12 AC 72 ms
71,160 KB
testcase_13 AC 81 ms
76,820 KB
testcase_14 AC 115 ms
78,060 KB
testcase_15 AC 86 ms
76,756 KB
testcase_16 AC 108 ms
78,520 KB
testcase_17 AC 72 ms
71,504 KB
testcase_18 AC 81 ms
76,648 KB
testcase_19 AC 106 ms
78,296 KB
testcase_20 AC 101 ms
77,740 KB
testcase_21 AC 96 ms
77,768 KB
testcase_22 AC 114 ms
78,060 KB
testcase_23 AC 71 ms
71,312 KB
testcase_24 AC 79 ms
76,848 KB
testcase_25 AC 101 ms
78,004 KB
testcase_26 AC 107 ms
78,200 KB
testcase_27 AC 69 ms
71,604 KB
testcase_28 AC 102 ms
77,892 KB
testcase_29 AC 86 ms
76,860 KB
testcase_30 AC 99 ms
78,116 KB
testcase_31 AC 86 ms
77,152 KB
testcase_32 AC 82 ms
76,700 KB
testcase_33 AC 82 ms
76,932 KB
testcase_34 AC 83 ms
76,416 KB
testcase_35 AC 98 ms
77,884 KB
testcase_36 AC 86 ms
76,852 KB
testcase_37 AC 94 ms
77,888 KB
testcase_38 AC 83 ms
76,752 KB
testcase_39 AC 100 ms
77,628 KB
testcase_40 AC 94 ms
77,804 KB
testcase_41 AC 98 ms
77,920 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