結果
| 問題 |
No.587 七対子
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-14 15:59:53 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 2,000 ms |
| コード長 | 886 bytes |
| コンパイル時間 | 899 ms |
| コンパイル使用メモリ | 107,136 KB |
| 実行使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2024-07-19 19:47:13 |
| 合計ジャッジ時間 | 3,043 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
var c = charGroup.Count();
var n = charGroup.Select(x => x.Count()).ToArray();
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;
}
}