結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー motxxmotxx
提出日時 2014-11-03 00:54:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 891 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 159,972 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 22:04:06
合計ジャッジ時間 2,291 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 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