結果
問題 |
No.55 正方形を描くだけの簡単なお仕事です。
|
ユーザー |
|
提出日時 | 2019-01-15 23:31:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 5,000 ms |
コード長 | 776 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 171,972 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 07:56:24 |
合計ジャッジ時間 | 2,923 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; bool is_rectangle(pair<int, int> a[4]) { vector<int> x; for(int i = 0; i < 4; i++) { for(int j = i + 1; j < 4; j++) { int s = (a[i].first - a[j].first); int t = (a[i].second - a[j].second); x.push_back(s * s + t * t); } } sort(x.begin(), x.end()); return x[0] == x[3] && x[4] == x[5] && x[0] * 2 == x[5]; } int main() { ios::sync_with_stdio(false); cin.tie(0); pair<int, int> a[4]; for(int i = 0; i < 3; i++) { cin >> a[i].first >> a[i].second; } for(int i = -200; i <= 200; i++) { for(int j = -200; j <= 200; j++) { a[3].first = i; a[3].second = j; if(is_rectangle(a)) { cout << i << " " << j << endl; return 0; } } } cout << -1 << endl; return 0; }