結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー なおなお
提出日時 2014-11-03 01:04:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 149,676 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-29 00:25:18
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
4,376 KB
testcase_01 AC 36 ms
4,376 KB
testcase_02 AC 19 ms
4,380 KB
testcase_03 AC 18 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 33 ms
4,380 KB
testcase_06 AC 34 ms
4,376 KB
testcase_07 AC 34 ms
4,380 KB
testcase_08 AC 35 ms
4,376 KB
testcase_09 AC 35 ms
4,376 KB
testcase_10 AC 35 ms
4,376 KB
testcase_11 AC 14 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 24 ms
4,376 KB
testcase_14 AC 11 ms
4,380 KB
testcase_15 AC 34 ms
4,376 KB
testcase_16 AC 47 ms
4,380 KB
testcase_17 AC 35 ms
4,376 KB
testcase_18 AC 13 ms
4,376 KB
testcase_19 AC 35 ms
4,384 KB
testcase_20 AC 29 ms
4,380 KB
testcase_21 AC 27 ms
4,376 KB
testcase_22 AC 19 ms
4,380 KB
testcase_23 AC 30 ms
4,376 KB
testcase_24 AC 13 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef pair<int,int> P;

bool check(P p[4]){
    for(int i = 0; i < 4; i++){
        set<int> s;
        for(int j = 0; j < 4; j++){
            if(i == j) continue;
            int mx = p[i].first - p[j].first, my = p[i].second - p[j].second;
            int d = mx*mx+my*my;
            if(d == 0) return false;
            s.insert(d);
        }
        if(s.size() != 2) return false;
    }
    return true;
}

int main(){
    P p[4];
    for(int i = 0; i < 3; i++){
        int x,y;
        cin >> x >> y;
        p[i] = P(x,y);
    }
    for(int y = -300; y <= 300; y++){
        for(int x = -300; x <= 300; x++){
            p[3] = P(x,y);
            if(check(p)){
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}
0