結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー けーむけーむ
提出日時 2020-03-25 15:49:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,098 bytes
コンパイル時間 1,709 ms
コンパイル使用メモリ 174,020 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 11:41:48
合計ジャッジ時間 3,215 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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())

double f(pair<ll, ll> xy1, pair<ll, ll> xy2) {
    ll dx = xy1.first - xy2.first;
    ll dy = xy1.second - xy2.second;
    return sqrt(dx * dx + dy * dy);
}

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, -100, 101) {
        reps(y, -100, 101) {
            bool ng = false;
            rep(i, 3) {
                if ((xy[i].first == x) && (xy[i].second == y)) {
                    ng = true;
                    break;
                }
            }
            if (ng) continue;
            double d = -1;
            xy[3].first = x; xy[3].second = y;
            rep(i, 4) {
                map<double, ll> cnt;
                ll mv = 0;
                rep(j, 4) {
                    if (i == j) continue;
                    double p = f(xy[i], xy[j]);
                    cnt[p]++;
                    mv = max(mv, cnt[p]);
                }
                if (mv < 2) {
                    ng = true;
                    break;
                }
                for(auto x : cnt) {
                    if (x.second == mv) {
                        if (d == -1) {
                            d = x.first;
                        }
                        else if (d != x.first) {
                            ng = true;
                            break;
                        }
                    }
                }
            }
            if (!ng) {
                printf("%lld %lld\n", x, y);
                return 0;
            }
        }
    }
    printf("-1\n");
    return 0;
}
0