This documentation is automatically generated by competitive-verifier/competitive-verifier
// clang-format off
// competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B
// clang-format on
// competitive-verifier: ERROR 0.00000001
#include <iomanip>
#include <iostream>
#include "../../geometry/reflection.hpp"
using namespace std;
using namespace geometry;
int main() {
cout << fixed << setprecision(10);
Line l;
cin >> l;
int Q;
cin >> Q;
while (Q--) {
Point p;
cin >> p;
cout << reflection(l, p) << "\n";
}
}
#line 1 "test/verify/aoj-cgl-1-b.test.cpp"
// clang-format off
// competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B
// clang-format on
// competitive-verifier: ERROR 0.00000001
#include <iomanip>
#include <iostream>
#line 2 "geometry/reflection.hpp"
#line 2 "geometry/line.hpp"
#include <cassert>
#line 5 "geometry/line.hpp"
#include <vector>
#line 2 "geometry/point.hpp"
#include <cmath>
#include <complex>
#line 7 "geometry/point.hpp"
#line 2 "geometry/base.hpp"
#line 4 "geometry/base.hpp"
namespace geometry {
using Real = double;
const Real EPS = 1e-8;
const Real PI = std::acos(static_cast<Real>(-1));
enum { OUT, ON, IN };
inline int sign(const Real& r) { return r <= -EPS ? -1 : r >= EPS ? 1 : 0; }
inline bool equals(const Real& a, const Real& b) { return sign(a - b) == 0; }
} // namespace geometry
#line 9 "geometry/point.hpp"
namespace geometry {
using Point = std::complex<Real>;
std::istream& operator>>(std::istream& is, Point& p) {
Real a, b;
is >> a >> b;
p = Point(a, b);
return is;
}
std::ostream& operator<<(std::ostream& os, const Point& p) {
return os << std::real(p) << " " << std::imag(p);
}
Point operator*(const Point& p, const Real& d) {
return Point(std::real(p) * d, std::imag(p) * d);
}
// rotate point p counterclockwise by theta rad
Point rotate(Real theta, const Point& p) {
return Point(std::cos(theta) * std::real(p) - std::sin(theta) * std::imag(p),
std::sin(theta) * std::real(p) + std::cos(theta) * std::imag(p));
}
Real cross(const Point& a, const Point& b) {
return std::real(a) * std::imag(b) - std::imag(a) * std::real(b);
}
Real dot(const Point& a, const Point& b) {
return std::real(a) * std::real(b) + std::imag(a) * std::imag(b);
}
bool compare_x(const Point& a, const Point& b) {
return equals(std::real(a), std::real(b)) ? std::imag(a) < std::imag(b)
: std::real(a) < std::real(b);
}
bool compare_y(const Point& a, const Point& b) {
return equals(std::imag(a), std::imag(b)) ? std::real(a) < std::real(b)
: std::imag(a) < std::imag(b);
}
using Points = std::vector<Point>;
} // namespace geometry
#line 8 "geometry/line.hpp"
namespace geometry {
struct Line {
Point a, b;
Line() = default;
Line(const Point& a, const Point& b) : a(a), b(b) {}
Line(const Real& A, const Real& B, const Real& C) { // Ax+By=C
if (equals(A, 0)) {
assert(!equals(B, 0));
a = Point(0, C / B);
b = Point(1, C / B);
} else if (equals(B, 0)) {
a = Point(C / A, 0);
b = Point(C / A, 1);
} else if (equals(C, 0)) {
a = Point(0, C / B);
b = Point(1, (C - A) / B);
} else {
a = Point(0, C / B);
b = Point(C / A, 0);
}
}
friend std::ostream& operator<<(std::ostream& os, Line& l) {
return os << l.a << " to " << l.b;
}
friend std::istream& operator>>(std::istream& is, Line& l) {
return is >> l.a >> l.b;
}
};
using Lines = std::vector<Line>;
} // namespace geometry
#line 2 "geometry/projection.hpp"
#line 4 "geometry/projection.hpp"
#line 7 "geometry/projection.hpp"
namespace geometry {
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A
Point projection(const Line& l, const Point& p) {
auto t = dot(p - l.a, l.a - l.b) / std::norm(l.a - l.b);
return l.a + (l.a - l.b) * t;
}
} // namespace geometry
#line 6 "geometry/reflection.hpp"
namespace geometry {
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B
Point reflection(const Line& l, const Point& p) {
return p + (projection(l, p) - p) * 2;
}
} // namespace geometry
#line 10 "test/verify/aoj-cgl-1-b.test.cpp"
using namespace std;
using namespace geometry;
int main() {
cout << fixed << setprecision(10);
Line l;
cin >> l;
int Q;
cin >> Q;
while (Q--) {
Point p;
cin >> p;
cout << reflection(l, p) << "\n";
}
}
| Env | Name | Status | Elapsed | Memory |
|---|---|---|---|---|
| g++ | 00_int_00 |
|
2 ms | 4 MB |
| g++ | 00_int_01 |
|
2 ms | 4 MB |
| g++ | 00_int_02 |
|
2 ms | 4 MB |
| g++ | 00_int_03 |
|
2 ms | 4 MB |
| g++ | 00_int_04 |
|
2 ms | 4 MB |
| g++ | 00_int_05 |
|
2 ms | 4 MB |
| g++ | 01_real_00 |
|
2 ms | 4 MB |
| g++ | 01_real_01 |
|
2 ms | 4 MB |
| g++ | 02_online_00 |
|
2 ms | 4 MB |
| g++ | 02_online_01 |
|
2 ms | 4 MB |
| g++ | 02_online_02 |
|
2 ms | 4 MB |
| g++ | 02_online_03 |
|
2 ms | 4 MB |
| g++ | 03_horizontal_00 |
|
2 ms | 4 MB |
| g++ | 03_horizontal_01 |
|
2 ms | 4 MB |
| g++ | 04_vertical_00 |
|
3 ms | 4 MB |
| g++ | 04_vertical_01 |
|
2 ms | 4 MB |
| g++ | 05_rand_00 |
|
3 ms | 4 MB |
| g++ | 05_rand_01 |
|
2 ms | 4 MB |
| g++ | 05_rand_02 |
|
3 ms | 4 MB |
| g++ | 05_rand_03 |
|
5 ms | 4 MB |
| g++ | 05_rand_04 |
|
5 ms | 4 MB |
| g++ | 05_rand_05 |
|
5 ms | 4 MB |
| g++ | 05_rand_06 |
|
5 ms | 4 MB |
| g++ | 05_rand_07 |
|
5 ms | 4 MB |
| g++ | 05_rand_08 |
|
5 ms | 4 MB |
| g++ | 05_rand_09 |
|
5 ms | 4 MB |
| g++ | 05_rand_10 |
|
8 ms | 4 MB |
| g++ | 05_rand_11 |
|
5 ms | 4 MB |
| g++ | 05_rand_12 |
|
5 ms | 4 MB |
| g++ | 05_rand_13 |
|
5 ms | 4 MB |
| g++ | 05_rand_14 |
|
5 ms | 4 MB |
| g++ | 05_rand_15 |
|
5 ms | 4 MB |
| clang++ | 00_int_00 |
|
2 ms | 4 MB |
| clang++ | 00_int_01 |
|
2 ms | 4 MB |
| clang++ | 00_int_02 |
|
2 ms | 4 MB |
| clang++ | 00_int_03 |
|
2 ms | 4 MB |
| clang++ | 00_int_04 |
|
2 ms | 4 MB |
| clang++ | 00_int_05 |
|
2 ms | 4 MB |
| clang++ | 01_real_00 |
|
2 ms | 4 MB |
| clang++ | 01_real_01 |
|
2 ms | 4 MB |
| clang++ | 02_online_00 |
|
2 ms | 4 MB |
| clang++ | 02_online_01 |
|
2 ms | 4 MB |
| clang++ | 02_online_02 |
|
2 ms | 4 MB |
| clang++ | 02_online_03 |
|
2 ms | 4 MB |
| clang++ | 03_horizontal_00 |
|
3 ms | 4 MB |
| clang++ | 03_horizontal_01 |
|
2 ms | 4 MB |
| clang++ | 04_vertical_00 |
|
2 ms | 4 MB |
| clang++ | 04_vertical_01 |
|
3 ms | 4 MB |
| clang++ | 05_rand_00 |
|
2 ms | 4 MB |
| clang++ | 05_rand_01 |
|
2 ms | 4 MB |
| clang++ | 05_rand_02 |
|
2 ms | 4 MB |
| clang++ | 05_rand_03 |
|
5 ms | 4 MB |
| clang++ | 05_rand_04 |
|
5 ms | 4 MB |
| clang++ | 05_rand_05 |
|
5 ms | 4 MB |
| clang++ | 05_rand_06 |
|
8 ms | 4 MB |
| clang++ | 05_rand_07 |
|
5 ms | 4 MB |
| clang++ | 05_rand_08 |
|
5 ms | 4 MB |
| clang++ | 05_rand_09 |
|
5 ms | 4 MB |
| clang++ | 05_rand_10 |
|
5 ms | 4 MB |
| clang++ | 05_rand_11 |
|
5 ms | 4 MB |
| clang++ | 05_rand_12 |
|
5 ms | 4 MB |
| clang++ | 05_rand_13 |
|
5 ms | 4 MB |
| clang++ | 05_rand_14 |
|
5 ms | 4 MB |
| clang++ | 05_rand_15 |
|
5 ms | 4 MB |