結果

問題 No.2021 Not A but B
ユーザー 👑 tatt61880tatt61880
提出日時 2022-10-15 12:54:58
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 2,749 ms
コンパイル使用メモリ 150,088 KB
実行使用メモリ 4,700 KB
最終ジャッジ日時 2023-09-09 02:29:39
合計ジャッジ時間 4,432 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 8 ms
4,568 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 8 ms
4,424 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 8 ms
4,608 KB
testcase_13 AC 8 ms
4,656 KB
testcase_14 AC 8 ms
4,656 KB
testcase_15 AC 8 ms
4,452 KB
testcase_16 AC 8 ms
4,560 KB
testcase_17 AC 8 ms
4,620 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 8 ms
4,544 KB
testcase_20 AC 8 ms
4,668 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 5 ms
4,556 KB
testcase_27 AC 6 ms
4,700 KB
testcase_28 AC 6 ms
4,408 KB
testcase_29 AC 6 ms
4,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var s: []char :: cui@input()
	
	var ans: int :: 0
	
	; 変化なしのカウント
	if(s.findStr("BB", -1) <> -1)
		do ans :+ 1
	end if
	
	; 1文字変化のカウント
	for i(0, n - 1)
		if(s[i] = 'A')
			var f: bool :: false
			if(i <> 0 & s[i - 1] = 'B')
				do ans :+ 1
			elif(i <> n - 1 & s[i + 1] = 'B')
				do ans :+ 1
			end if
		end if
	end for
	
	; 2文字変化のカウント
	for i(0, n - 2)
		if(s[i] = 'A' & s[i + 1] = 'A')
			do ans :+ 1
		end if
	end for
	
	do cui@print("\{ans}\n")
end func
0