結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー nenuonnenuon
提出日時 2017-06-28 11:41:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,286 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 90,752 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 04:00:56
合計ジャッジ時間 1,552 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

double d(double x1, double y1, double x2, double y2) {
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(){
  double x[3], y[3];
  FOR (i,0,3) {
    cin >> x[i] >> y[i];
  }
  FOR(i,0,3) {
    if(d(x[i%3], y[i%3], x[(i+1)%3], y[(i+1)%3]) == d(x[i%3], y[i%3], x[(i+2)%3], y[(i+2)%3])) {
      if(sqrt(2) * d(x[i%3],y[i%3],x[(i+1)%3],y[(i+1)%3]) == d(x[(i+2)%3],y[(i+2)%3],x[(i+1)%3],y[(i+1)%3])) {
        // 正方形になる点を探す
        for (double xx = -100; xx <= 100; xx++) {
          for (double yy = -100; yy <= 100; yy++) {
            if(d(xx, yy, x[(i+1)%3], y[(i+1)%3]) == d(xx, yy, x[(i+2)%3], y[(i+2)%3])) {
              if(sqrt(2) * d(xx,yy,x[(i+1)%3],y[(i+1)%3]) == d(x[(i+2)%3],y[(i+2)%3],x[(i+1)%3],y[(i+1)%3])) {
                cout << int(xx) << " " << int(yy) << endl;
                return 0;
              }
            }
          }
        }
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
0