結果

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

テストケース

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

ソースコード

diff #

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

typedef pair<int,int> P;

bool check(P p[4]){
    set<vector<int> > s;
    for(int i = 0; i < 4; i++){
        vector<int> v;
        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;
            v.push_back(d);
        }
        sort(v.begin(), v.end());
        if(v[0] != v[1] && v[1] != v[2]) return false;
        s.insert(v);
    }
    return (s.size() == 1);
}

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 = -200; y <= 200; y++){
        for(int x = -200; x <= 200; x++){
            p[3] = P(x,y);
            if(check(p)){
                cout << x << " " << y << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}
0