結果
問題 | No.2555 Intriguing Triangle |
ユーザー | risujiroh |
提出日時 | 2023-12-01 00:13:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 4,567 bytes |
コンパイル時間 | 2,753 ms |
コンパイル使用メモリ | 255,052 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-26 15:19:12 |
合計ジャッジ時間 | 3,605 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ // https://github.com/kth-competitive-programming/kactl namespace kactl { typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; template <class T> int sgn(T x) { return (x > 0) - (x < 0); } template <class T> struct Point { typedef Point P; T x, y; explicit Point(T x = 0, T y = 0) : x(x), y(y) {} bool operator<(P p) const { return tie(x, y) < tie(p.x, p.y); } bool operator==(P p) const { return tie(x, y) == tie(p.x, p.y); } P operator+(P p) const { return P(x + p.x, y + p.y); } P operator-(P p) const { return P(x - p.x, y - p.y); } P operator*(T d) const { return P(x * d, y * d); } P operator/(T d) const { return P(x / d, y / d); } T dot(P p) const { return x * p.x + y * p.y; } T cross(P p) const { return x * p.y - y * p.x; } T cross(P a, P b) const { return (a - *this).cross(b - *this); } T dist2() const { return x * x + y * y; } double dist() const { return sqrt((double)dist2()); } // angle to x-axis in interval [-pi, pi] double angle() const { return atan2(y, x); } P unit() const { return *this / dist(); } P perp() const { return P(-y, x); } P normal() const { return perp().unit(); } // returns point rotated 'a' radians ccw around the origin P rotate(double a) const { return P(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a)); } friend ostream& operator<<(ostream& os, P p) { return os << "(" << p.x << "," << p.y << ")"; } }; typedef Point<double> P; bool circleInter(P a, P b, double r1, double r2, pair<P, P>* out) { if (a == b) { assert(r1 != r2); return false; } P vec = b - a; double d2 = vec.dist2(), sum = r1 + r2, dif = r1 - r2, p = (d2 + r1 * r1 - r2 * r2) / (d2 * 2), h2 = r1 * r1 - p * p * d2; if (sum * sum < d2 || dif * dif > d2) return false; P mid = a + vec * p, per = vec.perp() * sqrt(fmax(0, h2) / d2); *out = {mid + per, mid - per}; return true; } } // namespace kactl namespace { void solve() { int a, b, c; scan(a, b, c); for (int x : rep1(200)) { for (int y : rep1(200)) { if (b + c <= x + a + y) { continue; } if ((x + a + y) + min(b, c) <= max(b, c)) { continue; } pair<kactl::P, kactl::P> out; kactl::P B(0, 0); kactl::P C(x + a + y, 0); kactl::circleInter(B, C, b, c, &out); if (out.first.y < 0) { swap(out.first, out.second); } kactl::P A = out.first; kactl::P D(x, 0); kactl::P E(x + a, 0); const double d1 = (B - A).unit().dot((D - A).unit()); const double d2 = (E - A).unit().dot((C - A).unit()); if (abs(d2 - d1) < 1e-9) { print("Yes"); return; } } } print("No"); } } // namespace int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); } #else // __INCLUDE_LEVEL__ #include <bits/stdc++.h> using namespace std; template <class T> concept tuple_like = __is_tuple_like<T>::value && !ranges::range<T>; template <class R> concept nstr_range = ranges::range<R> && !convertible_to<R, string_view>; namespace std { istream& operator>>(istream& is, tuple_like auto&& t) { return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t); } istream& operator>>(istream& is, nstr_range auto&& r) { for (auto&& e : r) { is >> e; } return is; } ostream& operator<<(ostream& os, tuple_like auto&& t) { auto f = [&os](auto&... xs) -> ostream& { [[maybe_unused]] auto sep = ""; ((os << exchange(sep, " ") << xs), ...); return os; }; return apply(f, t); } ostream& operator<<(ostream& os, nstr_range auto&& r) { auto sep = ""; for (auto&& e : r) { os << exchange(sep, " ") << e; } return os; } #define DEF_INC_OR_DEC(op) \ auto& operator op(tuple_like auto&& t) { \ apply([](auto&... xs) { (op xs, ...); }, t); \ return t; \ } \ auto& operator op(nstr_range auto&& r) { \ for (auto&& e : r) { \ op e; \ } \ return r; \ } DEF_INC_OR_DEC(++) DEF_INC_OR_DEC(--) #undef DEF_INC_OR_DEC } // namespace std void scan(auto&&... xs) { cin >> tie(xs...); } void print(auto&&... xs) { cout << tie(xs...) << '\n'; } using views::drop; using views::take; inline constexpr auto rev = views::reverse; inline constexpr auto len = ranges::ssize; inline auto rep(int l, int r) { return views::iota(min(l, r), r); } inline auto rep(int n) { return rep(0, n); } inline auto rep1(int l, int r) { return rep(l, r + 1); } inline auto rep1(int n) { return rep(1, n + 1); } #endif // __INCLUDE_LEVEL__