結果

問題 No.707 書道
ユーザー バカらっく
提出日時 2018-07-01 11:45:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 2,318 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 116,044 KB
実行使用メモリ 28,608 KB
最終ジャッジ日時 2024-07-01 01:08:51
合計ジャッジ時間 1,929 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
プレゼンテーションモードにする

using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program
{
public void Proc()
{
int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
int h = inpt[0];
int w = inpt[1];
bool[,] map = new bool[h, w];
for (int i = 0; i < h; i++) {
bool[] row = Reader.ReadLine().Select(a => a == '1').ToArray();
for (int j = 0; j < row.Length; j++) {
map[i, j] = row[j];
}
}
for (int i = 0; i < w; i++) {
this.Min = Math.Min(this.Min, GetCost(0, i + 1, map));
this.Min = Math.Min(this.Min, GetCost(h + 1, i + 1, map));
}
for (int i = 0; i < h; i++) {
this.Min = Math.Min(this.Min, GetCost(i + 1, 0, map));
this.Min = Math.Min(this.Min, GetCost(i + 1, w + 1, map));
}
Console.WriteLine(this.Min);
}
private double Min = double.MaxValue;
private double GetCost(int h, int w, bool[,] map) {
double ret = 0;
for (int i = 0; i < map.GetLength(0); i++) {
for (int j = 0; j < map.GetLength(1); j++) {
if(!map[i,j]) {
continue;
}
ret += Math.Sqrt(Math.Pow(Math.Abs(h - (i + 1)), 2) + Math.Pow(Math.Abs(w - (j + 1)), 2));
if(ret > Min) {
break;
}
}
if(ret > this.Min) {
break;
}
}
return ret;
}
public class Reader
{
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine()
{
if (IsDebug)
{
if (sr == null)
{
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
private static string InputText = @"
1 1
1
";
}
public static void Main(string[] args)
{
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0