結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー kk
提出日時 2020-07-17 17:05:17
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 176 ms / 5,000 ms
コード長 1,047 bytes
コンパイル時間 2,360 ms
コンパイル使用メモリ 206,692 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 10:02:49
合計ジャッジ時間 7,179 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
4,376 KB
testcase_01 AC 171 ms
4,380 KB
testcase_02 AC 86 ms
4,376 KB
testcase_03 AC 89 ms
4,376 KB
testcase_04 AC 172 ms
4,384 KB
testcase_05 AC 173 ms
4,376 KB
testcase_06 AC 174 ms
4,380 KB
testcase_07 AC 176 ms
4,376 KB
testcase_08 AC 173 ms
4,376 KB
testcase_09 AC 170 ms
4,380 KB
testcase_10 AC 170 ms
4,380 KB
testcase_11 AC 73 ms
4,376 KB
testcase_12 AC 169 ms
4,376 KB
testcase_13 AC 104 ms
4,380 KB
testcase_14 AC 85 ms
4,380 KB
testcase_15 AC 172 ms
4,376 KB
testcase_16 AC 87 ms
4,376 KB
testcase_17 AC 170 ms
4,380 KB
testcase_18 AC 70 ms
4,376 KB
testcase_19 AC 170 ms
4,376 KB
testcase_20 AC 86 ms
4,380 KB
testcase_21 AC 84 ms
4,380 KB
testcase_22 AC 119 ms
4,380 KB
testcase_23 AC 94 ms
4,380 KB
testcase_24 AC 69 ms
4,380 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