結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー hotpepsi
提出日時 2015-07-14 23:37:11
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 661 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 57,448 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 13:50:36
合計ジャッジ時間 1,255 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>

using namespace std;

int x[4], y[4];

bool check(int a, int b, int c) {
	int vbx = x[b] - x[a];
	int vby = y[b] - y[a];
	int vcx = x[c] - x[a];
	int vcy = y[c] - y[a];
	if (vbx * vcx + vby * vcy) {
		return false;
	}
	if ((vbx * vbx + vby * vby) != (vcx * vcx + vcy * vcy)) {
		return false;
	}
	x[3] = x[a] + vbx + vcx;
	y[3] = y[a] + vby + vcy;
	return true;
}

int main(int argc, char *argv[])
{
	cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];
	if (check(0, 1, 2) || check(1, 0, 2) || check(2, 0, 1)) {
		cout << x[3] << " " << y[3] << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}
0