結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kk
提出日時 2020-07-17 17:05:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 5,000 ms
コード長 1,047 bytes
コンパイル時間 2,602 ms
コンパイル使用メモリ 210,568 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 17:16:51
合計ジャッジ時間 6,541 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
5,248 KB
testcase_01 AC 167 ms
5,376 KB
testcase_02 AC 83 ms
5,376 KB
testcase_03 AC 86 ms
5,376 KB
testcase_04 AC 169 ms
5,376 KB
testcase_05 AC 167 ms
5,376 KB
testcase_06 AC 168 ms
5,376 KB
testcase_07 AC 169 ms
5,376 KB
testcase_08 AC 167 ms
5,376 KB
testcase_09 AC 164 ms
5,376 KB
testcase_10 AC 164 ms
5,376 KB
testcase_11 AC 71 ms
5,376 KB
testcase_12 AC 164 ms
5,376 KB
testcase_13 AC 100 ms
5,376 KB
testcase_14 AC 83 ms
5,376 KB
testcase_15 AC 168 ms
5,376 KB
testcase_16 AC 83 ms
5,376 KB
testcase_17 AC 163 ms
5,376 KB
testcase_18 AC 69 ms
5,376 KB
testcase_19 AC 165 ms
5,376 KB
testcase_20 AC 83 ms
5,376 KB
testcase_21 AC 80 ms
5,376 KB
testcase_22 AC 115 ms
5,376 KB
testcase_23 AC 91 ms
5,376 KB
testcase_24 AC 66 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);
double EPS = 1e-9;

bool check(vector<pair<int, int> > ps) {

  vector<int> dist;
  REP (i, 4) REP (j, i) {
    int x = ps[i].first - ps[j].first;
    int y = ps[i].second - ps[j].second;
    dist.push_back(x * x + y * y);
  }

  sort(dist.begin(), dist.end());

  return dist[1] == dist[0] && dist[2] == dist[0] && dist[3] == dist[0] && dist[4] == 2 * dist[0] && dist[5] == 2 * dist[0];
}


int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  vector<pair<int, int> > ps;
  REP (i, 3) {
    int x, y;
    cin >> x >> y;
    ps.emplace_back(x, y);
  }

  for (int x = -500; x <= 500; x++) {
    for (int y = -500; y <= 500; y++) {
      ps.emplace_back(x, y);
      if (check(ps)) {
        cout << x << " " << y << endl;
        return 0;
      }
      ps.pop_back();
    }
  }

  cout << -1 << endl;
  
  return 0;
}
0