結果

問題 No.455 冬の大三角
ユーザー qazqaz
提出日時 2017-05-20 13:03:29
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,018 bytes
コンパイル時間 970 ms
コンパイル使用メモリ 111,836 KB
実行使用メモリ 25,592 KB
最終ジャッジ日時 2023-10-19 04:11:20
合計ジャッジ時間 5,185 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
25,580 KB
testcase_01 AC 33 ms
25,580 KB
testcase_02 AC 34 ms
25,588 KB
testcase_03 AC 33 ms
25,580 KB
testcase_04 WA -
testcase_05 AC 32 ms
25,592 KB
testcase_06 WA -
testcase_07 AC 33 ms
25,572 KB
testcase_08 AC 57 ms
25,592 KB
testcase_09 AC 33 ms
25,580 KB
testcase_10 WA -
testcase_11 AC 33 ms
25,580 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 33 ms
25,560 KB
testcase_15 AC 33 ms
25,580 KB
testcase_16 AC 32 ms
25,580 KB
testcase_17 AC 32 ms
25,572 KB
testcase_18 AC 33 ms
25,580 KB
testcase_19 WA -
testcase_20 AC 35 ms
25,572 KB
testcase_21 AC 35 ms
25,580 KB
testcase_22 WA -
testcase_23 AC 33 ms
25,580 KB
testcase_24 WA -
testcase_25 AC 33 ms
25,580 KB
testcase_26 AC 33 ms
25,580 KB
testcase_27 AC 31 ms
25,560 KB
testcase_28 AC 32 ms
25,560 KB
testcase_29 AC 49 ms
25,592 KB
testcase_30 AC 44 ms
25,592 KB
testcase_31 AC 41 ms
25,592 KB
testcase_32 AC 39 ms
25,592 KB
testcase_33 AC 54 ms
25,592 KB
testcase_34 AC 34 ms
25,580 KB
testcase_35 AC 45 ms
25,592 KB
testcase_36 AC 43 ms
25,592 KB
testcase_37 AC 38 ms
25,592 KB
testcase_38 AC 37 ms
25,592 KB
testcase_39 AC 51 ms
25,592 KB
testcase_40 AC 46 ms
25,592 KB
testcase_41 AC 42 ms
25,592 KB
testcase_42 AC 40 ms
25,592 KB
testcase_43 AC 35 ms
25,584 KB
testcase_44 AC 35 ms
25,592 KB
testcase_45 AC 48 ms
25,592 KB
testcase_46 AC 43 ms
25,592 KB
testcase_47 AC 40 ms
25,592 KB
testcase_48 AC 38 ms
25,592 KB
testcase_49 AC 32 ms
25,580 KB
testcase_50 AC 33 ms
25,580 KB
testcase_51 AC 33 ms
25,580 KB
testcase_52 AC 34 ms
25,576 KB
testcase_53 AC 34 ms
25,580 KB
testcase_54 AC 33 ms
25,580 KB
testcase_55 AC 35 ms
25,584 KB
testcase_56 AC 34 ms
25,580 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.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() && !slope.Any(x => x == "");
    }

    public string GetSlope(Map map, int hh, int ww) {
        decimal h = map.H - hh;
        decimal w = map.W - ww;

        if(h == 0 && w == 0) {
            return "";
        }

        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; }
}
0