結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-04-16 21:51:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 158 ms / 5,000 ms
コード長 1,880 bytes
コンパイル時間 3,937 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 42,584 KB
最終ジャッジ日時 2024-04-26 22:12:12
合計ジャッジ時間 8,409 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
42,216 KB
testcase_01 AC 130 ms
41,284 KB
testcase_02 AC 151 ms
42,272 KB
testcase_03 AC 158 ms
42,320 KB
testcase_04 AC 130 ms
41,252 KB
testcase_05 AC 131 ms
41,164 KB
testcase_06 AC 130 ms
41,040 KB
testcase_07 AC 131 ms
41,316 KB
testcase_08 AC 128 ms
41,176 KB
testcase_09 AC 131 ms
41,308 KB
testcase_10 AC 129 ms
41,116 KB
testcase_11 AC 157 ms
42,532 KB
testcase_12 AC 128 ms
41,196 KB
testcase_13 AC 144 ms
41,940 KB
testcase_14 AC 158 ms
42,520 KB
testcase_15 AC 117 ms
40,188 KB
testcase_16 AC 155 ms
42,436 KB
testcase_17 AC 134 ms
41,424 KB
testcase_18 AC 140 ms
41,760 KB
testcase_19 AC 129 ms
41,220 KB
testcase_20 AC 142 ms
41,984 KB
testcase_21 AC 157 ms
42,584 KB
testcase_22 AC 157 ms
42,452 KB
testcase_23 AC 143 ms
42,184 KB
testcase_24 AC 138 ms
41,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//No.55 正方形を描くだけの簡単なお仕事です。

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No55 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int[] x = new int[3];
        int[] y = new int[3];
        for (int i=0; i<3; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
        }
        int[] tx = new int[4];
        int[] ty = new int[4];
        int[] d = {0,1,2};
        do {
            for (int i=0; i<3; i++) {
                tx[i] = x[d[i]];
                ty[i] = y[d[i]];
            }
            int dx = tx[1] - tx[0];
            int dy = ty[1] - ty[0];
            if (tx[1] - dy != tx[2] || ty[1] + dx != ty[2]) continue;
            tx[3] = tx[2] - dx;
            ty[3] = ty[2] - dy;
            if (tx[3] + dy != tx[0] || ty[3] - dx != ty[0]) continue;
            out.println(tx[3]+" "+ty[3]);
            return;

        }while(nextPermutation(d));
        out.println("-1");
    }

    static boolean nextPermutation(int[] a) {
        int n = a.length, i, j;
        for (i=n-2; i>=0 && a[i]>=a[i+1]; i--);
        if (i == -1) return false;
        for (j=i+1; j<n && a[i]<a[j]; j++);
        int temp = a[i]; a[i] = a[j-1]; a[j-1] = temp;
        for (int l=i+1, r=n-1; l<r; l++,r--) {
            temp = a[l]; a[l] = a[r]; a[r] = temp;
        }
        return true;
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        in.close();
        out.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0