結果

問題 No.2790 Athena 3
ユーザー t98slider
提出日時 2024-06-22 18:50:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,175 bytes
コンパイル時間 2,052 ms
コンパイル使用メモリ 196,736 KB
最終ジャッジ日時 2025-02-22 00:12:27
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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

#include <bits/stdc++.h>
using namespace std;
template<class T> istream& operator >> (istream& is, vector<T>& vec) {
for(T& x : vec) is >> x;
return is;
}
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
if(vec.empty()) return os;
os << vec[0];
for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
return os;
}
template<class T> struct point{
T x, y;
point(): x(0), y(0){}
point(T a, T b): x(a), y(b){}
point& operator += (const point& rhs) {x += rhs.x, y += rhs.y; return *this;}
point& operator -= (const point& rhs) {x -= rhs.x, y -= rhs.y; return *this;}
point& operator *= (const T& rhs) {x *= rhs, y *= rhs; return *this;}
point& operator /= (const T& rhs) {x /= rhs, y /= rhs; return *this;}
point operator +() const { return *this; }
point operator -() const { return point() - *this; }
friend point operator + (const point& lhs, const point& rhs) {return point(lhs) += rhs;}
friend point operator - (const point& lhs, const point& rhs) {return point(lhs) -= rhs;}
friend point operator * (const point& lhs, const T& rhs) {return point(lhs) *= rhs;}
friend point operator * (const T& lhs, const point& rhs) {return point(rhs) *= lhs;}
friend point operator / (const point& lhs, const T& rhs) {return point(lhs) /= rhs;}
friend T operator * (const point& lhs, const point& rhs) {return lhs.x * rhs.x + lhs.y * rhs.y;}
friend T operator ^ (const point& lhs, const point& rhs) {return lhs.x * rhs.y - lhs.y * rhs.x;}
friend bool operator == (const point& lhs, const point& rhs) {return (lhs.x == rhs.x && lhs.y == rhs.y);}
friend istream& operator >> (istream& os, point& rhs) noexcept {
os >> rhs.x >> rhs.y;
return os;
}
friend constexpr ostream& operator << (ostream &os, const point& rhs) noexcept {
return os << '('<< rhs.x << ',' << rhs.y << ')';
}
double norm(){return sqrt(x * x + y * y);}
T norm2(){return x * x + y * y;}
int orthant(){//(0,00)
if(x == 0 && y == 0)return 0;
if(y > 0)return (x > 0 ? 1 : 2);
return (x > 0 ? 4 : 3);
}
//->
friend bool operator < (point &lhs, point &rhs){//tuple&
int lo = lhs.orthant(), ro = rhs.orthant();
if(lo != ro)return (lo < ro);
T cv = (lhs ^ rhs);
if(cv != 0)return (cv > 0);
return (lhs.norm2() < rhs.norm2());
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
vector<point<int>> pos(3);
vector<point<int>> dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
cin >> pos;
int S = 0;
for(int i = 0; i < 4; i++){
auto p1 = pos[0] + dir[i];
for(int j = 0; j < 4; j++){
auto p2 = pos[1] + dir[j];
for(int k = 0; k < 4; k++){
auto p3 = pos[2] + dir[k];
S = max(S, abs((p2 - p1) ^ (p3 - p1)));
}
}
}
cout << double(S) / 2 << '\n';
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0