結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
コンテスト
ユーザー pillow
提出日時 2026-01-28 12:02:03
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 941 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,523 ms
コンパイル使用メモリ 333,880 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-01-28 12:02:10
合計ジャッジ時間 5,901 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int dis(int x1, int x2, int y1, int y2) {
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

pair<int, int> p(int x1, int y1, int x2, int y2, int x3, int y3) {
    return {x2 + x3 - x1, y2 + y3 - y1};
}

int main() {
    int x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    int d1 = dis(x1, x2, y1, y2);
    int d2 = dis(x1, x3, y1, y3);
    int d3 = dis(x2, x3, y2, y3);
    if (d1 == d2 && d1 + d2 == d3) {
        auto [x, y] = p(x1, y1, x2, y2, x3, y3);
        cout << x << ' ' << y << '\n';
        return 0;
    } else if (d1 == d3 && d1 + d3 == d2) {
        auto [x, y] = p(x2, y2, x1, y1, x3, y3);
        cout << x << ' ' << y << '\n';
        return 0;
    } else if (d2 == d3 && d2 + d3 == d1) {
        auto [x, y] = p(x3, y3, x1, y1, x2, y2);
        cout << x << ' ' << y << '\n';
        return 0;
    }
    cout << -1 << endl;
    return 0;
}
0