From f24f33946e39958afa0af6175efb12765622d3ac Mon Sep 17 00:00:00 2001 From: ei1333 Date: Mon, 8 Jul 2024 17:24:55 +0900 Subject: [PATCH 1/3] update point --- geometry/integer/point.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geometry/integer/point.hpp b/geometry/integer/point.hpp index fcef93fc7..fe45dfdc5 100644 --- a/geometry/integer/point.hpp +++ b/geometry/integer/point.hpp @@ -1,6 +1,11 @@ +#pragma once + template struct Point { T x, y; + + Point() : x(0), y(0) {} + Point(T x, T y) : x(x), y(y) {} }; // あとはまかせた! From 54ca1fd21224d1f779da72c355be6f26152a22a5 Mon Sep 17 00:00:00 2001 From: ei1333 Date: Mon, 15 Jul 2024 01:50:29 +0900 Subject: [PATCH 2/3] update point --- geometry/integer/point.hpp | 41 +++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/geometry/integer/point.hpp b/geometry/integer/point.hpp index fe45dfdc5..53aeb5596 100644 --- a/geometry/integer/point.hpp +++ b/geometry/integer/point.hpp @@ -5,7 +5,46 @@ struct Point { T x, y; Point() : x(0), y(0) {} - Point(T x, T y) : x(x), y(y) {} + Point(const T &x, const T &y) : x(x), y(y) {} + + Point &operator+=(const Point &p) { + x += p.x; + y += p.y; + return *this; + } + Point &operator-=(const Point &p) { + x -= p.x; + y -= p.y; + return *this; + } + Point &operator*=(const T &d) { + x *= d; + y *= d; + return *this; + } + + Point operator-() const { return Point() - *this; } + + Point operator+(const Point &p) const { return Point(*this) += p; } + + Point operator-(const Point &p) const { return Point(*this) -= p; } + + Point operator+(const T &d) const { return Point(*this) *= d; } + + bool operator==(const Point &p) const { return x == p.x and y == p.y; } + + bool operator!=(const Point &p) const { return x != p.x or y != p.y; } + + friend ostream &operator<<(ostream &os, const Point &p) { + return os << p.x << " " << p.y; + } + + friend istream &operator>>(istream &is, Point &p) { + T a, b; + is >> a >> b; + p = Point(a, b); + return is; + } }; // あとはまかせた! From 1c666fff71e9ccb92d720c691cb975dcc37e1732 Mon Sep 17 00:00:00 2001 From: ei1333 Date: Mon, 15 Jul 2024 03:11:41 +0900 Subject: [PATCH 3/3] =?UTF-8?q?point.hpp=20=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Luzhiled --- geometry/integer/point.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geometry/integer/point.hpp b/geometry/integer/point.hpp index 53aeb5596..1ad364a2c 100644 --- a/geometry/integer/point.hpp +++ b/geometry/integer/point.hpp @@ -29,7 +29,7 @@ struct Point { Point operator-(const Point &p) const { return Point(*this) -= p; } - Point operator+(const T &d) const { return Point(*this) *= d; } + Point operator-(const T &d) const { return Point(+this) /= d; } bool operator==(const Point &p) const { return x == p.x and y == p.y; }