結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー なおなお
提出日時 2014-11-03 01:43:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 995 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 160,524 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 22:04:35
合計ジャッジ時間 2,071 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define X real()
#define Y imag()
typedef int D;
typedef complex<D> P;

int norm(P p1, P p2){
    return (p1.X-p2.X)*(p1.X-p2.X)+(p1.Y-p2.Y)*(p1.Y-p2.Y);
}
inline D inprd(const P &a, const P &b){ return (conj(a) * b).X; }

int main(){
    P p[4];
    for(int i = 0; i < 3; i++){
        int x,y;
        cin >> x >> y;
        p[i] = P(x,y);
    }
    int ci = -1;
    int n[2];
    // 中間点の判定
    for(int i = 0; i < 3; i++){
        int k = 0;
        for(int j = 0; j < 3; j++){
            if(i == j) continue;
            n[k++] = norm(p[i],p[j]);
        }
        if(n[0]==n[1]) ci = i;
    }
    if(ci < 0){
        cout << -1 << endl; return 0;
    }
    swap(p[0], p[ci]);
    if(inprd(p[0]-p[1],p[0]-p[2]) != 0){
        cout << -1 << endl; return 0;
    }
    int x = p[1].X + p[2].X - p[0].X;
    int y = p[1].Y + p[2].Y - p[0].Y;
    cout << x << " " << y << endl;

    return 0;
}
0