結果
問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
ユーザー |
|
提出日時 | 2020-07-17 17:05:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 182 ms / 5,000 ms |
コード長 | 1,047 bytes |
コンパイル時間 | 2,096 ms |
コンパイル使用メモリ | 202,996 KB |
最終ジャッジ日時 | 2025-01-11 21:48:35 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); double EPS = 1e-9; bool check(vector<pair<int, int> > ps) { vector<int> dist; REP (i, 4) REP (j, i) { int x = ps[i].first - ps[j].first; int y = ps[i].second - ps[j].second; dist.push_back(x * x + y * y); } sort(dist.begin(), dist.end()); return dist[1] == dist[0] && dist[2] == dist[0] && dist[3] == dist[0] && dist[4] == 2 * dist[0] && dist[5] == 2 * dist[0]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<pair<int, int> > ps; REP (i, 3) { int x, y; cin >> x >> y; ps.emplace_back(x, y); } for (int x = -500; x <= 500; x++) { for (int y = -500; y <= 500; y++) { ps.emplace_back(x, y); if (check(ps)) { cout << x << " " << y << endl; return 0; } ps.pop_back(); } } cout << -1 << endl; return 0; }