結果
| 問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2024-07-29 21:23:32 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,727 bytes |
| コンパイル時間 | 1,530 ms |
| コンパイル使用メモリ | 119,160 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-29 21:23:35 |
| 合計ジャッジ時間 | 2,947 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
#include<set>
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n = 3;
vector<int> x(n),y(n);
for(int i = 0;i<n;i++) cin>>x[i]>>y[i];
vector<pair<int,int>> use;
for(int i = 0;i<n;i++) use.push_back(make_pair(x[i],y[i]));
sort(use.begin(),use.end());
auto ok = [](vector<pair<int,int>> use) {
int n = 4;
sort(use.begin(),use.end());
do{
bool ok = true;
set<int> s;
for(int i = 0;i<n;i++){
int ni = i + 1;
if(ni==n) ni = 0;
int dx = use[i].first - use[ni].first;
int dy = use[i].second - use[ni].second;
s.insert(dx*dx+dy*dy);
// cout<<dx*dx+dy*dy<<endl;
int p = i - 1;
if(p<0) p = n - 1;
int ddx = use[i].first - use[p].first;
int ddy = use[i].second - use[p].second;
if(dx*ddx+dy*ddy==0) continue;
ok = false;
}
if(s.size()!=1) ok = false;
if(ok) return true;
}while(next_permutation(use.begin(),use.end()));
return false;
};
// use.push_back(make_pair(1,1));
// ok(use);
// return 0;
do{
int nx = use[0].first + use[1].first - use[2].first;
int ny = use[0].second + use[1].second - use[2].second;
use.push_back(make_pair(nx,ny));
if(ok(use)){
cout<<nx<<" "<<ny<<endl;
return 0;
}
use.pop_back();
}while(next_permutation(use.begin(),use.end()));
cout<<-1<<endl;
}
momoyuu