結果
| 問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
t8m8⛄️
|
| 提出日時 | 2015-04-16 21:51:06 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 160 ms / 5,000 ms |
| コード長 | 1,880 bytes |
| コンパイル時間 | 4,011 ms |
| コンパイル使用メモリ | 81,692 KB |
| 実行使用メモリ | 55,476 KB |
| 最終ジャッジ日時 | 2024-11-14 13:49:15 |
| 合計ジャッジ時間 | 8,625 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
//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));}
}
t8m8⛄️