結果

問題 No.55 正方形を描くだけの簡単なお仕事です。
ユーザー shihu
提出日時 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
権限があれば一括ダウンロードができます

ソースコード

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

// #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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0