結果

問題 No.587 七対子
コンテスト
ユーザー tak
提出日時 2018-08-02 04:39:19
言語 F#
(F# 10.0 + ac-library)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 47 ms / 2,000 ms
+ 929µs
コード長 597 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 12,485 ms
コンパイル使用メモリ 208,592 KB
実行使用メモリ 33,024 KB
最終ジャッジ日時 2026-08-19 00:02:14
合計ジャッジ時間 16,176 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (258 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

let (|Possible|Impossible|) (tup : (char * int)[]) =
    let getN n = tup |> Array.where(fun (_, b) -> b = n)
    
    let num    = tup |> Array.length
    let pair   = getN 2
    let lonly  = getN 1
    let pairNum  = pair  |> Array.length     
    let lonlyNum = lonly |> Array.length
    
    if pairNum + lonlyNum = num && lonlyNum = 1 then
        let key,_ = lonly |> Array.head        
        Possible key
    else
        Impossible
    
let S = stdin.ReadLine()

S.ToCharArray() |> Array.countBy(fun x -> x)
|> function Possible x -> string x | Impossible -> "Impossible"
|> printfn "%s"
0