結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー けーむけーむ
提出日時 2020-03-25 16:22:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 1,846 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 172,900 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-30 11:42:36
合計ジャッジ時間 3,291 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

// template<class T>
// bool is_square(const vector<pair<T, T>> &xy) {
//     map<T, int> m;
//     for(int i = 0; i < 4; i++) {
//         for(int j = i + 1; j < 4; j++) {
//             T dx = xy[i].first - xy[j].first;
//             T dy = xy[i].second - xy[j].second;
//             m[dx * dx + dy * dy]++;
//         }
//     }
//     T l = m.begin()->first;
//     if (l == 0) return false;
//     return ((m[l] == 4) && (m[l * 2] == 2));
// }

template<class T>
bool is_square(const vector<pair<T, T>> &xy) {
    vector<T> v;
    for(int i = 0; i < 4; i++) {
        for(int j = i + 1; j < 4; j++) {
            T dx = xy[i].first - xy[j].first;
            T dy = xy[i].second - xy[j].second;
            v.push_back(dx * dx + dy * dy);
        }
    }
    sort(v.begin(), v.end());
    T l = v[0];
    if (l == 0) return false;
    return ((v[0] == l) && (v[1] == l) && (v[2] == l) && (v[3] == l) && (v[4] == l * 2) && (v[5] == l * 2));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    vector<pair<ll, ll>> xy(4);
    rep(i, 3) cin >> xy[i].first >> xy[i].second;
    reps(x, -200, 201) {
        reps(y, -200, 201) {
            xy[3].first = x; xy[3].second = y;
            if (is_square(xy)) {
                printf("%lld %lld\n", x, y);
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}
0