Yukicoder No.69 文字を自由に並び替え
solution
高級言語で書くなら、ソートして一致するか見ればよい。O(NlogN)。 そうでなければ、rolling hashのように多項式を使ったhash関数H(x)=∑f(xi)を用いて比較する。加算にO(a)で乗算をO(b)と仮定するとO(N(a+b)deg(f))。
implementation
提出: https://yukicoder.me/submissions/202298
整形前
#!/usr/bin/env bfi
>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> O
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> N
>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> S
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> E
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> Y
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> V
[ +[-<+] ]
#
+[->,+]
<-[+[-<]>[>]<-]
<[-<]
<[>>[>]+[>]<[-<]<-]
#
>>[>]>[>]<
[
>+++>+<[->[-<<[->>>+>+<<<<]>>>>[-<<<<+>>>>]<<]>[-<+>]<<]
>[<<[<]<[<]<+>>[>]>[>]>-]
<<[-]
<
]
#
<[
>+++>+<[->[-<<[->>>+>+<<<<]>>>>[-<<<<+>>>>]<<]>[-<+>]<<]
>[<<[<]<->>[>]>-]
<<[-]
<
]
<[<]<[.<]
daaaaaaaaa
bbbbbbbbba