結果

問題 No.587 七対子
ユーザー papinianus
提出日時 2017-11-14 15:55:44
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 784 bytes
コンパイル時間 1,040 ms
コンパイル使用メモリ 109,936 KB
実行使用メモリ 28,740 KB
最終ジャッジ日時 2024-11-25 02:04:44
合計ジャッジ時間 2,918 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 10 RE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using static System.Console;

namespace No587
{
    class Program
    {
        static void Main(string[] args)
        {
            var chars = ReadLine().ToCharArray();
            if (WillBeSevenPair(chars))
            {
                WriteLine(FindSoloChar(chars));
                return;
            }
            WriteLine("Impossible");
            return;
        }

        static bool WillBeSevenPair(char[] chars)
        {
            var charGroup = chars.GroupBy(x => x);
            return charGroup.Count() == 7 && !charGroup.Select(x=>x.Count()).All(y => y == 1 || y == 2);
        }
        static char FindSoloChar(char[] chars) => chars.GroupBy(x => x).Select(x => new { chr = x.Key, cnt = x.Count() }).Single(y => y.cnt == 1).chr;
    }
}
0