結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー sugim48sugim48
提出日時 2014-11-03 00:22:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 576 ms / 5,000 ms
コード長 1,404 bytes
コンパイル時間 1,329 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 07:19:18
合計ジャッジ時間 12,821 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 281 ms
4,376 KB
testcase_01 AC 567 ms
4,380 KB
testcase_02 AC 274 ms
4,376 KB
testcase_03 AC 286 ms
4,376 KB
testcase_04 AC 567 ms
4,376 KB
testcase_05 AC 561 ms
4,376 KB
testcase_06 AC 557 ms
4,376 KB
testcase_07 AC 564 ms
4,376 KB
testcase_08 AC 576 ms
4,376 KB
testcase_09 AC 544 ms
4,380 KB
testcase_10 AC 534 ms
4,376 KB
testcase_11 AC 257 ms
4,376 KB
testcase_12 AC 540 ms
4,376 KB
testcase_13 AC 298 ms
4,380 KB
testcase_14 AC 265 ms
4,376 KB
testcase_15 AC 574 ms
4,380 KB
testcase_16 AC 274 ms
4,380 KB
testcase_17 AC 561 ms
4,376 KB
testcase_18 AC 252 ms
4,384 KB
testcase_19 AC 556 ms
4,380 KB
testcase_20 AC 276 ms
4,376 KB
testcase_21 AC 280 ms
4,376 KB
testcase_22 AC 336 ms
4,376 KB
testcase_23 AC 294 ms
4,376 KB
testcase_24 AC 251 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; double w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
ll MOD2 = 1LL << 32;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

bool check(vector<int>& x, vector<int>& y) {
	vector<int> v;
	for (int i = 0; i < 4; i++)
		for (int j = i + 1; j < 4; j++) {
			int dx = x[i] - x[j], dy = y[i] - y[j];
			v.push_back(dx * dx + dy * dy);
		}
	sort(v.begin(), v.end());
	int l = v[0];
	if (l == 0) return false; // 点が重なる
	return v[0]==l && v[1]==l && v[2]==l && v[3]==l && v[4]==l*2 && v[5]==l*2;
}

int main() {
	vector<int> X(4), Y(4);
	for (int i = 0; i < 3; i++) cin >> X[i] >> Y[i];
	for (int x = -1000; x <= 1000; x++)
		for (int y = -1000; y <= 1000; y++) {
			X[3] = x; Y[3] = y;
			if (check(X, Y)) {
				cout << x << ' ' << y << endl;
				return 0;
			}
		}
	cout << -1 << endl;
}
0