結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2016-03-04 16:18:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,480 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 83,992 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 13:53:48 |
合計ジャッジ時間 | 1,572 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
/* -*- coding: utf-8 -*- * * 55.cc: No.55 正方形を描くだけの簡単なお仕事です。 - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ /* typedef */ template <typename T> struct Pt { T x, y; Pt() {} Pt(T _x, T _y) : x(_x), y(_y) {} Pt(const Pt& pt) : x(pt.x), y(pt.y) {} bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; } Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); } Pt<T> operator-() const { return Pt<T>(-x, -y); } Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); } T dot(Pt v) const { return x * v.x + y * v.y; } T cross(Pt v) const { return x * v.y - y * v.x; } T d2() { return x * x + y * y; } }; typedef Pt<int> pt; /* global variables */ pt pts[3]; /* subroutines */ /* main */ int main() { for (int i = 0; i < 3; i++) cin >> pts[i].x >> pts[i].y; for (int i = 0; i < 3; i++) { pt &p = pts[i]; pt v0 = pts[(i + 1) % 3] - p; pt v1 = pts[(i + 2) % 3] - p; if (v0.dot(v1) == 0 && v0.d2() == v1.d2()) { pt p3 = p + v0 + v1; printf("%d %d\n", p3.x, p3.y); return 0; } } puts("-1"); return 0; }