結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
|
提出日時 | 2014-11-03 01:23:12 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 41 ms / 5,000 ms |
コード長 | 1,016 bytes |
コンパイル時間 | 1,466 ms |
コンパイル使用メモリ | 171,212 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 13:41:47 |
合計ジャッジ時間 | 2,777 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef pair<int,int> P;bool check(P p[4]){set<vector<int> > s;for(int i = 0; i < 4; i++){vector<int> v;for(int j = 0; j < 4; j++){if(i == j) continue;int mx = p[i].first - p[j].first, my = p[i].second - p[j].second;int d = mx*mx+my*my;if(d == 0) return false;v.push_back(d);}sort(v.begin(), v.end());if(v[0] != v[1] && v[1] != v[2]) return false;s.insert(v);}return (s.size() == 1);}int main(){P p[4];for(int i = 0; i < 3; i++){int x,y;cin >> x >> y;p[i] = P(x,y);}for(int y = -200; y <= 200; y++){for(int x = -200; x <= 200; x++){p[3] = P(x,y);if(check(p)){cout << x << " " << y << endl;return 0;}}}cout << -1 << endl;return 0;}