QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#433968 | #8786. The Whole World | ucup-team159# | TL | 4905ms | 4840kb | C++23 | 18.8kb | 2024-06-08 14:03:41 | 2024-06-08 14:03:43 |
Judging History
answer
#line 1 "F.cpp"
// #pragma GCC target("avx2,avx512f,avx512vl,avx512bw,avx512dq,avx512cd,avx512vbmi,avx512vbmi2,avx512vpopcntdq,avx512bitalg,bmi,bmi2,lzcnt,popcnt")
// #pragma GCC optimize("Ofast")
#line 2 "/mnt/c/Users/tsigm/Documents/Cprogram/library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> bool chmax(T& x, U y){
if(x<y){ x=y; return true; }
return false;
}
template<class T,class U> bool chmin(T& x, U y){
if(y<x){ x=y; return true; }
return false;
}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class T> int lwb(const V<T>& v, const T& a){return lower_bound(all(v),a) - v.begin();}
template<class T>
V<T> Vec(size_t a) {
return V<T>(a);
}
template<class T, class... Ts>
auto Vec(size_t a, Ts... ts) {
return V<decltype(Vec<T>(ts...))>(a, Vec<T>(ts...));
}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
o<<"{";
for(const T& v:vc) o<<v<<",";
o<<"}";
return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }
#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
os<<t<<" ~ ";
dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {"; \
for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif
template<class D> D divFloor(D a, D b){
return a / b - (((a ^ b) < 0 && a % b != 0) ? 1 : 0);
}
template<class D> D divCeil(D a, D b) {
return a / b + (((a ^ b) > 0 && a % b != 0) ? 1 : 0);
}
/*
x 0 1 2 3 4 5 6 7 8 9
bsr(x) -1 0 1 1 2 2 2 2 3 3
最上位bit
*/
int bsr(int x){
return x == 0 ? -1 : 31 ^ __builtin_clz(x);
}
int bsr(uint x){
return x == 0 ? -1 : 31 ^ __builtin_clz(x);
}
int bsr(ll x){
return x == 0 ? -1 : 63 ^ __builtin_clzll(x);
}
int bsr(ull x){
return x == 0 ? -1 : 63 ^ __builtin_clzll(x);
}
/*
x 0 1 2 3 4 5 6 7 8 9
bsl(x) -1 0 1 0 2 0 1 0 3 0
最下位bit
*/
int bsl(int x){
if(x==0) return -1;
return __builtin_ctz(x);
}
int bsl(uint x){
if(x==0) return -1;
return __builtin_ctz(x);
}
int bsl(ll x){
if(x==0) return -1;
return __builtin_ctzll(x);
}
int bsl(ull x){
if(x==0) return -1;
return __builtin_ctzll(x);
}
template<class T>
T rnd(T l,T r){ //[l,r)
using D = uniform_int_distribution<T>;
static random_device rd;
static mt19937 gen(rd());
return D(l,r-1)(gen);
}
template<class T>
T rnd(T n){ //[0,n)
return rnd(T(0),n);
}
#line 5 "F.cpp"
/*
sunset's BigInt
*/
// base and base_digits must be consistent
const int base = 1000000000;
const int base_digits = 9;
struct Int {
vector<int> z;
int sign;
Int() : sign(1) {}
Int(long long v) {
*this = v;
}
Int(const string &s) {
read(s);
}
void operator=(const Int &v) {
sign = v.sign;
z = v.z;
}
void operator=(long long v) {
sign = 1;
if (v < 0) {
sign = -1, v = -v;
}
z.clear();
for (; v > 0; v = v / base) {
z.push_back(v % base);
}
}
Int operator+(const Int &v) const {
if (sign == v.sign) {
Int res = v;
for (int i = 0, carry = 0; i < (int) max(z.size(), v.z.size()) || carry; ++i) {
if (i == (int) res.z.size()) {
res.z.push_back(0);
}
res.z[i] += carry + (i < (int) z.size() ? z[i] : 0);
carry = res.z[i] >= base;
if (carry) {
res.z[i] -= base;
}
}
return res;
} else {
return *this - (-v);
}
}
Int operator-(const Int &v) const {
if (sign == v.sign) {
if (abs() >= v.abs()) {
Int res = *this;
for (int i = 0, carry = 0; i < (int) v.z.size() || carry; ++i) {
res.z[i] -= carry + (i < (int) v.z.size() ? v.z[i] : 0);
carry = res.z[i] < 0;
if (carry) {
res.z[i] += base;
}
}
res.trim();
return res;
} else {
return -(v - *this);
}
} else {
return *this + (-v);
}
}
void operator*=(int v) {
if (v < 0) {
sign = -sign, v = -v;
}
for (int i = 0, carry = 0; i < (int) z.size() || carry; ++i) {
if (i == (int) z.size()) {
z.push_back(0);
}
long long cur = (long long) z[i] * v + carry;
carry = cur / base;
z[i] = cur % base;
// asm("divl %%ecx" : "=a"(carry), "=d"(a[i]) : "A"(cur), "c"(base));
}
trim();
}
Int operator*(int v) const {
Int res = *this;
res *= v;
return res;
}
friend pair<Int, Int> divmod(const Int &a1, const Int &b1) {
int norm = base / (b1.z.back() + 1);
Int a = a1.abs() * norm;
Int b = b1.abs() * norm;
Int q, r;
q.z.resize(a.z.size());
for (int i = a.z.size() - 1; i >= 0; i--) {
r *= base;
r += a.z[i];
int s1 = b.z.size() < r.z.size() ? r.z[b.z.size()] : 0;
int s2 = b.z.size() - 1 < r.z.size() ? r.z[b.z.size() - 1] : 0;
int d = ((long long) s1 * base + s2) / b.z.back();
r -= b * d;
while (r < 0) {
r += b, --d;
}
q.z[i] = d;
}
q.sign = a1.sign * b1.sign;
r.sign = a1.sign;
q.trim();
r.trim();
return make_pair(q, r / norm);
}
friend Int sqrt(const Int &a1) {
Int a = a1;
while (a.z.empty() || (int) a.z.size() % 2 == 1) {
a.z.push_back(0);
}
int n = a.z.size();
int firstDigit = sqrt((long long) a.z[n - 1] * base + a.z[n - 2]);
int norm = base / (firstDigit + 1);
a *= norm;
a *= norm;
while (a.z.empty() || (int) a.z.size() % 2 == 1) {
a.z.push_back(0);
}
Int r = (long long) a.z[n - 1] * base + a.z[n - 2];
firstDigit = sqrt((long long) a.z[n - 1] * base + a.z[n - 2]);
int q = firstDigit;
Int res;
for (int j = n / 2 - 1; j >= 0; j--) {
for (;; --q) {
Int r1 =
(r - (res * 2 * base + q) * q) * base * base +
(j > 0 ? (long long) a.z[2 * j - 1] * base + a.z[2 * j - 2] : 0);
if (r1 >= 0) {
r = r1;
break;
}
}
res *= base;
res += q;
if (j > 0) {
int d1 = res.z.size() + 2 < r.z.size() ? r.z[res.z.size() + 2] : 0;
int d2 = res.z.size() + 1 < r.z.size() ? r.z[res.z.size() + 1] : 0;
int d3 = res.z.size() < r.z.size() ? r.z[res.z.size()] : 0;
q = ((long long) d1 * base * base + (long long) d2 * base + d3) /
(firstDigit * 2);
}
}
res.trim();
return res / norm;
}
Int operator/(const Int &v) const {
return divmod(*this, v).first;
}
Int operator%(const Int &v) const {
return divmod(*this, v).second;
}
void operator/=(int v) {
if (v < 0) {
sign = -sign, v = -v;
}
for (int i = z.size() - 1, rem = 0; i >= 0; --i) {
long long cur = z[i] + (long long) rem * base;
z[i] = cur / v;
rem = cur % v;
}
trim();
}
Int operator/(int v) const {
Int res = *this;
res /= v;
return res;
}
int operator%(int v) const {
if (v < 0) {
v = -v;
}
int m = 0;
for (int i = z.size() - 1; i >= 0; --i) {
m = ((long long) m * base + z[i]) % v;
}
return m * sign;
}
void operator+=(const Int &v) {
*this = *this + v;
}
void operator-=(const Int &v) {
*this = *this - v;
}
void operator*=(const Int &v) {
*this = *this * v;
}
void operator/=(const Int &v) {
*this = *this / v;
}
bool operator<(const Int &v) const {
if (sign != v.sign) {
return sign < v.sign;
}
if (z.size() != v.z.size()) {
return z.size() * sign < v.z.size() * v.sign;
}
for (int i = z.size() - 1; i >= 0; i--) {
if (z[i] != v.z[i]) {
return z[i] * sign < v.z[i] * sign;
}
}
return false;
}
bool operator>(const Int &v) const {
return v < *this;
}
bool operator<=(const Int &v) const {
return !(v < *this);
}
bool operator>=(const Int &v) const {
return !(*this < v);
}
bool operator==(const Int &v) const {
return !(*this < v) && !(v < *this);
}
bool operator!=(const Int &v) const {
return *this < v || v < *this;
}
void trim() {
while (!z.empty() && z.back() == 0) {
z.pop_back();
}
if (z.empty()) {
sign = 1;
}
}
bool isZero() const {
return z.empty() || ((int) z.size() == 1 && !z[0]);
}
Int operator-() const {
Int res = *this;
res.sign = -sign;
return res;
}
Int abs() const {
Int res = *this;
res.sign *= res.sign;
return res;
}
long long longValue() const {
long long res = 0;
for (int i = z.size() - 1; i >= 0; i--) {
res = res * base + z[i];
}
return res * sign;
}
friend Int gcd(const Int &a, const Int &b) {
return b.isZero() ? a : gcd(b, a % b);
}
friend Int lcm(const Int &a, const Int &b) {
return a / gcd(a, b) * b;
}
void read(const string &s) {
sign = 1;
z.clear();
int pos = 0;
while (pos < (int) s.size() && (s[pos] == '-' || s[pos] == '+')) {
if (s[pos] == '-') {
sign = -sign;
}
++pos;
}
for (int i = s.size() - 1; i >= pos; i -= base_digits) {
int x = 0;
for (int j = max(pos, i - base_digits + 1); j <= i; j++) {
x = x * 10 + s[j] - '0';
}
z.push_back(x);
}
trim();
}
friend istream &operator>>(istream &stream, Int &v) {
string s;
stream >> s;
v.read(s);
return stream;
}
friend ostream &operator<<(ostream &stream, const Int &v) {
if (v.sign == -1) {
stream << '-';
}
stream << (v.z.empty() ? 0 : v.z.back());
for (int i = v.z.size() - 2; i >= 0; --i) {
stream << setw(base_digits) << setfill('0') << v.z[i];
}
return stream;
}
static vector<int> convert_base(const vector<int> &a, int old_digits, int new_digits) {
vector<long long> p(max(old_digits, new_digits) + 1);
p[0] = 1;
for (int i = 1; i < (int) p.size(); i++) {
p[i] = p[i - 1] * 10;
}
vector<int> res;
long long cur = 0;
int cur_digits = 0;
for (int i = 0; i < (int) a.size(); i++) {
cur += a[i] * p[cur_digits];
cur_digits += old_digits;
while (cur_digits >= new_digits) {
res.push_back(cur % p[new_digits]);
cur /= p[new_digits];
cur_digits -= new_digits;
}
}
res.push_back(cur);
while (!res.empty() && res.back() == 0) {
res.pop_back();
}
return res;
}
typedef vector<long long> vll;
static vll karatsubaMultiply(const vll &a, const vll &b) {
int n = a.size();
vll res(n + n);
if (n <= 32) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
res[i + j] += a[i] * b[j];
}
}
return res;
}
int k = n >> 1;
vll a1(a.begin(), a.begin() + k);
vll a2(a.begin() + k, a.end());
vll b1(b.begin(), b.begin() + k);
vll b2(b.begin() + k, b.end());
vll a1b1 = karatsubaMultiply(a1, b1);
vll a2b2 = karatsubaMultiply(a2, b2);
for (int i = 0; i < k; i++) {
a2[i] += a1[i];
}
for (int i = 0; i < k; i++) {
b2[i] += b1[i];
}
vll r = karatsubaMultiply(a2, b2);
for (int i = 0; i < (int) a1b1.size(); i++) {
r[i] -= a1b1[i];
}
for (int i = 0; i < (int) a2b2.size(); i++) {
r[i] -= a2b2[i];
}
for (int i = 0; i < (int) r.size(); i++) {
res[i + k] += r[i];
}
for (int i = 0; i < (int) a1b1.size(); i++) {
res[i] += a1b1[i];
}
for (int i = 0; i < (int) a2b2.size(); i++) {
res[i + n] += a2b2[i];
}
return res;
}
Int operator*(const Int &v) const {
vector<int> a6 = convert_base(this->z, base_digits, 6);
vector<int> b6 = convert_base(v.z, base_digits, 6);
vll a(a6.begin(), a6.end());
vll b(b6.begin(), b6.end());
while (a.size() < b.size()) {
a.push_back(0);
}
while (b.size() < a.size()) {
b.push_back(0);
}
while (a.size() & (a.size() - 1)) {
a.push_back(0);
b.push_back(0);
}
vll c = karatsubaMultiply(a, b);
Int res;
res.sign = sign * v.sign;
for (int i = 0, carry = 0; i < (int) c.size(); i++) {
long long cur = c[i] + carry;
res.z.push_back(cur % 1000000);
carry = cur / 1000000;
}
res.z = convert_base(res.z, 6, base_digits);
res.trim();
return res;
}
};
template<unsigned int mod_>
struct ModInt{
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr static uint mod = mod_;
uint v;
ModInt():v(0){}
ModInt(ll _v):v(normS(_v%mod+mod)){}
explicit operator bool() const {return v!=0;}
static uint normS(const uint &x){return (x<mod)?x:x-mod;} // [0 , 2*mod-1] -> [0 , mod-1]
static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
ModInt operator-() const { return make(normS(mod-v)); }
ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
ModInt operator/(const ModInt& b) const { return *this*b.inv();}
ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
ModInt& operator++(int){ return *this=*this+1;}
ModInt& operator--(int){ return *this=*this-1;}
template<class T> friend ModInt operator+(T a, const ModInt& b){ return (ModInt(a) += b);}
template<class T> friend ModInt operator-(T a, const ModInt& b){ return (ModInt(a) -= b);}
template<class T> friend ModInt operator*(T a, const ModInt& b){ return (ModInt(a) *= b);}
template<class T> friend ModInt operator/(T a, const ModInt& b){ return (ModInt(a) /= b);}
ModInt pow(ll p) const {
if(p<0) return inv().pow(-p);
ModInt a = 1;
ModInt x = *this;
while(p){
if(p&1) a *= x;
x *= x;
p >>= 1;
}
return a;
}
ModInt inv() const { // should be prime
return pow(mod-2);
}
// ll extgcd(ll a,ll b,ll &x,ll &y) const{
// ll p[]={a,1,0},q[]={b,0,1};
// while(*q){
// ll t=*p/ *q;
// rep(i,3) swap(p[i]-=t*q[i],q[i]);
// }
// if(p[0]<0) rep(i,3) p[i]=-p[i];
// x=p[1],y=p[2];
// return p[0];
// }
// ModInt inv() const {
// ll x,y;
// extgcd(v,mod,x,y);
// return make(normS(x+mod));
// }
bool operator==(const ModInt& b) const { return v==b.v;}
bool operator!=(const ModInt& b) const { return v!=b.v;}
bool operator<(const ModInt& b) const { return v<b.v;}
friend istream& operator>>(istream &o,ModInt& x){
ll tmp;
o>>tmp;
x=ModInt(tmp);
return o;
}
friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
// friend ostream& operator<<(ostream &o,const ModInt& x){
// for(int b=1;b<=100;b++){
// for(int a=-100;a<=100;a++){
// if(ModInt(a)/b == x){
// return o << a << "/" << b;
// }
// }
// }
// return o<<x.v;
// }
};
using mint = ModInt<998244353>;
/*
左c列をsweep 指定しないとc = w
行のswapはする
掃き出しに使った列の集合を返す
*/
template<class T>
vector<int> sweep(vector<vector<T>>& a, int c = -1){
if(a.empty()) return {};
if(c == -1) c = a[0].size();
int h = a.size(), w = a[0].size(), r = 0;
vector<int> used_col;
rep(i,c){
if(r == h) break;
for(int j=r;j<h;j++) if(a[j][i]){
swap(a[r],a[j]); break;
}
if(!a[r][i]) continue;
rep(j,h) if(j != r){
const T t = -a[j][i]/a[r][i];
for(int k=i;k<w;k++) a[j][k] += a[r][k]*t;
}
used_col.pb(i);
r++;
}
return used_col;
}
/*
ax = b の解のひとつを出力
解空間は (output) + ker(a)
解が存在しないなら {}
式が0個(si(a) == 0) で壊れないように変数の個数 ( = si(a[0]) ) w を与える
*/
template<class T>
vector<T> linearEquation(vector<vector<T>> a, int w, vector<T> b){
assert(a.size() == b.size());
int h = a.size();
rep(i,h) a[i].pb(b[i]);
vector<int> idx = sweep(a,w);
for(int i = idx.size();i<h;i++) if(a[i][w]) return {};
vector<T> x(w);
rep(i,idx.size()) x[idx[i]] = a[i][w] / a[i][idx[i]];
return x;
}
Int C(Int x,int i){
Int res = 1;
rep(j,i){
res *= x-j;
res /= j+1;
}
return res;
}
bool has_int_solution(vector<vector<Int>> A, vector<Int> b){
assert(si(A) == si(b));
int M = si(A);
if(M == 0) return true;
int N = si(A[0]);
auto Swap = [&](int i, int j){
rep(k,M) swap(A[k][i],A[k][j]);
};
auto sub = [&](int i, int j, Int c){
// A[*][i] -= A[*][j] * c
assert(i != j);
rep(k,M) A[k][i] -= A[k][j] * c;
};
auto flip = [&](int i){
// A[*][i] *= -1
rep(k,M) A[k][i] = -A[k][i];
};
rep(i,N) if(A[0][i] < 0) flip(i);
{
int non0 = -1;
rep(i,N) if(A[0][i] != 0) non0 = i;
if(non0 == -1){
if(b[0] != 0) return false;
vector<vector<Int>> AA(M-1,vector<Int>(N));
rep(i,M-1) rep(j,N) AA[i][j] = A[i+1][j];
vector<Int> bb(M-1);
rep(i,M-1) bb[i] = b[i+1];
return has_int_solution(AA,bb);
}
Swap(0,non0);
assert(A[0][0] != 0);
}
for(int i=1;i<N;i++){
while(A[0][i] != 0){
if(A[0][0] < A[0][i]){
Swap(0,i); continue;
}
Int q = A[0][0]/A[0][i];
sub(0,i,q);
}
}
if(b[0]%A[0][0] != 0) return false;
Int q = b[0]/A[0][0];
vector<vector<Int>> AA(M-1,vector<Int>(N-1));
rep(k,M-1) rep(i,N-1) AA[k][i] = A[k+1][i+1];
vector<Int> bb(M-1);
rep(k,M-1) bb[k] = b[k+1] - q * A[k+1][0];
return has_int_solution(AA,bb);
}
int solve(){
std::random_device seed_gen;
std::mt19937 engine(seed_gen());
int M; cin >> M;
vector<Int> xs(M), ys(M);
rep(i,M) cin >> xs[i] >> ys[i];
rep(i,M-1) rep(j,M-1){
if(xs[j] > xs[j+1]){
swap(xs[j],xs[j+1]);
swap(ys[j],ys[j+1]);
}
}
auto has = [&](int D){
int N = D+1;
vector<vector<Int>> A(M,vector<Int>(N));
vector<Int> b = ys;
{
rep(i,M){
rep(j,N){
A[i][j] = C(xs[i],j);
}
}
rep(i,M) b[i] = ys[i];
}
{
// precheck via mint
vector<vector<mint>> mA(M,vector<mint>(N));
vector<mint> mb(M);
rep(i,M) rep(j,N) mA[i][j] = A[i][j].longValue();
rep(i,M) mb[i] = b[i].longValue();
if(linearEquation(mA,N,mb).empty()) return false;
}
return has_int_solution(A,b);
};
int lb = -1, ub = 30;
while(ub-lb>1){
int m = (lb+ub)/2;
if(has(m)) ub = m;
else lb = m;
}
return ub;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false); //DON'T USE scanf/printf/puts !!
cout << fixed << setprecision(20);
int T; cin >> T;
while(T--) cout << solve() << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
2 2 1 0 4 1 3 1 1 4 4 6 6
output:
3 1
result:
ok 2 number(s): "3 1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
2 2 1 0 4 1 3 1 0 3 0 5 4
output:
3 3
result:
ok 2 number(s): "3 3"
Test #3:
score: 0
Accepted
time: 3ms
memory: 3728kb
input:
2 10 1 557 2 -172 3 -497 5 763 6 -149 7 -355 8 -29 9 -588 10 -171 11 -355 10 1 -461 2 -219 3 -45 4 -212 5 749 6 -294 9 -85 10 213 11 -412 12 125
output:
10 11
result:
ok 2 number(s): "10 11"
Test #4:
score: 0
Accepted
time: 2928ms
memory: 4348kb
input:
20 10 1 -193165761 4 426322868 5 -408198139 7 -455731045 9 -389028341 17 -590246653 18 119481348 21 809814532 23 47591392 26 -21020402 10 3 -715116939 5 -263142266 6 -426687860 10 342227448 14 141724722 15 576758779 18 123410194 19 256532828 20 -223524833 25 386574889 10 5 34943085 7 238431559 9 168...
output:
25 22 23 20 20 25 23 25 26 23 23 25 29 23 24 29 29 27 25 19
result:
ok 20 numbers
Test #5:
score: 0
Accepted
time: 2182ms
memory: 4216kb
input:
100 10 1 158027281 3 -154375927 6 -515683907 9 -801063453 15 371607728 16 -30224647 24 -215349633 26 219182013 29 -87257968 30 186925822 10 2 205585983 9 740879281 11 -672242855 14 -53907640 16 146130715 20 -17941862 25 -424140108 26 593743162 27 -8310423 28 84863497 10 3 46810292 4 361101002 5 4687...
output:
29 25 25 20 19 25 20 29 29 19 25 19 26 26 27 21 27 26 25 25 24 26 27 25 25 27 26 23 27 23 29 25 27 26 28 29 29 20 21 23 22 25 23 16 25 29 26 25 26 18 23 18 23 19 28 19 26 26 24 18 26 19 23 27 21 23 17 26 28 25 27 23 16 19 25 26 23 25 14 23 20 20 25 23 24 23 19 19 20 20 22 26 26 25 22 23 28 17 19 19
result:
ok 100 numbers
Test #6:
score: 0
Accepted
time: 1838ms
memory: 4784kb
input:
100 30 1 -519015304 2 269671593 3 -163533023 4 830108438 5 337806976 6 -87888761 7 -195233355 8 -341350273 9 38092088 10 285610643 11 -240058763 12 256373103 13 297741964 14 -247379404 15 -26410774 16 -755197562 17 -643221179 18 159031836 19 689848941 20 622207228 21 -407862690 22 401550934 23 10884...
output:
29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29
result:
ok 100 numbers
Test #7:
score: 0
Accepted
time: 1869ms
memory: 4780kb
input:
100 29 1 149105603 2 19193029 3 -254160491 4 -298710412 5 -329725675 6 644578442 7 611132722 8 -806708763 9 506813970 10 566271854 11 -621025393 12 293347092 13 -332652769 14 -320671582 15 507576094 16 -153368460 17 -242687628 18 545685752 19 -359086703 20 -31631637 21 34200734 22 695203819 23 66205...
output:
29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 28 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 28 29 29 29 29 29 29 29 28 29 29 29 29 28 29 29 29 29 29 29 29 28 29
result:
ok 100 numbers
Test #8:
score: 0
Accepted
time: 1853ms
memory: 4604kb
input:
100 27 1 -219694090 2 313611706 3 19681553 4 -393439728 5 137039465 6 -210242538 7 -257014477 8 711593910 9 -126342644 10 317378740 12 -27880234 14 -312500245 15 -611623850 16 26965932 17 -344751802 19 25604908 20 -925684523 21 218732296 22 -906235432 23 128008760 24 128339229 25 -373435576 26 78643...
output:
29 29 29 29 29 29 29 29 29 28 28 29 29 29 28 29 29 29 29 29 29 29 29 29 29 28 28 29 29 29 29 29 29 29 29 29 29 29 29 28 29 29 29 29 29 29 29 29 28 29 28 29 29 29 29 28 29 29 29 28 29 29 29 29 28 28 29 28 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 28 29 29 28 29 28 29 29 29 29 29 29 29 29 29 28 29
result:
ok 100 numbers
Test #9:
score: 0
Accepted
time: 1793ms
memory: 4840kb
input:
100 26 1 66877446 2 -164941227 3 225463507 4 184131912 5 102090525 7 758317818 8 -97450001 9 370239141 11 3046899 13 323733227 14 -130439971 16 -635446409 17 -859978167 18 48284039 19 -447989609 20 -127277242 21 557802358 22 101519428 23 62166242 24 -314606125 25 -689141632 26 -358169960 27 -4857611...
output:
29 29 28 29 29 29 28 29 29 29 29 29 29 28 29 29 28 28 29 29 29 29 29 29 28 29 28 27 29 27 28 29 29 29 29 29 28 29 29 28 29 28 29 29 29 29 28 28 29 29 29 29 29 29 29 29 29 29 28 29 28 29 28 27 29 29 28 29 29 29 29 29 29 29 29 29 29 29 29 28 29 28 29 29 29 29 29 29 29 29 29 28 29 28 29 29 28 28 29 29
result:
ok 100 numbers
Test #10:
score: 0
Accepted
time: 1775ms
memory: 4572kb
input:
100 25 1 348246102 2 -750467389 3 -68044274 4 -686461116 5 -293360003 7 -262211929 8 669230593 9 -78704756 10 609746050 11 41527955 12 -497959309 14 -647052946 15 -588566559 16 -19571993 18 -540729853 19 146529178 20 -814716222 21 28809002 22 -486593284 24 330571691 25 -313603881 26 757285671 27 -65...
output:
29 29 27 29 27 29 28 29 28 28 29 29 28 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 29 27 28 29 29 29 29 29 28 29 29 28 27 28 29 29 29 27 28 29 27 28 28 29 29 29 28 28 29 29 28 29 28 29 29 29 27 28 29 29 29 28 29 28 29 29 29 29 28 28 29 27 29 29 28 29 29 27 29 29 27 29 29 29 29 29 28 29 29
result:
ok 100 numbers
Test #11:
score: 0
Accepted
time: 1694ms
memory: 4520kb
input:
100 24 1 232880847 2 -489768736 4 -535788421 5 -109001398 6 -632734245 8 -411753361 10 275051825 11 577581411 12 -81737036 13 -221509120 14 -561678665 15 365478690 19 -324173702 20 208854667 21 -387192388 22 -649434295 23 291048454 24 344365482 25 76539150 26 126031273 27 -396021296 28 -344960240 29...
output:
29 29 29 29 26 28 29 26 28 29 29 29 29 29 27 29 28 25 28 29 28 29 29 29 29 27 29 28 29 27 29 28 29 28 28 27 29 29 29 28 29 29 29 28 27 28 28 29 27 29 27 29 29 29 29 29 27 28 28 28 29 29 29 28 28 28 29 29 29 27 28 28 29 29 29 27 28 28 26 29 28 26 29 29 27 29 29 29 29 29 29 27 29 29 29 27 28 29 27 27
result:
ok 100 numbers
Test #12:
score: 0
Accepted
time: 1754ms
memory: 4536kb
input:
100 23 1 478739509 2 359667718 3 -882444045 4 57243210 5 -383836266 7 697287195 8 794293697 9 596461407 10 -376755911 11 -342210915 14 -307035202 15 516844954 16 273425410 17 622517588 18 331049509 20 291385046 21 441000840 23 301865030 25 -47497896 26 454086322 27 -700208571 28 75982830 30 86810034...
output:
29 29 29 29 27 28 28 29 29 29 29 28 29 27 29 28 27 28 29 28 27 27 29 29 29 27 29 28 29 29 27 27 29 29 29 29 29 27 29 29 28 29 29 29 28 28 27 29 29 29 28 29 28 29 29 29 29 29 28 29 28 27 28 28 29 27 29 29 28 29 29 29 27 28 29 28 29 29 28 27 27 29 27 29 29 29 28 27 28 27 29 28 29 28 29 27 28 27 26 29
result:
ok 100 numbers
Test #13:
score: 0
Accepted
time: 1789ms
memory: 4752kb
input:
100 22 1 82224311 2 380989415 3 -57663623 4 11085277 5 -582683316 8 -471665926 9 -6237828 10 207354682 11 -637027084 12 -377093059 15 -525136114 17 -487354995 18 547677692 19 -4946643 21 585507148 22 -819450009 23 700393091 24 -382069257 27 687298238 28 -217201782 29 -213847359 30 -618012461 22 1 -1...
output:
29 27 29 29 28 29 27 28 29 28 29 27 29 27 29 27 29 29 29 29 29 29 29 29 28 28 29 27 29 29 28 29 28 29 29 27 26 29 26 29 28 29 29 29 29 28 27 29 29 29 27 29 29 29 27 29 27 29 28 26 27 27 29 28 29 28 26 29 28 29 27 29 29 29 29 29 28 29 27 29 29 29 28 29 28 29 27 27 28 27 28 29 29 29 29 28 29 29 29 29
result:
ok 100 numbers
Test #14:
score: 0
Accepted
time: 1669ms
memory: 4384kb
input:
100 21 1 230002188 2 183945321 3 651536456 4 -643918753 5 211711257 6 654169344 7 -36956799 10 -563182976 11 780329888 12 83318851 14 680921670 16 144574582 17 -412078292 20 59369731 22 191902719 23 -168624389 25 -230822751 26 162445773 28 529054626 29 349224830 30 60377140 21 1 -116191033 3 9358547...
output:
29 25 29 26 29 29 29 27 29 29 29 29 29 29 29 29 26 29 29 29 27 29 26 29 28 29 28 27 29 28 29 27 29 27 29 27 29 28 29 29 27 29 29 28 28 29 28 26 29 29 28 29 27 29 27 28 29 29 29 27 29 27 26 28 27 29 29 28 26 29 29 29 29 29 29 26 27 28 26 28 29 27 27 27 26 28 29 29 29 27 27 29 29 28 27 29 27 27 26 27
result:
ok 100 numbers
Test #15:
score: 0
Accepted
time: 786ms
memory: 4116kb
input:
100 20 1 79862239 2 13563425 3 442926139 4 751723600 5 -388108679 6 340056379 7 265769938 8 264356154 9 -767173552 10 677960143 11 -417566533 12 -109239724 13 -217075453 14 -431467593 15 283334122 16 -184655006 17 -583644166 18 687896311 19 -428898891 20 -153559940 20 1 45135061 2 -402948599 3 -3068...
output:
19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19
result:
ok 100 numbers
Test #16:
score: 0
Accepted
time: 772ms
memory: 4020kb
input:
100 19 1 -181371540 2 13240092 3 314423105 5 -394312316 6 -234691535 7 -361087288 8 -86290439 9 380662523 10 441658935 11 53438172 12 730947574 13 63208482 14 366463967 15 -421649955 16 777637605 17 885895472 18 825604443 19 -300184228 20 -242061244 19 1 -361908907 2 -299110845 3 680021944 4 9035898...
output:
19 19 19 19 18 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 18 19 19 18 19 18 19 19 19 19 19 18 18 19 19 19 19 19 19 19 19 19 19 19 19 19 18 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 18 19 19 19 19 18 19 19 19 19 19 18 19 19 19 18 19 19 19 18 19
result:
ok 100 numbers
Test #17:
score: 0
Accepted
time: 750ms
memory: 4244kb
input:
100 18 1 -354653395 2 42066904 4 -68276768 5 -192085395 6 58560317 7 -207318090 8 537360505 9 40763183 10 156146366 11 -429382519 12 322008688 13 -28358871 14 609666646 15 -9538294 16 703168906 18 -72298640 19 477629958 20 -13376890 18 1 202247530 3 -69182766 4 318152992 5 -103746478 6 188766430 7 -...
output:
19 18 19 18 19 19 19 19 19 19 19 19 19 17 19 18 19 19 18 19 19 19 19 19 19 19 19 19 19 19 19 19 19 19 18 18 18 19 18 19 19 19 19 19 18 19 19 19 18 18 18 18 19 19 19 18 19 18 19 19 19 19 19 19 19 19 19 19 19 19 19 18 19 18 19 19 19 19 19 19 19 19 19 19 18 18 19 19 19 19 19 18 19 19 19 18 19 19 19 18
result:
ok 100 numbers
Test #18:
score: 0
Accepted
time: 757ms
memory: 4056kb
input:
100 17 1 -520284730 2 -514466075 3 79886711 4 -425878138 5 180732260 6 55285306 8 345562838 9 90565947 10 -355737856 12 -707405720 13 -702604328 14 461805437 15 -617984149 16 315426606 17 98275951 19 301389112 20 17753554 17 2 257428766 3 -138011315 5 -57866095 6 465506635 7 550205616 8 439902409 9 ...
output:
19 17 19 18 18 18 18 18 19 19 19 19 18 19 19 18 19 19 19 18 19 19 19 19 19 19 18 19 18 19 19 19 19 18 19 19 19 19 18 19 19 18 19 19 18 17 19 19 19 19 19 18 19 18 19 19 19 19 19 19 19 17 19 19 19 19 19 19 19 19 19 18 19 18 18 18 19 19 19 19 18 19 19 16 18 18 17 19 19 19 18 18 19 18 19 19 19 17 19 18
result:
ok 100 numbers
Test #19:
score: 0
Accepted
time: 675ms
memory: 4036kb
input:
100 16 1 -436119416 3 391185595 4 -435418162 7 -691793974 8 245585835 10 -371621633 11 210958524 12 569976178 13 768802725 14 -941519049 15 -343297444 16 511343513 17 196563299 18 -480863886 19 124725083 20 904182202 16 2 334944378 6 648051647 7 -765319693 8 -618274082 9 -103023609 10 -523171753 11 ...
output:
19 17 19 18 19 19 19 18 19 19 19 19 18 19 19 19 18 16 19 18 19 19 19 19 18 18 19 19 18 19 17 18 19 18 17 19 19 19 19 17 19 19 18 19 18 17 19 19 18 19 19 19 19 19 18 18 19 18 19 18 19 19 19 17 18 19 19 17 18 18 17 19 19 19 19 18 18 19 19 18 19 19 18 19 18 19 18 18 18 18 19 19 19 18 19 19 18 19 19 18
result:
ok 100 numbers
Test #20:
score: 0
Accepted
time: 686ms
memory: 4232kb
input:
100 15 3 393201231 4 -473082363 5 288075459 6 -781304926 8 -344605578 9 -762599458 10 148398381 11 -74721014 12 30515839 15 135235819 16 249775138 17 10438875 18 380474650 19 -188178720 20 236686798 15 1 -288477317 2 127071531 4 -144735677 5 558661851 7 399284631 9 -222168762 10 161402510 12 4769221...
output:
17 19 18 19 19 19 18 17 19 19 19 17 18 19 19 19 19 18 19 19 18 18 18 18 18 16 18 19 18 18 19 19 18 19 19 17 17 19 19 16 19 18 19 17 19 18 18 17 18 19 19 19 18 19 19 18 19 19 18 18 18 19 17 18 18 18 19 18 18 19 19 19 18 19 19 18 19 19 19 18 19 18 19 17 19 19 18 19 19 19 17 18 18 17 18 19 19 18 17 19
result:
ok 100 numbers
Test #21:
score: 0
Accepted
time: 632ms
memory: 3940kb
input:
100 14 1 -192276589 2 463022051 4 -80886076 6 217581726 7 60147874 9 910596718 10 835086587 11 271854523 12 42865965 14 -29751969 15 -113715891 18 -51572533 19 -473585126 20 -629221007 14 1 -11470255 2 81461908 4 -59304196 5 181367500 7 -159328723 9 237736152 10 -486771655 11 -395980960 14 657515062...
output:
19 19 19 19 19 17 18 19 18 18 18 18 18 18 19 19 18 17 16 19 17 18 19 18 19 18 19 16 18 18 18 17 17 17 19 19 19 19 18 17 19 17 18 17 19 17 16 18 18 19 19 18 19 18 19 16 18 16 17 18 17 19 18 19 17 17 19 18 17 19 19 18 19 19 17 17 19 19 18 18 19 19 18 18 19 18 18 17 18 17 17 18 17 19 19 19 18 17 18 18
result:
ok 100 numbers
Test #22:
score: 0
Accepted
time: 595ms
memory: 3924kb
input:
100 13 1 -863121769 3 -233128926 4 -377235222 5 -673951134 6 4136818 7 405871550 9 -260407300 12 72841502 13 244040530 15 408164919 16 287387341 17 156191482 18 134237218 13 2 57325712 4 637332399 5 -101974089 6 126851796 11 -221389590 12 175998065 13 -566603004 14 142214875 15 -57895880 16 43406090...
output:
17 18 17 18 14 19 18 17 17 16 16 18 16 19 19 16 16 19 18 19 18 19 18 18 17 18 19 18 18 17 19 17 19 19 19 19 17 19 15 18 16 19 17 18 17 16 19 19 18 17 15 19 18 17 19 19 18 19 17 16 17 18 19 19 18 19 17 17 17 19 19 19 19 19 19 19 19 18 14 16 15 19 17 19 17 17 17 19 17 19 19 17 16 18 18 17 17 17 16 18
result:
ok 100 numbers
Test #23:
score: 0
Accepted
time: 4905ms
memory: 4392kb
input:
100 12 1 -446217998 7 -791225517 9 73408189 11 -106337857 15 -104940040 17 62436238 18 101915123 19 634463899 22 -682278321 24 173008410 25 13330045 28 177562882 12 4 242985533 10 -69256930 12 800744571 13 66071467 14 266447106 16 -617719069 17 -336076323 18 -352901627 19 -499160520 22 424949885 24 ...
output:
23 18 29 23 26 20 23 27 18 29 27 23 25 25 20 23 29 27 27 23 23 25 24 27 29 24 23 24 27 29 21 27 24 29 27 29 29 29 27 29 24 23 27 26 25 25 19 27 29 27 26 25 23 27 23 29 29 27 22 25 27 29 21 23 25 29 26 23 24 28 25 27 25 25 22 20 27 25 26 25 27 24 26 27 22 27 27 29 29 24 27 25 27 25 22 22 23 25 21 26
result:
ok 100 numbers
Test #24:
score: -100
Time Limit Exceeded
input:
100 11 2 45805640 4 -646328719 5 207358977 6 -397475219 12 74326792 14 -720327036 17 589847619 22 131060182 23 139741592 26 2049141 27 -110705785 11 1 609352575 3 47393004 4 -79755028 5 40310136 6 606700068 7 741322213 9 -403282727 20 -189581978 21 46299345 25 457503077 27 -189306816 11 1 -127398323...
output:
23 23 28 20 29 27 23 19 27 25 19 19 23 26 26 25 27 25 23 23 27 25 25 26 25 25 25 26 24 27 26 27 27 27 27 20 27 19 25 25 27 25 29 23 26 26 18 29 25 23 25 29 25 26 27 24 21 25 27 27 27 27 27 25 26 29 25 27 29 19 29 23 23 27 27 29