結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2024-10-08 15:36:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 1,005 bytes |
コンパイル時間 | 3,095 ms |
コンパイル使用メモリ | 250,200 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 15:37:01 |
合計ジャッジ時間 | 4,102 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for(long long i = 0; i < n; i++)#define ALL(v) (v).begin(), (v).end()#define rALL(v) (v).rbegin(), (v).rend()using namespace std;using lint = long long;int main() {vector<pair<int, int>> xy(3);rep(i, 3) {cin >> xy[i].first >> xy[i].second;}auto dist = [](int x1, int y1, int x2, int y2) {return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);};auto right = [](int x1, int y1, int x2, int y2) {return x1 * x2 + y1 * y2 == 0;};vector<int> id = {0, 1, 2};do {auto [x1, y1] = xy[id[0]];auto [x2, y2] = xy[id[1]];auto [x3, y3] = xy[id[2]];if (dist(x1, y1, x2, y2) == dist(x2, y2, x3, y3) && right(x1 - x2, y1 - y2, x3 - x2, y3 - y2)) {int x4 = x3 + (x1 - x2);int y4 = y3 + (y1 - y2);cout << x4 << " " << y4 << endl;return 0;}} while (next_permutation(ALL(id)));cout << -1 << endl;}