QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#284726 | #7934. Christmas Sky | ucup-team180# | AC ✓ | 1045ms | 65764kb | C++20 | 41.5kb | 2023-12-16 14:44:44 | 2023-12-16 14:44:45 |
Judging History
answer
#pragma region Macros
#ifdef noimi
#include "my_template.hpp"
#else
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <immintrin.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <immintrin.h>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <variant>
#ifdef noimi
#define oj_local(a, b) b
#else
#define oj_local(a, b) a
#endif
#define LOCAL if(oj_local(0, 1))
#define OJ if(oj_local(1, 0))
using namespace std;
using ll = long long;
using ull = unsigned long long int;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vc<T>>;
template <typename T> using vvvc = vector<vvc<T>>;
using vi = vc<int>;
using vl = vc<ll>;
using vpi = vc<pii>;
using vpl = vc<pll>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename T> int si(const T &x) { return x.size(); }
template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
vi iota(int n) {
vi a(n);
return iota(a.begin(), a.end(), 0), a;
}
template <typename T> vi iota(const vector<T> &a, bool greater = false) {
vi res(a.size());
iota(res.begin(), res.end(), 0);
sort(res.begin(), res.end(), [&](int i, int j) {
if(greater) return a[i] > a[j];
return a[i] < a[j];
});
return res;
}
// macros
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define endl '\n'
#define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf)
#define REP1(i, n) for(ll i = 0; i < (n); ++i)
#define REP2(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf)
#define per1(i, n) for(ll i = (n)-1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (a)-1; i >= b; --i)
#define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__)
#define fore0(a) rep(a.size())
#define fore1(i, a) for(auto &&i : a)
#define fore2(a, b, v) for(auto &&[a, b] : v)
#define fore3(a, b, c, v) for(auto &&[a, b, c] : v)
#define fore4(a, b, c, d, v) for(auto &&[a, b, c, d] : v)
#define fore(...) overload5(__VA_ARGS__, fore4, fore3, fore2, fore1, fore0)(__VA_ARGS__)
#define setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii))
#define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, false) : next_permutation(all(v)));)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define drop(s) cout << #s << endl, exit(0)
#define si(c) (int)(c).size()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
#define rng(v, l, r) v.begin() + (l), v.begin() + (r)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define SORT(v) sort(all(v))
#define REV(v) reverse(all(v))
#define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end())
template <typename T = ll, typename S> T SUM(const S &v) { return accumulate(all(v), T(0)); }
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...) \
vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
constexpr pii dx4[4] = {pii{1, 0}, pii{0, 1}, pii{-1, 0}, pii{0, -1}};
constexpr pii dx8[8] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};
namespace yesno_impl {
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
const string firstsecond[2] = {"second", "first"};
const string FirstSecond[2] = {"Second", "First"};
const string possiblestr[2] = {"impossible", "possible"};
const string Possiblestr[2] = {"Impossible", "Possible"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { cout << yesno[t] << endl; }
void no(bool t = 1) { yes(!t); }
void first(bool t = 1) { cout << firstsecond[t] << endl; }
void First(bool t = 1) { cout << FirstSecond[t] << endl; }
void possible(bool t = 1) { cout << possiblestr[t] << endl; }
void Possible(bool t = 1) { cout << Possiblestr[t] << endl; }
}; // namespace yesno_impl
using namespace yesno_impl;
#define INT(...) \
int __VA_ARGS__; \
IN(__VA_ARGS__)
#define INTd(...) \
int __VA_ARGS__; \
IN2(__VA_ARGS__)
#define LL(...) \
ll __VA_ARGS__; \
IN(__VA_ARGS__)
#define LLd(...) \
ll __VA_ARGS__; \
IN2(__VA_ARGS__)
#define STR(...) \
string __VA_ARGS__; \
IN(__VA_ARGS__)
#define CHR(...) \
char __VA_ARGS__; \
IN(__VA_ARGS__)
#define DBL(...) \
double __VA_ARGS__; \
IN(__VA_ARGS__)
#define VEC(type, name, size) \
vector<type> name(size); \
IN(name)
#define VECd(type, name, size) \
vector<type> name(size); \
IN2(name)
#define VEC2(type, name1, name2, size) \
vector<type> name1(size), name2(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i])
#define VEC2d(type, name1, name2, size) \
vector<type> name1(size), name2(size); \
for(int i = 0; i < size; i++) IN2(name1[i], name2[i])
#define VEC3(type, name1, name2, name3, size) \
vector<type> name1(size), name2(size), name3(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])
#define VEC3d(type, name1, name2, name3, size) \
vector<type> name1(size), name2(size), name3(size); \
for(int i = 0; i < size; i++) IN2(name1[i], name2[i], name3[i])
#define VEC4(type, name1, name2, name3, name4, size) \
vector<type> name1(size), name2(size), name3(size), name4(size); \
for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i], name4[i]);
#define VEC4d(type, name1, name2, name3, name4, size) \
vector<type> name1(size), name2(size), name3(size), name4(size); \
for(int i = 0; i < size; i++) IN2(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
IN(name)
#define VVd(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
IN2(name)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
void IN2() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
scan(head);
IN(tail...);
}
template <class Head, class... Tail> void IN2(Head &head, Tail &...tail) {
scan(head);
--head;
IN2(tail...);
}
template <int p = -1> void pat() {}
template <int p = -1, class Head, class... Tail> void pat(Head &h, Tail &...tail) {
h += p;
pat<p>(tail...);
}
template <typename T, typename S> T ceil(T x, S y) {
assert(y);
return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y));
}
template <typename T, typename S> T floor(T x, S y) {
assert(y);
return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : x / y - (x % y == 0 ? 0 : 1)));
}
template <typename T, typename S, typename U> U bigmul(const T &x, const S &y, const U &lim) { // clamp(x * y, -lim, lim)
if(x < 0 and y < 0) return bigmul(-x, -y, lim);
if(x < 0) return -bigmul(-x, y, lim);
if(y < 0) return -bigmul(x, -y, lim);
return y == 0 or x <= lim / y ? x * y : lim;
}
template <class T> T POW(T x, int n) {
T res = 1;
for(; n; n >>= 1, x *= x)
if(n & 1) res *= x;
return res;
}
template <class T, class S> T POW(T x, S n, const ll &mod) {
T res = 1;
x %= mod;
for(; n; n >>= 1, x = x * x % mod)
if(n & 1) res = res * x % mod;
return res;
}
vector<pll> factor(ll x) {
vector<pll> ans;
for(ll i = 2; i * i <= x; i++)
if(x % i == 0) {
ans.push_back({i, 1});
while((x /= i) % i == 0) ans.back().second++;
}
if(x != 1) ans.push_back({x, 1});
return ans;
}
template <class T> vector<T> divisor(T x) {
vector<T> ans;
for(T i = 1; i * i <= x; i++)
if(x % i == 0) {
ans.pb(i);
if(i * i != x) ans.pb(x / i);
}
return ans;
}
template <typename T> void zip(vector<T> &x) {
vector<T> y = x;
UNIQUE(y);
for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }
}
template <class S> void fold_in(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void fold_in(vector<S> &v, Head &&a, Tail &&...tail) {
for(auto e : a) v.emplace_back(e);
fold_in(v, tail...);
}
template <class S> void renumber(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void renumber(vector<S> &v, Head &&a, Tail &&...tail) {
for(auto &&e : a) e = lb(v, e);
renumber(v, tail...);
}
template <class S, class... Args> vector<S> zip(vector<S> &head, Args &&...args) {
vector<S> v;
fold_in(v, head, args...);
sort(all(v)), v.erase(unique(all(v)), v.end());
renumber(v, head, args...);
return v;
}
template <typename S> void rearrange(const vector<S> &id) {}
template <typename S, typename T> void rearrange_exec(const vector<S> &id, vector<T> &v) {
vector<T> w(v.size());
rep(i, si(id)) w[i] = v[id[i]];
v.swap(w);
}
// 並び替える順番, 並び替える vector 達
template <typename S, typename Head, typename... Tail> void rearrange(const vector<S> &id, Head &a, Tail &...tail) {
rearrange_exec(id, a);
rearrange(id, tail...);
}
template <typename T> vector<T> RUI(const vector<T> &v) {
vector<T> res(v.size() + 1);
for(int i = 0; i < v.size(); i++) res[i + 1] = res[i] + v[i];
return res;
}
template <typename T> void zeta_supersetsum(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b] += f[b | i];
}
template <typename T> void zeta_subsetsum(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b | i] += f[b];
}
template <typename T> void mobius_subset(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b] -= f[b | i];
}
template <typename T> void mobius_superset(vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b | i] -= f[b];
}
// 反時計周りに 90 度回転
template <typename T> void rot(vector<vector<T>> &v) {
if(empty(v)) return;
int n = v.size(), m = v[0].size();
vector<vector<T>> res(m, vector<T>(n));
rep(i, n) rep(j, m) res[m - 1 - j][i] = v[i][j];
v.swap(res);
}
vector<int> counter(const vector<int> &v, int max_num = -1) {
if(max_num == -1) max_num = MAX(v);
vector<int> res(max_num + 1);
fore(e, v) res[e]++;
return res;
}
// x in [l, r)
template <class T, class S> bool inc(const T &x, const S &l, const S &r) { return l <= x and x < r; }
template <class T, class S> bool inc(const T &x, const pair<S, S> &p) { return p.first <= x and x < p.second; }
// 便利関数
constexpr ll ten(int n) { return n == 0 ? 1 : ten(n - 1) * 10; }
constexpr ll tri(ll n) { return n * (n + 1) / 2; }
// l + ... + r
constexpr ll tri(ll l, ll r) { return (l + r) * (r - l + 1) / 2; }
ll max(int x, ll y) { return max((ll)x, y); }
ll max(ll x, int y) { return max(x, (ll)y); }
int min(int x, ll y) { return min((ll)x, y); }
int min(ll x, int y) { return min(x, (ll)y); }
// bit 演算系
#define bit(i) (1LL << i) // (1 << i)
#define test(b, i) (b >> i & 1) // b の i bit 目が立っているか
ll pow2(int i) { return 1LL << i; }
int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }
int lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); }
// int allbit(int n) { return (1 << n) - 1; }
constexpr ll mask(int n) { return (1LL << n) - 1; }
// int popcount(signed t) { return __builtin_popcount(t); }
// int popcount(ll t) { return __builtin_popcountll(t); }
int popcount(uint64_t t) { return __builtin_popcountll(t); }
static inline uint64_t popcount64(uint64_t x) {
uint64_t m1 = 0x5555555555555555ll;
uint64_t m2 = 0x3333333333333333ll;
uint64_t m4 = 0x0F0F0F0F0F0F0F0Fll;
uint64_t h01 = 0x0101010101010101ll;
x -= (x >> 1) & m1;
x = (x & m2) + ((x >> 2) & m2);
x = (x + (x >> 4)) & m4;
return (x * h01) >> 56;
}
bool ispow2(int i) { return i && (i & -i) == i; }
ll rnd(ll l, ll r) { //[l, r)
#ifdef noimi
static mt19937_64 gen;
#else
static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
#endif
return uniform_int_distribution<ll>(l, r - 1)(gen);
}
ll rnd(ll n) { return rnd(0, n); }
template <class t> void random_shuffle(vc<t> &a) { rep(i, si(a)) swap(a[i], a[rnd(0, i + 1)]); }
int in() {
int x;
cin >> x;
return x;
}
ll lin() {
unsigned long long x;
cin >> x;
return x;
}
template <class T, class S> pair<T, S> operator-(const pair<T, S> &x) { return pair<T, S>(-x.first, -x.second); }
template <class T, class S> pair<T, S> operator-(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi - y.fi, x.se - y.se); }
template <class T, class S> pair<T, S> operator+(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi + y.fi, x.se + y.se); }
template <class T> pair<T, T> operator&(const pair<T, T> &l, const pair<T, T> &r) { return pair<T, T>(max(l.fi, r.fi), min(l.se, r.se)); }
template <class T, class S> pair<T, S> operator+=(pair<T, S> &l, const pair<T, S> &r) { return l = l + r; }
template <class T, class S> pair<T, S> operator-=(pair<T, S> &l, const pair<T, S> &r) { return l = l - r; }
template <class T> bool intersect(const pair<T, T> &l, const pair<T, T> &r) { return (l.se < r.se ? r.fi < l.se : l.fi < r.se); }
template <class T> vector<T> &operator++(vector<T> &v) {
fore(e, v) e++;
return v;
}
template <class T> vector<T> operator++(vector<T> &v, int) {
auto res = v;
fore(e, v) e++;
return res;
}
template <class T> vector<T> &operator--(vector<T> &v) {
fore(e, v) e--;
return v;
}
template <class T> vector<T> operator--(vector<T> &v, int) {
auto res = v;
fore(e, v) e--;
return res;
}
template <class T> void connect(vector<T> &l, const vector<T> &r) { fore(e, r) l.eb(e); }
template <class T> vector<T> operator+(const vector<T> &l, const vector<T> &r) {
vector<T> res(max(si(l), si(r)));
rep(i, si(l)) res[i] += l[i];
rep(i, si(r)) res[i] += r[i];
return res;
}
template <class T> vector<T> operator-(const vector<T> &l, const vector<T> &r) {
vector<T> res(max(si(l), si(r)));
rep(i, si(l)) res[i] += l[i];
rep(i, si(r)) res[i] -= r[i];
return res;
}
template <class T> vector<T> &operator+=(const vector<T> &l, const vector<T> &r) {
if(si(l) < si(r)) l.resize(si(r));
rep(i, si(r)) l[i] += r[i];
return l;
}
template <class T> vector<T> &operator-=(const vector<T> &l, const vector<T> &r) {
if(si(l) < si(r)) l.resize(si(r));
rep(i, si(r)) l[i] -= r[i];
return l;
}
template <class T> vector<T> &operator+=(vector<T> &v, const T &x) {
fore(e, v) e += x;
return v;
}
template <class T> vector<T> &operator-=(vector<T> &v, const T &x) {
fore(e, v) e -= x;
return v;
}
template <typename T> struct edge {
int from, to;
T cost;
int id;
edge(int to, T cost) : from(-1), to(to), cost(cost) {}
edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id) {}
constexpr bool operator<(const edge<T> &rhs) const noexcept { return cost < rhs.cost; }
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
friend ostream operator<<(ostream &os, const edge &e) { return os << e.to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T = int> Edges<T> read_edges(int m, bool weighted = false) {
Edges<T> res;
res.reserve(m);
for(int i = 0; i < m; i++) {
int u, v, c = 0;
scan(u), scan(v), u--, v--;
if(weighted) scan(c);
res.eb(u, v, c, i);
}
return res;
}
using Tree = vector<vector<int>>;
using Graph = vector<vector<int>>;
template <class T> using Wgraph = vector<vector<edge<T>>>;
Graph getG(int n, int m = -1, bool directed = false, int margin = 1) {
Tree res(n);
if(m == -1) m = n - 1;
while(m--) {
int a, b;
cin >> a >> b;
a -= margin, b -= margin;
res[a].emplace_back(b);
if(!directed) res[b].emplace_back(a);
}
return res;
}
Graph getTreeFromPar(int n, int margin = 1) {
Graph res(n);
for(int i = 1; i < n; i++) {
int a;
cin >> a;
res[a - margin].emplace_back(i);
}
return res;
}
template <class T> Wgraph<T> getWg(int n, int m = -1, bool directed = false, int margin = 1) {
Wgraph<T> res(n);
if(m == -1) m = n - 1;
while(m--) {
int a, b;
T c;
scan(a), scan(b), scan(c);
a -= margin, b -= margin;
res[a].emplace_back(b, c);
if(!directed) res[b].emplace_back(a, c);
}
return res;
}
void add(Graph &G, int x, int y) { G[x].eb(y), G[y].eb(x); }
template <class S, class T> void add(Wgraph<S> &G, int x, int y, T c) { G[x].eb(y, c), G[y].eb(x, c); }
#define TEST \
INT(testcases); \
while(testcases--)
i128 abs(const i128 &x) { return x > 0 ? x : -x; }
istream &operator>>(istream &is, i128 &v) {
string s;
is >> s;
v = 0;
for(int i = 0; i < (int)s.size(); i++) {
if(isdigit(s[i])) { v = v * 10 + s[i] - '0'; }
}
if(s[0] == '-') { v *= -1; }
return is;
}
ostream &operator<<(ostream &os, const i128 &v) {
if(v == 0) { return (os << "0"); }
i128 num = v;
if(v < 0) {
os << '-';
num = -num;
}
string s;
for(; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
reverse(s.begin(), s.end());
return (os << s);
}
namespace aux {
template <typename T, unsigned N, unsigned L> struct tp {
static void output(std::ostream &os, const T &v) {
os << std::get<N>(v) << (&os == &cerr ? ", " : " ");
tp<T, N + 1, L>::output(os, v);
}
};
template <typename T, unsigned N> struct tp<T, N, N> {
static void output(std::ostream &os, const T &v) { os << std::get<N>(v); }
};
} // namespace aux
template <typename... Ts> std::ostream &operator<<(std::ostream &os, const std::tuple<Ts...> &t) {
if(&os == &cerr) { os << '('; }
aux::tp<std::tuple<Ts...>, 0, sizeof...(Ts) - 1>::output(os, t);
if(&os == &cerr) { os << ')'; }
return os;
}
template <typename T, typename S, typename U> std::ostream &operator<<(std::ostream &os, const priority_queue<T, S, U> &_pq) {
auto pq = _pq;
vector<T> res;
while(!empty(pq)) res.emplace_back(pq.top()), pq.pop();
return os << res;
}
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) {
if(&os == &cerr) { return os << "(" << p.first << ", " << p.second << ")"; }
return os << p.first << " " << p.second;
}
template <class Ch, class Tr, class Container> std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, const Container &x) {
bool f = true;
if(&os == &cerr) os << "[";
for(auto &y : x) {
if(&os == &cerr)
os << (f ? "" : ", ") << y;
else
os << (f ? "" : " ") << y;
f = false;
}
if(&os == &cerr) os << "]";
return os;
}
#define dump(...) static_cast<void>(0)
#define dbg(...) static_cast<void>(0)
void OUT() { cout << endl; }
template <class Head, class... Tail> void OUT(const Head &head, const Tail &...tail) {
cout << head;
if(sizeof...(tail)) cout << ' ';
OUT(tail...);
}
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
template <class T, class S> constexpr pair<T, S> inf<pair<T, S>> = {inf<T>, inf<S>};
template <class T> void OUT2(const T &t, T INF = inf<T>, T res = -1) { OUT(t != INF ? t : res); }
template <class T> void OUT2(vector<T> &v, T INF = inf<T>, T res = -1) {
fore(e, v) if(e == INF) e = res;
OUT(v);
fore(e, v) if(e == res) e = INF;
}
template <class F> struct REC {
F f;
REC(F &&f_) : f(forward<F>(f_)) {}
template <class... Args> auto operator()(Args &&...args) const { return f(*this, forward<Args>(args)...); }
};
template <class S> vector<pair<S, int>> runLength(const vector<S> &v) {
vector<pair<S, int>> res;
for(auto &e : v) {
if(res.empty() or res.back().fi != e)
res.eb(e, 1);
else
res.back().se++;
}
return res;
}
vector<pair<char, int>> runLength(const string &v) {
vector<pair<char, int>> res;
for(auto &e : v) {
if(res.empty() or res.back().fi != e)
res.eb(e, 1);
else
res.back().se++;
}
return res;
}
struct string_converter {
char start = 0;
char type(const char &c) const { return (islower(c) ? 'a' : isupper(c) ? 'A' : isdigit(c) ? '0' : 0); }
int convert(const char &c) {
if(!start) start = type(c);
return c - start;
}
int convert(const char &c, const string &chars) { return chars.find(c); }
template <typename T> auto convert(const T &v) {
vector<decltype(convert(v[0]))> ret;
ret.reserve(size(v));
for(auto &&e : v) ret.emplace_back(convert(e));
return ret;
}
template <typename T> auto convert(const T &v, const string &chars) {
vector<decltype(convert(v[0], chars))> ret;
ret.reserve(size(v));
for(auto &&e : v) ret.emplace_back(convert(e, chars));
return ret;
}
int operator()(const char &v, char s = 0) {
start = s;
return convert(v);
}
int operator()(const char &v, const string &chars) { return convert(v, chars); }
template <typename T> auto operator()(const T &v, char s = 0) {
start = s;
return convert(v);
}
template <typename T> auto operator()(const T &v, const string &chars) { return convert(v, chars); }
} toint;
template <class T, class F> T bin_search(T ok, T ng, const F &f) {
while(abs(ok - ng) > 1) {
T mid = ok + ng >> 1;
(f(mid) ? ok : ng) = mid;
}
return ok;
}
template <class T, class F> T bin_search_double(T ok, T ng, const F &f, int iter = 80) {
while(iter--) {
// T mid = (ok + ng) / 2;
T mid = sqrtl(ok * ng);
(f(mid) ? ok : ng) = mid;
}
return ok;
}
struct Setup_io {
Setup_io() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(11);
}
} setup_io;
#endif
#pragma endregion
namespace Geometry {
using T = ll;
constexpr T eps = 0;
bool eq(const T &x, const T &y) { return abs(x - y) <= eps; }
inline constexpr int type(T x, T y) {
if(x == 0 and y == 0) return 0;
if(y < 0 or (y == 0 and x > 0)) return -1;
return 1;
}
struct Point {
T x, y;
constexpr Point(T _x = 0, T _y = 0) : x(_x), y(_y) {}
constexpr Point operator+() const noexcept { return *this; }
constexpr Point operator-() const noexcept { return Point(-x, -y); }
constexpr Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
constexpr Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }
constexpr Point &operator+=(const Point &p) { return x += p.x, y += p.y, *this; }
constexpr Point &operator-=(const Point &p) { return x -= p.x, y -= p.y, *this; }
constexpr T operator*(const Point &p) const { return x * p.x + y * p.y; }
constexpr Point &operator*=(const T &k) { return x *= k, y *= k, *this; }
constexpr Point operator*(const T &k) { return Point(x * k, y * k); }
constexpr bool operator==(const Point &r) const noexcept { return r.x == x and r.y == y; }
constexpr T cross(const Point &r) const { return x * r.y - y * r.x; }
constexpr bool operator<(const Point &r) const { return pair(x, y) < pair(r.x, r.y); }
// 1 : left, 0 : same, -1 : right
constexpr int toleft(const Point &r) const {
auto t = cross(r);
return t > eps ? 1 : t < -eps ? -1 : 0;
}
constexpr bool arg_cmp(const Point &r) const {
int L = type(x, y), R = type(r.x, r.y);
if(L != R) return L < R;
T X = x * r.y, Y = r.x * y;
if(X != Y) return X > Y;
return x < r.x;
}
};
bool arg_cmp(const Point &l, const Point &r) { return l.arg_cmp(r); }
ostream &operator<<(ostream &os, const Point &p) { return os << p.x << " " << p.y; }
istream &operator>>(istream &is, Point &p) {
is >> p.x >> p.y;
return is;
}
struct Line {
Point a, b;
Line() = default;
Line(Point a, Point b) : a(a), b(b) {}
// ax + by = c
Line(T A, T B, T C) {
if(A == 0) {
a = Point(0, C / B), b = Point(1, C / B);
} else if(B == 0) {
a = Point(C / A, 0), b = Point(C / A, 1);
} else {
a = Point(0, C / B), b = Point(C / A, 0);
}
}
// 1 : left, 0 : same, -1 : right
constexpr int toleft(const Point &r) const {
auto t = (b - a).cross(r - a);
return t > eps ? 1 : t < -eps ? -1 : 0;
}
friend std::ostream &operator<<(std::ostream &os, Line &ls) {
return os << "{"
<< "(" << ls.a.x << ", " << ls.a.y << "), (" << ls.b.x << ", " << ls.b.y << ")}";
}
};
istream &operator>>(istream &is, Line &p) { return is >> p.a >> p.b; }
struct Segment : Line {
Segment() = default;
Segment(Point a, Point b) : Line(a, b) {}
};
ostream &operator<<(ostream &os, Segment &p) { return os << p.a << " to " << p.b; }
istream &operator>>(istream &is, Segment &p) {
is >> p.a >> p.b;
return is;
}
struct Circle {
Point p;
T r;
Circle() = default;
Circle(Point p, T r) : p(p), r(r) {}
};
using pt = Point;
using Points = vector<pt>;
using Polygon = Points;
T cross(const pt &x, const pt &y) { return x.x * y.y - x.y * y.x; }
T dot(const pt &x, const pt &y) { return x.x * y.x + x.y * y.y; }
T abs2(const pt &x) { return dot(x, x); }
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C
// 点の回転方向
int ccw(const Point &a, Point b, Point c) {
b = b - a, c = c - a;
if(cross(b, c) > 0) return +1; // "COUNTER_CLOCKWISE"
if(cross(b, c) < 0) return -1; // "CLOCKWISE"
if(dot(b, c) < 0) return +2; // "ONLINE_BACK"
if(abs2(b) < abs2(c)) return -2; // "ONLINE_FRONT"
return 0; // "ON_SEGMENT"
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A
// 平行判定
bool parallel(const Line &a, const Line &b) { return (cross(a.b - a.a, b.b - b.a) == 0); }
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A
// 垂直判定
bool orthogonal(const Line &a, const Line &b) { return (dot(a.a - a.b, b.a - b.b) == 0); }
bool intersect(const Line &l, const Point &p) { return abs(ccw(l.a, l.b, p)) != 1; }
bool intersect(const Line &l, const Line &m) { return !parallel(l, m); }
bool intersect(const Segment &s, const Point &p) { return ccw(s.a, s.b, p) == 0; }
bool intersect(const Line &l, const Segment &s) { return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) <= 0; }
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B
bool intersect(const Segment &s, const Segment &t) { return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0; }
bool intersect(const Polygon &ps, const Polygon &qs) {
int pl = si(ps), ql = si(qs), i = 0, j = 0;
while((i < pl or j < ql) and (i < 2 * pl) and (j < 2 * ql)) {
auto ps0 = ps[(i + pl - 1) % pl], ps1 = ps[i % pl];
auto qs0 = qs[(j + ql - 1) % ql], qs1 = qs[j % ql];
if(intersect(Segment(ps0, ps1), Segment(qs0, qs1))) return true;
Point a = ps1 - ps0;
Point b = qs1 - qs0;
T v = cross(a, b);
T va = cross(qs1 - qs0, ps1 - qs0);
T vb = cross(ps1 - ps0, qs1 - ps0);
if(!v and va < 0 and vb < 0) return false;
if(!v and !va and !vb) {
i += 1;
} else if(v >= 0) {
if(vb > 0)
i += 1;
else
j += 1;
} else {
if(va > 0)
j += 1;
else
i += 1;
}
}
return false;
}
T norm(const Point &p) { return p.x * p.x + p.y * p.y; }
Point projection(const Segment &l, const Point &p) {
T t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + (l.a - l.b) * t;
}
Point crosspoint(const Line &l, const Line &m) {
T A = cross(l.b - l.a, m.b - m.a);
T B = cross(l.b - l.a, l.b - m.a);
if(A == 0 and B == 0) return m.a;
return m.a + (m.b - m.a) * (B / A);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_C
Point crosspoint(const Segment &l, const Segment &m) { return crosspoint(Line(l), Line(m)); }
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_B
// 凸性判定
bool is_convex(const Points &p) {
int n = (int)p.size();
for(int i = 0; i < n; i++) {
if(ccw(p[(i + n - 1) % n], p[i], p[(i + 1) % n]) == -1) return false;
}
return true;
}
Points convex_hull(Points p) {
int n = p.size(), k = 0;
if(n <= 2) return p;
sort(begin(p), end(p), [](pt x, pt y) { return (x.x != y.x ? x.x < y.x : x.y < y.y); });
Points ch(2 * n);
for(int i = 0; i < n; ch[k++] = p[i++]) {
while(k >= 2 && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) <= 0) --k;
}
for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
while(k >= t && cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) <= 0) --k;
}
ch.resize(k - 1);
return ch;
}
// 面積の 2 倍
T area2(const Points &p) {
T res = 0;
rep(i, si(p)) { res += cross(p[i], p[i == si(p) - 1 ? 0 : i + 1]); }
return res;
}
enum { _OUT, _ON, _IN };
int contains(const Polygon &Q, const Point &p) {
bool in = false;
for(int i = 0; i < Q.size(); i++) {
Point a = Q[i] - p, b = Q[(i + 1) % Q.size()] - p;
if(a.y > b.y) swap(a, b);
if(a.y <= 0 && 0 < b.y && cross(a, b) < 0) in = !in;
if(cross(a, b) == 0 && dot(a, b) <= 0) return _ON;
}
return in ? _IN : _OUT;
}
Polygon Minkowski_sum(const Polygon &P, const Polygon &Q) {
vector<Segment> e1(P.size()), e2(Q.size()), ed(P.size() + Q.size());
const auto cmp = [](const Segment &u, const Segment &v) { return (u.b - u.a).arg_cmp(v.b - v.a); };
rep(i, P.size()) e1[i] = {P[i], P[(i + 1) % P.size()]};
rep(i, Q.size()) e2[i] = {Q[i], Q[(i + 1) % Q.size()]};
rotate(begin(e1), min_element(all(e1), cmp), end(e1));
rotate(begin(e2), min_element(all(e2), cmp), end(e2));
merge(all(e1), all(e2), begin(ed), cmp);
const auto check = [](const Points &res, const Point &u) {
const auto back1 = res.back(), back2 = *prev(end(res), 2);
return eq(cross(back1 - back2, u - back2), eps) and dot(back1 - back2, u - back1) >= -eps;
};
auto u = e1[0].a + e2[0].a;
Points res{u};
res.reserve(P.size() + Q.size());
for(const auto &v : ed) {
u = u + v.b - v.a;
while(si(res) >= 2 and check(res, u)) res.pop_back();
res.eb(u);
}
if(res.size() and check(res, res[0])) res.pop_back();
return res;
}
// -1 : on, 0 : out, 1 : in
// O(log(n))
int is_in(const Polygon &p, const Point &a) {
if(p.size() == 1) return a == p[0] ? -1 : 0;
if(p.size() == 2) return intersect(Segment(p[0], p[1]), a);
if(a == p[0]) return -1;
if((p[1] - p[0]).toleft(a - p[0]) == -1 || (p.back() - p[0]).toleft(a - p[0]) == 1) return 0;
const auto cmp = [&](const Point &u, const Point &v) { return (u - p[0]).toleft(v - p[0]) == 1; };
const size_t i = lower_bound(p.begin() + 1, p.end(), a, cmp) - p.begin();
if(i == 1) return intersect(Segment(p[0], p[i]), a) ? -1 : 0;
if(i == p.size() - 1 && intersect(Segment(p[0], p[i]), a)) return -1;
if(intersect(Segment(p[i - 1], p[i]), a)) return -1;
return (p[i] - p[i - 1]).toleft(a - p[i - 1]) > 0;
}
Points halfplane_intersection(vector<Line> L, const T inf = 1e9) {
Point box[4] = {Point(inf, inf), Point(-inf, inf), Point(-inf, -inf), Point(inf, -inf)};
rep(i, 4) { L.emplace_back(box[i], box[(i + 1) % 4]); }
sort(all(L), [](const Line &l, const Line &r) { return (l.b - l.a).arg_cmp(r.b - r.a); });
deque<Line> dq;
int len = 0;
auto check = [](const Line &a, const Line &b, const Line &c) { return a.toleft(crosspoint(b, c)) == -1; };
rep(i, L.size()) {
while(dq.size() > 1 and check(L[i], *(end(dq) - 2), *(end(dq) - 1))) dq.pop_back();
while(dq.size() > 1 and check(L[i], dq[0], dq[1])) dq.pop_front();
// dump(L[i], si(dq));
if(dq.size() and eq(cross(L[i].b - L[i].a, dq.back().b - dq.back().a), 0)) {
if(dot(L[i].b - L[i].a, dq.back().b - dq.back().a) < eps) return {};
if(L[i].toleft(dq.back().a) == -1)
dq.pop_back();
else
continue;
}
dq.emplace_back(L[i]);
}
while(dq.size() > 2 and check(dq[0], *(end(dq) - 2), *(end(dq) - 1))) dq.pop_back();
while(dq.size() > 2 and check(dq.back(), dq[0], dq[1])) dq.pop_front();
if(si(dq) < 3) return {};
Polygon ret(dq.size());
rep(i, dq.size()) ret[i] = crosspoint(dq[i], dq[(i + 1) % dq.size()]);
return ret;
}
} // namespace Geometry
using namespace Geometry;
int main() {
INT(n);
Points P(n);
rep(i, n) cin >> P[i].x >> P[i].y;
INT(m);
Points Q(m);
rep(i, m) cin >> Q[i].x >> Q[i].y;
Points a;
rep(i, n) rep(j, m) a.eb(P[i] - Q[j]);
a = convex_hull(a);
long double lx = -3e6, rx = 3e6;
const int iter = 200;
auto d = [&](long double x, long double y) {
long double ma = 0;
rep(i, si(a)) { chmax(ma, POW<long double>(a[i].x - x, 2) + POW<long double>(a[i].y - y, 2)); }
return ma;
};
auto f = [&](long double x) {
long double ly = -3e6, ry = 3e6;
rep(iter) {
long double lly = (ly * 2 + ry * 1) / 3;
long double rry = (ly * 1 + ry * 2) / 3;
if(d(x, lly) < d(x, rry))
ry = rry;
else
ly = lly;
}
return pair(d(x, (ly + ry) / 2), (ly + ry) / 2);
};
rep(iter) {
long double llx = (lx * 2 + rx * 1) / 3;
long double rrx = (lx * 1 + rx * 2) / 3;
if(f(llx).fi < f(rrx).fi)
rx = rrx;
else
lx = llx;
}
long double x = (lx + rx) / 2;
auto [ans, y] = f(x);
OUT(sqrtl(ans), -x, -y);
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3800kb
input:
3 1 5 2 4 6 8 2 1 3 1 6
output:
4.03112887415 -3.00000000022 -1.49999999988
result:
ok n=3 m=2 err=0.000000
Test #2:
score: 0
Accepted
time: 2ms
memory: 3816kb
input:
1 5 1 1 4 9
output:
0.00000000000 -1.00000000000 8.00000000000
result:
ok n=1 m=1 err=0.000000
Test #3:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
1 2 2 1 10 3
output:
0.00000000000 8.00000000000 1.00000000000
result:
ok n=1 m=1 err=0.000000
Test #4:
score: 0
Accepted
time: 2ms
memory: 3888kb
input:
1 1 2 1 1 2
output:
0.00000000000 -0.00000000000 -0.00000000000
result:
ok n=1 m=1 err=0.000000
Test #5:
score: 0
Accepted
time: 2ms
memory: 3764kb
input:
5 1 6 2 10 5 2 6 10 7 10 1 6 5
output:
4.40347873845 1.50000000000 -1.37500000000
result:
ok n=5 m=1 err=0.000000
Test #6:
score: 0
Accepted
time: 3ms
memory: 4016kb
input:
1 7 3 6 2 9 7 6 4 1 8 8 3 9 1 9
output:
4.59512410489 -2.91509433962 2.59433962264
result:
ok n=1 m=6 err=0.000000
Test #7:
score: 0
Accepted
time: 3ms
memory: 3908kb
input:
2 2 3 9 9 2 4 1 8 10
output:
9.30053761887 0.49999999907 -0.49999999932
result:
ok n=2 m=2 err=0.000000
Test #8:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
1 9 8 8 10 6 6 8 3 4 10 9 5 7 2 7 5 3 5 10
output:
4.31386919779 -2.69230769231 -1.23076923077
result:
ok n=1 m=8 err=0.000000
Test #9:
score: 0
Accepted
time: 2ms
memory: 4084kb
input:
3 7 3 4 9 7 1 1 6 2
output:
4.27200187266 0.50000000013 -2.99999999995
result:
ok n=3 m=1 err=0.000000
Test #10:
score: 0
Accepted
time: 0ms
memory: 4080kb
input:
2 6 8 8 8 1 4 3
output:
1.00000000000 -3.00000000000 -5.00000000023
result:
ok n=2 m=1 err=0.000000
Test #11:
score: 0
Accepted
time: 3ms
memory: 3860kb
input:
1 2 3 11 7 6 5 10 2 2 4 1 9 3 7 4 1 3 5 6 3 1 9 9 1 1
output:
5.65685424949 2.99999999908 2.00000000092
result:
ok n=1 m=11 err=0.000000
Test #12:
score: 0
Accepted
time: 3ms
memory: 3948kb
input:
11 7 4 5 1 7 3 9 10 3 1 10 10 5 5 10 5 5 6 4 1 10 4 1 8 10
output:
5.70087712550 1.49999999965 4.50000000027
result:
ok n=11 m=1 err=0.000000
Test #13:
score: 0
Accepted
time: 4ms
memory: 3868kb
input:
9 8 8 3 1 6 5 5 6 9 6 9 2 9 3 9 10 3 4 11 2 8 1 2 6 7 1 6 4 1 4 5 1 7 10 2 9 8 10 9 6 2
output:
10.96585609973 -0.50000000099 0.00000000093
result:
ok n=9 m=11 err=0.000000
Test #14:
score: 0
Accepted
time: 3ms
memory: 3856kb
input:
1 8 9 5 8 2 9 7 10 6 3 10 8 1
output:
5.14781507049 -2.50000000066 -3.50000000037
result:
ok n=1 m=5 err=0.000000
Test #15:
score: 0
Accepted
time: 2ms
memory: 4020kb
input:
1 2 5 3 6 10 6 5 5 5
output:
2.54950975680 3.50000000047 2.49999999991
result:
ok n=1 m=3 err=0.000000
Test #16:
score: 0
Accepted
time: 4ms
memory: 4072kb
input:
8 3 9 5 9 8 2 3 2 2 3 6 10 2 5 8 4 2 6 1 2 8
output:
8.32165848855 -1.50000000088 -1.00000000056
result:
ok n=8 m=2 err=0.000000
Test #17:
score: 0
Accepted
time: 14ms
memory: 3972kb
input:
96 499494 995347 917205 115724 615677 485675 26653 628830 290255 636019 436997 310488 679704 554538 836274 957304 523167 839393 156311 171726 69930 651786 817224 146624 576446 502999 448250 62722 233665 306365 158866 262089 119321 739022 740724 416112 447595 593338 896009 396447 197000 643460 732359...
output:
1237916.27993537697 -44154.23339819574 -45820.20369020559
result:
ok n=96 m=85 err=0.000000
Test #18:
score: 0
Accepted
time: 10ms
memory: 3984kb
input:
99 257522 959200 592396 748566 183664 7040 814688 14427 587861 749501 257013 647974 574312 16452 303911 801221 273835 163180 320884 988776 240807 795947 942562 731067 373821 953920 143172 74694 539481 15429 684143 403399 387168 771412 46522 597152 511683 147921 958389 1583 942733 714163 774789 32821...
output:
1288871.16778142337 -29975.50024568535 -9263.00022718374
result:
ok n=99 m=92 err=0.000000
Test #19:
score: 0
Accepted
time: 9ms
memory: 3948kb
input:
100 987841 173526 177982 166740 549515 522092 384826 507690 101387 672150 49976 800615 263841 244885 317357 360030 83752 360207 52473 896219 93778 10715 492695 855171 736451 599872 1405 199234 260020 787483 480774 125801 846063 137442 730974 808875 4697 513596 734335 772872 741817 525484 249698 1474...
output:
1212182.43911250528 57834.08674358403 25727.07544253068
result:
ok n=100 m=96 err=0.000000
Test #20:
score: 0
Accepted
time: 57ms
memory: 4208kb
input:
100 2100 493261 2232 480924 2363 513583 4231 526960 5996 428721 7499 412811 9989 390221 14718 367273 19269 350934 34370 302009 36805 295415 75680 204256 83177 188051 84259 186130 88584 543060 92807 572895 100939 609000 101502 163596 101936 613024 105050 624874 108584 156500 109230 638827 111400 1537...
output:
1032223.02490716102 58026.19226508812 20246.69109833946
result:
ok n=100 m=83 err=0.000000
Test #21:
score: 0
Accepted
time: 33ms
memory: 3984kb
input:
66 95860 272900 97306 254938 117654 220167 131357 199036 150957 318785 151093 362911 152746 380860 155133 169263 158495 427838 167614 471428 173305 494093 186930 517242 188000 142329 197122 532864 205961 899507 230549 551919 233463 928587 237597 102501 254306 999332 259764 557400 263409 558031 26877...
output:
987761.97199945393 224224.99983146762 -21726.50004072203
result:
ok n=66 m=100 err=0.000000
Test #22:
score: 0
Accepted
time: 76ms
memory: 3984kb
input:
98 23339 492481 89014 480660 89041 432908 90903 386255 91839 377309 134955 357101 140159 546249 140713 575042 170884 602523 172201 282212 196218 882407 200781 903891 202717 911224 203781 619304 208527 929437 209385 931430 209829 219728 214483 940179 216525 157708 221247 951565 222331 626997 225762 9...
output:
1000001.38194524936 -16724.78256427830 4967.85406119355
result:
ok n=98 m=99 err=0.000000
Test #23:
score: 0
Accepted
time: 51ms
memory: 4008kb
input:
88 25877 687813 31632 702872 50292 749437 58777 768460 60926 312678 61187 346434 62171 298892 63334 289745 67208 402050 73088 451930 75449 258737 77118 482674 77152 806056 81712 515955 83815 238185 84163 819202 92870 588484 98801 622179 106497 853280 111544 669489 112605 179371 114699 863818 133030 ...
output:
1012119.11881057440 -147183.60958249256 8191.84224334278
result:
ok n=88 m=91 err=0.000000
Test #24:
score: 0
Accepted
time: 43ms
memory: 4216kb
input:
77 303632 539543 304231 548535 306013 483196 307296 571896 307669 478206 309536 575990 313039 102618 317759 94854 321820 596009 335628 618096 344252 66009 354055 293491 360439 57058 361107 141696 363089 634276 366149 635865 379856 421457 382611 45803 384214 385713 386625 448925 402881 653417 410695 ...
output:
1043521.24206793697 -157896.39294954706 65902.50284577370
result:
ok n=77 m=80 err=0.000000
Test #25:
score: 0
Accepted
time: 51ms
memory: 4000kb
input:
97 2794 362191 4147 399220 4454 349686 6130 432943 6717 333182 6763 112567 10800 107497 12057 458770 18182 481566 22445 286502 22713 93363 28176 504839 31887 265270 35243 516538 38731 76253 49895 242059 51365 64668 64528 55827 67950 566520 79806 583152 84049 44162 90265 594464 111249 33641 122377 62...
output:
993406.36177826041 20325.88960076998 8484.77877817052
result:
ok n=97 m=66 err=0.000000
Test #26:
score: 0
Accepted
time: 55ms
memory: 4008kb
input:
89 47942 182627 55836 169685 66878 154453 76686 141108 84417 131462 101401 112835 105496 109507 127132 395883 127138 419676 128075 475215 129083 503243 129988 363220 130044 526666 131560 535537 133757 331768 134256 549340 135613 94546 145931 599346 148304 254635 155338 629736 162849 229793 163518 65...
output:
1117550.71585252899 13481.49981882337 1764.50015721804
result:
ok n=89 m=97 err=0.000000
Test #27:
score: 0
Accepted
time: 65ms
memory: 4112kb
input:
98 16284 502642 16633 493430 17800 515105 22765 550870 28059 586648 36346 613844 50719 638074 70086 456050 79472 684155 97022 711165 103050 336448 104891 383989 104938 723128 105132 311455 109161 443923 111816 251085 117512 740938 128560 188633 142349 159709 151508 142130 151783 785286 164551 800156...
output:
1023187.68441481844 21894.86919316593 21493.23893595838
result:
ok n=98 m=92 err=0.000000
Test #28:
score: 0
Accepted
time: 58ms
memory: 4116kb
input:
97 174144 365544 175753 338535 176411 390960 179994 299289 180147 426730 182463 290428 184873 468930 191401 520692 193260 535025 195371 246795 198343 554865 204761 578268 209835 589959 212303 595491 213329 220953 220160 612606 220241 211257 224517 617663 261610 164554 280034 145374 298974 669061 307...
output:
1014748.12439221454 -79822.82769343484 26708.19044272220
result:
ok n=97 m=96 err=0.000000
Test #29:
score: 0
Accepted
time: 66ms
memory: 3984kb
input:
95 98065 636830 103777 691006 113633 747583 127257 805793 133097 829409 139376 847000 145099 859891 174956 919356 179338 585491 180375 929035 188474 609821 204919 950405 208035 447744 217023 956198 242307 968209 244358 475478 252142 566321 264197 412819 276158 981100 280280 982412 284393 983205 3014...
output:
1027711.16079461811 11106.51914834121 5712.60236353654
result:
ok n=95 m=95 err=0.000000
Test #30:
score: 0
Accepted
time: 127ms
memory: 65524kb
input:
996 499494 995347 917205 115724 615677 485675 26653 628830 290255 636019 436997 310488 679704 554538 836274 957304 523167 839393 156311 171726 69930 651786 817224 146624 576446 502999 448250 62722 233665 306365 158866 262089 119321 739022 740724 416112 447595 593338 896009 396447 197000 643460 73235...
output:
1352561.66275852626 18438.40799460773 -25.17113807256
result:
ok n=996 m=985 err=0.000000
Test #31:
score: 0
Accepted
time: 131ms
memory: 65280kb
input:
999 257522 959200 592396 748566 183664 7040 814688 14427 587861 749501 257013 647974 574312 16452 303911 801221 273835 163180 320884 988776 240807 795947 942562 731067 373821 953920 143172 74694 539481 15429 684143 403399 387168 771412 46522 597152 511683 147921 958389 1583 942733 714163 774789 3282...
output:
1378487.82490125752 2842.99987784368 5770.00012484137
result:
ok n=999 m=992 err=0.000000
Test #32:
score: 0
Accepted
time: 1015ms
memory: 63876kb
input:
993 615 519218 617 517469 619 515767 624 524431 626 525094 630 513100 642 527669 660 508605 660 529253 685 531414 730 499678 762 536468 779 537073 816 493023 842 491073 875 489905 927 488312 950 541893 1117 482527 1206 547427 1264 478680 1490 473007 1514 553162 1552 471495 1796 558255 1799 466169 18...
output:
1062252.79452922094 4452.25150732915 -12326.78957162131
result:
ok n=993 m=976 err=0.000000
Test #33:
score: 0
Accepted
time: 1023ms
memory: 64876kb
input:
981 1017 566234 1019 563943 1020 567032 1023 559536 1043 557326 1061 555877 1082 554710 1082 572289 1125 552838 1140 577041 1182 550439 1237 548237 1237 582678 1308 546219 1326 586146 1388 544028 1463 590551 1535 540215 1577 594018 1640 537506 1833 532998 1882 531924 1963 603078 2143 607114 2165 526...
output:
1079230.20077716505 7723.73863763873 -10971.60098826280
result:
ok n=981 m=990 err=0.000000
Test #34:
score: 0
Accepted
time: 1006ms
memory: 63036kb
input:
972 1349 512364 1364 516711 1379 504982 1380 518796 1420 499424 1423 523276 1427 523682 1435 497837 1442 524561 1523 489993 1538 530105 1631 483721 1639 534802 1672 535964 1736 479419 1835 475666 1879 540869 1957 471546 1963 542804 2053 468665 2088 545588 2169 466450 2256 464959 2621 459302 2840 456...
output:
1074931.55438590601 7678.49997070389 2282.50002750435
result:
ok n=972 m=969 err=0.000000
Test #35:
score: 0
Accepted
time: 1039ms
memory: 65764kb
input:
1000 164 534631 166 533532 189 527791 212 537500 221 525573 299 542342 348 544665 367 518493 441 515154 491 551253 514 512559 589 555378 647 508575 774 561637 919 566166 934 501125 1205 573809 1259 493586 1476 488568 1559 486663 1612 485603 1625 584283 1852 589866 1938 479997 2063 594624 2139 476569...
output:
1081453.23508878552 5570.99982567343 -1776.00017628391
result:
ok n=1000 m=998 err=0.000000
Test #36:
score: 0
Accepted
time: 1035ms
memory: 65240kb
input:
994 631 442590 641 444412 644 439051 686 450632 687 431990 699 430187 706 429189 728 452731 757 422171 771 420270 822 416597 843 457792 861 414434 881 459362 910 460435 967 410702 1043 465018 1049 408220 1198 470104 1212 403386 1311 401186 1320 474050 1346 474797 1444 477359 1483 397515 1518 396784 ...
output:
1054401.72944967034 -6981.94484394909 -6433.85302241189
result:
ok n=994 m=996 err=0.000000
Test #37:
score: 0
Accepted
time: 1020ms
memory: 64972kb
input:
991 1850 564831 1852 562297 1855 559736 1872 557599 1876 569480 1967 549168 1982 573517 2012 574537 2034 544935 2080 542038 2104 577105 2223 535854 2469 525460 2509 523828 2529 523133 2615 590300 2668 591588 2674 518694 2683 518423 2739 516933 2856 595782 2875 513379 3026 510561 3182 602250 3238 507...
output:
1060980.93806138658 8294.00492296561 -6497.23304009625
result:
ok n=991 m=995 err=0.000000
Test #38:
score: 0
Accepted
time: 1036ms
memory: 65192kb
input:
994 425 477653 426 481113 427 472213 430 482938 434 484599 437 485348 441 486079 486 490258 489 466458 534 493880 603 459742 614 499472 651 457772 681 503775 705 455761 762 508666 876 449933 997 517849 1051 445577 1089 521053 1128 443937 1168 523373 1212 524660 1225 442009 1422 529769 1497 531584 19...
output:
1082267.45544306992 -1421.63566833730 14387.42195584418
result:
ok n=994 m=994 err=0.000000
Test #39:
score: 0
Accepted
time: 1033ms
memory: 65328kb
input:
991 1164 448671 1172 446635 1180 445056 1183 451382 1184 444270 1225 456408 1235 457554 1238 438265 1247 458200 1312 430347 1345 462205 1366 425285 1416 420916 1450 418161 1527 412566 1608 406816 1648 404489 1689 402226 1716 476811 1752 478195 1929 484629 1953 394091 2074 488972 2087 390190 2125 490...
output:
1072254.61133538614 17891.99985194016 -7285.99985656726
result:
ok n=991 m=1000 err=0.000000
Test #40:
score: 0
Accepted
time: 1036ms
memory: 64716kb
input:
989 1041 516925 1043 521187 1046 522648 1050 515202 1055 514689 1081 535143 1098 539942 1127 547011 1139 548732 1170 552696 1257 563452 1278 495918 1280 566051 1295 494496 1316 568966 1360 489985 1368 572937 1435 484947 1517 479665 1525 479171 1535 582555 1553 477552 1588 475994 1603 584808 1756 589...
output:
1071350.16165455914 11952.49989047127 4381.00012156048
result:
ok n=989 m=992 err=0.000000
Test #41:
score: 0
Accepted
time: 1043ms
memory: 65364kb
input:
1000 1195 462128 1201 463009 1234 457015 1237 456705 1249 466226 1269 454141 1285 468002 1329 449635 1334 469813 1347 470254 1352 448262 1392 446152 1447 473533 1485 443138 1496 475073 1535 476212 1587 477569 1755 436423 1755 481897 1782 435783 1849 484151 2011 430504 2052 429700 2060 489009 2077 48...
output:
1056333.78573878030 4025.55327848841 3532.07462409414
result:
ok n=1000 m=991 err=0.000000
Test #42:
score: 0
Accepted
time: 1034ms
memory: 65184kb
input:
993 614 483119 615 482738 651 478578 710 473392 717 497183 738 499968 763 470294 829 509584 836 466495 881 513317 903 463452 912 515293 985 518319 1055 521174 1087 522385 1138 453322 1151 524359 1171 452247 1298 448166 1418 444353 1469 442962 1555 440623 1633 438708 1804 434526 1821 434159 1923 4322...
output:
1075574.38650258128 7087.80568674703 4861.12892616092
result:
ok n=993 m=994 err=0.000000
Test #43:
score: 0
Accepted
time: 1037ms
memory: 65652kb
input:
997 75 449509 76 446631 78 450295 95 432993 109 456855 125 458612 152 461005 184 463086 207 464565 228 423968 231 465884 255 423079 342 421238 355 471781 406 474202 412 474480 480 476787 696 414429 906 490192 1020 493693 1040 408413 1063 494968 1201 498932 1344 502970 1399 504512 1546 508208 1624 39...
output:
1071140.64965616220 3538.08364279319 3842.17600763180
result:
ok n=997 m=997 err=0.000000
Test #44:
score: 0
Accepted
time: 1034ms
memory: 64848kb
input:
989 459 533612 460 526411 462 541026 464 522019 470 549472 473 549914 479 518626 493 516263 524 511559 550 508138 563 507308 572 506895 597 559114 633 561642 721 500997 732 565245 804 567350 805 498117 894 495241 1043 573673 1146 576117 1185 486712 1227 485630 1384 580969 1537 479019 1788 473674 186...
output:
1060385.32755179337 4035.97993104926 -2002.21621449948
result:
ok n=989 m=996 err=0.000000
Test #45:
score: 0
Accepted
time: 1039ms
memory: 65652kb
input:
997 1316 518316 1322 521512 1325 508449 1343 505459 1346 526415 1365 502360 1365 529214 1382 499983 1392 498868 1432 496132 1475 493712 1495 539863 1516 491426 1580 544084 1635 546558 1669 483232 1684 547717 1713 481004 1751 479253 1832 476553 1973 473579 2087 556581 2175 469575 2238 468498 2420 465...
output:
1070746.73966582779 15035.99988055929 3623.00012801186
result:
ok n=997 m=999 err=0.000000
Test #46:
score: 0
Accepted
time: 1045ms
memory: 65444kb
input:
994 2205 552253 2206 552689 2209 552951 2215 548753 2259 543640 2274 542257 2357 539254 2374 561411 2427 563387 2513 566395 2548 532374 2602 569239 2624 569935 2656 528952 2811 524516 2861 523164 2884 577414 2910 578134 2962 579377 3067 517953 3070 581791 3188 584059 3189 514970 3302 586224 3505 589...
output:
1069818.05367184841 13613.35982782010 -1991.94366434684
result:
ok n=994 m=999 err=0.000000
Test #47:
score: 0
Accepted
time: 1014ms
memory: 64100kb
input:
963 834 543361 836 535792 849 552072 850 552501 874 531035 883 556864 888 557488 914 560360 930 561193 935 527487 1037 524408 1240 577124 1244 518226 1280 578701 1319 516158 1439 583355 1462 512721 1525 511304 1584 587278 1608 509538 1817 592099 1828 505026 1948 594421 2073 596472 2134 498784 2135 5...
output:
1064784.73614964766 2330.39517099106 7032.76207084154
result:
ok n=963 m=993 err=0.000000
Test #48:
score: 0
Accepted
time: 1030ms
memory: 64744kb
input:
985 2582 537826 2618 542713 2624 531735 2651 528037 2673 525287 2751 519638 2816 515139 2898 510087 2954 554627 3019 503015 3098 558595 3109 558889 3123 497277 3155 559944 3321 487951 3479 480516 3583 476304 3636 474522 3636 569898 3700 472612 3896 467080 3942 465895 3960 576596 4113 461584 4209 581...
output:
1069365.25385729188 -3085.07195017484 10396.21136461483
result:
ok n=985 m=997 err=0.000000
Test #49:
score: 0
Accepted
time: 1032ms
memory: 64764kb
input:
987 1181 498215 1183 500828 1194 494762 1202 506979 1212 508963 1252 514679 1296 487535 1299 487332 1312 486465 1339 524535 1361 526912 1373 527965 1398 529760 1444 479976 1444 532681 1507 536063 1530 536924 1556 474716 1868 548605 2021 553300 2034 455842 2147 556616 2234 558875 2262 449370 2294 560...
output:
1074840.58267308097 12125.72313247728 13972.04666307748
result:
ok n=987 m=990 err=0.000000
Test #50:
score: 0
Accepted
time: 2ms
memory: 3904kb
input:
3 15 4 3 4 19 16 2 9 15 15 15
output:
12.52996408614 0.99999999869 5.00000000241
result:
ok n=3 m=2 err=0.000000
Test #51:
score: 0
Accepted
time: 4ms
memory: 3880kb
input:
14 9 1 10 1 7 20 10 16 14 5 17 4 7 12 20 13 1 3 20 17 7 10 6 1 6 15 11 11 4 4 13 20 13 16 13 15 13
output:
18.84807682497 1.49999999980 3.00000000051
result:
ok n=14 m=4 err=0.000000
Extra Test:
score: 0
Extra Test Passed