結果
問題 |
No.707 書道
|
ユーザー |
![]() |
提出日時 | 2018-06-29 23:08:59 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,545 bytes |
コンパイル時間 | 1,097 ms |
コンパイル使用メモリ | 117,124 KB |
実行使用メモリ | 26,696 KB |
最終ジャッジ日時 | 2024-07-01 00:11:45 |
合計ジャッジ時間 | 1,891 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; namespace _707 { class Program { static void Main(string[] args) { var line = Console.ReadLine().Split(' ').Select(int.Parse).ToList(); var h = line[0]; var w = line[1]; var blacks = new List<Tuple<int, int>>(); for (int x = 0; x < h; x++) { var row = Console.ReadLine().Select(ch => ch - '0').ToList(); for (int y = 0; y < w; y++) { if (row[y] == 1) { blacks.Add(Tuple.Create(x + 1, y + 1)); } } } var positions = Enumerable.Range(0, h + 2) .SelectMany(x => Enumerable.Range(0, w + 2).Select(y => Tuple.Create(x, y))) .Where(position => position.Item1 == 0 || position.Item2 == h + 1 || position.Item2 == 0 || position.Item2 == w + 1) .ToList(); var answer = positions.Min(position => { return blacks.Sum(black => { var x = Math.Pow((double)(position.Item1 - black.Item1), 2.0); var y = Math.Pow((double)(position.Item2 - black.Item2), 2.0); return Math.Sqrt(x + y); }); }); Console.WriteLine(Math.Round(answer, 8)); } } }