結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー 👑 CleyLCleyL
提出日時 2022-09-26 15:23:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,186 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 77,112 KB
最終ジャッジ日時 2025-02-07 16:08:15
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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 = -100; 100 >= i; i++){
    for(int j = -100; 100 >= 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];
      }
      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){
          
          cout << i << " " << j << endl;
          return 0;
        }
      }while(next_permutation(B.begin(),B.end()));
    }
  }
  cout << -1 << endl;
}
0