結果

問題 No.1362 [Zelkova 8th Tune] Black Sheep
コンテスト
ユーザー tanson
提出日時 2026-01-14 00:09:12
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 27 ms / 1,000 ms
コード長 814 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 7,579 ms
コンパイル使用メモリ 708,232 KB
実行使用メモリ 40,300 KB
最終ジャッジ日時 2026-01-14 00:09:24
合計ジャッジ時間 7,083 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fun readStr () =
    let
        fun scan reader stream = SOME (StringCvt.splitl (not o Char.isSpace) reader (StringCvt.skipWS reader stream))
    in
        valOf (TextIO.scanStream scan TextIO.stdIn)
    end


exception BadInput
fun findAns _ [] = raise BadInput
  | findAns _ [_] = raise BadInput
  | findAns _ [_, _] = raise BadInput  
  | findAns index (h1 :: h2 :: h3 :: tl) =
    if (h1 = h2 andalso h2 <> h3) then (index + 2, h3)
    else if (h2 = h3 andalso h1 <> h2) then (index, h1)
    else if (h3 = h1 andalso h2 <> h3) then (index + 1, h2)
    else findAns (index + 1) (h2 :: h3 :: tl)
              

val () =
    let
        val s = readStr ()

        val (ansIndex, ansChar) = findAns 1 (String.explode s)
    in
        print (Int.toString ansIndex ^ " " ^ Char.toString ansChar ^ "\n")
    end
0