結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2020-03-25 16:21:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 5,000 ms |
コード長 | 1,306 bytes |
コンパイル時間 | 1,687 ms |
コンパイル使用メモリ | 170,112 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-01 23:58:02 |
合計ジャッジ時間 | 3,451 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)#define all(x) (x).begin(), (x).end()#define sz(x) ((ll)(x).size())#define len(x) ((ll)(x).length())template<class T>bool is_square(const vector<pair<T, T>> &xy) {map<T, int> m;for(int i = 0; i < 4; i++) {for(int j = i + 1; j < 4; j++) {T dx = xy[i].first - xy[j].first;T dy = xy[i].second - xy[j].second;m[dx * dx + dy * dy]++;}}T l = m.begin()->first;if (l == 0) return false;return ((m[l] == 4) && (m[l * 2] == 2));}int main() {cin.tie(0);ios::sync_with_stdio(false);// ifstream in("input.txt");// cin.rdbuf(in.rdbuf());vector<pair<ll, ll>> xy(4);rep(i, 3) cin >> xy[i].first >> xy[i].second;reps(x, -200, 201) {reps(y, -200, 201) {xy[3].first = x; xy[3].second = y;if (is_square(xy)) {printf("%lld %lld\n", x, y);return 0;}}}printf("-1\n");return 0;}