結果
| 問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-21 22:54:55 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,536 bytes |
| コンパイル時間 | 1,323 ms |
| コンパイル使用メモリ | 112,188 KB |
| 最終ジャッジ日時 | 2025-01-24 16:11:14 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std; // NOLINT
int main() {
int32_t x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
auto d12 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
auto d23 = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);
auto d31 = (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1);
int32_t d;
if (d12 == d23) {
swap(x1, x2);
swap(y1, y2);
d = d12;
} else if (d12 == d31) {
d = d12;
} else if (d23 == d31) {
swap(x1, x3);
swap(y1, y3);
d = d23;
} else {
cout << -1 << endl;
return 0;
}
auto cx21 = x2 - x1, cy21 = y2 - y1;
auto cx31 = x3 - x1, cy31 = y3 - y1;
if (cx21 * cx31 + cy21 * cy31 != 0) {
cout << -1 << endl;
return 0;
}
for (auto x = -500; x <= 500; ++x) {
for (auto y = -500; y <= 500; ++y) {
if (x == x1 && y == y1)
continue;
auto d42 = (x - x2) * (x - x2) + (y - y2) * (y - y2);
auto d43 = (x - x3) * (x - x3) + (y - y3) * (y - y3);
if (d42 == d && d43 == d) {
cout << x << " " << y << endl;
return 0;
}
}
}
cout << -1 << endl;
return 0;
}