結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー CleyLCleyL
提出日時 2022-09-26 15:43:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 5,000 ms
コード長 1,244 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 81,404 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 02:53:01
合計ジャッジ時間 2,595 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct z{
  int x,y;
  bool operator<(z A){
    if(x == A.x){
      return y < A.y;
    }
    return x < A.x;
  }
  bool operator==(z A){
    return x == A.x && y == A.y;
  }
  bool operator >(z A){
    return !((*this) < A || (*this) == A);
  }
};

int dist(z a,z b){
  return abs(a.x-b.x)*abs(a.x-b.x) + abs(a.y-b.y)*abs(a.y-b.y);
}

int main(){
  vector<z> A(4);
  for(int i = 0; 3 > i; i++){
    cin>>A[i].x>>A[i].y;
  }
  for(int i = -200; 200 >= i; i++){
    for(int j = -200; 200 >= j; j++){
      A[3].x = i;
      A[3].y = j;
      if(A[0] == A[3] || A[1] == A[3] || A[2] == A[3])continue;
      vector<z> B(4);
      for(int k = 0; 4 > k; k++){
        B[k] = A[k];
      }
      sort(B.begin(),B.end());
      do{
        int di = dist(B[0],B[1]);
        bool ok = true;
        for(int k = 0; 4 > k; k++){
          if(di != dist(B[k],B[(k+1)%4])){
            ok = false;
            break;
          }
        }
        if(ok && dist(B[0],B[2]) == 2*di && dist(B[1],B[3]) == 2*di){
          
          cout << i << " " << j << endl;
          return 0;
        }
      }while(next_permutation(B.begin(),B.end()));
    }
  }
  cout << -1 << endl;
}
0