結果

問題 No.69 文字を自由に並び替え
コンテスト
ユーザー maimai8
提出日時 2020-08-03 15:31:24
言語 OCaml
(5.5.0)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 281µs
コード長 472 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 124 ms
コンパイル使用メモリ 22,912 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-12 07:53:19
合計ジャッジ時間 1,392 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

diff #
raw source code

let () =
  let rec charlist_of_string str n i = 
    if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in
  Scanf.scanf "%s\n%s\n" @@ fun a b ->
  let arr = List.fast_sort compare (charlist_of_string a (String.length a) 0) in
  let brr = List.fast_sort compare (charlist_of_string b (String.length b) 0) in
  let ans = List.fold_left2 
    (fun a x y -> if x = y then a && true else false) true arr brr in
  Printf.printf "%s\n" (if ans then "YES" else "NO")
0