結果
| 問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-09-26 15:35:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,244 bytes |
| コンパイル時間 | 852 ms |
| コンパイル使用メモリ | 80,448 KB |
| 最終ジャッジ日時 | 2025-02-07 16:09:03 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 WA * 5 |
ソースコード
#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];
}
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;
}