結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー atn112323
提出日時 2017-01-03 16:31:44
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 648 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 55,260 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-16 06:23:35
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int X1, Y1, X2, Y2, X3, Y3;

int dist2(int x1, int y1, int x2, int y2) {
	return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

int main() {
	cin >> X1 >> Y1 >> X2 >> Y2 >> X3 >> Y3;
	int d12 = dist2(X1, Y1, X2, Y2);
	int d23 = dist2(X2, Y2, X3, Y3);
	int d31 = dist2(X3, Y3, X1, Y1);
	if (d12 == d23 && d31 == d12 + d23) {
		swap(X1, X2); swap(Y1, Y2);
	} else if (d23 == d31 && d12 == d23 + d31) {
		swap(X1, X3); swap(Y1, Y3);
	} else if (d31 != d12 || d23 != d31 + d12) {
		cout << -1 << endl;
		return 0;
	}
	int X4 = X2 + X3 - X1, Y4 = Y2 + Y3 - Y1;
	cout << X4 << " " << Y4 << endl;
	return 0;
}
0