結果
問題 | No.587 七対子 |
ユーザー |
|
提出日時 | 2018-09-23 19:48:11 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 78 ms / 2,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 13,888 ms |
コンパイル使用メモリ | 194,672 KB |
実行使用メモリ | 31,616 KB |
最終ジャッジ日時 | 2024-07-19 19:56:06 |
合計ジャッジ時間 | 11,574 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (235 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
open Systemlet solve (s : string) =let pairs =Seq.groupBy id s|> Seq.map (fun (c, cSeq) -> (c, Seq.length cSeq))|> Seq.toListlet maxPair = List.maxBy (fun (_, cnt) -> cnt) pairs |> fun (c, cnt) -> cntif maxPair > 2 then"Impossible"elselet single =List.filter (fun (_, cnt) -> cnt = 1) pairs|> List.map (fun (c, _) -> c)if List.length single > 1 then"Impossible"elsenew String(single.[0], 1)let () =let s = stdin.ReadLine()solve s|> printfn "%s"