結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー MayimgMayimg
提出日時 2019-01-15 23:31:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 776 bytes
コンパイル時間 1,708 ms
コンパイル使用メモリ 170,176 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 14:51:39
合計ジャッジ時間 3,341 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
bool is_rectangle(pair<int, int> a[4]) {
	vector<int> x;
	for(int i = 0; i < 4; i++) {
		for(int j = i + 1; j < 4; j++) {
			int s = (a[i].first - a[j].first);
			int t = (a[i].second - a[j].second);
			x.push_back(s * s + t * t);
		}
	}
	sort(x.begin(), x.end());
	return x[0] == x[3] && x[4] == x[5] && x[0] * 2 == x[5];
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	pair<int, int> a[4];
	for(int i = 0; i < 3; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for(int i = -200; i <= 200; i++) {
		for(int j = -200; j <= 200; j++) {
			a[3].first = i;
			a[3].second = j;
			if(is_rectangle(a)) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;	
}
0