結果
問題 |
No.455 冬の大三角
|
ユーザー |
|
提出日時 | 2017-05-20 12:57:53 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,925 bytes |
コンパイル時間 | 797 ms |
コンパイル使用メモリ | 115,140 KB |
実行使用メモリ | 27,408 KB |
最終ジャッジ日時 | 2024-09-19 00:26:58 |
合計ジャッジ時間 | 4,201 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 WA * 10 |
コンパイルメッセージ
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; public class Program { public static void Main() { var data = Console.ReadLine().Split(' '); int H = int.Parse(data[0]); int W = int.Parse(data[1]); var maps = new Maps(); for (int i = 0; i < H; i++) { int w = Console.ReadLine().IndexOf('*'); if (w >= 0) { maps.Map.Add(new Map { H = i, W = w }); } } var map = maps.Search(H, W); if (map != null) { maps.Map.Add(map); } for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (maps.Map.Any(x => x.H == i && x.W == j)) { Console.Write("*"); } else { Console.Write("-"); } } Console.WriteLine(); } } } public class Maps { public List<Map> Map { get; set; } public Maps() { Map = new List<Map>(); } public Map Search(int H, int W) { for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (IsConfirm(i, j)) { return new Map { H = i, W = j }; } } } return null; } public bool IsConfirm(int h, int w) { var slope = new List<string>(); foreach (var item in Map) { slope.Add(GetSlope(item, h, w)); } return slope.Count() == slope.Distinct().Count(); } public string GetSlope(Map map, int hh, int ww) { decimal h = map.H - hh; decimal w = map.W - ww; if (w == 0) { return "∞"; } if (h == 0) { return "0"; } return (h / w).ToString(); } } public class Map { public int H { get; set; } public int W { get; set; } }