結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー Pachicobue
提出日時 2017-07-14 19:23:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,192 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 172,544 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-07 21:49:58
合計ジャッジ時間 3,081 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#define show(x) cout << #x << " = " << x << endl
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
os << "sz=" << v.size() << "\n[";
for (const auto& p : v) {
os << p << ",";
}
os << "]\n";
return os;
}
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
os << "(" << p.first << "," << p.second
<< ")";
return os;
}
constexpr ll MOD = 1e9 + 7;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;
struct Vec {
Vec() = default;
Vec(int x, int y) : dx(x), dy(y) {}
Vec(const Vec& v) : dx(v.dx), dy(v.dy)
{
}
int dx;
int dy;
int normSq() const
{
return dx * dx + dy * dy;
}
int product(const Vec& v) const
{
return dx * v.dx + dy * v.dy;
}
Vec operator+(const Vec& v) const
{
return Vec{dx + v.dx, dy + v.dy};
}
Vec operator-(const Vec& v) const
{
return Vec{dx - v.dx, dy - v.dy};
}
bool operator<(const Vec& v) const
{
return normSq() > v.normSq();
}
};
int main()
{
Vec pos[3];
for (ll i = 0; i < 3; i++) {
cin >> pos[i].dx >> pos[i].dy;
}
pair<Vec, int> v_[3];
v_[0].first = pos[1] - pos[0];
v_[1].first = pos[2] - pos[1];
v_[2].first = pos[0] - pos[2];
v_[0].second = 0;
v_[1].second = 1;
v_[2].second = 2;
pair<Vec, int> v[3];
v[0] = v_[0];
v[1] = v_[1];
v[2] = v_[2];
sort(v, v + 3);
if (v[1].first.product(v[2].first) == 0 and v[1].first.normSq() == v[2].first.normSq()) {
Vec ans;
if (v[0].second == 0) {
ans = pos[0] - v_[1].first;
cout << ans.dx << " " << ans.dy << endl;
} else if (v[0].second == 1) {
ans = pos[1] - v_[2].first;
cout << ans.dx << " " << ans.dy << endl;
} else {
ans = pos[2] - v_[0].first;
cout << ans.dx << " " << ans.dy << endl;
}
} else {
cout << -1 << endl;
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0