結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー woodsgreenwoodsgreen
提出日時 2022-01-11 18:20:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 972 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 195,340 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 20:43:26
合計ジャッジ時間 2,961 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//
#include <bits/stdc++.h>
using namespace std;
int p[3][2],a[6][3]={{0,1,2},{0,2,1},{1,0,2},{1,2,0},{2,0,1},{2,1,0}};
double dis(int x,int y,int p,int q){
    return sqrt((x-p)*(x-p)+(y-q)*(y-q));
}
int main(){
//    freopen("aa.in","r",stdin);
//    freopen("aa.out","w",stdout);
    for(int i=0;i<3;++i) cin>>p[i][0]>>p[i][1];
    for(int i=0;i<6;++i){
        // d1: p0~p1, d2: p1~p2, d3: p0~p2
        double d1=dis(p[a[i][0]][0],p[a[i][0]][1],p[a[i][1]][0],p[a[i][1]][1]);
        double d2=dis(p[a[i][1]][0],p[a[i][1]][1],p[a[i][2]][0],p[a[i][2]][1]);
        double d3=dis(p[a[i][0]][0],p[a[i][0]][1],p[a[i][2]][0],p[a[i][2]][1]);
        // p1ΪֱǶ
        if(fabs(d1-d2)<1e-6&&fabs(d1*d1+d2*d2-d3*d3)<1e-6){
            int x=p[a[i][0]][0]+p[a[i][2]][0]-p[a[i][1]][0];
            int y=p[a[i][0]][1]+p[a[i][2]][1]-p[a[i][1]][1];
            cout<<x<<" "<<y;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

0