#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef KK2_TEMPLATE_PROCON_HPP #define KK2_TEMPLATE_PROCON_HPP 1 #ifndef KK2_TEMPLATE_CONSTANT_HPP #define KK2_TEMPLATE_CONSTANT_HPP 1 #ifndef KK2_TEMPLATE_TYPE_ALIAS_HPP #define KK2_TEMPLATE_TYPE_ALIAS_HPP 1 using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using i128 = __int128_t; using u128 = __uint128_t; using pi = std::pair; using pl = std::pair; using pil = std::pair; using pli = std::pair; template using vc = std::vector; template using vvc = std::vector>; template using vvvc = std::vector>; template using vvvvc = std::vector>; template using pq = std::priority_queue; template using pqi = std::priority_queue, std::greater>; #endif // KK2_TEMPLATE_TYPE_ALIAS_HPP template constexpr T infty = 0; template <> constexpr int infty = (1 << 30) - 123; template <> constexpr i64 infty = (1ll << 62) - (1ll << 31); template <> constexpr i128 infty = (i128(1) << 126) - (i128(1) << 63); template <> constexpr u32 infty = infty; template <> constexpr u64 infty = infty; template <> constexpr u128 infty = infty; template <> constexpr double infty = infty; template <> constexpr long double infty = infty; constexpr int mod = 998244353; constexpr int modu = 1e9 + 7; constexpr long double PI = 3.14159265358979323846; #endif // KK2_TEMPLATE_CONSTANT_HPP #ifndef KK2_TEMPLATE_FUNCTION_UTIL_HPP #define KK2_TEMPLATE_FUNCTION_UTIL_HPP 1 namespace kk2 { template auto make_vector(int first, Sizes... sizes) { if constexpr (sizeof...(sizes) == 0) { return std::vector(first); } else { return std::vector(sizes...))>(first, make_vector(sizes...)); } } template void fill_all(std::vector &v, const U &x) { std::fill(std::begin(v), std::end(v), T(x)); } template void fill_all(std::vector> &v, const U &x) { for (auto &u : v) fill_all(u, x); } template int mysize(const C &c) { return c.size(); } // T: comutative monoid template U all_sum(const std::vector &v, U init, U = U()) { U res = init; for (const auto &x : v) res += x; return res; } template U all_sum(const std::vector> &v, U init, U unit = U()) { U res = init; for (const auto &u : v) res += all_sum(u, unit, unit); return res; } // T: commutative monoid, F: (U, T) -> U template U all_prod(const std::vector &v, U init, const F &f, U = U()) { U res = init; for (const auto &x : v) res = f(res, x); return res; } template U all_prod(const std::vector> &v, U init, const F &f, U unit) { U res = init; for (const auto &u : v) res = f(res, all_prod(u, unit, f, unit)); return res; } template T all_min(const std::vector &v) { if (v.empty()) return T(); T res = v[0]; for (const auto &x : v) res = res > x ? x : res; return res; } template T all_min(const std::vector> &v) { T res{}; bool first = true; for (const auto &u : v) { if (u.empty()) continue; if (first) { res = all_min(u); first = false; } else { T tmp = all_min(u); res = res > tmp ? tmp : res; } } return res; } template T all_max(const std::vector &v) { if (v.empty()) return T(); T res = v[0]; for (const auto &x : v) res = res < x ? x : res; return res; } template T all_max(const std::vector> &v) { T res{}; bool first = true; for (const auto &u : v) { if (u.empty()) continue; if (first) { res = all_max(u); first = false; } else { T tmp = all_max(u); res = res < tmp ? tmp : res; } } return res; } } // namespace kk2 #endif // KK2_TEMPLATE_FUNCTION_UTIL_HPP #ifndef KK2_TEMPLATE_IO_UTIL_HPP #define KK2_TEMPLATE_IO_UTIL_HPP 1 #ifndef KK2_TYPE_TRAITS_TYPE_TRAITS_HPP #define KK2_TYPE_TRAITS_TYPE_TRAITS_HPP 1 namespace kk2 { #ifndef _MSC_VER template using is_signed_int128 = typename std::conditional::value or std::is_same::value, std::true_type, std::false_type>::type; template using is_unsigned_int128 = typename std::conditional::value or std::is_same::value, std::true_type, std::false_type>::type; template using is_integral = typename std::conditional::value or is_signed_int128::value or is_unsigned_int128::value, std::true_type, std::false_type>::type; template using is_signed = typename std::conditional::value or is_signed_int128::value, std::true_type, std::false_type>::type; template using is_unsigned = typename std::conditional::value or is_unsigned_int128::value, std::true_type, std::false_type>::type; template using make_unsigned_int128 = typename std::conditional::value, __uint128_t, unsigned __int128>; template using to_unsigned = typename std::conditional::value, make_unsigned_int128, typename std::conditional::value, std::make_unsigned, std::common_type>::type>::type; #else template using is_integral = std::enable_if_t::value>; template using is_signed = std::enable_if_t::value>; template using is_unsigned = std::enable_if_t::value>; template using to_unsigned = std::make_unsigned; #endif // _MSC_VER template using is_integral_t = std::enable_if_t::value>; template using is_signed_t = std::enable_if_t::value>; template using is_unsigned_t = std::enable_if_t::value>; template using is_function_pointer = typename std::conditional && std::is_function_v>, std::true_type, std::false_type>::type; template ::value> * = nullptr> struct is_two_args_function_pointer : std::false_type {}; template struct is_two_args_function_pointer : std::true_type {}; template using is_two_args_function_pointer_t = std::enable_if_t::value>; namespace type_traits { struct istream_tag {}; struct ostream_tag {}; } // namespace type_traits template using is_standard_istream = typename std::conditional::value || std::is_same::value, std::true_type, std::false_type>::type; template using is_standard_ostream = typename std::conditional::value || std::is_same::value, std::true_type, std::false_type>::type; template using is_user_defined_istream = std::is_base_of; template using is_user_defined_ostream = std::is_base_of; template using is_istream = typename std::conditional::value || is_user_defined_istream::value, std::true_type, std::false_type>::type; template using is_ostream = typename std::conditional::value || is_user_defined_ostream::value, std::true_type, std::false_type>::type; template using is_istream_t = std::enable_if_t::value>; template using is_ostream_t = std::enable_if_t::value>; } // namespace kk2 #endif // KK2_TYPE_TRAITS_TYPE_TRAITS_HPP // なんかoj verifyはプロトタイプ宣言が落ちる namespace impl { struct read { template inline static void all_read(IStream &is, T &x) { is >> x; } template inline static void all_read(IStream &is, std::pair &p) { all_read(is, p.first); all_read(is, p.second); } template inline static void all_read(IStream &is, std::vector &v) { for (T &x : v) all_read(is, x); } template inline static void all_read(IStream &is, std::array &a) { for (T &x : a) all_read(is, x); } }; struct write { template inline static void all_write(OStream &os, const T &x) { os << x; } template inline static void all_write(OStream &os, const std::pair &p) { all_write(os, p.first); all_write(os, ' '); all_write(os, p.second); } template inline static void all_write(OStream &os, const std::vector &v) { for (int i = 0; i < (int)v.size(); ++i) { if (i) all_write(os, ' '); all_write(os, v[i]); } } template inline static void all_write(OStream &os, const std::array &a) { for (int i = 0; i < (int)F; ++i) { if (i) all_write(os, ' '); all_write(os, a[i]); } } }; } // namespace impl template * = nullptr> IStream &operator>>(IStream &is, std::pair &p) { impl::read::all_read(is, p); return is; } template * = nullptr> IStream &operator>>(IStream &is, std::vector &v) { impl::read::all_read(is, v); return is; } template * = nullptr> IStream &operator>>(IStream &is, std::array &a) { impl::read::all_read(is, a); return is; } template * = nullptr> OStream &operator<<(OStream &os, const std::pair &p) { impl::write::all_write(os, p); return os; } template * = nullptr> OStream &operator<<(OStream &os, const std::vector &v) { impl::write::all_write(os, v); return os; } template * = nullptr> OStream &operator<<(OStream &os, const std::array &a) { impl::write::all_write(os, a); return os; } #endif // KK2_TEMPLATE_IO_UTIL_HPP #ifndef KK2_TEMPLATE_MACROS_HPP #define KK2_TEMPLATE_MACROS_HPP 1 #define rep1(a) for (long long _ = 0; _ < (long long)(a); ++_) #define rep2(i, a) for (long long i = 0; i < (long long)(a); ++i) #define rep3(i, a, b) for (long long i = (a); i < (long long)(b); ++i) #define repi2(i, a) for (long long i = (a) - 1; i >= 0; --i) #define repi3(i, a, b) for (long long i = (a) - 1; i >= (long long)(b); --i) #define overload3(a, b, c, d, ...) d #define rep(...) overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define repi(...) overload3(__VA_ARGS__, repi3, repi2, rep1)(__VA_ARGS__) #define fi first #define se second #define all(p) p.begin(), p.end() #endif // KK2_TEMPLATE_MACROS_HPP struct FastIOSetUp { FastIOSetUp() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } fast_io_set_up; auto &kin = std::cin; auto &kout = std::cout; auto (*kendl)(std::ostream &) = std::endl>; void Yes(bool b = 1) { kout << (b ? "Yes\n" : "No\n"); } void No(bool b = 1) { kout << (b ? "No\n" : "Yes\n"); } void YES(bool b = 1) { kout << (b ? "YES\n" : "NO\n"); } void NO(bool b = 1) { kout << (b ? "NO\n" : "YES\n"); } void yes(bool b = 1) { kout << (b ? "yes\n" : "no\n"); } void no(bool b = 1) { kout << (b ? "no\n" : "yes\n"); } template inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); } template inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); } std::istream &operator>>(std::istream &is, u128 &x) { std::string s; is >> s; x = 0; for (char c : s) { assert('0' <= c && c <= '9'); x = x * 10 + c - '0'; } return is; } std::istream &operator>>(std::istream &is, i128 &x) { std::string s; is >> s; bool neg = s[0] == '-'; x = 0; for (int i = neg; i < (int)s.size(); i++) { assert('0' <= s[i] && s[i] <= '9'); x = x * 10 + s[i] - '0'; } if (neg) x = -x; return is; } std::ostream &operator<<(std::ostream &os, u128 x) { if (x == 0) return os << '0'; std::string s; while (x) { s.push_back('0' + x % 10); x /= 10; } std::reverse(s.begin(), s.end()); return os << s; } std::ostream &operator<<(std::ostream &os, i128 x) { if (x == 0) return os << '0'; if (x < 0) { os << '-'; x = -x; } std::string s; while (x) { s.push_back('0' + x % 10); x /= 10; } std::reverse(s.begin(), s.end()); return os << s; } #endif // KK2_TEMPLATE_PROCON_HPP #ifndef KK2_TEMPLATE_DEBUG_HPP #define KK2_TEMPLATE_DEBUG_HPP 1 #ifndef KK2_TYPE_TRAITS_MEMBER_HPP #define KK2_TYPE_TRAITS_MEMBER_HPP 1 namespace kk2 { #define HAS_MEMBER_FUNC(member) \ template struct has_member_func_##member##_impl { \ template \ static std::true_type check(decltype(std::declval().member(std::declval()...)) *); \ template static std::false_type check(...); \ using type = decltype(check(nullptr)); \ }; \ template \ struct has_member_func_##member : has_member_func_##member##_impl::type {}; \ template \ using has_member_func_##member##_t = \ std::enable_if_t::value>; \ template \ using not_has_member_func_##member##_t = \ std::enable_if_t::value>; #define HAS_MEMBER_VAR(member) \ template struct has_member_var_##member##_impl { \ template static std::true_type check(decltype(std::declval().member) *); \ template static std::false_type check(...); \ using type = decltype(check(nullptr)); \ }; \ template \ struct has_member_var_##member : has_member_var_##member##_impl::type {}; \ template \ using has_member_var_##member##_t = std::enable_if_t::value>; \ template \ using not_has_member_var_##member##_t = std::enable_if_t::value>; HAS_MEMBER_FUNC(debug_output) HAS_MEMBER_FUNC(val) #undef HAS_MEMBER_FUNC #undef HAS_MEMBER_VAR } // namespace kk2 #endif // KK2_TYPE_TRAITS_MEMBER_HPP namespace kk2 { namespace debug { #ifdef KK2 template *> void output(OStream &os); template *> void output(OStream &os, const T &t); template *> void output(OStream &os, const std::vector &v); template *> void output(OStream &os, const std::vector> &d); template *> void output(OStream &os, const std::array &a); template *> void output(OStream &os, const std::pair &p); template *> void output(OStream &os, const std::queue &q); template *> void output(OStream &os, const std::priority_queue &q); template *> void output(OStream &os, const std::deque &d); template *> void output(OStream &os, const std::stack &s); template *> void output(OStream &os, const std::set &s); template *> void output(OStream &os, const std::multiset &s); template *> void output(OStream &os, const std::unordered_set &s); template *> void output(OStream &os, const std::unordered_multiset &s); template *> void output(OStream &os, const std::map &m); template *> void output(OStream &os, const std::unordered_map &m); template * = nullptr> void output(OStream &) { } template * = nullptr> void output(OStream &os, const T &t) { if constexpr (has_member_func_debug_output::value) { t.debug_output(os); } else { os << t; } } template * = nullptr> void output(OStream &os, const std::vector &v) { os << "["; for (int i = 0; i < (int)v.size(); i++) { output(os, v[i]); if (i + 1 != (int)v.size()) os << ", "; } os << "]"; } template * = nullptr> void output(OStream &os, const std::vector> &d) { os << "[\n"; for (int i = 0; i < (int)d.size(); i++) { output(os, d[i]); output(os, "\n"); } os << "]"; } template * = nullptr> void output(OStream &os, const std::array &a) { os << "["; for (int i = 0; i < (int)F; i++) { output(os, a[i]); if (i + 1 != (int)F) os << ", "; } os << "]"; } template * = nullptr> void output(OStream &os, const std::pair &p) { os << "("; output(os, p.first); os << ", "; output(os, p.second); os << ")"; } template * = nullptr> void output(OStream &os, const std::queue &q) { os << "["; std::queue tmp = q; while (!tmp.empty()) { output(os, tmp.front()); tmp.pop(); if (!tmp.empty()) os << ", "; } os << "]"; } template * = nullptr> void output(OStream &os, const std::priority_queue &q) { os << "["; std::priority_queue tmp = q; while (!tmp.empty()) { output(os, tmp.top()); tmp.pop(); if (!tmp.empty()) os << ", "; } os << "]"; } template * = nullptr> void output(OStream &os, const std::deque &d) { os << "["; std::deque tmp = d; while (!tmp.empty()) { output(os, tmp.front()); tmp.pop_front(); if (!tmp.empty()) os << ", "; } os << "]"; } template * = nullptr> void output(OStream &os, const std::stack &s) { os << "["; std::stack tmp = s; std::vector v; while (!tmp.empty()) { v.push_back(tmp.top()); tmp.pop(); } for (int i = (int)v.size() - 1; i >= 0; i--) { output(os, v[i]); if (i != 0) os << ", "; } os << "]"; } template * = nullptr> void output(OStream &os, const std::set &s) { os << "{"; std::set tmp = s; for (auto it = tmp.begin(); it != tmp.end(); ++it) { output(os, *it); if (std::next(it) != tmp.end()) os << ", "; } os << "}"; } template * = nullptr> void output(OStream &os, const std::multiset &s) { os << "{"; std::multiset tmp = s; for (auto it = tmp.begin(); it != tmp.end(); ++it) { output(os, *it); if (std::next(it) != tmp.end()) os << ", "; } os << "}"; } template * = nullptr> void output(OStream &os, const std::unordered_set &s) { os << "{"; std::unordered_set tmp = s; for (auto it = tmp.begin(); it != tmp.end(); ++it) { output(os, *it); if (std::next(it) != tmp.end()) os << ", "; } os << "}"; } template * = nullptr> void output(OStream &os, const std::unordered_multiset &s) { os << "{"; std::unordered_multiset tmp = s; for (auto it = tmp.begin(); it != tmp.end(); ++it) { output(os, *it); if (std::next(it) != tmp.end()) os << ", "; } os << "}"; } template * = nullptr> void output(OStream &os, const std::map &m) { os << "{"; std::map tmp = m; for (auto it = tmp.begin(); it != tmp.end(); ++it) { output(os, it->first); os << ": "; output(os, it->second); if (std::next(it) != tmp.end()) os << ", "; } os << "}"; } template * = nullptr> void output(OStream &os, const std::unordered_map &m) { os << "{"; std::unordered_map tmp = m; for (auto it = tmp.begin(); it != tmp.end(); ++it) { output(os, it->first); os << ": "; output(os, it->second); if (std::next(it) != tmp.end()) os << ", "; } os << "}"; } template * = nullptr> void output(OStream &os, const T &t, const Args &...args) { output(os, t); os << ' '; output(os, args...); } template * = nullptr> void outputln(OStream &os) { os << '\n'; os.flush(); } template * = nullptr> void outputln(OStream &os, const T &t, const Args &...args) { output(os, t, args...); os << '\n'; os.flush(); } #else template * = nullptr> void output(OStream &, const Args &...) { } template * = nullptr> void outputln(OStream &, const Args &...) { } #endif // KK2 } // namespace debug } // namespace kk2 #endif // KK2_TEMPLATE_DEBUG_HPP #ifndef KK2_GEOMETRY_POINT_HPP #define KK2_GEOMETRY_POINT_HPP 1 namespace kk2 { template struct Point { static long double PI; T x, y; Point(T x = 0, T y = 0) : x(x), y(y) {} bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator<=(const Point &p) const { return x != p.x ? x < p.x : y <= p.y; } bool operator>(const Point &p) const { return x != p.x ? x > p.x : y > p.y; } bool operator>=(const Point &p) const { return x != p.x ? x > p.x : y >= p.y; } bool operator==(const Point &p) const { return x == p.x && y == p.y; } bool operator!=(const Point &p) const { return x != p.x || y != p.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*=(T k) { x *= k; y *= k; return *this; } Point &operator/=(T k) { x /= k; y /= k; return *this; } Point operator+(const Point &p) const { return Point(*this) += p; } Point operator-(const Point &p) const { return Point(*this) -= p; } Point operator*(T k) const { return Point(*this) *= k; } Point operator/(T k) const { return Point(*this) /= k; } T dot(const Point &p) const { return x * p.x + y * p.y; } T cross(const Point &p) const { return x * p.y - y * p.x; } T cross(const Point &p, const Point &O) const { return (*this - O).cross(p - O); } T norm() const { return x * x + y * y; } T norm(const Point &p) const { return (p - *this).norm(); } long double abs() const { return sqrt(norm()); } long double dist(const Point &p) const { return (p - *this).abs(); } long double argument() const { return atan2(y, x); } // this -> p long double argument(const Point &p) const { long double res = p.argument() - argument(); if (res < -PI) res += 2 * PI; if (res > PI) res -= 2 * PI; return res; } long double argument(const Point &p, const Point &O) const { return (*this - O).argument(p - O); } Point inplace_rotate90() { std::swap(x, y); x = -x; return *this; } Point inplace_rotate90(const Point &O) { *this -= O; inplace_rotate90(); return *this += O; } Point rotate90() const { return Point(-y, x); } Point rotate90(Point O) const { return (*this - O).rotate90() + O; } Point inplace_rotate180() { x = -x; y = -y; return *this; } Point inplace_rotate180(const Point &O) { *this -= O; inplace_rotate180(); return *this += O; } Point rotate180() const { return Point(-x, -y); } Point rotate180(const Point &O) const { return (*this - O).rotate180() + O; } Point inplace_rotate270() { std::swap(x, y); y = -y; return *this; } Point inplace_rotate270(const Point &O) { *this -= O; inplace_rotate270(); return *this += O; } Point rotate270() const { return Point(y, -x); } Point rotate270(const Point &O) const { return (*this - O).rotate270() + O; } friend T dot(const Point &p, const Point &q) { return p.dot(q); } friend T cross(const Point &p, const Point &q) { return p.cross(q); } friend T cross(const Point &p, const Point &q, const Point &O) { return p.cross(q, O); } friend T norm(const Point &p) { return p.norm(); } friend T norm(const Point &p, const Point &q) { return p.norm(q); } friend long double abs(const Point &p) { return p.abs(); } friend long double dist(const Point &p, const Point &q) { return (p - q).abs(); } friend long double argument(const Point &p) { return p.argument(); } friend long double argument(const Point &p, const Point &q) { return p.argument(q); } friend long double argument(const Point &p, const Point &q, const Point &O) { return p.argument(q, O); } friend Point rotate90(const Point &p) { return p.rotate90(); } friend Point rotate90(const Point &p, const Point &O) { return p.rotate90(O); } friend Point rotate180(const Point &p) { return p.rotate180(); } friend Point rotate180(const Point &p, const Point &O) { return p.rotate180(O); } friend Point rotate270(const Point &p) { return p.rotate270(); } friend Point rotate270(const Point &p, const Point &O) { return p.rotate270(O); } template * = nullptr> friend OStream &operator<<(OStream &os, const Point &p) { return os << p.x << " " << p.y; } template * = nullptr> friend IStream &operator>>(IStream &is, Point &p) { return is >> p.x >> p.y; } }; template long double Point::PI = std::acos(-1.0); } // namespace kk2 #endif // KK2_GEOMETRY_POINT_HPP #ifndef KK2_RANDOM_GEN_HPP #define KK2_RANDOM_GEN_HPP 1 #ifndef KK2_RANDOM_SEED_HPP #define KK2_RANDOM_SEED_HPP 1 namespace kk2 { namespace random { using u64 = unsigned long long; inline u64 non_deterministic_seed() { u64 seed = std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); seed ^= reinterpret_cast(&seed); seed ^= seed << 5; seed ^= seed >> 41; seed ^= seed << 20; return seed; } inline u64 deterministic_seed() { return 5801799128519729247ull; } inline u64 seed() { #if defined(KK2_RANDOM_DETERMINISTIC) return deterministic_seed(); #else return non_deterministic_seed(); #endif } } // namespace random } // namespace kk2 #endif // KK2_RANDOM_SEED_HPP namespace kk2 { namespace random { using i64 = long long; using u64 = unsigned long long; inline u64 rng() { static std::mt19937_64 mt(kk2::random::seed()); return mt(); } // [l, r) inline i64 rng(i64 l, i64 r) { assert(l < r); return l + rng() % (r - l); } // [l, r) template std::vector random_vector(int n, T l, T r) { std::vector res(n); for (int i = 0; i < n; i++) res[i] = rng(l, r); return res; } // [l, r) std::vector distinct_rng(i64 l, i64 r, i64 n) { assert(l < r and n <= r - l); std::unordered_set st; for (i64 i = n; i; --i) { i64 m = rng(l, r + 1 - i); if (st.find(m) != st.end()) m = r - i; st.insert(m); } std::vector res(st.begin(), st.end()); std::sort(res.begin(), res.end()); return res; } template void shuffle(Iter first, Iter last) { if (first == last) return; int len = 1; for (auto it = first + 1; it != last; ++it) { len++; int j = rng(0, len); if (j != len - 1) std::iter_swap(first + j, it); } } template std::vector perm(int n) { std::vector res(n); std::iota(res.begin(), res.end(), T(0)); shuffle(res.begin(), res.end()); return res; } template std::vector choices(int l, int r, int k) { assert(l < r and k <= r - l); std::vector res(r - l); std::iota(res.begin(), res.end(), T(l)); shuffle(res.begin(), res.end()); res.resize(k); return res; } } // namespace random } // namespace kk2 #endif // KK2_RANDOM_GEN_HPP using namespace std; void solve() { /* 縦線でだいたい分けて,すこしだけ傾ければ良い |a|, |b| <= 10^5 がとても厳しい 傾きを適当にとってきて, 半分を目指す. 直線の上側か下側かを見ればカウントができる 普通に符号をみればよい 傾きの種類は, m = 1e5 2 * \sum_{n=1}^{m} \floor(m / n) * \phi(n) > 10^10 */ int n; kin >> n; vc> p(2 * n); kin >> p; sort(all(p)); constexpr int m = 1e5; auto count = [&](i64 a, i64 b, i64 c) -> array { // y = (a / b)x + c / b int count_up = 0, count_down = 0, count_on = 0; rep (i, 2 * n) { i64 l = b * p[i].y; i64 r = a * p[i].x + c; if (l > r) count_up++; else if (l < r) count_down++; else count_on++; } return {count_up, count_down, count_on}; }; while (true) { int b = kk2::random::rng(1, m + 1), a = kk2::random::rng(0, m + 1); // int b = 3, a = 1; int g = gcd(a, b); a /= g, b /= g; // kk2::debug::outputln(kout, a, b); i64 ok = i64(-2e10), ng = i64(2e10); while (ng - ok > 1) { i64 mid = (ok + ng) / 2; auto [count_up, count_down, count_on] = count(a, b, mid); if (count_up == n and count_down == n) { ok = mid; break; } if (count_up >= n) ok = mid; else ng = mid; } auto [count_up, count_down, count_on] = count(a, b, ok); // kout << ok << kendl; if (count_up == n and count_down == n) { kout << -a << " " << b << " " << -ok << kendl; return; } else continue; } } int main() { int t = 1; // kin >> t; rep (t) solve(); return 0; } // Author: kk2 // converted by https://github.com/kk2a/cpp-bundle // 2025-03-31 06:36:37