結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー ooooobaoooooba
提出日時 2021-09-21 22:54:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,536 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 117,312 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 12:48:13
合計ジャッジ時間 2,723 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0