結果

問題 No.455 冬の大三角
ユーザー qazqaz
提出日時 2017-05-20 13:10:48
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 2,111 bytes
コンパイル時間 2,567 ms
コンパイル使用メモリ 109,608 KB
実行使用メモリ 23,864 KB
最終ジャッジ日時 2023-09-12 12:53:03
合計ジャッジ時間 9,706 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
21,720 KB
testcase_01 AC 72 ms
21,756 KB
testcase_02 AC 73 ms
21,608 KB
testcase_03 AC 70 ms
21,724 KB
testcase_04 AC 72 ms
23,836 KB
testcase_05 AC 72 ms
23,720 KB
testcase_06 AC 71 ms
21,660 KB
testcase_07 AC 72 ms
23,776 KB
testcase_08 AC 95 ms
21,696 KB
testcase_09 AC 71 ms
21,660 KB
testcase_10 AC 72 ms
21,660 KB
testcase_11 AC 72 ms
21,872 KB
testcase_12 AC 71 ms
23,768 KB
testcase_13 AC 72 ms
21,816 KB
testcase_14 AC 67 ms
21,580 KB
testcase_15 AC 71 ms
23,852 KB
testcase_16 AC 72 ms
23,864 KB
testcase_17 AC 71 ms
23,808 KB
testcase_18 AC 70 ms
23,672 KB
testcase_19 AC 71 ms
21,908 KB
testcase_20 AC 73 ms
23,768 KB
testcase_21 AC 73 ms
19,764 KB
testcase_22 AC 71 ms
21,720 KB
testcase_23 AC 72 ms
21,828 KB
testcase_24 AC 73 ms
19,720 KB
testcase_25 AC 72 ms
21,800 KB
testcase_26 AC 72 ms
21,804 KB
testcase_27 AC 69 ms
21,644 KB
testcase_28 AC 68 ms
21,776 KB
testcase_29 AC 88 ms
21,744 KB
testcase_30 AC 83 ms
21,772 KB
testcase_31 AC 79 ms
21,872 KB
testcase_32 AC 78 ms
21,692 KB
testcase_33 AC 94 ms
21,888 KB
testcase_34 AC 72 ms
21,728 KB
testcase_35 AC 84 ms
23,716 KB
testcase_36 AC 81 ms
21,696 KB
testcase_37 AC 78 ms
21,824 KB
testcase_38 AC 76 ms
21,720 KB
testcase_39 AC 90 ms
23,756 KB
testcase_40 AC 83 ms
19,628 KB
testcase_41 AC 83 ms
21,780 KB
testcase_42 AC 80 ms
21,672 KB
testcase_43 AC 75 ms
21,844 KB
testcase_44 AC 76 ms
21,772 KB
testcase_45 AC 87 ms
21,620 KB
testcase_46 AC 82 ms
23,820 KB
testcase_47 AC 80 ms
23,772 KB
testcase_48 AC 77 ms
21,716 KB
testcase_49 AC 72 ms
21,676 KB
testcase_50 AC 71 ms
21,724 KB
testcase_51 AC 72 ms
21,736 KB
testcase_52 AC 72 ms
21,864 KB
testcase_53 AC 74 ms
21,716 KB
testcase_54 AC 73 ms
21,744 KB
testcase_55 AC 76 ms
23,712 KB
testcase_56 AC 76 ms
23,728 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++) {
            string line = Console.ReadLine();
            foreach(var c in line.Select((x, j) => new { x, j })) {
                if( c.x == '*') {
                    maps.Map.Add(new Map { H = i, W = c.j });
                }
            }
        }

        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