結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー | nanophoto12 |
提出日時 | 2014-11-03 01:50:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 29 ms / 5,000 ms |
コード長 | 3,058 bytes |
コンパイル時間 | 2,404 ms |
コンパイル使用メモリ | 116,144 KB |
実行使用メモリ | 27,144 KB |
最終ジャッジ日時 | 2024-11-14 13:42:11 |
合計ジャッジ時間 | 2,545 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
24,816 KB |
testcase_01 | AC | 28 ms
24,880 KB |
testcase_02 | AC | 28 ms
27,012 KB |
testcase_03 | AC | 29 ms
25,132 KB |
testcase_04 | AC | 29 ms
24,940 KB |
testcase_05 | AC | 27 ms
25,096 KB |
testcase_06 | AC | 28 ms
26,888 KB |
testcase_07 | AC | 28 ms
24,880 KB |
testcase_08 | AC | 29 ms
25,196 KB |
testcase_09 | AC | 29 ms
25,008 KB |
testcase_10 | AC | 27 ms
25,132 KB |
testcase_11 | AC | 29 ms
22,840 KB |
testcase_12 | AC | 28 ms
25,204 KB |
testcase_13 | AC | 27 ms
22,704 KB |
testcase_14 | AC | 29 ms
25,200 KB |
testcase_15 | AC | 29 ms
25,068 KB |
testcase_16 | AC | 28 ms
27,020 KB |
testcase_17 | AC | 28 ms
27,144 KB |
testcase_18 | AC | 28 ms
26,892 KB |
testcase_19 | AC | 28 ms
27,140 KB |
testcase_20 | AC | 29 ms
24,944 KB |
testcase_21 | AC | 29 ms
24,940 KB |
testcase_22 | AC | 28 ms
24,944 KB |
testcase_23 | AC | 29 ms
27,144 KB |
testcase_24 | AC | 29 ms
25,068 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; class Program { public class Point { private readonly int _x; private readonly int _y; public Point(int x, int y) { _x = x; _y = y; } public int X { get { return _x; } } public int Y { get { return _y; } } } 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) - opposite.X * 2); var y = opposite.Y + ((lineStart.Y + lineEnd.Y) - opposite.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); } }