結果

問題 No.52 よくある文字列の問題
ユーザー 👑 tatt61880tatt61880
提出日時 2021-03-21 01:32:02
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,125 bytes
コンパイル時間 2,211 ms
コンパイル使用メモリ 153,596 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-14 17:47:21
合計ジャッジ時間 3,072 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var s: []char :: cui@input()
	var n: int :: ^s
	
	var idxs: []int :: #[n]int
	for i(0, n - 1)
		do idxs[i] :: i
	end for
	
	var dic: dict<[]char, bool> :: #dict<[]char, bool>
	for id(0, 2 ^ (n - 1) - 1)
		var ns: []char :: #[n]char
		var ii: int :: id
		var mn: int :: 0
		var mx: int :: n - 1
		for i(0, n - 1)
			if(ii % 2 = 0)
				do ns[i] :: s[mn]
				do mn :+ 1
			else
				do ns[i] :: s[mx]
				do mx :- 1
			end if
			do ii :/ 2
		end for
		do dic.add(ns, true)
	end for
	var ans: int :: ^dic
	do cui@print("\{ans}\n")
	
	func nextPermutation(arr: []int): bool
		var len: int :: ^arr
		var left: int :: len - 2
		while(left >= 0 & arr[left] >= arr[left + 1])
			do left :- 1
		end while
		if(left < 0)
			ret false
		end if
		var right: int :: len - 1
		while(arr[left] >= arr[right])
			do right :- 1
		end while
		var tmp: int :: arr[left]
		do arr[left] :: arr[right]
		do arr[right] :: tmp
		do left :+ 1
		do right :: len - 1
		while(left < right)
			do tmp :: arr[left]
			do arr[left] :: arr[right]
			do arr[right] :: tmp
			do left :+ 1
			do right :- 1
		end while
		ret true
	end func
end func
0