結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
|
提出日時 | 2024-10-08 09:58:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 5,060 bytes |
コンパイル時間 | 5,492 ms |
コンパイル使用メモリ | 287,456 KB |
最終ジャッジ日時 | 2025-02-24 16:46:10 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
// #pragma GCC target("avx2")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using namespace atcoder;using mint = modint998244353;// using mint = modint1000000007;using ll = long long;using ull = unsigned long long;using ld = long double;using pii = pair<int, int>;using pll = pair<ll, ll>;using T = tuple<int, int, int>;using G = vector<vector<int>>;#define rep(i, n) for (ll i = 0; i < (n); ++i)#define rep2(i, a, b) for (ll i = a; i < (b); ++i)#define rrep2(i, a, b) for (ll i = a-1; i >= (b); --i)#define rep3(i, a, b, c) for (ll i = a; i < (b); i+=c)#define rng(a) a.begin(),a.end()#define rrng(a) a.rbegin(),a.rend()#define popcount __builtin_popcount#define popcountll __builtin_popcountll#define fi first#define se second#define UNIQUE(v) sort(rng(v)), v.erase(unique(rng(v)), v.end())#define MIN(v) *min_element(rng(v))#define MAX(v) *max_element(rng(v))#define SUM(v) accumulate(rng(v),0)#define IN(v, x) (find(rng(v),x) != v.end())template<class T> bool chmin(T &a,T b){if(a>b){a=b;return 1;}else return 0;}template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}template<class T> void printv(vector<T> &v){rep(i,v.size())cout<<v[i]<<" \n"[i==v.size()-1];}template<class T> void printvv(vector<vector<T>> &v){rep(i,v.size())rep(j,v[i].size())cout<<v[i][j]<<" \n"[j==v[i].size()-1];cout<<endl;}const ll dx[] = {0, 1, 0, -1};const ll dy[] = {1, 0, -1, 0};const ll dxx[] = {0, 1, 0, -1, 1, -1, 1, -1};const ll dyy[] = {1, 0, -1, 0, 1, 1, -1, -1};const ll LINF = 1001002003004005006ll;const int INF = 1001001001;// ベクトル演算を行うライブラリ。誤差で落ちる場合は適宜ll->longlong, exp->0に変更すること。const double eps = 1e-10;bool equal(double a, double b) { return abs(a-b) < eps;}struct V {double x, y;V(double x=0, double y=0): x(x), y(y) {}V& operator+=(const V& v) { x += v.x; y += v.y; return *this;}V operator+(const V& v) const { return V(*this) += v;}V& operator-=(const V& v) { x -= v.x; y -= v.y; return *this;}V operator-(const V& v) const { return V(*this) -= v;}V& operator*=(double s) { x *= s; y *= s; return *this;}V operator*(double s) const { return V(*this) *= s;}V& operator/=(double s) { x /= s; y /= s; return *this;}V operator/(double s) const { return V(*this) /= s;}double dot(const V& v) const { return x*v.x + y*v.y;} // 内積double cross(const V& v) const { return x*v.y - v.x*y;} // 外積double norm1() const { return abs(x) + abs(y);} // L1ノルムdouble norm2() const { return sqrt(norm2s());} // L2ノルムdouble norm2s() const { return x*x + y*y;} // L2ノルムの二乗V normalize() const { return *this/norm2();} // 正規化(ノルムを1にスケールする)V rotate90c() const { return V(-y, x);} // 反時計回りに90度回転V rotate90() const { return V(y, -x);} // 時計回りに90度回転// Vがどの象限に属するかの判定を行う関数int ort() const {if (abs(x) < eps && abs(y) < eps) return 0;if (y > 0) return x>0 ? 1 : 2;else return x>0 ? 4 : 3;}// 偏角の大小関係を定義するための<演算子オーバーロードbool operator<(const V& v) const {int o = ort(), vo = v.ort();if (o != vo) return o < vo;return cross(v) > 0;}};istream& operator>>(istream& is, V& v) {is >> v.x >> v.y; return is;}ostream& operator<<(ostream& os, const V& v) {os<<"("<<v.x<<","<<v.y<<")"; return os;}struct Line {V s, t;Line(V s=V(0,0), V t=V(0,0)):s(s),t(t){}V dir() const { return t-s;} // 方向ベクトル(stベクトル)を求める。V normalize() const { return dir().normalize();} // ベクトルの正規化double norm2() const { return dir().norm2();} // ベクトルのL2ノルムを取得。// 点と直線の位置関係を求める関数int ccw(const V& p) const {if (dir().cross(p-s) > eps) return +1; // 方向ベクトルから見て点pは反時計回り。if (dir().cross(p-s) < -eps) return -1; // 方向ベクトルから見て点pは時計回り。if (dir().dot(p-s) < -eps) return +2; // 方向ベクトルの始点側(s側)の延長線上にある。if (dir().dot(t-p) < -eps) return -2; // 方向ベクトルの終点側(t側)の延長線上にある。return 0; // 線分st上にある。}// 2直線が交わるかどうかの判定を行う関数bool touch(const Line& l) const {int a = ccw(l.s)*ccw(l.t), b = l.ccw(s)*l.ccw(t);return !a || !b || (a == -1 && b == -1);}};int main(){ios::sync_with_stdio(false);cin.tie(nullptr);vector<V> p(3);rep(i, 3){cin >> p[i];}rep(i, 3){V v1 = p[(i+1)%3]-p[i], v2 = p[(i+2)%3]-p[i];if (v1.dot(v2) != 0 || v1.norm2s() != v2.norm2s()) continue;V ans = p[(i+1)%3] + p[(i+2)%3] - p[i];cout << ans.x << " " << ans.y << endl;return 0;}cout << -1 << endl;return 0;}