結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー chakkuchakku
提出日時 2016-03-16 03:00:30
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,153 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 67,664 KB
実行使用メモリ 6,940 KB
最終ジャッジ日時 2024-04-16 22:26:20
合計ジャッジ時間 1,355 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int x[3];
int y[3];

double dict(int a, int b, int c, int d){
	return sqrt((double)((a - c)*(a - c) + (b - d)*(b - d)));
}
double dict0(int xx, int yy){
	return dict(x[0], y[0], xx, yy);
}
double dict1(int xx, int yy){
	return dict(x[1], y[1], xx, yy);
}
double dict2(int xx, int yy){
	return dict(x[2], y[2], xx, yy);
}

#define EPS 0.0000000001

int main(){
	for (int i = 0; i < 3; i++) cin >> x[i] >> y[i];

	double d01 = dict0(x[1], y[1]);
	double d12 = dict1(x[2], y[2]);
	double d20 = dict2(x[0], y[0]);

	//cout << d01 << endl;
	//cout << d12 << endl;
	//cout << d20 << endl;

	if (d01 == d12){
		if (abs(d01*d01 + d12*d12 - d20*d20)>EPS){
			cout << -1 << endl;
			return 0;
		}
	}
	if (d12 == d20){
		if (abs(d12*d12 + d20*d20 - d01*d01)>EPS){
			cout << -1 << endl;
			return 0;
		}
	}
	if (d20 == d01){
		if (abs(d20*d20 + d01*d01 - d12*d12)>EPS){
			cout << d20*d20 + d01*d01 << endl;
			cout << d12 * d12 << endl;
			cout << -1 << endl;
			return 0;
		}
	}

	if (dict0(x[1], y[1]) == dict0(x[2], y[2])){
	//	cout << 0 << endl;
		double d = dict0(x[1], y[1]);
		for (int i = -200; i <= 200; i++) for (int j = -200; j <= 200; j++){
			if (dict(i, j, x[1], y[1]) == d && dict(i, j, x[2], y[2]) == d){
				if (i == x[0] && j == y[0]) continue;
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	else if (dict1(x[0], y[0]) == dict1(x[2], y[2])){
	//	cout << 1 << endl;
		double d = dict1(x[0], y[0]);
		for (int i = -200; i <= 200; i++) for (int j = -200; j <= 200; j++){
			if (dict(i, j, x[0], y[0]) == d && dict(i, j, x[2], y[2]) == d){
				if (i == x[1] && j == y[1])	continue;
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	else if (dict2(x[0], y[0]) == dict2(x[1], y[1])){
	//	cout << 2 << endl;
		double d = dict2(x[0], y[0]);
		for (int i = -200; i <= 200; i++) for (int j = -200; j <= 200; j++){
			if (dict(i, j, x[0], y[0]) == d && dict(i, j, x[1], y[1]) == d){
				if (i == x[2] && j == y[2]) continue;
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	else{
		cout << -1 << endl;
		return 0;
	}
}
0