QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#84369 | #5667. Meeting Places | noimi | AC ✓ | 990ms | 66024kb | C++20 | 44.9kb | 2023-03-06 12:31:17 | 2023-03-06 12:31:22 |
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 <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 flag = true; (flag ? exchange(flag, 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 LL(...) \
ll __VA_ARGS__; \
IN(__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 VEC2(type, name1, name2, size) \
vector<type> name1(size), name2(size); \
for(int i = 0; i < size; i++) IN(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 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 VV(type, name, h, w) \
vector<vector<type>> name(h, vector<type>(w)); \
IN(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() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
scan(head);
IN(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);
}
// 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; }
// 便利関数
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> vector<T> &operator+=(vector<T> &l, const vector<T> &r) {
fore(e, r) l.eb(e);
return l;
}
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;
(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 std {
bool operator<(const complex<double> &a, const complex<double> &b) { return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag(); }
} // namespace std
namespace Geometry {
using Real = double;
using Point = complex<Real>;
const Real EPS = 1e-8, PI = acos(-1);
inline bool eq(Real a, Real b) { return fabs(b - a) < EPS; }
Point operator*(const Point &p, const Real &d) { return Point(real(p) * d, imag(p) * d); }
istream &operator>>(istream &is, Point &p) {
Real a, b;
is >> a >> b;
p = Point(a, b);
return is;
}
ostream &operator<<(ostream &os, Point &p) { return os << fixed << setprecision(10) << p.real() << " " << p.imag(); }
// 点 p を反時計回りに theta 回転
Point rotate(Real theta, const Point &p) { return Point(cos(theta) * p.real() - sin(theta) * p.imag(), sin(theta) * p.real() + cos(theta) * p.imag()); }
Real radian_to_degree(Real r) { return (r * 180.0 / PI); }
Real degree_to_radian(Real d) { return (d * PI / 180.0); }
// a-b-c の角度のうち小さい方を返す
Real get_angle(const Point &a, const Point &b, const Point &c) {
const Point v(b - a), w(c - b);
Real alpha = atan2(v.imag(), v.real()), beta = atan2(w.imag(), w.real());
if(alpha > beta) swap(alpha, beta);
Real theta = (beta - alpha);
return min(theta, 2 * acos(-1) - theta);
}
struct Line {
Point a, b;
Line() = default;
Line(Point a, Point b) : a(a), b(b) {}
Line(Real A, Real B, Real C) // Ax + By = C
{
if(eq(A, 0))
a = Point(0, C / B), b = Point(1, C / B);
else if(eq(B, 0))
a = Point(C / A, 0), b = Point(C / A, 1);
else if(eq(C, 0))
a = Point(), b = Point(B, -A);
else
a = Point(0, C / B), b = Point(C / A, 0);
}
friend ostream &operator<<(ostream &os, Line &p) { return os << p.a << " to " << p.b; }
friend istream &operator>>(istream &is, Line &a) { return is >> a.a >> a.b; }
};
struct Segment : Line {
Segment() = default;
Segment(Point a, Point b) : Line(a, b) {}
};
struct Circle {
Point p;
Real r;
Circle() = default;
Circle(Point p, Real r) : p(p), r(r) {}
};
using Points = vector<Point>;
using Polygon = vector<Point>;
using Segments = vector<Segment>;
using Lines = vector<Line>;
using Circles = vector<Circle>;
Real cross(const Point &a, const Point &b) { return real(a) * imag(b) - imag(a) * real(b); }
Real dot(const Point &a, const Point &b) { return real(a) * real(b) + imag(a) * imag(b); }
// 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) > EPS) return +1; // "COUNTER_CLOCKWISE"
if(cross(b, c) < -EPS) return -1; // "CLOCKWISE"
if(dot(b, c) < 0) return +2; // "ONLINE_BACK"
if(norm(b) < norm(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 eq(cross(a.b - a.a, b.b - b.a), 0.0); }
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A
// 垂直判定
bool orthogonal(const Line &a, const Line &b) { return eq(dot(a.a - a.b, b.a - b.b), 0.0); }
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A
// 射影
// 直線 l に p から垂線を引いた交点を求める
Point projection(const Line &l, const Point &p) {
double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + (l.a - l.b) * t;
}
Point projection(const Segment &l, const Point &p) {
double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
return l.a + (l.a - l.b) * t;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B
// 反射
// 直線 l を対称軸として点 p と線対称にある点を求める
Point reflection(const Line &l, const Point &p) { return p + (projection(l, p) - p) * 2.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 abs(cross(l.b - l.a, m.b - m.a)) > EPS || abs(cross(l.b - l.a, m.b - l.a)) < EPS; }
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) < EPS; }
Real distance(const Line &l, const Point &p);
bool intersect(const Circle &c, const Line &l) { return distance(l, c.p) <= c.r + EPS; }
bool intersect(const Circle &c, const Point &p) { return abs(abs(p - c.p) - c.r) < EPS; }
// 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; }
int intersect(const Circle &c, const Segment &l) {
if(norm(projection(l, c.p) - c.p) - c.r * c.r > EPS) return 0;
auto d1 = abs(c.p - l.a), d2 = abs(c.p - l.b);
if(d1 < c.r + EPS && d2 < c.r + EPS) return 0;
if(d1 < c.r - EPS && d2 > c.r + EPS || d1 > c.r + EPS && d2 < c.r - EPS) return 1;
const Point h = projection(l, c.p);
if(dot(l.a - h, l.b - h) < 0) return 2;
return 0;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_A&lang=jp
int intersect(Circle c1, Circle c2) {
if(c1.r < c2.r) swap(c1, c2);
Real d = abs(c1.p - c2.p);
if(c1.r + c2.r < d) return 4;
if(eq(c1.r + c2.r, d)) return 3;
if(c1.r - c2.r < d) return 2;
if(eq(c1.r - c2.r, d)) return 1;
return 0;
}
Real distance(const Point &a, const Point &b) { return abs(a - b); }
Real distance(const Line &l, const Point &p) { return abs(p - projection(l, p)); }
Real distance(const Line &l, const Line &m) { return intersect(l, m) ? 0 : distance(l, m.a); }
Real distance(const Segment &s, const Point &p) {
Point r = projection(s, p);
if(intersect(s, r)) return abs(r - p);
return min(abs(s.a - p), abs(s.b - p));
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D
Real distance(const Segment &a, const Segment &b) {
if(intersect(a, b)) return 0;
return min({distance(a, b.a), distance(a, b.b), distance(b, a.a), distance(b, a.b)});
}
Real distance(const Line &l, const Segment &s) {
if(intersect(l, s)) return 0;
return min(distance(l, s.a), distance(l, s.b));
}
Point crosspoint(const Line &l, const Line &m) {
Real A = cross(l.b - l.a, m.b - m.a);
Real B = cross(l.b - l.a, l.b - m.a);
if(eq(abs(A), 0.0) && eq(abs(B), 0.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_7_D
pair<Point, Point> crosspoint(const Circle &c, const Line l) {
Point pr = projection(l, c.p);
Point e = (l.b - l.a) / abs(l.b - l.a);
if(eq(distance(l, c.p), c.r)) return {pr, pr};
double base = sqrt(c.r * c.r - norm(pr - c.p));
return {pr - e * base, pr + e * base};
}
pair<Point, Point> crosspoint(const Circle &c, const Segment &l) {
Line aa = Line(l.a, l.b);
if(intersect(c, l) == 2) return crosspoint(c, aa);
auto ret = crosspoint(c, aa);
if(dot(l.a - ret.first, l.b - ret.first) < 0)
ret.second = ret.first;
else
ret.first = ret.second;
return ret;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_E
pair<Point, Point> crosspoint(const Circle &c1, const Circle &c2) {
Real d = abs(c1.p - c2.p);
Real a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2 * c1.r * d));
Real t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());
Point p1 = c1.p + Point(cos(t + a) * c1.r, sin(t + a) * c1.r);
Point p2 = c1.p + Point(cos(t - a) * c1.r, sin(t - a) * c1.r);
return {p1, p2};
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_F
// 点 p を通る円 c の接線
pair<Point, Point> tangent(const Circle &c1, const Point &p2) { return crosspoint(c1, Circle(p2, sqrt(norm(c1.p - p2) - c1.r * c1.r))); }
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_G
// 円 c1, c2 の共通接線
Lines tangent(Circle c1, Circle c2) {
Lines ret;
if(c1.r < c2.r) swap(c1, c2);
Real g = norm(c1.p - c2.p);
if(eq(g, 0)) return ret;
Point u = (c2.p - c1.p) / sqrt(g);
Point v = rotate(PI * 0.5, u);
for(int s : {-1, 1}) {
Real h = (c1.r + s * c2.r) / sqrt(g);
if(eq(1 - h * h, 0)) {
ret.emplace_back(c1.p + u * c1.r, c1.p + (u + v) * c1.r);
} else if(1 - h * h > 0) {
Point uu = u * h, vv = v * sqrt(1 - h * h);
ret.emplace_back(c1.p + (uu + vv) * c1.r, c2.p - (uu + vv) * c2.r * s);
ret.emplace_back(c1.p + (uu - vv) * c1.r, c2.p - (uu - vv) * c2.r * s);
}
}
return ret;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_B
// 凸性判定
bool is_convex(const Polygon &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;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_A
// 凸包
Polygon convex_hull(Polygon p) {
int n = (int)p.size(), k = 0;
if(n <= 2) return p;
sort(p.begin(), p.end());
vector<Point> 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]) < EPS) --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]) < EPS) --k;
}
ch.resize(k - 1);
return ch;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_C
// 多角形と点の包含判定
enum { OUTTT, ONNN, INNN };
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.imag() > b.imag()) swap(a, b);
if(a.imag() <= 0 && 0 < b.imag() && cross(a, b) < 0) in = !in;
if(cross(a, b) == 0 && dot(a, b) <= 0) return ONNN;
}
return in ? INNN : OUTTT;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1033
// 線分の重複除去
void merge_segments(vector<Segment> &segs) {
auto merge_if_able = [](Segment &s1, const Segment &s2) {
if(abs(cross(s1.b - s1.a, s2.b - s2.a)) > EPS) return false;
if(ccw(s1.a, s2.a, s1.b) == 1 || ccw(s1.a, s2.a, s1.b) == -1) return false;
if(ccw(s1.a, s1.b, s2.a) == -2 || ccw(s2.a, s2.b, s1.a) == -2) return false;
s1 = Segment(min(s1.a, s2.a), max(s1.b, s2.b));
return true;
};
for(int i = 0; i < segs.size(); i++) {
if(segs[i].b < segs[i].a) swap(segs[i].a, segs[i].b);
}
for(int i = 0; i < segs.size(); i++) {
for(int j = i + 1; j < segs.size(); j++) {
if(merge_if_able(segs[i], segs[j])) { segs[j--] = segs.back(), segs.pop_back(); }
}
}
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1033
// 線分アレンジメント
// 任意の2線分の交点を頂点としたグラフを構築する
vector<vector<int>> segment_arrangement(vector<Segment> &segs, vector<Point> &ps) {
vector<vector<int>> g;
int N = (int)segs.size();
for(int i = 0; i < N; i++) {
ps.emplace_back(segs[i].a);
ps.emplace_back(segs[i].b);
for(int j = i + 1; j < N; j++) {
const Point p1 = segs[i].b - segs[i].a;
const Point p2 = segs[j].b - segs[j].a;
if(cross(p1, p2) == 0) continue;
if(intersect(segs[i], segs[j])) { ps.emplace_back(crosspoint(segs[i], segs[j])); }
}
}
sort(begin(ps), end(ps));
ps.erase(unique(begin(ps), end(ps)), end(ps));
int M = (int)ps.size();
g.resize(M);
for(int i = 0; i < N; i++) {
vector<int> vec;
for(int j = 0; j < M; j++) {
if(intersect(segs[i], ps[j])) { vec.emplace_back(j); }
}
for(int j = 1; j < vec.size(); j++) {
g[vec[j - 1]].push_back(vec[j]);
g[vec[j]].push_back(vec[j - 1]);
}
}
return (g);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_C
// 凸多角形の切断
// 直線 l.a-l.b で切断しその左側にできる凸多角形を返す
Polygon convex_cut(const Polygon &U, Line l) {
Polygon ret;
for(int i = 0; i < U.size(); i++) {
Point now = U[i], nxt = U[(i + 1) % U.size()];
if(ccw(l.a, l.b, now) != -1) ret.push_back(now);
if(ccw(l.a, l.b, now) * ccw(l.a, l.b, nxt) < 0) { ret.push_back(crosspoint(Line(now, nxt), l)); }
}
return (ret);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A
// 多角形の面積
Real area(const Polygon &p) {
Real A = 0;
for(int i = 0; i < p.size(); ++i) { A += cross(p[i], p[(i + 1) % p.size()]); }
return A * 0.5;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_H
// 円と多角形の共通部分の面積
Real area(const Polygon &p, const Circle &c) {
if(p.size() < 3) return 0.0;
function<Real(Circle, Point, Point)> cross_area = [&](const Circle &c, const Point &a, const Point &b) {
Point va = c.p - a, vb = c.p - b;
Real f = cross(va, vb), ret = 0.0;
if(eq(f, 0.0)) return ret;
if(max(abs(va), abs(vb)) < c.r + EPS) return f;
if(distance(Segment(a, b), c.p) > c.r - EPS) return c.r * c.r * arg(vb * conj(va));
auto u = crosspoint(c, Segment(a, b));
vector<Point> tot{a, u.first, u.second, b};
for(int i = 0; i + 1 < tot.size(); i++) { ret += cross_area(c, tot[i], tot[i + 1]); }
return ret;
};
Real A = 0;
for(int i = 0; i < p.size(); i++) { A += cross_area(c, p[i], p[(i + 1) % p.size()]); }
return A;
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_B
// 凸多角形の直径(最遠頂点対間距離)
Real convex_diameter(const Polygon &p) {
int N = (int)p.size();
int is = 0, js = 0;
for(int i = 1; i < N; i++) {
if(p[i].imag() > p[is].imag()) is = i;
if(p[i].imag() < p[js].imag()) js = i;
}
Real maxdis = norm(p[is] - p[js]);
int maxi, maxj, i, j;
i = maxi = is;
j = maxj = js;
do {
if(cross(p[(i + 1) % N] - p[i], p[(j + 1) % N] - p[j]) >= 0) {
j = (j + 1) % N;
} else {
i = (i + 1) % N;
}
if(norm(p[i] - p[j]) > maxdis) {
maxdis = norm(p[i] - p[j]);
maxi = i;
maxj = j;
}
} while(i != is || j != js);
return sqrt(maxdis);
}
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_5_A
// 最近点対
Real closest_pair(Points ps) {
if(ps.size() <= 1) throw(0);
sort(begin(ps), end(ps));
auto compare_y = [&](const Point &a, const Point &b) { return imag(a) < imag(b); };
vector<Point> beet(ps.size());
const Real INF = 1e18;
function<Real(int, int)> rec = [&](int left, int right) {
if(right - left <= 1) return INF;
int mid = (left + right) >> 1;
auto x = real(ps[mid]);
auto ret = min(rec(left, mid), rec(mid, right));
inplace_merge(begin(ps) + left, begin(ps) + mid, begin(ps) + right, compare_y);
int ptr = 0;
for(int i = left; i < right; i++) {
if(abs(real(ps[i]) - x) >= ret) continue;
for(int j = 0; j < ptr; j++) {
auto luz = ps[i] - beet[ptr - j - 1];
if(imag(luz) >= ret) break;
ret = min(ret, abs(luz));
}
beet[ptr++] = ps[i];
}
return ret;
};
return rec(0, (int)ps.size());
}
} // namespace Geometry
using namespace Geometry;
ll nxt(ll x) { return (x * 233811181 + 1) % ((1LL << 31) - 1); }
Circle make_circle_3(const Point &a, const Point &b, const Point &c) {
double A = std::norm(b - c), B = std::norm(c - a), C = std::norm(a - b), S = cross(b - a, c - a);
Point p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) * (1. / (4 * S * S));
double r2 = sqrt(std::norm(p - a));
return {p, r2};
};
template <typename T, typename Compare = less<T>>
vector<pair<int, T>> monotone_minima(int H, int W, const function<T(int, int)> &f, const Compare &comp = Compare()) {
vector<pair<int, T>> dp(H);
function<void(int, int, int, int)> dfs = [&](int top, int bottom, int left, int right) {
if(top > bottom) return;
int line = (top + bottom) / 2;
T ma;
int mi = -1;
for(int i = left; i <= right; i++) {
T cst = f(line, i);
if(mi == -1 || comp(cst, ma)) {
ma = cst;
mi = i;
}
}
dp[line] = make_pair(mi, ma);
dfs(top, line - 1, left, mi);
dfs(line + 1, bottom, mi, right);
};
dfs(0, H - 1, 0, W - 1);
return dp;
}
template <typename T, typename Compare = less<T>>
vector<vector<T>> divide_and_conquer_optimization(int H, int W, T INF, const function<T(int, int)> &f, const Compare &comp = Compare()) {
vector<vector<T>> dp(H + 1, vector<T>(W + 1, INF));
dp[0][0] = 0;
for(int i = 1; i <= H; i++) {
function<T(int, int)> get_cost = [&](int y, int x) {
if(x >= y) return INF;
return dp[i - 1][x] + f(x, y);
};
auto ret = monotone_minima(W + 1, W + 1, get_cost, comp);
for(int j = 0; j <= W; j++) dp[i][j] = ret[j].second;
}
return dp;
}
int main() {
INT(n, k, x1);
vl x(n), y(n);
x[0] = x1, y[0] = nxt(x1);
rep(i, 1, n) {
x[i] = nxt(y[i - 1]);
y[i] = nxt(x[i]);
}
double upb = 1e18;
Points P(n);
rep(i, n) P[i] = Point{x[i], y[i]};
vv(double, f, n + 1, n + 1);
rep(i, n) {
Circle c(P[i], 0);
auto ins = [&](Point p) { return abs(c.p - p) <= c.r; };
auto make2 = [&](const Point &l, const Point &r) { return Circle((l + r) * 0.5, abs(r - l) / 2); };
rep(j, i + 1, n) {
if(!ins(P[j])) {
c = make2(P[i], P[j]);
rep(k, i + 1, j) {
if(!ins(P[k])) {
c = make2(P[j], P[k]);
rep(t, i, k) {
if(!ins(P[t])) { c = make_circle_3(P[j], P[k], P[t]); }
}
}
}
}
f[i][j + 1] = c.r;
}
}
vv(double, dp, k + 1, n + 1, 1e18);
dp[0][0] = 0;
constexpr int T = 50;
if(1LL * k * n * n <= 200000000) {
rep(i, k) { rep(l, n) rep(r, l + 1, n + 1) chmin(dp[i + 1][r], dp[i][l] + f[l][r]); }
} else {
rep(i, k) {
rep(j, n) {
rep(s, 1, T + 1) {
if(j + s > n) break;
chmin(dp[i + 1][j + s], dp[i][j] + f[j][j + s]);
}
int ma = n - (k - i - 1);
per(s, ma + 1, ma + 1 - T) {
if(s <= j) break;
chmin(dp[i + 1][s], dp[i][j] + f[j][s]);
}
}
}
}
OUT(dp.back().back());
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3652kb
input:
100 23 213
output:
1319350480.80073261261
result:
ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3768kb
input:
10 1 1060
output:
1042753143.34516763687
result:
ok found '1042753143.3451676', expected '1042753143.3451676', error '0.0000000'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3764kb
input:
10 10 2373
output:
0.00000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3692kb
input:
10 2 3396
output:
1236610536.94692301750
result:
ok found '1236610536.9469230', expected '1236610536.9469230', error '0.0000000'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3684kb
input:
10 3 1998
output:
973790809.82244420052
result:
ok found '973790809.8224442', expected '973790809.8224442', error '0.0000000'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
10 4 562
output:
910867389.90693295002
result:
ok found '910867389.9069330', expected '910867389.9069330', error '0.0000000'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3772kb
input:
10 5 6048
output:
818240814.71051537991
result:
ok found '818240814.7105154', expected '818240814.7105150', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
10 6 2524
output:
500106979.34677618742
result:
ok found '500106979.3467762', expected '500106979.3467762', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
10 7 5415
output:
559478971.43200588226
result:
ok found '559478971.4320059', expected '559478971.4320059', error '0.0000000'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3772kb
input:
10 8 1438
output:
500309745.46276998520
result:
ok found '500309745.4627700', expected '500309745.4627700', error '0.0000000'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3588kb
input:
10 9 3172
output:
162279748.87534517050
result:
ok found '162279748.8753452', expected '162279748.8753452', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
100 1 8316
output:
1320052902.15229034424
result:
ok found '1320052902.1522903', expected '1320052902.1522903', error '0.0000000'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
100 100 4179
output:
0.00000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #14:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
100 12 3405
output:
1329687126.13045501709
result:
ok found '1329687126.1304550', expected '1329687126.1304548', error '0.0000000'
Test #15:
score: 0
Accepted
time: 3ms
memory: 3788kb
input:
100 16 8378
output:
1338056514.48426938057
result:
ok found '1338056514.4842694', expected '1338056514.4842694', error '0.0000000'
Test #16:
score: 0
Accepted
time: 2ms
memory: 3880kb
input:
100 2 1858
output:
1310392496.14305806160
result:
ok found '1310392496.1430581', expected '1310392496.1430581', error '0.0000000'
Test #17:
score: 0
Accepted
time: 3ms
memory: 3804kb
input:
100 25 4596
output:
1440464106.62292957306
result:
ok found '1440464106.6229296', expected '1440464106.6229298', error '0.0000000'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
100 3 5633
output:
1399621082.61427378654
result:
ok found '1399621082.6142738', expected '1399621082.6142738', error '0.0000000'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
100 32 7827
output:
1342073760.53223299980
result:
ok found '1342073760.5322330', expected '1342073760.5322330', error '0.0000000'
Test #20:
score: 0
Accepted
time: 3ms
memory: 3632kb
input:
100 4 3693
output:
1339808706.70986914635
result:
ok found '1339808706.7098691', expected '1339808706.7098689', error '0.0000000'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3772kb
input:
100 5 2252
output:
1394874243.50570416451
result:
ok found '1394874243.5057042', expected '1394874243.5057042', error '0.0000000'
Test #22:
score: 0
Accepted
time: 3ms
memory: 3892kb
input:
100 50 4254
output:
1322809748.40528345108
result:
ok found '1322809748.4052835', expected '1322809748.4052832', error '0.0000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
100 6 53
output:
1364441356.17009902000
result:
ok found '1364441356.1700990', expected '1364441356.1700988', error '0.0000000'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3728kb
input:
100 64 4337
output:
1180754550.24228382111
result:
ok found '1180754550.2422838', expected '1180754550.2422838', error '0.0000000'
Test #25:
score: 0
Accepted
time: 2ms
memory: 3780kb
input:
100 7 5366
output:
1423557626.35867977142
result:
ok found '1423557626.3586798', expected '1423557626.3586798', error '0.0000000'
Test #26:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
100 8 8509
output:
1353289305.35199546814
result:
ok found '1353289305.3519955', expected '1353289305.3519957', error '0.0000000'
Test #27:
score: 0
Accepted
time: 2ms
memory: 3848kb
input:
100 9 1423
output:
1228887266.56616735458
result:
ok found '1228887266.5661674', expected '1228887266.5661671', error '0.0000000'
Test #28:
score: 0
Accepted
time: 3ms
memory: 3848kb
input:
100 91 4806
output:
656574218.50867509842
result:
ok found '656574218.5086751', expected '656574218.5086756', error '0.0000000'
Test #29:
score: 0
Accepted
time: 1ms
memory: 3756kb
input:
100 92 4024
output:
794693428.61622381210
result:
ok found '794693428.6162238', expected '794693428.6162238', error '0.0000000'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
100 93 606
output:
677641787.48631238937
result:
ok found '677641787.4863124', expected '677641787.4863122', error '0.0000000'
Test #31:
score: 0
Accepted
time: 1ms
memory: 3832kb
input:
100 94 7265
output:
686423239.26260280609
result:
ok found '686423239.2626028', expected '686423239.2626028', error '0.0000000'
Test #32:
score: 0
Accepted
time: 3ms
memory: 3920kb
input:
100 95 8469
output:
328187125.92359507084
result:
ok found '328187125.9235951', expected '328187125.9235951', error '0.0000000'
Test #33:
score: 0
Accepted
time: 2ms
memory: 3860kb
input:
100 96 1079
output:
492964787.62590903044
result:
ok found '492964787.6259090', expected '492964787.6259086', error '0.0000000'
Test #34:
score: 0
Accepted
time: 1ms
memory: 3936kb
input:
100 97 5453
output:
258652807.79065644741
result:
ok found '258652807.7906564', expected '258652807.7906564', error '0.0000000'
Test #35:
score: 0
Accepted
time: 3ms
memory: 3724kb
input:
100 98 1778
output:
159490192.11889058352
result:
ok found '159490192.1188906', expected '159490192.1188908', error '0.0000000'
Test #36:
score: 0
Accepted
time: 3ms
memory: 3760kb
input:
100 99 1825
output:
33793756.32899804413
result:
ok found '33793756.3289980', expected '33793756.3289980', error '0.0000000'
Test #37:
score: 0
Accepted
time: 41ms
memory: 11616kb
input:
1000 1 2453
output:
1486878333.28585743904
result:
ok found '1486878333.2858574', expected '1486878333.2858574', error '0.0000000'
Test #38:
score: 0
Accepted
time: 156ms
memory: 18932kb
input:
1000 1000 1798
output:
0.00000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #39:
score: 0
Accepted
time: 81ms
memory: 12052kb
input:
1000 125 43
output:
1474031969.51742315292
result:
ok found '1474031969.5174232', expected '1474031969.5174232', error '0.0000000'
Test #40:
score: 0
Accepted
time: 95ms
memory: 11996kb
input:
1000 128 8107
output:
1440374614.93919801712
result:
ok found '1440374614.9391980', expected '1440374614.9391975', error '0.0000000'
Test #41:
score: 0
Accepted
time: 107ms
memory: 11816kb
input:
1000 15 6639
output:
1491336935.55362486839
result:
ok found '1491336935.5536249', expected '1491336935.5536251', error '0.0000000'
Test #42:
score: 0
Accepted
time: 93ms
memory: 11732kb
input:
1000 16 1251
output:
1445211807.11609625816
result:
ok found '1445211807.1160963', expected '1445211807.1160963', error '0.0000000'
Test #43:
score: 0
Accepted
time: 80ms
memory: 11512kb
input:
1000 2 1303
output:
1468989868.64860224724
result:
ok found '1468989868.6486022', expected '1468989868.6486022', error '0.0000000'
Test #44:
score: 0
Accepted
time: 88ms
memory: 13064kb
input:
1000 250 4457
output:
1487674970.76601600647
result:
ok found '1487674970.7660160', expected '1487674970.7660158', error '0.0000000'
Test #45:
score: 0
Accepted
time: 111ms
memory: 13128kb
input:
1000 256 4135
output:
1474218271.51407718658
result:
ok found '1474218271.5140772', expected '1474218271.5140772', error '0.0000000'
Test #46:
score: 0
Accepted
time: 53ms
memory: 11636kb
input:
1000 3 713
output:
1482496228.99047780037
result:
ok found '1482496228.9904778', expected '1482496228.9904778', error '0.0000000'
Test #47:
score: 0
Accepted
time: 70ms
memory: 11728kb
input:
1000 31 8139
output:
1494361943.47991943359
result:
ok found '1494361943.4799194', expected '1494361943.4799194', error '0.0000000'
Test #48:
score: 0
Accepted
time: 70ms
memory: 11724kb
input:
1000 32 7916
output:
1499333171.09386467934
result:
ok found '1499333171.0938647', expected '1499333171.0938647', error '0.0000000'
Test #49:
score: 0
Accepted
time: 55ms
memory: 11704kb
input:
1000 4 2432
output:
1455826569.03941035271
result:
ok found '1455826569.0394104', expected '1455826569.0394101', error '0.0000000'
Test #50:
score: 0
Accepted
time: 54ms
memory: 11736kb
input:
1000 5 2457
output:
1452189628.19671416283
result:
ok found '1452189628.1967142', expected '1452189628.1967139', error '0.0000000'
Test #51:
score: 0
Accepted
time: 113ms
memory: 14984kb
input:
1000 500 8734
output:
1432279300.56627249718
result:
ok found '1432279300.5662725', expected '1432279300.5662787', error '0.0000000'
Test #52:
score: 0
Accepted
time: 131ms
memory: 14920kb
input:
1000 512 1866
output:
1446804508.03518652916
result:
ok found '1446804508.0351865', expected '1446804508.0351865', error '0.0000000'
Test #53:
score: 0
Accepted
time: 42ms
memory: 11544kb
input:
1000 6 1580
output:
1490178756.85660338402
result:
ok found '1490178756.8566034', expected '1490178756.8566034', error '0.0000000'
Test #54:
score: 0
Accepted
time: 88ms
memory: 11444kb
input:
1000 62 3047
output:
1482100829.64671087265
result:
ok found '1482100829.6467109', expected '1482100829.6467109', error '0.0000000'
Test #55:
score: 0
Accepted
time: 67ms
memory: 11428kb
input:
1000 64 4836
output:
1441850815.85536146164
result:
ok found '1441850815.8553615', expected '1441850815.8553615', error '0.0000000'
Test #56:
score: 0
Accepted
time: 86ms
memory: 11504kb
input:
1000 7 5269
output:
1473104490.72879838943
result:
ok found '1473104490.7287984', expected '1473104490.7287984', error '0.0000000'
Test #57:
score: 0
Accepted
time: 46ms
memory: 11616kb
input:
1000 8 2649
output:
1459133296.60662341118
result:
ok found '1459133296.6066234', expected '1459133296.6066234', error '0.0000000'
Test #58:
score: 0
Accepted
time: 64ms
memory: 11568kb
input:
1000 9 3999
output:
1482914523.38070392609
result:
ok found '1482914523.3807039', expected '1482914523.3807039', error '0.0000000'
Test #59:
score: 0
Accepted
time: 152ms
memory: 18864kb
input:
1000 991 3610
output:
295501032.47808742523
result:
ok found '295501032.4780874', expected '295501032.4780874', error '0.0000000'
Test #60:
score: 0
Accepted
time: 150ms
memory: 18880kb
input:
1000 992 3030
output:
337274092.65403813124
result:
ok found '337274092.6540381', expected '337274092.6540381', error '0.0000000'
Test #61:
score: 0
Accepted
time: 143ms
memory: 18824kb
input:
1000 993 6980
output:
222375113.10579860210
result:
ok found '222375113.1057986', expected '222375113.1057986', error '0.0000000'
Test #62:
score: 0
Accepted
time: 150ms
memory: 18740kb
input:
1000 994 7222
output:
218007091.69330409169
result:
ok found '218007091.6933041', expected '218007091.6933041', error '0.0000000'
Test #63:
score: 0
Accepted
time: 144ms
memory: 18876kb
input:
1000 995 1323
output:
169577520.22365289927
result:
ok found '169577520.2236529', expected '169577520.2236529', error '0.0000000'
Test #64:
score: 0
Accepted
time: 131ms
memory: 18736kb
input:
1000 996 2761
output:
135524743.91144853830
result:
ok found '135524743.9114485', expected '135524743.9114488', error '0.0000000'
Test #65:
score: 0
Accepted
time: 141ms
memory: 18932kb
input:
1000 997 4946
output:
87043806.42279207706
result:
ok found '87043806.4227921', expected '87043806.4227921', error '0.0000000'
Test #66:
score: 0
Accepted
time: 136ms
memory: 18696kb
input:
1000 998 842
output:
24094936.55119168758
result:
ok found '24094936.5511917', expected '24094936.5511917', error '0.0000000'
Test #67:
score: 0
Accepted
time: 147ms
memory: 18816kb
input:
1000 999 5078
output:
4597519.06465503387
result:
ok found '4597519.0646550', expected '4597519.0646550', error '0.0000000'
Test #68:
score: 0
Accepted
time: 236ms
memory: 35120kb
input:
2000 1 2633
output:
1502350354.49952697754
result:
ok found '1502350354.4995270', expected '1502350354.4995270', error '0.0000000'
Test #69:
score: 0
Accepted
time: 613ms
memory: 50284kb
input:
2000 1000 6248
output:
1469507093.40421080589
result:
ok found '1469507093.4042108', expected '1469507093.4042110', error '0.0000000'
Test #70:
score: 0
Accepted
time: 563ms
memory: 50420kb
input:
2000 1024 2507
output:
1448066815.31847858429
result:
ok found '1448066815.3184786', expected '1448066815.3184788', error '0.0000000'
Test #71:
score: 0
Accepted
time: 432ms
memory: 36500kb
input:
2000 125 3002
output:
1476846542.03189110756
result:
ok found '1476846542.0318911', expected '1476846542.0318909', error '0.0000000'
Test #72:
score: 0
Accepted
time: 258ms
memory: 36504kb
input:
2000 128 5622
output:
1464957942.64003753662
result:
ok found '1464957942.6400375', expected '1464957942.6400380', error '0.0000000'
Test #73:
score: 0
Accepted
time: 171ms
memory: 35312kb
input:
2000 15 5891
output:
1490626300.15586662292
result:
ok found '1490626300.1558666', expected '1490626300.1558671', error '0.0000000'
Test #74:
score: 0
Accepted
time: 201ms
memory: 35228kb
input:
2000 16 1750
output:
1504400245.41498064995
result:
ok found '1504400245.4149806', expected '1504400245.4149806', error '0.0000000'
Test #75:
score: 0
Accepted
time: 868ms
memory: 65608kb
input:
2000 1990 6698
output:
313951388.40465110540
result:
ok found '313951388.4046511', expected '313951388.4046511', error '0.0000000'
Test #76:
score: 0
Accepted
time: 774ms
memory: 66024kb
input:
2000 1991 80
output:
248800118.67930603027
result:
ok found '248800118.6793060', expected '248800118.6793060', error '0.0000000'
Test #77:
score: 0
Accepted
time: 887ms
memory: 65852kb
input:
2000 1992 4802
output:
257156356.52167940140
result:
ok found '257156356.5216794', expected '257156356.5216795', error '0.0000000'
Test #78:
score: 0
Accepted
time: 851ms
memory: 65776kb
input:
2000 1993 169
output:
197117968.44822478294
result:
ok found '197117968.4482248', expected '197117968.4482248', error '0.0000000'
Test #79:
score: 0
Accepted
time: 780ms
memory: 65928kb
input:
2000 1994 6269
output:
109695555.80885010958
result:
ok found '109695555.8088501', expected '109695555.8088501', error '0.0000000'
Test #80:
score: 0
Accepted
time: 869ms
memory: 65920kb
input:
2000 1995 3452
output:
179563229.39678430557
result:
ok found '179563229.3967843', expected '179563229.3967843', error '0.0000000'
Test #81:
score: 0
Accepted
time: 990ms
memory: 65928kb
input:
2000 1996 2191
output:
84783513.64558957517
result:
ok found '84783513.6455896', expected '84783513.6455896', error '0.0000000'
Test #82:
score: 0
Accepted
time: 809ms
memory: 65732kb
input:
2000 1997 7803
output:
53635859.33998997509
result:
ok found '53635859.3399900', expected '53635859.3399900', error '0.0000000'
Test #83:
score: 0
Accepted
time: 975ms
memory: 65724kb
input:
2000 1998 8341
output:
33466185.81494423002
result:
ok found '33466185.8149442', expected '33466185.8149442', error '0.0000000'
Test #84:
score: 0
Accepted
time: 914ms
memory: 65912kb
input:
2000 1999 6773
output:
2608075.46528326115
result:
ok found '2608075.4652833', expected '2608075.4652833', error '0.0000000'
Test #85:
score: 0
Accepted
time: 214ms
memory: 35060kb
input:
2000 2 4496
output:
1484602254.13100123405
result:
ok found '1484602254.1310012', expected '1484602254.1310012', error '0.0000000'
Test #86:
score: 0
Accepted
time: 873ms
memory: 65932kb
input:
2000 2000 5384
output:
0.00000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #87:
score: 0
Accepted
time: 375ms
memory: 38420kb
input:
2000 250 1029
output:
1465117434.06310057640
result:
ok found '1465117434.0631006', expected '1465117434.0631006', error '0.0000000'
Test #88:
score: 0
Accepted
time: 264ms
memory: 38624kb
input:
2000 256 5220
output:
1481878242.21847391129
result:
ok found '1481878242.2184739', expected '1481878242.2184739', error '0.0000000'
Test #89:
score: 0
Accepted
time: 392ms
memory: 35148kb
input:
2000 3 8403
output:
1489320436.43185305595
result:
ok found '1489320436.4318531', expected '1489320436.4318533', error '0.0000000'
Test #90:
score: 0
Accepted
time: 268ms
memory: 35308kb
input:
2000 31 6950
output:
1477330995.22513103485
result:
ok found '1477330995.2251310', expected '1477330995.2251310', error '0.0000000'
Test #91:
score: 0
Accepted
time: 292ms
memory: 35160kb
input:
2000 32 3632
output:
1496222504.64900636673
result:
ok found '1496222504.6490064', expected '1496222504.6490064', error '0.0000000'
Test #92:
score: 0
Accepted
time: 328ms
memory: 35268kb
input:
2000 4 2987
output:
1477889007.50545930862
result:
ok found '1477889007.5054593', expected '1477889007.5054593', error '0.0000000'
Test #93:
score: 0
Accepted
time: 197ms
memory: 35192kb
input:
2000 5 2580
output:
1485468254.73749518394
result:
ok found '1485468254.7374952', expected '1485468254.7374952', error '0.0000000'
Test #94:
score: 0
Accepted
time: 429ms
memory: 42308kb
input:
2000 500 6270
output:
1475788271.02759885788
result:
ok found '1475788271.0275989', expected '1475788271.0275989', error '0.0000000'
Test #95:
score: 0
Accepted
time: 462ms
memory: 42692kb
input:
2000 512 1864
output:
1470340599.47498559952
result:
ok found '1470340599.4749856', expected '1470340599.4749856', error '0.0000000'
Test #96:
score: 0
Accepted
time: 199ms
memory: 35220kb
input:
2000 6 8814
output:
1497075189.01349568367
result:
ok found '1497075189.0134957', expected '1497075189.0134962', error '0.0000000'
Test #97:
score: 0
Accepted
time: 368ms
memory: 35500kb
input:
2000 62 4139
output:
1490927650.97321200371
result:
ok found '1490927650.9732120', expected '1490927650.9732120', error '0.0000000'
Test #98:
score: 0
Accepted
time: 206ms
memory: 35584kb
input:
2000 64 7700
output:
1494910912.61378335953
result:
ok found '1494910912.6137834', expected '1494910912.6137834', error '0.0000000'
Test #99:
score: 0
Accepted
time: 302ms
memory: 35336kb
input:
2000 7 8304
output:
1488325857.82198953629
result:
ok found '1488325857.8219895', expected '1488325857.8219898', error '0.0000000'
Test #100:
score: 0
Accepted
time: 178ms
memory: 35240kb
input:
2000 8 7774
output:
1507136513.17155909538
result:
ok found '1507136513.1715591', expected '1507136513.1715591', error '0.0000000'
Test #101:
score: 0
Accepted
time: 226ms
memory: 35316kb
input:
2000 9 2618
output:
1492019659.03731632233
result:
ok found '1492019659.0373163', expected '1492019659.0373163', error '0.0000000'
Test #102:
score: 0
Accepted
time: 12ms
memory: 5792kb
input:
500 1 7674
output:
1463672939.78124976158
result:
ok found '1463672939.7812498', expected '1463672939.7812500', error '0.0000000'
Test #103:
score: 0
Accepted
time: 16ms
memory: 5716kb
input:
500 125 1629
output:
1420736329.08382725716
result:
ok found '1420736329.0838273', expected '1420736329.0838273', error '0.0000000'
Test #104:
score: 0
Accepted
time: 12ms
memory: 5844kb
input:
500 15 7376
output:
1465677415.50638794899
result:
ok found '1465677415.5063879', expected '1465677415.5063879', error '0.0000000'
Test #105:
score: 0
Accepted
time: 18ms
memory: 6148kb
input:
500 250 5627
output:
1411074935.88235807419
result:
ok found '1411074935.8823581', expected '1411074935.8823581', error '0.0000000'
Test #106:
score: 0
Accepted
time: 15ms
memory: 5776kb
input:
500 3 2245
output:
1437079231.54098105431
result:
ok found '1437079231.5409811', expected '1437079231.5409811', error '0.0000000'
Test #107:
score: 0
Accepted
time: 12ms
memory: 5772kb
input:
500 31 8072
output:
1487957912.03146123886
result:
ok found '1487957912.0314612', expected '1487957912.0314612', error '0.0000000'
Test #108:
score: 0
Accepted
time: 13ms
memory: 5524kb
input:
500 62 2415
output:
1454787477.64937734604
result:
ok found '1454787477.6493773', expected '1454787477.6493773', error '0.0000000'
Test #109:
score: 0
Accepted
time: 15ms
memory: 5796kb
input:
500 7 1586
output:
1459900114.70466065407
result:
ok found '1459900114.7046607', expected '1459900114.7046607', error '0.0000000'