結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2018-10-29 17:59:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 5,000 ms |
コード長 | 1,326 bytes |
コンパイル時間 | 1,756 ms |
コンパイル使用メモリ | 197,392 KB |
最終ジャッジ日時 | 2025-01-06 15:02:22 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h>using namespace std;using i64 = int64_t;using vi = vector<i64>;using vvi = vector<vi>;struct vec2 {int x, y;vec2 operator+(const vec2 rhs) {return {x + rhs.x, y + rhs.y};}vec2 operator-(const vec2 rhs) {return {x - rhs.x, y - rhs.y};}vec2 operator/(const int k) {return {x / k, y / k};}bool operator==(const vec2 rhs) {return x == rhs.x && y == rhs.y;}};int dot(vec2 a, vec2 b) {return a.x * b.x + a.y * b.y;}int dist2(vec2 a) {return dot(a, a);}int main() {vector<vec2> ps;for (int i = 0; i < 3; i++) {int x, y;cin >> x >> y;ps.push_back({x, y});}int cind = -1;for (int i = 0; i < 3; i++) {vector<vec2> dir;for (int j = 0; j < 3; j++) {if (i == j) continue;dir.push_back(ps[j] - ps[i]);}if (dot(dir[0], dir[1]) == 0 && dist2(dir[0]) == dist2(dir[1])) {vector<int> hoge;for (int k = 0; k < 3; k++) {if (k != i) {hoge.push_back(k);}}vec2 z = ps[hoge[1]] + dir[0];cout << z.x << " " << z.y << endl;return 0;}}cout << -1 << endl;}