結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー HiroakiSoftware
提出日時 2014-11-03 01:09:19
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 2,062 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 23,424 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 16:42:34
合計ジャッジ時間 1,284 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 15 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d %d %d %d %d %d", &inPoint[0].X, &inPoint[0].Y, &inPoint[1].X, &inPoint[1].Y, &inPoint[2].X, &inPoint[2].Y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/*
yukicoder No.55(Ver1)
作成者:ヒロソフ
*/

#include <stdio.h>

struct  Point {
	int X;
	int Y;
};

int main(void) {
	Point inPoint[3];

	scanf("%d %d %d %d %d %d", &inPoint[0].X, &inPoint[0].Y, &inPoint[1].X, &inPoint[1].Y, &inPoint[2].X, &inPoint[2].Y);


	//ソート
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 2; j++) {
			if (inPoint[j].Y > inPoint[j + 1].Y) {
				Point pt = inPoint[j];
				inPoint[j] = inPoint[j + 1];
				inPoint[j + 1] = pt;
			}
		}
	}

	int lenp2[2];

	lenp2[0] = (inPoint[1].X - inPoint[0].X) * (inPoint[1].X - inPoint[0].X) + (inPoint[1].Y - inPoint[0].Y) * (inPoint[1].Y - inPoint[0].Y);
	lenp2[1] = (inPoint[1].X - inPoint[2].X) * (inPoint[1].X - inPoint[2].X) + (inPoint[1].Y - inPoint[2].Y) * (inPoint[1].Y - inPoint[2].Y);


	if (lenp2[0] != lenp2[1]) {
		
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 2; j++) {
				if (inPoint[j].X > inPoint[j + 1].X) {
					Point pt = inPoint[j];
					inPoint[j] = inPoint[j + 1];
					inPoint[j + 1] = pt;
				}
			}
		}

		lenp2[0] = (inPoint[1].X - inPoint[0].X) * (inPoint[1].X - inPoint[0].X) + (inPoint[1].Y - inPoint[0].Y) * (inPoint[1].Y - inPoint[0].Y);
		lenp2[1] = (inPoint[1].X - inPoint[2].X) * (inPoint[1].X - inPoint[2].X) + (inPoint[1].Y - inPoint[2].Y) * (inPoint[1].Y - inPoint[2].Y);

		if (lenp2[0] != lenp2[1]) {
			printf("-1\n");
		} else {
			Point pt_Center;
			pt_Center.X = (inPoint[0].X + inPoint[2].X) / 2;
			pt_Center.Y = (inPoint[0].Y + inPoint[2].Y) / 2;

			Point diff;
			diff.X = pt_Center.X - inPoint[1].X;
			diff.Y = pt_Center.Y - inPoint[1].Y;

			printf("%d %d\n", inPoint[1].X + 2 * diff.X, inPoint[1].Y + 2 * diff.Y);

		}
	} else {

		Point pt_Center;
		pt_Center.X = (inPoint[0].X + inPoint[2].X) / 2;
		pt_Center.Y = (inPoint[0].Y + inPoint[2].Y) / 2;

		Point diff;
		diff.X = pt_Center.X - inPoint[1].X;
		diff.Y = pt_Center.Y - inPoint[1].Y;

		printf("%d %d\n", inPoint[1].X + 2 * diff.X, inPoint[1].Y + 2 * diff.Y);

	}
	return 0;
}
0