結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー koba-e964koba-e964
提出日時 2015-06-04 19:19:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,183 bytes
コンパイル時間 837 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 22:13:15
合計ジャッジ時間 1,633 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;



int main(void){
  int x1,y1,x2,y2,x3,y3;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  int d2 = x2 - x1,e2 = y2 - y1, d3 = x3 - x1, e3 = y3 - y1;
  if (d2 * d2 + e2 * e2 > d3 * d3 + e3 * e3) {
    swap(d2, d3);
    swap(e2, e3);
  }
  int n2 = d2 * d2 + e2 * e2;
  int n3 = d3 * d3 + e3 * e3;
  int x4 = x1, y4 = y1;
  bool ok = true;
  if (n2 < n3) {
    if (2 * n2 == n3 && d2 * d3 + e2 * e3 == n2) {
      x4 += d3 - d2;
      y4 += e3 - e2;
    } else {
      ok = false;
    }
  } else {
    if (n2 == n3 && d2 * d3 + e2 * e3 == 0) {
      x4 += d2 + d3;
      y4 += e2 + e3;
    } else {
      ok = false;
    }
  }
  if (ok) {
    cout << x4 << " " << y4 << endl;
  } else {
    cout << -1 << endl;
  }
}
0