結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー motimoti
提出日時 2020-03-08 15:02:12
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 134,696 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-20 14:13:28
合計ジャッジ時間 2,726 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef complex<double> P;
#define rep(i,n) for(int i=0;i<n;i++)

bool cmp (P const& a, P const& b) {
  if(a.real() != b.real()) return a.real() < b.real();
  return a.imag() < b.imag();
}

int main() {
  
  P ps[3];
  int x, y;
  rep(i, 3) {
    cin >> x >> y;
    ps[i] = P(x, y);
  }
  
  int per[3]; rep(i, 3) per[i] = i;
  
  bool ok = 0;
  P ans;
  do {
    
    P v = ps[per[1]] - ps[per[0]];
    double len = abs(v);
    if(ps[per[1]] + v*P(0,1) != ps[per[2]]) continue;
    P p3 = ps[per[2]] + v*P(0,1)*P(0,1);
    if(ps[per[0]] != p3 + v*P(0,1)*P(0,1)*P(0,1)) continue;
    ok = 1;
    ans = p3;
    break;
    
  } while(next_permutation(per, per+3));
  
  if(ok) {
    cout << (int)ans.real() << " " << (int)ans.imag() << endl;
  }
  else {
    cout << -1 << endl;
  }
  
  return 0;
}
0