結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー nanophoto12nanophoto12
提出日時 2014-11-03 01:41:51
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,687 bytes
コンパイル時間 2,005 ms
コンパイル使用メモリ 105,440 KB
実行使用メモリ 26,192 KB
最終ジャッジ日時 2023-08-29 00:25:47
合計ジャッジ時間 4,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 59 ms
22,248 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 60 ms
22,288 KB
testcase_05 AC 60 ms
22,476 KB
testcase_06 AC 57 ms
22,280 KB
testcase_07 AC 58 ms
22,408 KB
testcase_08 AC 58 ms
24,324 KB
testcase_09 AC 60 ms
22,384 KB
testcase_10 AC 59 ms
22,476 KB
testcase_11 WA -
testcase_12 AC 61 ms
22,472 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 59 ms
22,212 KB
testcase_16 WA -
testcase_17 AC 61 ms
22,252 KB
testcase_18 WA -
testcase_19 AC 61 ms
22,332 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Drawing;
using System.Linq;

class Program
{
    public static int DistanceSquare(Point first, Point second)
    {
        var dx = first.X - second.X;
        var dy = first.Y - second.Y;
        return dx*dx + dy*dy;
    }

    private static Point ToVector(Point first, Point second)
    {
        return new Point(second.X - first.X, second.Y - first.Y);
    }

    private static bool IsDiagnostic(Point firstVector, Point secondVector)
    {
        if (firstVector.X*secondVector.X + firstVector.Y*secondVector.Y == 0)
        {
            return true;
        }
        return false;
    }

    private static Point CreateFourth(Point opposite, Point lineStart, Point lineEnd)
    {
        var x = opposite.X + (lineStart.X + lineEnd.X)/2;
        var y = opposite.Y + (lineStart.Y + lineEnd.Y)/2;
        return new Point(x, y);
    }


    public static void Main(string[] args)
    {
        var values = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Point[] points = new Point[3];
        points[0] = new Point(values[0], values[1]);
        points[1] = new Point(values[2], values[3]);
        points[2] = new Point(values[4], values[5]);
        if (DistanceSquare(points[0], points[1]) == DistanceSquare(points[1], points[2]))
        {
            if (!IsDiagnostic(ToVector(points[1], points[0]), ToVector(points[2], points[1])))
            {
                Console.WriteLine(-1);
                return;                
            }
            var fourth = CreateFourth(points[1], points[0], points[2]);
            Console.WriteLine("{0} {1}", fourth.X, fourth.Y);
            return;

        }
        if (DistanceSquare(points[0], points[2]) != DistanceSquare(points[1], points[2]))
        {
            if (!IsDiagnostic(ToVector(points[2], points[0]), ToVector(points[2], points[1])))
            {
                Console.WriteLine(-1);
                return;
            }
            var fourth = CreateFourth(points[2], points[0], points[1]);
            Console.WriteLine("{0} {1}", fourth.X, fourth.Y);
            return;
        }
        if (DistanceSquare(points[0], points[1]) != DistanceSquare(points[0], points[2]))
        {
            if (!IsDiagnostic(ToVector(points[1], points[0]), ToVector(points[2], points[0])))
            {
                Console.WriteLine(-1);
                return;
            }
            var fourth = CreateFourth(points[0], points[2], points[1]);
            Console.WriteLine("{0} {1}", fourth.X, fourth.Y);
            return;
        }
        Console.WriteLine(-1);
    }
}
0