結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー bal4ubal4u
提出日時 2019-05-13 21:55:40
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 607 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 28,568 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 16:49:51
合計ジャッジ時間 1,864 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,384 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 0 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 0 ms
4,376 KB
testcase_23 AC 0 ms
4,376 KB
testcase_24 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#include <stdio.h>

int x[5], y[5];

int dis2(int i, int j) {
	int dx = x[i]-x[j], dy = y[i]-y[j];
	return dx*dx + dy*dy;
}

int main()
{
	int i, a, b, dx, dy;

	for (i = 1; i <= 3; i++) scanf("%d%d", x+i, y+i);
	x[0] = x[3], y[0] = y[3], x[4] = x[1], y[4] = y[1];
	for (i = 1; i <= 3; i++) {
		a = dis2(i, i-1), b = dis2(i, i+1);
		if (a == b) break;
	}
	if (i > 3) goto NG;
	if (2*a != dis2(i-1, i+1)) goto NG;
	printf("%d %d\n", x[i-1]+x[i+1]-x[i], y[i-1]+y[i+1]-y[i]);
	return 0;
NG: puts("-1");
	return 0;
}
0