結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー | htensai |
提出日時 | 2019-12-30 13:23:00 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 158 ms / 5,000 ms |
コード長 | 1,333 bytes |
コンパイル時間 | 2,226 ms |
コンパイル使用メモリ | 79,580 KB |
実行使用メモリ | 55,184 KB |
最終ジャッジ日時 | 2024-04-25 15:51:40 |
合計ジャッジ時間 | 6,676 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 158 ms
54,720 KB |
testcase_01 | AC | 120 ms
53,836 KB |
testcase_02 | AC | 132 ms
54,404 KB |
testcase_03 | AC | 147 ms
54,756 KB |
testcase_04 | AC | 120 ms
53,876 KB |
testcase_05 | AC | 123 ms
54,056 KB |
testcase_06 | AC | 124 ms
53,996 KB |
testcase_07 | AC | 125 ms
54,256 KB |
testcase_08 | AC | 126 ms
54,220 KB |
testcase_09 | AC | 126 ms
54,260 KB |
testcase_10 | AC | 128 ms
54,108 KB |
testcase_11 | AC | 146 ms
55,184 KB |
testcase_12 | AC | 125 ms
54,268 KB |
testcase_13 | AC | 134 ms
54,536 KB |
testcase_14 | AC | 145 ms
55,104 KB |
testcase_15 | AC | 124 ms
53,904 KB |
testcase_16 | AC | 148 ms
55,008 KB |
testcase_17 | AC | 127 ms
54,536 KB |
testcase_18 | AC | 148 ms
55,080 KB |
testcase_19 | AC | 132 ms
54,152 KB |
testcase_20 | AC | 156 ms
54,824 KB |
testcase_21 | AC | 154 ms
55,152 KB |
testcase_22 | AC | 138 ms
54,600 KB |
testcase_23 | AC | 136 ms
54,744 KB |
testcase_24 | AC | 145 ms
54,888 KB |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Point p1 = new Point(sc.nextInt(), sc.nextInt()); Point p2 = new Point(sc.nextInt(), sc.nextInt()); Point p3 = new Point(sc.nextInt(), sc.nextInt()); int d1 = p2.getD(p3); int d2 = p3.getD(p1); int d3 = p1.getD(p2); Point p4; if (d1 == d2 && d1 * 2 == d3) { p4 = p3.getAnother(p1, p2); } else if (d2 == d3 && d2 * 2 == d1) { p4 = p1.getAnother(p2, p3); } else if (d3 == d1 && d3 * 2 == d2) { p4 = p2.getAnother(p3, p1); } else { System.out.println(-1); return; } System.out.println(p4); } static class Point { int x; int y; public Point(int x, int y) { this.x = x; this.y = y; } public int getD(Point another) { return (x - another.x) * (x - another.x) + (y - another.y) * (y - another.y); } public Point getAnother(Point p1, Point p2) { return new Point(p1.x + p2.x - x, p1.y + p2.y - y); } public String toString() { return x + " " + y; } } }