結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
4,380 KB
testcase_01 AC 41 ms
4,376 KB
testcase_02 AC 18 ms
4,380 KB
testcase_03 AC 19 ms
4,376 KB
testcase_04 AC 35 ms
4,380 KB
testcase_05 AC 41 ms
4,376 KB
testcase_06 AC 40 ms
4,376 KB
testcase_07 AC 41 ms
4,376 KB
testcase_08 AC 41 ms
4,380 KB
testcase_09 AC 42 ms
4,376 KB
testcase_10 AC 41 ms
4,376 KB
testcase_11 AC 11 ms
4,376 KB
testcase_12 AC 35 ms
4,376 KB
testcase_13 AC 27 ms
4,376 KB
testcase_14 AC 19 ms
4,376 KB
testcase_15 AC 39 ms
4,380 KB
testcase_16 AC 19 ms
4,380 KB
testcase_17 AC 35 ms
4,376 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 41 ms
4,380 KB
testcase_20 AC 18 ms
4,376 KB
testcase_21 AC 18 ms
4,380 KB
testcase_22 AC 35 ms
4,380 KB
testcase_23 AC 23 ms
4,376 KB
testcase_24 AC 10 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));
}

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