結果

問題 No.587 七対子
ユーザー ichibanshiboriichibanshibori
提出日時 2018-09-23 19:48:11
言語 F#
(F# 4.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 598 bytes
コンパイル時間 3,494 ms
コンパイル使用メモリ 165,740 KB
実行使用メモリ 25,228 KB
最終ジャッジ日時 2023-09-27 02:26:04
合計ジャッジ時間 8,071 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
25,160 KB
testcase_01 AC 90 ms
23,132 KB
testcase_02 AC 89 ms
25,096 KB
testcase_03 AC 91 ms
23,220 KB
testcase_04 AC 90 ms
21,256 KB
testcase_05 AC 89 ms
25,072 KB
testcase_06 AC 89 ms
25,156 KB
testcase_07 AC 90 ms
23,112 KB
testcase_08 AC 89 ms
23,016 KB
testcase_09 AC 90 ms
25,100 KB
testcase_10 AC 91 ms
23,216 KB
testcase_11 AC 91 ms
23,220 KB
testcase_12 AC 90 ms
22,976 KB
testcase_13 AC 90 ms
23,144 KB
testcase_14 AC 91 ms
23,124 KB
testcase_15 AC 91 ms
25,184 KB
testcase_16 AC 91 ms
25,076 KB
testcase_17 AC 91 ms
25,112 KB
testcase_18 AC 90 ms
24,980 KB
testcase_19 AC 92 ms
23,148 KB
testcase_20 AC 91 ms
25,228 KB
testcase_21 AC 90 ms
23,056 KB
testcase_22 AC 90 ms
23,148 KB
testcase_23 AC 87 ms
22,956 KB
testcase_24 AC 89 ms
25,212 KB
testcase_25 AC 89 ms
23,148 KB
testcase_26 AC 88 ms
23,140 KB
testcase_27 AC 87 ms
23,108 KB
testcase_28 AC 89 ms
21,164 KB
testcase_29 AC 89 ms
23,100 KB
testcase_30 AC 91 ms
25,176 KB
testcase_31 AC 91 ms
23,120 KB
testcase_32 AC 91 ms
21,116 KB
testcase_33 AC 91 ms
25,148 KB
testcase_34 AC 90 ms
23,036 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System

let solve (s : string) =
    let pairs =
        Seq.groupBy id s
        |> Seq.map (fun (c, cSeq) -> (c, Seq.length cSeq))
        |> Seq.toList
    let maxPair = List.maxBy (fun (_, cnt) -> cnt) pairs |> fun (c, cnt) -> cnt
    if maxPair > 2 then
        "Impossible"
    else
        let single =
            List.filter (fun (_, cnt) -> cnt = 1) pairs
            |> List.map (fun (c, _) -> c)
        if List.length single > 1 then
            "Impossible"
        else
            new String(single.[0], 1)

let () =
    let s = stdin.ReadLine()
    solve s
    |> printfn "%s"
0