結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー Mcpu3Mcpu3
提出日時 2019-03-15 15:11:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 894 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 71,824 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 12:16:15
合計ジャッジ時間 2,330 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
	double X1, Y1, X2, Y2, X3, Y3, i, j;
	cin >> X1 >> Y1 >> X2 >> Y2 >> X3 >> Y3;
	pair<double, double> tmp1 = minmax({ hypot(X1 - X2, Y1 - Y2), hypot(X1 - X3, Y1 - Y3), hypot(X2 - X3, Y2 - Y3) });
	for (i = -200.0; i <= 200.0; ++i) {
		for (j = -200.0; j <= 200.0; ++j) {
			int tmp2 = 0, tmp3 = 0;
			if (hypot(X1 - i, Y1 - j) == tmp1.first) ++tmp2;
			else if (hypot(X1 - i, Y1 - j) == tmp1.second) ++tmp3;
			if (hypot(X2 - i, Y2 - j) == tmp1.first) ++tmp2;
			else if (hypot(X2 - i, Y2 - j) == tmp1.second) ++tmp3;
			if (hypot(X3 - i, Y3 - j) == tmp1.first) ++tmp2;
			else if (hypot(X3 - i, Y3 - j) == tmp1.second) ++tmp3;
			if (tmp2 == 2 && tmp3 == 1) break;
		}
		if (j != 201.0) break;
	}
	if (i != 201.0) cout << i << ' ' << j;
	else cout << -1;
}
0