QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#297751 | #5142. Grid Points | ucup-team087# | AC ✓ | 105ms | 3968kb | C++20 | 26.8kb | 2024-01-05 06:29:06 | 2024-01-05 06:29:07 |
Judging History
answer
#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
return os<<"{"<<p.a<<","<<p.b<<"}";
}
template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
os<<"{";
for(auto e:v)os<<e<<",";
return os<<"}";
}
#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
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 dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif
using uint=unsigned;
using ull=unsigned long long;
template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
return os<<vc<t>(all(a));
}
template<int i,class T>
void print_tuple(ostream&,const T&){
}
template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
if(i)os<<",";
os<<get<i>(t);
print_tuple<i+1,T,Args...>(os,t);
}
template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
os<<"{";
print_tuple<0,tuple<Args...>,Args...>(os,t);
return os<<"}";
}
ll read(){
ll i;
cin>>i;
return i;
}
vi readvi(int n,int off=0){
vi v(n);
rep(i,n)v[i]=read()+off;
return v;
}
pi readpi(int off=0){
int a,b;cin>>a>>b;
return pi(a+off,b+off);
}
template<class t>
void print_single(t x,int suc=1){
cout<<x;
if(suc==1)
cout<<"\n";
if(suc==2)
cout<<" ";
}
template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
print_single(p.a,2);
print_single(p.b,suc);
}
template<class T>
void print_single(const vector<T>&v,int suc=1){
rep(i,v.size())
print_single(v[i],i==int(v.size())-1?suc:2);
}
template<class T>
void print_offset(const vector<T>&v,ll off,int suc=1){
rep(i,v.size())
print_single(v[i]+off,i==int(v.size())-1?suc:2);
}
template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
rep(i,N)
print_single(v[i],i==int(N)-1?suc:2);
}
template<class T>
void print(const T&t){
print_single(t);
}
template<class T,class ...Args>
void print(const T&t,const Args&...args){
print_single(t,2);
print(args...);
}
string readString(){
string s;
cin>>s;
return s;
}
template<class T>
T sq(const T& t){
return t*t;
}
void YES(bool ex=true){
cout<<"YES\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void NO(bool ex=true){
cout<<"NO\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void Yes(bool ex=true){
cout<<"Yes\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void No(bool ex=true){
cout<<"No\n";
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
#ifdef CAPITAL
cout<<"YES"<<"\n";
#else
cout<<"Yes"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void no(bool ex=true){
#ifdef CAPITAL
cout<<"NO"<<"\n";
#else
cout<<"No"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}*/
void possible(bool ex=true){
#ifdef CAPITAL
cout<<"POSSIBLE"<<"\n";
#else
cout<<"Possible"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
void impossible(bool ex=true){
#ifdef CAPITAL
cout<<"IMPOSSIBLE"<<"\n";
#else
cout<<"Impossible"<<"\n";
#endif
if(ex)exit(0);
#ifdef LOCAL
cout.flush();
#endif
}
constexpr ll ten(int n){
return n==0?1:ten(n-1)*10;
}
const ll infLL=LLONG_MAX/3;
#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif
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 topbit(ull t){
return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
return __builtin_popcount(t);
}
int popcount(ll t){
return __builtin_popcountll(t);
}
int popcount(ull t){
return __builtin_popcountll(t);
}
int bitparity(ll t){
return __builtin_parityll(t);
}
bool ispow2(int i){
return i&&(i&-i)==i;
}
ll mask(int i){
return (ll(1)<<i)-1;
}
ull umask(int i){
return (ull(1)<<i)-1;
}
ll minp2(ll n){
if(n<=1)return 1;
else return ll(1)<<(topbit(n-1)+1);
}
bool inc(int a,int b,int c){
return a<=b&&b<=c;
}
template<class t> void mkuni(vc<t>&v){
sort(all(v));
v.erase(unique(all(v)),v.ed);
}
ll rand_int(ll l, ll r) { //[l, r]
//#ifdef LOCAL
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)(gen);
}
ll rand_int(ll k){ //[0,k)
return rand_int(0,k-1);
}
template<class t>
void myshuffle(vc<t>&a){
rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}
template<class t,class u>
int lwb(const vc<t>&v,const u&a){
return lower_bound(all(v),a)-v.bg;
}
template<class t,class u>
bool bis(const vc<t>&v,const u&a){
return binary_search(all(v),a);
}
vvc<int> readGraph(int n,int m){
vvc<int> g(n);
rep(i,m){
int a,b;
cin>>a>>b;
//sc.read(a,b);
a--;b--;
g[a].pb(b);
g[b].pb(a);
}
return g;
}
vvc<int> readTree(int n){
return readGraph(n,n-1);
}
template<class t>
vc<t> presum(const vc<t>&a){
vc<t> s(si(a)+1);
rep(i,si(a))s[i+1]=s[i]+a[i];
return s;
}
vc<ll> presum(const vi&a){
vc<ll> s(si(a)+1);
rep(i,si(a))s[i+1]=s[i]+a[i];
return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
gnr(i,1,si(a))a[i]-=a[i-1];
return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
int n=si(a),m=si(a[0]);
vvc<ll> b(n+1,vc<ll>(m+1));
rep(i,n)rep(j,m)
b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
return b;
}
//verify してないや
void transvvc(int&n,int&m){
swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
assert(si(a)==n);
vvc<t> b(m,vi(n));
rep(i,n){
assert(si(a[i])==m);
rep(j,m)b[j][i]=a[i][j];
}
a.swap(b);
transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
assert(si(a)==n);
vvc<t> b(m,vi(n));
rep(i,n){
assert(si(a[i])==m);
rep(j,m)b[m-1-j][i]=a[i][j];
}
a.swap(b);
rotvvc(n,m,args...);
}
//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
int n=si(a);
vi idx(n);iota(all(idx),0);
sort(all(idx),[&](int i,int j){return a[i]<a[j];});
return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
int n=si(a);
assert(si(idx)==n);
vc<t> vs(n);
rep(i,n)vs[i]=a[idx[i]];
return vs;
}
//CF850C
vi invperm(const vi&p){
int n=si(p);
vi q(n);
rep(i,n)q[p[i]]=i;
return q;
}
template<class t,class s=t>
s SUM(const vc<t>&a){
return accumulate(all(a),s(0));
}
template<class t,size_t K,class s=t>
s SUM(const array<t,K>&a){
return accumulate(all(a),s(0));
}
template<class t>
t MAX(const vc<t>&a){
return *max_element(all(a));
}
template<class t>
pair<t,int> MAXi(const vc<t>&a){
auto itr=max_element(all(a));
return mp(*itr,itr-a.bg);
}
template<class A>
auto MIN(const A&a){
return *min_element(all(a));
}
template<class t>
pair<t,int> MINi(const vc<t>&a){
auto itr=min_element(all(a));
return mp(*itr,itr-a.bg);
}
vi vid(int n){
vi res(n);iota(all(res),0);
return res;
}
template<class S>
void soin(S&s){
sort(all(s));
}
template<class S,class F>
void soin(S&s,F&&f){
sort(all(s),forward<F>(f));
}
template<class S>
S soout(S s){
soin(s);
return s;
}
template<class S>
void rein(S&s){
reverse(all(s));
}
template<class S>
S reout(S s){
rein(s);
return s;
}
template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a){return mp(-a.a,-a.b);}
template<class t,class u>
istream&operator>>(istream&is,pair<t,u>&a){
return is>>a.a>>a.b;
}
template<class t>
t gpp(vc<t>&vs){
assert(si(vs));
t res=move(vs.back());
vs.pop_back();
return res;
}
template<class t,class u>
void pb(vc<t>&a,const vc<u>&b){
a.insert(a.ed,all(b));
}
template<class t,class...Args>
vc<t> cat(vc<t> a,Args&&...b){
(pb(a,forward<Args>(b)),...);
return a;
}
template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
for(auto&v:a)v+=x;
return a;
}
template<class t,class u>
vc<t> operator+(vc<t> a,u x){
return a+=x;
}
template<class t>
vc<t> operator+(const vc<t>&a,const vc<t>&b){
vc<t> c(max(si(a),si(b)));
rep(i,si(a))c[i]+=a[i];
rep(i,si(b))c[i]+=b[i];
return c;
}
template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
for(auto&v:a)v-=x;
return a;
}
template<class t,class u>
vc<t>& operator-(vc<t> a,u x){
return a-=x;
}
template<class t,class u>
void remval(vc<t>&a,const u&v){
a.erase(remove(all(a),v),a.ed);
}
//消した要素の個数を返してくれる
//UCUP 2-8-F
template<class t,class F>
int remif(vc<t>&a,F f){
auto itr=remove_if(all(a),f);
int res=a.ed-itr;
a.erase(itr,a.ed);
return res;
}
template<class VS,class u>
void fila(VS&vs,const u&a){
fill(all(vs),a);
}
template<class t,class u>
int findid(const vc<t>&vs,const u&a){
auto itr=find(all(vs),a);
if(itr==vs.ed)return -1;
else return itr-vs.bg;
}
template<class t>
void rtt(vc<t>&vs,int i){
rotate(vs.bg,vs.bg+i,vs.ed);
}
//copied from yosupo's library
//PARTLY VERIFIED
//USACO 2022 January ptlatinum C
//#define GEOF
#ifdef GEOF
using ld=long double;
//using ld=double;
const ld PI=acos(ld(-1));
#else
using ld=ll;
#endif
const ld eps=1e-9;
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
int sgn(ld a,ld b){return sgn(a-b);}
/*
using pt=complex<ld>;
#define x real()
#define y imag()
*/
struct pt {
ld x,y;
//pt(ld _x = ld(0), ld _y = ld(0)) : x(_x), y(_y) {}
pt():x(0),y(0){}
pt(ld xx,ld yy):x(xx),y(yy){}
pt operator+(const pt& r) const { return {x + r.x, y + r.y}; }
pt operator-(const pt& r) const { return {x - r.x, y - r.y}; }
pt operator*(const pt& r) const {
return {x * r.x - y * r.y, x * r.y + y * r.x};
}
pt inv()const{
ld d=norm();
return {x/d,-y/d};
}
pt operator/(const pt&r)const{
return operator*(r.inv());
}
pt operator*(const ld& r) const { return {x * r, y * r}; }
pt operator/(const ld& r) const { return {x / r, y / r}; }
pt& operator+=(const pt& r) { return *this = *this + r; }
pt& operator-=(const pt& r) { return *this = *this - r; }
pt& operator*=(const pt& r) { return *this = *this * r; }
pt& operator/=(const pt& r) { return *this = *this / r; }
pt& operator*=(const ld& r) { return *this = *this * r; }
pt& operator/=(const ld& r) { return *this = *this / r; }
pt operator-() const { return {-x, -y}; }
static int cmp(const pt&a,const pt&b){
int v=sgn(a.x,b.x);
return v?v:sgn(a.y,b.y);
}
bool operator<(const pt& r) const {
return cmp(*this,r)<0;
}
bool operator<=(const pt& r) const {
return cmp(*this,r)<=0;
}
bool operator>(const pt& r) const {
return cmp(*this,r)>0;
}
bool operator==(const pt& r) const { return sgn((*this - r).rabs()) == 0; }
bool operator!=(const pt& r) const { return !(*this == r); }
ld norm() const { return x * x + y * y; }
ld rabs() const { return max(std::abs(x), std::abs(y)); } // robust abs
pair<ld, ld> to_pair() const { return {x, y}; }
#ifdef GEOF
ld abs() const { return sqrt(norm()); }
ld arg() const { return atan2(y, x); }
static pt polar(ld le, ld th) { return {le * cos(th), le * sin(th)}; }
#endif
};
istream& operator>>(istream& is, pt& p){
return is>>p.x>>p.y;
}
ostream& operator<<(ostream& os, const pt& p) {
return os << "pt(" << p.x << ", " << p.y << ")";
}
ld norm(const pt&a){
return a.norm();
}
ld rabs(const pt&a){
return a.rabs();
}
#ifdef GEOF
ld abs(const pt&a){
return sqrt(norm(a));
}
//XXII Opencup Gpt of Ural K
pt normalized(const pt&a){
return a/abs(a);
}
ld arg(const pt&a){return a.arg();}
//normalize to [-PI,PI)
//Contest 2: ptKU Contest 1, ptTZ Summer 2022 Day 4
ld normarg(ld a){
ld res=fmod(a+PI,2*PI);
if(res<0)res+=PI;
else res-=PI;
return res;
}
//normalize to [0,2*PI)
//Multiuni2023-10-E
ld normarg_nonnegative(ld a){
ld res=fmod(a,2*PI);
if(res<0)res+=2*PI;
return res;
}
//AOJ1183
//arg between ab
//assume given lengths are valid
ld arg(ld a,ld b,ld c){
return acos(min(max((a*a+b*b-c*c)/(2*a*b),ld(-1)),ld(1)));
}
#endif
ld norm(const pt&a,const pt&b){
return (a-b).norm();
}
ld dot(const pt&a,const pt&b){return a.x*b.x+a.y*b.y;}
ld crs(const pt& a,const pt& b){return a.x*b.y-a.y*b.x;}
ld crs(const pt& a,const pt& b,const pt& c){return crs(b-a,c-a);}
int ccw(const pt& a,const pt& b){return sgn(crs(a,b));}
int ccw(const pt& a,const pt& b,const pt& c){return ccw(b-a,c-a);}
//(-pi,0](0,pi]
int argtype(const pt&a){
if(sgn(a.y)==0)return a.x<0?1:0;
return a.y<0?0:1;
}
int argcmp(const pt&a,const pt&b){
int at=argtype(a),bt=argtype(b);
if(at!=bt)return at<bt?-1:1;
return -ccw(a,b);
};
bool argless(const pt&a,const pt&b){return argcmp(a,b)<0;}
//(-2)[a,-1](0)[b,1](2)
int bet(pt a,pt b,pt c){
pt d=b-a;
ld e=dot(d,c-a);
if(sgn(e)<=0)return sgn(e)-1;
return sgn(e-norm(d))+1;
}
//AOJ0153
//三角形 abc に d が含まれるか?0-no,1-edge,2-in
int cont(pt a,pt b,pt c,pt d){
if(ccw(a,b,c)==-1) swap(b,c);
return min({ccw(a,b,d),ccw(b,c,d),ccw(c,a,d)})+1;
}
//(a,b) を結ぶ直線を考え,x 座標との交点の y 座標を求める
//(分子,分母)を返す
pair<ld,ld> xcut(const pt&a,const pt&b,ld x){
return mp(a.y*(b.x-x)-b.y*(a.x-x),b.x-a.x);
}
//XXII Opencup Gpt of Ural K
pt rot90(pt a){
return pt(-a.y,a.x);
}
#ifdef GEOF
ld xcutval(const pt&a,const pt&b,ld x){
auto [p,q]=xcut(a,b,x);
return p/q;
}
//AOJ1183
//Xmas2010 E
//-+ の 順で返す
//a の符号により,small/large が決まる
int qeq(ld a,ld b,ld c,ld&d,ld&e){
if(sgn(a)==0){
if(sgn(b)==0)return 0;
d=-c/b;
return 1;
}
ld f=b*b-4*a*c;
if(sgn(f)<0)return 0;
ld g=sqrt(max(f,ld(0)));
d=(-b-g)/(2*a);
e=(-b+g)/(2*a);
return sgn(f)+1;
}
#else
pt normdir(pt a){
if(a==pt(0,0))return a;
int g=gcd(a.x,a.y);
return pt(a.x/g,a.y/g);
}
#endif
ld area2(const vc<pt>&ps){
ld res=0;
rep(i,si(ps))res+=crs(ps[i],ps[(i+1)%si(ps)]);
return res;
}
using ln=pair<pt,pt>;
pt dir(ln a){return a.b-a.a;}
pt eval(ln a,ld b){return a.a+dir(a)*b;}
ld crs(ln a,pt b){return crs(a.a,a.b,b);}
int ccw(ln a,pt b){return ccw(a.a,a.b,b);}
int bet(ln a,pt b){return bet(a.a,a.b,b);}
ld projt(ln a,pt b){
pt c=dir(a);
return dot(c,b-a.a)/norm(c);
}
pt proj(ln a,pt b){
pt c=dir(a);
return a.a+c*dot(c,b-a.a)/norm(c);
}
pt refl(ln a,pt b){
return proj(a,b)*2-b;
}
//AOJ1157
//0-no,1-yes(endpoint),2-yes(innner),3-overelap
//if the two line touch like this
// x----x----x
//it returns 1
int iss(ln a,ln b){
int c1=ccw(a.a,a.b,b.a),c2=ccw(a.a,a.b,b.b);
int d1=ccw(b.a,b.b,a.a),d2=ccw(b.a,b.b,a.b);
if(c1||c2||d1||d2)return 1-max(c1*c2,d1*d2);
int f=bet(a.a,a.b,b.a),g=bet(a.a,a.b,b.b);
if(max(f,g)==-2||min(f,g)==2)return 0;
if(max(f,g)==-1||min(f,g)==1)return 1;
return 3;
}
//segment a intersects line b?
//endpoints inclusive
bool isl(ln a,ln b){
int d1=ccw(b.a,b.b,a.a),d2=ccw(b.a,b.b,a.b);
return d1*d2<=0;
}
//並行でない->true, というだけ
//直線が一致とかは考えてないことに注意
bool ill(ln a,ln b){
return ccw(dir(a),dir(b));
}
ld cllt(ln a,ln b){
return crs(b.a,b.b,a.a)/crs(dir(a),dir(b));
}
//ICPC Yokohama 2022 J
pair<ld,ld> clltf(ln a,ln b){
return mp(crs(b.a,b.b,a.a),crs(dir(a),dir(b)));
}
//AOJ1033
pt cll(ln a,ln b){
return eval(a,crs(b.a,b.b,a.a)/crs(dir(a),dir(b)));
}
#ifdef GEOF
//AOJ2201
ld dlp(ln a,pt b){
return abs(crs(a,b)/abs(dir(a)));
}
//AOJ0153
ld dsp(ln a,pt b){
pt c=proj(a,b);
if(abs(bet(a.a,a.b,c))<=1)return abs(b-c);
return min(abs(b-a.a),abs(b-a.b));
}
//ABC314H
//b から最も近い a 上の点を返す
pt dsp_tar(ln a,pt b){
pt c=proj(a,b);
if(abs(bet(a.a,a.b,c))<=1)return c;
return abs(b-a.a)<abs(b-a.b)?a.a:a.b;
}
//AOJ1157
ld dss(ln a,ln b){
if(iss(a,b))return 0;
return min({dsp(a,b.a),dsp(a,b.b),dsp(b,a.a),dsp(b,a.b)});
}
//AOJ2160
//反時計回り方向に伸びる垂直二等分線
ln vbis(pt a,pt b){
pt c=(a+b)*ld(0.5),d=b-a;
return ln(c,pt(c.x-d.y,c.y+d.x));
}
ld cutareat(ln z,ld l,ld r){
pt a=eval(z,l);
pt b=eval(z,r);
return -(b.x-a.x)*(a.y+b.y)/2;
}
#endif
//ABC286H
//simple polygon と線分が交わるか
//接している場合も true
/*
bool icl(const vc<pt>&ps,ln z){
int n=si(ps);
rep(i,n){
pt p=ps[i],q=ps[(i+1)%n];
if(iss(z,ln(p,q)))return true;
}
return cont(ps,z.a);
}*/
//f(x) が ] -1 | 0 | 1 [ みたいな形をしているとする
//f(0)<=0 を仮定
//f(inf)=1 を仮定
//f(x)=0 なる x を見つけてくる.
//分母最小,その中で分子最小を見つける
//f(x)=0 なる call の中で最後のやつが答えになっている
//stress-tested
template<class F>
pi frac_bisect(F func){
pi lw(0,1),up(1,0);
int f;
auto load=[&](pi v){
f=func(v);
assert(inc(-1,f,1));
};
load(lw);
assert(f<=0);
if(f==0)return lw;
auto mid=[&](int a,int b){
return pi(lw.a*a+up.a*b,lw.b*a+up.b*b);
};
load(mid(1,1));
while(1){
//func(lw)==-1
//func(up)==1
if(f==0)return mid(1,1);
else if(f==-1){
int w=1;
while(1){
w*=2;
load(mid(1,w));
if(f>-1)break;
}
int l=w/2,r=w,rf=f;
while(r-l>1){
const int v=(l+r)/2;
load(mid(1,v));
if(f==-1)l=v;
else{
r=v;
rf=f;
}
}
lw=mid(1,l);
f=rf;
}else if(f==1){
int w=1;
while(1){
w*=2;
load(mid(w,1));
if(f<1)break;
}
int l=w/2,r=w,rf=f;
while(r-l>1){
const int v=(l+r)/2;
load(mid(v,1));
if(f==1)l=v;
else{
r=v;
rf=f;
}
}
up=mid(l,1);
f=rf;
}else assert(0);
}
}
bool dbg=false;
//デバッグ実行でオーバーフローするとコアダンプしがち
using int128=__int128_t;
using uint128=unsigned __int128_t;
istream& operator>>(istream&is,int128&res){
res=0;
string s;is>>s;
int head=0;
int128 w=1;
if(s[0]=='-'){
w=-1;
head++;
}
while(head<int(s.size())){
res=res*10+s[head++]-'0';
}
res*=w;
return is;
}
ostream& operator<<(ostream&os,int128 i){
if(i==0)
return os<<0;
static char buf[100];
if(i<0){
os<<"-";
i=-i;
}
int p=0;
while(i){
buf[p++]='0'+i%10;
i/=10;
}
reverse(buf,buf+p);
buf[p]=0;
return os<<buf;
}
ostream& operator<<(ostream&os,uint128 i){
if(i==0)
return os<<0;
static char buf[100];
int p=0;
while(i){
buf[p++]='0'+i%10;
i/=10;
}
reverse(buf,buf+p);
buf[p]=0;
return os<<buf;
}
int128 abs128(int128 a){
return a<0?-a:a;
}
int botbit(int128 a){
const int128 m=(int128(1)<<64)-1;
if(a&m)return __builtin_ctzll(ll(a));
else return __builtin_ctzll(ll(a>>64))+64;
}
int128 gcd(int128 a,int128 b){
if(a<0)a=-a;
if(b<0)b=-b;
if(a==0)return b;
if(b==0)return a;
int128 s=botbit(a|b);
a>>=botbit(a);
do{
b>>=botbit(b);
if(a>b)swap(a,b);
b-=a;
}while(b);
return a<<s;
}
const int128 inf128=int128(1)<<122;
//UCUP 2-Prime-97
int128 fld(int128 a,int128 b) { // floored division
return a / b - ((a ^ b) < 0 && a % b); }
int128 cld(int128 a, int128 b) { // ceiled division
return a / b + ((a ^ b) > 0 && a % b); }
//a,c O(10^36)
//b,d O(10^18)
//a/b, c/d の大小比較
int cmpfrac(int128 a,int128 b,int128 c,int128 d){
assert(b);
assert(d);
if(b<0){
a=-a;
b=-b;
}
if(d<0){
c=-c;
d=-d;
}
int128 x=fld(a,b),y=fld(c,d);
if(x<y)return -1;
if(x>y)return 1;
int128 u=(a-x*b)*d,v=(c-y*d)*b;
if(u<v)return -1;
if(u>v)return 1;
return 0;
}
bool inc(int128 a,int128 b,int128 c){
return a<=b&&b<=c;
}
//CF530E,ARC055D
//yosupo sum_of_floor_of_linear
//x_i=floor((a*i+b)/c), i=0,1,..n-1
//c>0
//UCUP 2-Prime-43
//n>=0, n,a,c が O(10^9) で b が O(10^18)
int gauss_sum(int n,int a,int b,int c){
if(n==0)return 0;
int res=0;
{
int p=fld(a,c);
res+=n*(n-1)/2*p;
a-=p*c;
}
{
int p=fld(b,c);
res+=n*p;
b-=p*c;
}
if(a==0)return res;
int top=(a*(n-1)+b)/c;
res+=top*n;
int h=(b+1+c-1)/c;
if(h<=top)
res-=gauss_sum(top-h+1,c,c*h-(b+1),a)+top-h+1;
return res;
}
//Not Verified (9割くらい大丈夫だと思うけど)
//c>=0: Prime New Year Contest 2022 7
//UCUP 2-prime-43
//↑ l,r,a,c が O(10^9) で b が O(10^18)
int gauss_helper(int l,int r,int a,int b,int c){
int s=1;
if(r<l){
s=-s;
swap(l,r);
}
if(c<0){
a=-a;
b=-b;
c=-c;
}
b+=l*a;
return gauss_sum(r-l,a,b,c)*s;
}
//x+=y*eps した座標系で考える
//直線 w を伸ばしてその下にある格子点の数を数える
//[eval(w,0),eval(w,p/q)) と進むことを考える.
//y 座標正の点を + の点,非正の点を - の点と呼ぶことにする.
//strict below にある + と weak above にある - を足し合わせる.
//これが result.a
//result.b は直線上の点の個数
//w が左向きだった場合は -1 倍される
//w=O(10^9), p,q=O(10^18)
pi sub(ln w,int p,int q){
//dmp2(w,p,q);
bool sw=w.a>w.b;
if(sw)w=mp(-w.a+pt(0,1),-w.b+pt(0,1));
int t=0;
pt d=dir(w);
{
int g=gcd(d.x,d.y);
int h=gcd(q,g);
q/=h;
p*=g/h;
d/=g;
}
//dmp(d);
int online=cld(p,q);
if(0<d.x){
int l=1,r=fld((int128)d.x*p,q);
if(w.a.y>0)t++;
else t+=w.a.y;
int v=fld((int128)r*d.y,d.x)+w.a.y;
if(p%q==0){
if(v>0)t+=v-1;
}else if((int128)d.x*p%q==0){
if(v>0)t+=v;
}else{
t+=v;
}
//dmp2(l,r,below);
//dmp2(l,r,d.y,d.x*w.a.y,d.x);
t+=gauss_helper(l,r,d.y,d.x*w.a.y,d.x);
//dmp(below);
t-=online;
}else{
t=max<ll>(1-(w.a.y+online),0)-max<ll>(1-w.a.y,0);
}
if(sw){
t+=online;
online*=-1;
}
//dmp2(t,online);
return pi(t,online);
}
int adjust(pt in,pt out){
int c=ccw(in,out);
if(in<pt()&&pt()<out&&c==1)
return 1;
if(out<pt()&&pt()<in&&c==-1)
return -1;
return 0;
}
//int128!! (for cmpfrac)
//simple polygon と直線が与えられる
//simple polygon (周含む) と直線の交わる区間を列挙する
vc<pi> overlap_ranges(const vc<pt>&ps,ln z){
const int n=si(ps);
vc<pi> res;
rep(i,n){
pt p=ps[i],q=ps[(i+1)%n],r=ps[(i+n-1)%n];
int a=ccw(z,p),b=ccw(z,q);
if(a*b==-1){
res.pb(clltf(z,ln(p,q)));
}
if(a==0){
pi u(rabs(ps[i]-z.a),rabs(dir(z)));
int c=ccw(z,r);
if(b!=c&&(b*c<0||ccw(p,q,r)>0))
res.pb(u);
if(b*c==1&&ccw(p,q,r)>0){
res.pb(u);
res.pb(u);
}
}
}
assert(si(res)%2==0);
soin(res,[&](pi a,pi b){
return cmpfrac(a.a,a.b,b.a,b.b)<0;
});
return res;
}
void slv(){
int n,k;cin>>n>>k;
k--;
vc<pt> ps(n);
rep(i,n)cin>>ps[i];
pt ans;
auto work=[&](pi tilt)->int{
//dmp(tilt);
//if(max(abs(tilt.b),abs(tilt.a))>2)exit(0);
pt K(tilt.b,tilt.a);
vi ct(n);
rep(i,n)ct[i]=ccw(K,ps[i]);
vc<bool> use(n);
rep(i,n){
if(ct[i]<=0){
use[i]=true;
}else{
use[i]=false;
}
}
//dmp(use);
//vc<tuple<int128,int128,int128>> fs;
vc<pi> ts;
int tot=0,asum=0;
rep(i,n){
int j=(i+1)%n;
ln w(ps[i],ps[j]);
if(use[i]){
asum+=adjust(ps[i]-ps[(i+n-1)%n],ps[j]-ps[i]);
int p=1,q=1;
if(!use[j]){
tie(p,q)=clltf(w,ln(pt(),-K));//18,18
ts.pb(clltf(ln(pt(),-K),ln(ps[i],ps[j])));
{
auto [u,v]=ts.back();
if(u%v==0)
asum+=adjust(ps[j]-ps[i],-K);
}
}
auto [va,vb]=sub(w,p,q);
if(ps[i]<ps[j]){//-
tot-=va;
}else{//+
tot-=va+vb;
}
}else if(use[j]){
auto [p,q]=clltf(w,ln(pt(),-K));//18,18
ts.pb(clltf(ln(pt(),-K),ln(ps[i],ps[j])));
{
auto [u,v]=ts.back();
if(u%v==0)
asum+=adjust(-K,ps[j]-ps[i]);
}
auto [va,vb]=sub(w,1,1);
auto [wa,wb]=sub(w,p,q);
if(ps[i]<ps[j]){//-
tot-=va-wa;
}else{//+
tot-=(va-wa)+(vb-wb);
}
}
}
soin(ts,[&](pi a,pi b){
return cmpfrac(a.a,a.b,b.a,b.b)<0;
});
//dmp(ts);
assert(si(ts)%2==0);
rep(i,si(ts)){
auto [va,vb]=sub(ln(pt(),-K),ts[i].a,ts[i].b);
if(i%2==0)tot+=va+vb;
else tot-=va+vb;
}
vc<pi> os=overlap_ranges(ps,ln(pt(),K));
//dmp(os);
int online=0;
for(int i=0;i<si(os);i+=2){
int l=cld(os[i].a,os[i].b);
int r=cld(os[i+1].a+1,os[i+1].b);
online+=r-l;
}
tot+=asum;
//dmp2(tot,asum,online);
if(inc(tot-online,k,tot-1)){
int need=k-(tot-online);
assert(need>=0);
for(int i=0;i<si(os);i+=2){
int l=cld(os[i].a,os[i].b);
int r=cld(os[i+1].a+1,os[i+1].b);
int u=(r-l);
if(need<u){
ans=K*(l+need);
need-=u;
break;
}else{
need-=u;
}
}
assert(need<0);
return 0;
}
//if(tilt==pi(1,2))exit(0);
assert(tot>=0);
if(tot<=k)return -1;
if(k<tot-online)return 1;
assert(false);
};
frac_bisect(work);
print(ans.x,ans.y);
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(20);
if(dbg){
while(1)slv();
}else{
int t;cin>>t;rep(_,t)
slv();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3636kb
input:
4 3 3 1 1 3 1 3 3 4 500000000000000000 1 1 1000000000 1 1000000000 1000000000 1 1000000000 9 22 9 6 6 7 9 7 10 10 6 9 3 9 1 6 1 5 7 3 5 22447972861454999 270353376 593874603 230208698 598303091 237630296 255016434 782669452 568066304 654623868 958264153
output:
3 2 500000000 500000000 7 8 730715389 644702744
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3844kb
input:
500 3 1 9 5 3 6 5 5 3 3 7 7 2 8 8 6 3 3 2 7 1 1 3 1 3 1 6 9 4 6 5 2 3 9 8 10 7 6 10 3 3 3 8 10 5 2 7 7 3 4 6 3 6 2 8 10 3 5 8 4 10 8 4 4 3 16 10 1 5 6 3 2 3 7 4 2 6 2 3 7 3 11 1 7 3 3 8 7 3 2 1 10 1 6 2 6 3 5 8 1 10 5 1 9 3 10 7 4 6 8 2 4 3 3 6 10 1 3 4 7 3 9 7 5 1 5 4 2 3 15 4 1 5 9 2 10 3 5 1 9 7 ...
output:
9 5 6 7 1 1 5 2 8 8 8 10 8 10 9 6 5 4 4 5 5 7 1 6 7 3 4 5 1 3 4 4 2 10 4 6 5 7 3 9 7 10 9 5 4 4 6 5 4 2 6 7 6 8 1 4 1 4 4 8 3 2 4 1 4 4 5 9 1 6 4 7 4 5 8 4 7 1 8 8 3 8 6 6 1 3 6 5 5 4 1 8 4 6 2 4 2 9 4 5 6 6 6 4 7 9 3 1 6 3 3 2 1 2 5 2 8 3 4 8 7 7 1 4 3 3 4 4 3 4 9 6 7 5 2 4 4 9 5 4 7 9 3 1 1 3 5 5 ...
result:
ok 500 lines
Test #3:
score: 0
Accepted
time: 62ms
memory: 3568kb
input:
500 3 12084405018385710 331460715 119904076 443992474 212176195 368959752 599178417 3 937652047917574 387890965 806690359 891389107 876297576 748723443 908286602 3 267910256628065 119712014 822811526 833361776 400608712 489063137 637454364 3 4102577495633102 533141838 823294265 842790945 803579971 8...
output:
369728953 276931697 808838386 866937398 757911281 447754520 765428784 827219064 737447482 855771288 597469869 358367482 408096141 714265302 580224987 155586131 273338160 543280361 519074060 469124540 263317572 545088776 470386462 441783156 466093854 608579356 540499761 718677631 534581495 546549779 ...
result:
ok 500 lines
Test #4:
score: 0
Accepted
time: 3ms
memory: 3564kb
input:
500 4 13 10 8 9 9 5 9 2 8 4 5 8 5 6 10 5 10 7 1 4 23 8 1 9 5 10 9 3 4 4 18 3 1 10 2 10 3 6 5 4 9 4 4 3 2 10 5 9 9 4 6 8 9 7 9 4 5 7 2 4 2 10 5 6 7 1 10 10 3 4 9 7 1 10 2 5 5 7 2 4 20 5 4 4 10 1 4 1 2 4 2 9 8 3 9 1 1 4 3 4 10 2 5 9 6 9 8 8 9 4 12 10 8 3 6 8 7 10 3 4 7 7 7 2 1 4 1 7 2 4 11 10 10 2 6 5...
output:
3 8 8 5 4 4 6 5 7 5 7 5 10 4 5 5 2 6 5 4 8 9 3 6 2 1 8 9 3 7 6 5 6 3 3 4 7 6 1 2 2 4 1 5 6 5 2 6 8 2 3 5 10 6 4 6 6 8 4 1 9 6 6 7 10 10 6 4 3 3 6 5 4 1 2 6 6 3 2 8 7 5 2 6 8 8 6 2 5 10 6 7 8 7 6 6 2 6 9 9 5 10 6 5 3 4 4 7 4 6 6 10 6 5 5 5 3 5 4 6 6 10 7 5 9 2 3 5 6 7 3 7 6 6 7 3 6 1 7 7 4 4 5 2 8 3 ...
result:
ok 500 lines
Test #5:
score: 0
Accepted
time: 70ms
memory: 3564kb
input:
500 4 33987609407043373 875939492 849676059 284683599 946361575 726296656 591469339 712143740 525145277 4 31936267258098893 729598728 196208690 790703190 626609620 442959304 299137943 387712098 266775762 4 31131923528747089 270918921 573583695 305809394 82289425 768050313 829505323 504721047 7406640...
output:
701518230 775473280 566797057 314487539 581738338 541098664 411889202 415577468 806219508 467506456 339040957 343744579 520081303 580156065 695446950 594297907 752374606 698805860 433544009 389392262 412088424 557786862 491290169 879295059 324516896 343712505 516978349 298999319 248652432 628560992 ...
result:
ok 500 lines
Test #6:
score: 0
Accepted
time: 2ms
memory: 3788kb
input:
200 10 34 6 8 9 9 8 9 2 8 4 5 1 3 6 1 6 4 9 4 10 7 10 35 6 7 5 10 4 10 3 9 2 6 6 1 7 2 9 5 8 6 8 7 10 35 5 4 10 1 10 2 8 8 8 10 6 10 6 9 7 7 1 8 1 1 10 22 5 4 1 1 4 2 5 2 7 2 9 9 7 8 5 9 5 5 2 7 10 5 5 8 1 7 2 6 1 4 3 2 4 1 10 3 8 5 8 6 9 10 10 9 5 4 2 4 2 3 10 2 8 4 10 9 7 8 6 7 3 6 4 5 10 48 6 8 3...
output:
6 8 3 7 5 7 8 8 9 3 8 5 2 6 9 8 6 5 4 8 7 7 10 1 4 6 5 9 9 5 4 3 9 9 7 8 1 6 6 9 4 6 1 4 2 7 1 5 4 10 4 2 1 8 2 2 6 7 2 4 3 2 3 2 9 9 8 4 5 7 3 5 5 5 5 5 8 9 7 4 7 4 5 6 3 9 6 4 3 6 1 8 6 3 4 3 4 4 8 5 9 10 9 1 5 5 7 3 5 6 5 4 7 3 2 4 7 5 4 3 9 9 5 4 5 7 3 5 5 2 8 7 8 6 9 8 7 7 4 5 9 5 10 8 7 5 6 7 ...
result:
ok 200 lines
Test #7:
score: 0
Accepted
time: 2ms
memory: 3792kb
input:
200 10 5 4 3 5 1 10 1 6 4 8 10 6 9 4 8 3 6 3 10 1 6 10 7 5 7 2 3 4 4 4 2 5 5 5 3 8 1 6 7 2 8 1 7 10 3 8 5 9 9 3 10 4 7 4 6 4 4 1 7 3 4 2 1 7 5 10 22 4 3 1 1 7 2 6 4 9 6 9 7 10 7 6 9 5 9 2 10 10 20 4 4 7 4 7 3 9 2 10 7 9 8 5 5 6 8 4 8 4 6 10 45 8 9 5 9 1 7 5 1 5 2 7 2 7 3 9 2 10 1 9 5 10 28 2 2 8 1 9...
output:
6 1 5 3 3 2 6 6 9 8 3 6 2 2 7 1 4 6 8 1 6 2 2 8 6 7 8 8 8 3 3 9 1 9 3 9 5 5 7 7 4 7 5 2 6 7 5 2 3 9 9 3 6 3 5 7 6 4 8 4 5 7 4 6 3 4 7 9 5 1 7 9 6 6 4 5 9 7 8 5 8 6 3 8 6 9 3 8 7 4 3 5 1 5 4 6 8 6 6 2 3 3 2 7 8 3 5 5 5 6 5 6 6 7 7 9 8 4 8 7 6 3 7 6 3 4 7 8 4 5 4 5 2 4 4 7 5 7 7 6 6 8 4 4 5 1 4 3 5 4 ...
result:
ok 200 lines
Test #8:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
200 10 30 4 3 5 1 6 2 7 3 9 7 8 8 5 5 4 8 3 9 2 2 10 2 5 7 7 5 7 9 6 10 5 10 2 9 1 9 2 4 3 5 4 2 10 35 3 7 7 1 10 2 9 5 10 8 10 10 8 8 6 7 7 8 4 6 10 37 9 8 7 10 8 8 4 6 1 5 6 5 7 5 5 1 9 1 9 4 10 4 8 7 10 9 6 9 5 7 5 5 7 1 7 7 8 2 8 5 10 3 10 40 8 2 7 8 5 10 4 9 5 5 2 7 1 6 2 6 1 2 7 1 10 31 1 1 2 ...
output:
3 6 7 5 5 6 3 5 10 3 4 9 3 4 3 4 6 6 8 3 8 8 5 1 8 6 5 4 1 10 8 7 6 4 2 2 7 7 4 9 7 6 7 7 6 4 6 3 7 2 5 6 6 3 3 2 5 7 5 2 6 6 2 6 7 6 9 3 5 5 2 2 4 8 8 6 7 6 9 10 5 7 2 7 2 3 6 5 3 6 5 7 2 4 8 4 3 5 9 5 8 4 4 10 9 7 3 8 9 5 3 7 1 2 6 7 6 7 1 4 9 5 7 4 5 9 5 5 9 9 2 2 8 6 5 5 5 4 2 5 2 4 3 4 7 6 3 4 ...
result:
ok 200 lines
Test #9:
score: 0
Accepted
time: 2ms
memory: 3564kb
input:
200 10 9 2 7 3 5 2 5 2 1 6 3 7 3 9 3 9 6 3 10 4 7 10 35 3 2 9 1 7 4 9 3 7 5 9 6 7 6 4 7 3 8 1 4 10 48 6 3 9 1 10 9 9 10 8 10 5 7 5 9 4 9 3 4 5 2 10 38 10 5 10 9 6 8 1 5 1 3 2 5 4 5 5 5 4 4 6 1 10 37 10 5 9 8 3 10 3 4 2 3 1 1 7 7 8 6 9 3 10 1 10 44 6 5 10 4 9 10 6 6 2 10 1 9 1 6 1 2 5 2 4 4 10 42 5 3...
output:
9 5 3 7 4 8 5 7 4 8 1 4 4 7 4 6 2 6 5 8 8 2 2 8 5 5 6 9 5 4 2 10 5 2 8 2 9 3 4 9 2 6 7 4 4 3 6 9 9 7 6 4 7 9 7 3 10 3 8 4 7 9 3 3 5 5 7 4 5 5 2 8 6 7 5 3 9 2 6 4 3 7 6 8 4 9 6 5 8 7 7 10 8 3 5 3 6 4 3 3 6 2 8 7 2 4 1 8 4 9 2 3 2 6 5 5 7 10 1 9 8 4 7 3 6 6 5 1 7 5 6 8 2 4 6 7 4 3 3 7 8 6 2 6 9 2 7 9 ...
result:
ok 200 lines
Test #10:
score: 0
Accepted
time: 2ms
memory: 3628kb
input:
200 10 2 10 2 8 4 7 4 6 4 3 9 2 5 2 4 2 3 4 1 9 1 10 19 8 8 1 9 2 8 1 4 2 2 4 5 3 3 10 1 8 4 10 3 10 7 5 2 5 1 10 6 8 6 6 4 4 7 3 4 3 3 4 3 5 3 10 20 4 6 8 6 8 7 2 10 3 7 2 5 3 2 4 5 6 3 6 4 10 17 2 3 3 1 9 4 10 6 4 7 3 10 1 10 1 6 1 3 2 5 10 42 8 8 5 8 5 10 1 7 1 6 2 4 4 4 7 3 9 1 10 3 10 4 7 7 6 9...
output:
8 1 5 4 9 5 3 5 4 3 3 7 6 2 4 5 4 9 5 4 4 9 1 4 5 3 8 4 7 8 3 8 2 5 5 8 4 8 2 7 7 2 3 9 8 2 5 8 7 3 6 8 3 5 3 6 7 6 7 8 3 3 4 2 3 8 10 2 2 1 7 7 9 6 9 9 4 3 3 4 7 5 9 5 4 6 6 5 5 4 3 6 8 8 9 4 9 7 5 4 8 5 5 5 8 6 6 7 3 2 6 6 6 5 4 7 9 10 2 6 6 5 6 1 3 6 4 9 6 6 1 2 2 5 8 7 7 3 3 3 10 10 6 8 8 4 5 2 ...
result:
ok 200 lines
Test #11:
score: 0
Accepted
time: 46ms
memory: 3564kb
input:
200 10 51389395003818138 274110746 812150345 151056109 770557320 72547514 777458294 160254536 662053657 251877784 469544808 296724609 128967723 339595003 352511908 978993827 835819987 641729042 704379000 382879284 754861256 10 113391077951023525 614486567 149483526 616241394 25662099 938799922 77117...
output:
624263300 692614344 719797766 358125683 645283913 632678790 409364845 599793693 198371106 491921289 779443552 336045055 183908853 687745195 439216280 605320621 189804837 305720057 275314948 637561583 659360572 276498659 416519216 491236147 419727721 173766771 707151980 450975421 395933060 876232919 ...
result:
ok 200 lines
Test #12:
score: 0
Accepted
time: 2ms
memory: 3564kb
input:
40 50 121 6 13 3 8 1 4 5 8 11 15 7 9 14 11 14 9 11 7 10 7 4 6 14 7 12 6 4 3 7 4 13 6 2 1 14 5 16 1 17 4 18 5 17 9 16 10 15 10 16 13 20 12 18 15 20 16 13 16 20 19 19 19 12 16 16 19 14 19 12 18 14 20 12 19 13 20 12 20 6 20 4 20 2 20 1 20 5 18 6 15 4 16 3 13 3 14 1 16 2 11 50 141 12 9 12 6 8 1 11 4 10 ...
output:
13 19 10 14 17 11 14 12 6 4 10 16 15 8 14 15 14 16 9 6 2 12 12 9 5 8 8 16 12 18 12 9 14 7 8 14 12 17 19 19 6 9 6 3 7 14 17 12 16 17 12 12 16 20 13 9 1 3 17 6 3 18 15 9 10 13 6 9 4 6 6 12 6 17 7 13 14 10 11 14
result:
ok 40 lines
Test #13:
score: 0
Accepted
time: 33ms
memory: 3824kb
input:
40 50 482851715791165276 546326159 188010383 610974197 352600737 661025009 421289671 682778451 396215362 707879921 337976248 744033112 251622709 853159846 76598487 977808549 114660165 990265221 239686197 948363025 341661773 920139552 208511591 948006309 695934039 883615961 565728136 955215470 978862...
output:
92234837 581927490 713300757 73995563 685035698 495285272 724234348 327326739 671255782 250153225 834996919 388372002 872091985 716957981 315646104 182177912 476966746 722363817 533458828 316989502 229486465 768859315 835741088 530520918 181042984 307052453 178855411 659189295 164643632 488887550 43...
result:
ok 40 lines
Test #14:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
20 100 247 14 18 12 20 11 19 11 20 7 20 12 16 13 13 12 13 11 14 9 16 6 19 4 20 6 18 5 18 4 19 4 18 5 17 6 16 9 14 11 13 11 12 13 10 7 15 8 14 4 17 1 18 9 12 13 9 7 13 2 17 6 13 1 17 3 14 4 12 4 11 4 10 1 7 2 6 2 3 3 6 3 2 3 1 4 2 6 4 4 1 7 2 10 1 8 4 9 5 7 7 5 9 8 7 9 6 10 3 12 4 11 5 11 6 12 5 11 7...
output:
4 10 4 13 8 10 18 12 3 4 18 9 14 14 19 13 9 18 5 5 10 6 16 1 11 3 5 15 14 12 12 16 3 6 11 14 10 17 13 14
result:
ok 20 lines
Test #15:
score: 0
Accepted
time: 32ms
memory: 3552kb
input:
20 100 162153495280354252 501610500 151561800 493789150 175949847 924419080 9549341 621275716 137157995 987235435 11358215 840802570 92921005 731340935 170842820 993822978 116747213 889901111 142380493 915653395 138002865 900883723 149721622 952638180 211520865 409039435 292471770 824566184 24096776...
output:
655544886 430451996 621604657 849634990 576461780 508426508 236196302 886571780 41109900 65255472 469962250 835280239 834491251 774752441 355524414 547150300 775889340 317086741 220628210 403759047 494309101 591039187 607286316 401296265 276941560 380712192 557110380 436881862 308065002 25246685 674...
result:
ok 20 lines
Test #16:
score: 0
Accepted
time: 3ms
memory: 3580kb
input:
4 500 1572 42 49 42 48 38 42 35 38 29 29 23 20 32 33 36 38 37 37 39 39 40 40 29 27 24 20 29 26 33 30 40 38 24 19 16 9 13 5 15 3 16 8 17 8 20 8 24 5 23 16 24 11 24 14 25 11 26 9 27 14 29 6 30 5 29 10 30 8 32 3 32 7 32 9 31 8 32 10 33 3 33 1 35 10 36 16 32 20 30 16 28 16 26 20 37 23 38 27 41 35 40 29 ...
output:
72 67 11 74 20 59 45 74
result:
ok 4 lines
Test #17:
score: 0
Accepted
time: 42ms
memory: 3652kb
input:
4 500 326810793396625908 923289363 281790836 977025913 317936081 811490147 245307012 831958500 251231979 877506224 261187896 680211478 156709020 727428138 189886332 740756099 213075437 938671618 312643329 897513565 300001476 821348572 270878049 733772848 233183854 708966548 233864071 693273982 23351...
output:
285650615 400437842 286617888 781545827 98064207 918136592 775281699 974464115
result:
ok 4 lines
Test #18:
score: 0
Accepted
time: 3ms
memory: 3612kb
input:
1 2000 74335 346 231 332 226 339 235 339 237 338 239 344 237 346 240 357 244 352 234 357 237 371 242 362 246 372 252 381 250 380 258 394 255 397 260 395 271 400 272 395 275 387 274 380 269 370 260 383 277 399 291 368 265 323 231 325 235 321 232 342 249 337 247 328 240 310 228 294 214 286 213 274 208...
output:
86 310
result:
ok single line: '86 310'
Test #19:
score: 0
Accepted
time: 8ms
memory: 3604kb
input:
1 2000 40203989437233947 33916963 27241751 46050915 9335619 65684829 40138915 69729772 47370582 57648515 59318446 53398946 106896533 58553292 122325552 66488088 79191623 60835391 132008742 69223973 79140473 61972249 134396814 77823236 124966861 75049875 121280444 70543780 110706477 89929906 10642862...
output:
529257085 92909258
result:
ok single line: '529257085 92909258'
Test #20:
score: 0
Accepted
time: 16ms
memory: 3892kb
input:
1 2000 119235751223864797 917033091 600790595 982044424 619234710 867754595 602222405 844493577 593056677 824431858 601614726 828307378 610236049 822027339 602658028 823800275 610582319 791931015 617586959 880336297 621886345 870802184 622666088 848576972 623660627 910447437 622581993 956966817 6271...
output:
515436269 253717829
result:
ok single line: '515436269 253717829'
Test #21:
score: 0
Accepted
time: 21ms
memory: 3680kb
input:
1 2000 156825723005340909 95116515 469306736 104543124 453847845 105751226 452862542 86679245 390045405 78995501 364397799 57867108 400694748 63009273 373024886 58547886 333579623 52889928 307846775 51356858 361462896 47357794 430184263 47367981 410144373 12136233 371719600 44437292 359415994 503604...
output:
244115273 160394672
result:
ok single line: '244115273 160394672'
Test #22:
score: 0
Accepted
time: 25ms
memory: 3648kb
input:
1 2000 196389323929026005 273199939 897631388 289914823 890943428 158976818 927499391 170244133 921967857 290337091 884472455 241760527 899314001 101040858 941283694 208434633 903630376 245530384 887194415 224481938 884632219 230996855 873872326 172576675 890594961 107375976 929113768 164729633 8702...
output:
566681712 432553739
result:
ok single line: '566681712 432553739'
Test #23:
score: 0
Accepted
time: 15ms
memory: 3880kb
input:
1 2000 80673198294743043 451283363 176212936 478513990 202599251 495594352 186386259 507746415 184446241 471007553 152953554 476203037 143258733 469913357 127811760 468359138 129128827 458477789 144872312 453722155 93747707 468556012 106210213 482967453 122718691 496373709 153291776 503906986 164270...
output:
520172771 185971123
result:
ok single line: '520172771 185971123'
Test #24:
score: 0
Accepted
time: 34ms
memory: 3860kb
input:
10 199 75665468080744538 998246910 601469 996243848 513997972 987969238 513389625 976938909 515521652 976499273 503465623 975017118 519932247 958654079 491699991 957632838 521457139 953905158 491240058 951546613 524646795 946492292 486113226 944768417 531162698 941125688 485168867 940488237 53186131...
output:
888759001 145709257 929769361 23671822 606159016 540250277 781114728 528955223 331295227 56861631 582698062 204896053 471799929 9890038 914551373 347992661 823741426 423964191 659723562 401166600
result:
ok 10 lines
Test #25:
score: 0
Accepted
time: 41ms
memory: 3580kb
input:
10 199 223887038020548999 995590859 2905885 992525378 500159669 983876600 497188487 980211540 509600623 974818641 490874044 973884140 521152391 966936042 482507417 966552207 527404351 963201987 482122216 957345382 538855655 949421816 477238508 947480249 542699205 941692551 477089203 930113852 543597...
output:
831019037 383446905 199595019 217756889 58874027 207252081 408733476 139688906 941828548 60334994 101107312 53292047 119196386 174307600 86919995 19043348 471248961 323254916 596372521 160431160
result:
ok 10 lines
Test #26:
score: 0
Accepted
time: 33ms
memory: 3600kb
input:
10 199 192415647491948020 995864039 2360823 994406411 511198418 993646595 510721217 992643004 526553654 989314220 510552995 988250483 535253183 985201100 501399274 982017750 541577304 968109912 493580925 967434253 559184848 963737382 492646168 955182632 559255350 954544693 491724053 947590988 565667...
output:
428847251 169736975 35741169 172022738 346734706 203482792 406999797 657834680 300181712 761885073 924548024 387321310 537303974 199485412 787192462 442435162 877230582 109391024 871773557 158737682
result:
ok 10 lines
Test #27:
score: 0
Accepted
time: 4ms
memory: 3692kb
input:
1 1999 197372282195117275 999602210 1261 999092115 534312295 997987225 532544949 997531367 535593465 996608188 532426275 996469938 536041700 996407245 532095135 995959882 536172059 995861337 530153792 995179705 536317740 994811677 529832896 993491560 536426878 993185524 529349952 992969877 537388270...
output:
745942633 295429882
result:
ok single line: '745942633 295429882'
Test #28:
score: 0
Accepted
time: 105ms
memory: 3744kb
input:
1 1999 321751104047913169 999913910 458152 999133909 498402055 997157204 498245084 996977228 498593767 996772461 497674531 996590923 499410661 996402131 496946559 994670031 500276421 994589458 496705711 994583793 500293277 994575665 495512152 993856032 500555092 993091845 495203611 992494536 5007461...
output:
347685052 256519434
result:
ok single line: '347685052 256519434'
Test #29:
score: 0
Accepted
time: 97ms
memory: 3668kb
input:
1 1999 347464795230406602 998566345 143858 998260702 493427579 997757700 493234598 997152288 493453752 997127897 493047635 996679397 493917026 996449610 492608504 996125707 496015206 996029682 492600374 995988102 496489714 995830082 491907665 993841155 498018701 993764311 491882159 993178941 4982816...
output:
659013918 593384614
result:
ok single line: '659013918 593384614'
Test #30:
score: 0
Accepted
time: 60ms
memory: 3780kb
input:
10 199 377970472850495883 458726 361620 979436384 414362 1865575 3669526 974478667 12147039 8961567 15975676 971688420 16222230 26157938 16489613 971664326 16551657 27598738 22385464 964627090 25177416 32989000 27438882 963995879 31144819 37680299 32007097 959041021 37190259 38882375 45222418 955125...
output:
163040694 853665543 437278254 421880982 556172253 22321669 371413280 958483424 79905529 793657825 434029162 423930666 369839144 171220982 295747087 706641870 294068632 312623985 203886320 162992053
result:
ok 10 lines
Test #31:
score: 0
Accepted
time: 75ms
memory: 3600kb
input:
10 199 147503427117916649 7812690 16060847 993840531 16119697 10921629 18738883 988620995 29784667 16381032 38345682 988060039 44239709 19895110 47650214 987019556 49378116 23307048 51079682 985752485 51090364 25067575 52566823 983940838 57476356 31219164 58102727 982945980 63994517 32751609 6563665...
output:
550464819 617049607 104099196 557401499 89796418 15482599 442938937 739737316 18762983 69601288 244542742 193731212 403863698 279047463 252573821 242910256 409522632 508850069 59114487 274582481
result:
ok 10 lines
Test #32:
score: 0
Accepted
time: 43ms
memory: 3648kb
input:
10 199 52958032434506311 5080150 937072 999359321 1923864 7553746 10418306 994978576 18508508 31279391 25760959 993316764 35089366 45104311 35813792 987467525 36130083 46469770 38377037 976949682 41619471 58426339 41860250 970821775 43856929 61231488 44909747 967712259 47599869 63264334 54191087 966...
output:
287660633 99216830 197763414 284961185 243412486 24189429 34952678 681588050 288041969 671297927 169557820 906873342 88343645 394453764 263244360 17785648 118994081 396590697 48610858 227343983
result:
ok 10 lines
Test #33:
score: 0
Accepted
time: 55ms
memory: 3956kb
input:
1 1999 76946703007919028 746745 1127282 999937634 1208824 1190186 1481677 999898136 1914736 1847606 2566558 998674639 2930257 2775090 3989849 998673972 4873274 3022121 4932418 997782348 6110572 3440276 6476643 997240428 6488240 3889125 6625313 996732423 7406214 4262466 8051392 996692180 8490889 4458...
output:
658093664 341173705
result:
ok single line: '658093664 341173705'
Test #34:
score: 0
Accepted
time: 68ms
memory: 3896kb
input:
1 1999 92960182075729971 1780194 2483537 999606436 3152345 2114525 3589114 998518535 4022968 2222110 4448102 997816399 4747113 2734411 5009367 996905723 5075400 2737930 6393915 996757901 6614823 3810137 6736802 996455683 6817747 4560695 7230538 996225912 7401898 5769358 7592839 995760659 8566675 594...
output:
328790887 214672065
result:
ok single line: '328790887 214672065'
Test #35:
score: 0
Accepted
time: 93ms
memory: 3968kb
input:
1 1999 110852529382447463 194478 91958 999925831 275656 1573289 408171 999559220 627373 1737886 877905 999319379 1160109 1780615 1944253 998943350 3037117 1944221 4407433 998729835 4571486 2146212 5113802 998477676 6039570 2304014 7047409 998327091 7672706 2501217 8213766 998120584 8278840 2559126 8...
output:
105896388 81589284
result:
ok single line: '105896388 81589284'
Test #36:
score: 0
Accepted
time: 24ms
memory: 3792kb
input:
500 3 8179003110119496 269448210 898160700 179632140 718528560 538896420 898160700 3 43692340786554 39023991 30351993 30351993 43359990 30351993 17343996 3 806029174713120 50743917 456695253 355207419 355207419 253719585 405951336 3 35370480447243542 293146225 58629245 586292450 175887735 410404715 ...
output:
351222983 834128318 36545035 30569196 258027551 397812469 400264008 249033808 215971701 376147333 652743207 473823535 42365617 81520037 208832266 137139286 671374914 379195612 730990874 535511283 351320271 427207620 221328008 133308318 305769195 594004999 374054335 381476271 111686339 190928924 1204...
result:
ok 500 lines
Test #37:
score: 0
Accepted
time: 27ms
memory: 3560kb
input:
500 3 7404006427544139 56715137 226860548 510436233 397005959 340290822 397005959 3 25038918358256316 408919585 490703502 163567834 654271336 327135668 327135668 3 1809459417492222 116608906 58304453 291522265 291522265 116608906 116608906 3 7760417177872683 313736720 627473440 439231408 376484064 5...
output:
313307704 357865197 209310794 575703905 136333273 116743504 456677882 453910024 137040513 384974569 241331492 571453390 210890246 505342001 245009067 261063011 236513201 314242123 219190386 398930379 491401349 213114186 545005553 609514789 561460477 475181152 353347802 438953281 514204803 462002388 ...
result:
ok 500 lines
Test #38:
score: 0
Accepted
time: 32ms
memory: 3788kb
input:
500 4 95965839308939 53536112 53536112 46844098 53536112 60228126 33460070 66920140 46844098 4 78026743115837030 232883848 523988658 116441924 349325772 582209620 58220962 465767696 523988658 4 3673385564200733 201142270 120685362 20114227 40228454 100571135 40228454 140799589 20114227 4 26597672369...
output:
57576119 45376063 286772573 368943722 186705470 108786044 193234087 139639022 396161160 497531199 227346277 195660003 101474532 495531198 456181630 479365913 134063945 155022450 129477200 131052247 85718630 71889397 129475749 102497229 223084823 280003315 85450622 41706083 49666481 39014653 67978459...
result:
ok 500 lines
Test #39:
score: 0
Accepted
time: 33ms
memory: 3848kb
input:
500 4 594817022250013 177992392 177992392 711969568 622973372 889961960 889961960 355984784 355984784 4 42213522703171210 151526706 454580118 50508902 151526706 151526706 151526706 404071216 101017804 4 87299892778749042 783813267 174180726 87090363 609632541 174180726 435451815 174180726 261271089 ...
output:
668528188 592072402 126439807 265428899 211554742 528876434 95549808 102624035 42619640 60095184 50566840 18073058 217805344 189501695 476684120 340625480 406690207 267057442 79563729 89223997 410722539 508168658 46032581 18025729 239984503 565005537 119870618 225408090 188131561 842641171 18658412 ...
result:
ok 500 lines
Test #40:
score: 0
Accepted
time: 18ms
memory: 3572kb
input:
200 10 278411292735419107 558719964 744959952 838079946 838079946 744959952 838079946 186239988 744959952 372479976 465599970 93119994 279359982 558719964 93119994 558719964 372479976 838079946 372479976 931199940 651839958 10 23709034457434826 165851244 27641874 193493118 55283748 248776866 1382093...
output:
429033930 735824552 122101574 257254692 704007946 476628956 259925022 322761188 448369555 373179142 706974975 517984870 267174303 854965116 330842139 259237881 77064644 233061195 59211193 76921596 744982525 158688990 227447483 86620671 133733685 114357635 70305055 35982958 239935872 46452292 4521264...
result:
ok 200 lines
Test #41:
score: 0
Accepted
time: 19ms
memory: 3588kb
input:
200 10 38284739875362 4726044 3544533 5907555 1181511 11815110 1181511 7089066 4726044 9452088 11815110 7089066 10633599 4726044 9452088 3544533 7089066 3544533 11815110 1181511 7089066 10 8271619677730010 131910156 113065848 150754464 37688616 131910156 150754464 56532924 188443080 18844308 9422154...
output:
4596761 7998223 89807144 162068092 347904652 152245165 29720118 80170197 153143759 91639230 136867115 161467931 443825851 639415254 331062702 480993359 45141881 71878858 82573535 40948940 300169383 409707096 232757955 59690895 97876436 450609680 71740760 67177653 397624467 488734300 229018688 217787...
result:
ok 200 lines
Test #42:
score: 0
Accepted
time: 19ms
memory: 3528kb
input:
200 10 3302335300500112 77233744 57925308 96542180 19308436 115850616 38616872 135159052 57925308 173775924 135159052 154467488 154467488 96542180 96542180 77233744 154467488 57925308 173775924 38616872 38616872 10 25375242959281507 431915930 129574779 431915930 302341151 431915930 431915930 3887243...
output:
126599102 96782808 212956416 292374431 461657686 309763591 538632384 245129729 312971260 466327293 201488157 164150704 378545897 652819210 280731845 54512985 243716772 187231230 271638421 348593552 322966180 390794610 146438503 181191716 122164562 447081919 440563521 468003527 256868124 262347870 90...
result:
ok 200 lines
Test #43:
score: 0
Accepted
time: 19ms
memory: 3560kb
input:
200 10 9166095315752107 64805314 226818599 97207971 162013285 64805314 162013285 64805314 32402657 194415942 97207971 226818599 97207971 291623913 97207971 291623913 194415942 97207971 324026570 129610628 226818599 10 14500015844861572 44629372 66944058 89258744 22314686 178517488 156202802 15620280...
output:
192478671 128637051 56553413 155694800 397152967 551556708 346556938 208578925 79435408 126716306 145641134 334813854 52279877 19612885 573760236 452417978 383527351 496305012 58680434 57630752 235954826 248213337 616545590 438653803 232556684 519879098 97728862 81059784 170514790 154619383 35863154...
result:
ok 200 lines
Test #44:
score: 0
Accepted
time: 15ms
memory: 3528kb
input:
200 10 32822749153322362 404641750 80928350 323713400 161856700 283249225 161856700 242785050 161856700 121392525 364177575 80928350 202320875 80928350 161856700 80928350 121392525 161856700 40464175 364177575 40464175 10 25235022608004957 413557400 51694675 465252075 516946750 413557400 516946750 2...
output:
182714724 201271829 252185410 127457555 340777808 489033720 262872117 348594841 394599842 206102817 149597556 272773554 114640935 95026143 317670938 362279632 398324273 509521001 45041558 33129388 105919972 225704750 89401901 74142956 241501184 280617371 255644708 153142089 612642600 453681902 15452...
result:
ok 200 lines
Test #45:
score: 0
Accepted
time: 11ms
memory: 3536kb
input:
40 50 8166019241779258 656043780 690572400 517929300 690572400 207171720 690572400 69057240 656043780 310757580 656043780 552457920 656043780 34528620 621515160 138114480 621515160 276228960 621515160 552457920 621515160 552457920 586986540 345286200 552457920 172643100 586986540 276228960 552457920...
output:
598708731 189634734 505075752 625603511 300419772 65197384 250853588 229750010 195891531 82631657 96414478 135355678 8926579 4671506 109548855 146643488 430742253 205063419 204574171 239528462 86455139 102539070 246417301 90351886 140757345 87698911 300731948 293993574 183927299 172550815 345999226 ...
result:
ok 40 lines
Test #46:
score: 0
Accepted
time: 12ms
memory: 3560kb
input:
40 50 7732936868389850 100175453 114486232 100175453 143107790 228972464 42932337 214661685 42932337 157418569 42932337 214661685 14310779 243283243 14310779 271904801 14310779 271904801 28621558 286215580 28621558 271904801 71553895 271904801 100175453 228972464 143107790 243283243 114486232 214661...
output:
239925958 117845959 516012561 104462982 144724636 250237624 777771367 365778987 56152583 33888417 54324094 54561286 70357394 345769267 302220422 114250398 165064456 108828583 258869537 38014158 670285410 535907731 64992091 187292951 793660084 942788356 595526866 210532915 150165018 341642281 1526647...
result:
ok 40 lines
Test #47:
score: 0
Accepted
time: 6ms
memory: 3772kb
input:
20 100 28105602313477997 389977728 552468448 519970304 617464736 324981440 552468448 422475872 617464736 487472160 649962880 422475872 649962880 389977728 649962880 324981440 584966592 324981440 617464736 292483296 584966592 324981440 649962880 227487008 649962880 292483296 617464736 259985152 58496...
output:
477417857 183667030 363762912 251001084 343819509 340490516 371814963 476512009 150598925 542622187 262972098 358384347 3843815 15847399 19644123 5625060 343235059 378425488 547970948 526279239 38034234 375103910 320107186 241068545 163590145 113720709 596323113 142741830 197571508 325078080 2472385...
result:
ok 20 lines
Test #48:
score: 0
Accepted
time: 9ms
memory: 3620kb
input:
20 100 18207757606619088 58462842 126669491 48719035 136413298 48719035 126669491 58462842 97438070 48719035 107181877 38975228 136413298 29231421 136413298 9743807 165644719 29231421 126669491 29231421 116925684 19487614 116925684 19487614 97438070 19487614 87694263 48719035 77950456 29231421 68206...
output:
26560446 92367311 293137399 86400007 914253299 133961432 130052103 144713303 703765558 260941975 422576191 50294151 78420748 16814165 97701261 197284933 217168832 283431634 117300433 131361274 102526411 368040389 519159540 224571620 135964539 147337806 778356997 233226664 59947700 20750925 122358087...
result:
ok 20 lines
Test #49:
score: 0
Accepted
time: 12ms
memory: 3540kb
input:
4 500 47826285034211960 441806912 296839019 393484281 317548718 428000446 324451951 393484281 331355184 372774582 338258417 379677815 338258417 379677815 345161650 414193980 338258417 379677815 365871349 365871349 372774582 407290747 372774582 379677815 393484281 407290747 428000446 421097213 421097...
output:
460742757 312886107 90140185 169760591 212137082 318086418 111622379 587586047
result:
ok 4 lines
Test #50:
score: 0
Accepted
time: 8ms
memory: 3624kb
input:
4 500 152340619463114549 185977840 548634628 176678948 548634628 241771192 530036844 251070084 511439060 223173408 520737952 232472300 502140168 241771192 455645708 232472300 446346816 204575624 502140168 223173408 455645708 213874516 446346816 232472300 427749032 185977840 437047924 130184488 39985...
output:
226909091 263855329 247908191 177402130 866479368 707527191 409208117 211067383
result:
ok 4 lines
Test #51:
score: 0
Accepted
time: 11ms
memory: 3676kb
input:
1 2000 214722131619342111 404726592 75581472 394974144 14628672 416917152 97524480 421793376 138972384 421793376 114591264 419355264 65829024 433983936 190172736 433983936 143848608 433983936 90210144 412040928 43886016 412040928 9752448 426669600 46324128 421793376 26819232 414479040 2438112 419355...
output:
586893856 538468987
result:
ok single line: '586893856 538468987'
Test #52:
score: 0
Accepted
time: 15ms
memory: 3584kb
input:
1 2000 7177955778710578 85361367 5940901 83485293 312679 85048688 1250716 88488157 2814111 89113515 3126790 88175478 2188753 88488157 312679 91302268 625358 92552984 938037 93178342 2188753 94429058 1250716 96930490 1250716 98493885 312679 98493885 2188753 99744601 2814111 100369959 4064827 95054416...
output:
14123555 57988947
result:
ok single line: '14123555 57988947'
Test #53:
score: 0
Accepted
time: 11ms
memory: 3632kb
input:
500 3 1 53656179 178853930 35770786 143083144 107312358 178853930 3 42377813772224294 612311959 612311959 262419411 174946274 787258233 262419411 3 39008513493774274 670789584 754638282 83848698 670789584 419243490 335394792 3 11175735157245155 329453640 247090230 205908525 205908525 411817050 41181...
output:
107312358 178853930 440246095 264147657 550027660 687534575 266392553 190280395 191506816 143630112 146473855 292923926 182693140 208792160 409226671 545635561 91489585 106737846 263068806 43844801 311093354 559964632 49838062 99676124 138512882 323196725 261885148 785655439 294563803 331384279 1451...
result:
ok 500 lines
Test #54:
score: 0
Accepted
time: 10ms
memory: 3644kb
input:
500 3 494470421385252 38819548 155278192 349375932 271736836 232917288 271736836 3 4232670765120727 317700820 254160656 190620492 222390574 222390574 31770082 3 995146570594483 203628190 203628190 325805104 244353828 81451276 203628190 3 1733810893952508 254418824 254418824 254418824 63604706 381628...
output:
306870593 268511770 254160656 158850410 203628190 203628190 254418824 63604706 154958070 309916140 232495279 542488984 92296271 323036952 592652064 592648815 77285188 77285188 60692200 84969080 471780248 235890124 125654960 75392976 387683048 436143429 61976960 371861760 345718280 553149247 33682828...
result:
ok 500 lines
Test #55:
score: 0
Accepted
time: 11ms
memory: 3608kb
input:
500 4 1853317 780788032 780788032 683189528 780788032 878386536 487992520 975985040 683189528 4 65896776633459157 59682392 119364784 537141528 358094352 358094352 477459136 119364784 298411960 4 1 3788470 541210 3788470 3788470 1623630 2706050 541210 1082420 4 394209544 506840841 506840841 337893894...
output:
878387330 487994734 119364784 298411960 3788470 541210 450525192 450525192 327986746 72887611 361886573 506641202 105716358 352387860 556586499 556586500 250179237 111190772 261788970 261788970 157775460 126220368 326545924 326545925 705228241 626869547 398127480 298595610 433294449 495193656 477515...
result:
ok 500 lines
Test #56:
score: 0
Accepted
time: 11ms
memory: 3620kb
input:
500 4 11718297823356024 108251086 108251086 433004344 378878801 541255430 541255430 216502172 216502172 4 1635696057174644 70050610 35025305 105075915 105075915 105075915 245177135 70050610 315227745 4 351463384479598 40789806 122369418 27193204 13596602 40789806 13596602 95176214 27193204 4 3916945...
output:
473804342 473804342 105075915 140101220 52265945 20906378 485361012 323574008 15440067 15440067 579310128 868965192 31639272 21092848 224963483 84361306 352926186 529389279 33217739 22145160 99649621 99649621 115406344 403922204 400878548 400878548 258660720 193995540 623166320 701062110 151694279 6...
result:
ok 500 lines
Test #57:
score: 0
Accepted
time: 5ms
memory: 3644kb
input:
200 10 86741714945139306 377753868 503671824 566630802 566630802 503671824 566630802 125917956 503671824 62958978 188876934 251835912 314794890 377753868 62958978 377753868 251835912 566630802 251835912 629589780 440712846 10 93221264438959788 639615648 559663692 479711736 719567604 399759780 799519...
output:
314794890 440712846 390496733 390496733 317379653 238034740 871535124 871535124 469991672 626655563 174712753 145593961 546029780 273014890 315123325 210082217 302714844 378393555 413135076 550846768 64355939 579203451 632345679 813015873 126986930 108845940 476153087 264529493 198457311 198457311 1...
result:
ok 200 lines
Test #58:
score: 0
Accepted
time: 7ms
memory: 3776kb
input:
200 10 27473219203633369 129876992 97407744 162346240 32469248 324692480 32469248 194815488 129876992 259753984 324692480 194815488 292223232 129876992 259753984 97407744 324692480 97407744 194815488 32469248 194815488 10 4560944465918408 121451585 24290317 194322536 48580634 194322536 121451585 170...
output:
98102852 156964563 100999330 57713903 596913444 464266012 51342501 205370004 173142180 76952080 75741092 16831354 55134819 36756546 73855559 590844472 248204424 248204424 403515788 907910524 339031690 610257042 102342234 102342234 380503599 326145942 61484424 163958464 471897162 424707446 523368480 ...
result:
ok 200 lines
Test #59:
score: 0
Accepted
time: 6ms
memory: 3608kb
input:
200 10 4547530164186715 227021308 170265981 283776635 56755327 340531962 113510654 397287289 170265981 510797943 397287289 454042616 454042616 283776635 283776635 227021308 454042616 170265981 510797943 113510654 113510654 10 16090857 317823310 363226640 272419980 408629970 227016650 408629970 45403...
output:
397287289 170265981 272407251 45403364 124453707 248907414 484685620 581622744 587730544 514264226 230818165 115409082 101044022 181879240 151876472 18984559 120915657 80610438 112055330 112055329 193265033 82827871 210765692 316148538 149665726 448997178 527347504 395510628 244365944 183274458 3456...
result:
ok 200 lines
Test #60:
score: 0
Accepted
time: 6ms
memory: 3608kb
input:
200 10 12854793739954670 52531194 183859179 52531194 131327985 78796791 131327985 52531194 26265597 157593582 78796791 183859179 78796791 236390373 78796791 236390373 157593582 78796791 262655970 105062388 183859179 10 958583383487912 21892731 65678193 7297577 29190308 29190308 7297577 36487885 2189...
output:
178504336 178504337 40636916 60955374 693935389 693935389 614995995 409997330 845403447 739728016 89787426 59858284 276075026 441720041 189107512 330938146 536456562 357637708 144667936 144667936 2954543 2585225 255114896 31889362 121213246 484852985 57911180 104240124 59104674 98507790 619548059 20...
result:
ok 200 lines
Test #61:
score: 0
Accepted
time: 5ms
memory: 3532kb
input:
200 10 35774766210713893 957758680 191551736 766206944 383103472 670431076 383103472 574655208 383103472 287327604 861982812 191551736 478879340 191551736 383103472 191551736 287327604 383103472 95775868 861982812 95775868 10 2732409117888208 21709410 86837640 54273525 54273525 43418820 54273525 325...
output:
766206944 191551736 41702364 27801576 52728147 316368882 284690468 284690468 59913324 59913324 96319359 256851624 307993688 123197475 554644590 462203825 203918964 262181525 12946680 7398103 198633680 297950520 114003927 380013090 288334390 259500951 348043635 348043635 493376070 328917380 20361100 ...
result:
ok 200 lines
Test #62:
score: 0
Accepted
time: 5ms
memory: 3612kb
input:
40 50 159837481406820710 637158160 670692800 503019600 670692800 201207840 670692800 536554240 637158160 536554240 603623520 301811760 637158160 67069280 637158160 268277120 603623520 536554240 570088880 335346400 536554240 134138560 603623520 402415680 503019600 268277120 536554240 167673200 570088...
output:
204963375 380646268 111520848 130107656 322583620 161291810 763925397 763925396 85642486 68513989 131548729 10962394 282510449 282510449 398315813 398315813 280916734 60196443 233422518 427941283 603561613 804748817 106363387 67176876 242187134 172990810 253408695 200059496 870644181 512143636 28380...
result:
ok 40 lines
Test #63:
score: 0
Accepted
time: 4ms
memory: 3536kb
input:
40 50 4077180329987028 326734548 373410912 513440004 140029092 326734548 466763640 700145460 46676364 793498188 46676364 700145460 140029092 746821824 140029092 886850916 46676364 886850916 93352728 606792732 560116368 933527280 93352728 793498188 373410912 886850916 233381820 886850916 326734548 74...
output:
858858887 90406199 94275424 76598782 154826601 51608867 192438804 769755216 372827227 512637437 446166545 501937363 138084558 207126837 43688502 33606540 489367344 489367344 88732985 112932890 672038532 42002408 81418286 379952001 183765565 735062260 94339425 50314360 918019173 918019173 15362326 18...
result:
ok 40 lines
Test #64:
score: 0
Accepted
time: 4ms
memory: 3644kb
input:
20 100 281448128760709759 278393370 46398895 417590055 92797790 556786740 185595580 510387845 139196685 603185635 139196685 463988950 92797790 510387845 46398895 603185635 92797790 695983425 139196685 603185635 46398895 788781215 92797790 881579005 92797790 835180110 185595580 835180110 231994475 69...
output:
371191160 603185635 75222900 37611450 502515348 335010232 74213140 89055768 844095870 234471075 77965310 62372248 620302072 165413886 49715199 81352144 169711520 148497580 158807082 272240712 167201346 212801713 133172225 506054455 499386458 470010784 179866740 215840088 1748574 971430 264731774 218...
result:
ok 20 lines
Test #65:
score: 0
Accepted
time: 2ms
memory: 3568kb
input:
20 100 48838581066917632 303928384 284932860 322923908 303928384 303928384 303928384 265937336 265937336 227946288 246941812 246941812 265937336 246941812 284932860 265937336 303928384 284932860 322923908 360914956 360914956 322923908 360914956 303928384 360914956 284932860 360914956 265937336 34191...
output:
239236866 324678604 15121443 24572345 200266192 185961464 1773908 2217385 113811569 154458558 367906092 582517979 453423026 421035667 12268296 8178864 343975185 458633580 135839232 769755648 244622249 815407497 204448205 131430989 592486244 383373452 10612740 12735288 381319730 228791838 31779545 19...
result:
ok 20 lines
Test #66:
score: 0
Accepted
time: 4ms
memory: 3800kb
input:
4 500 62294625915229369 493186531 198746811 478464545 198746811 507908517 235551776 529991496 250273762 507908517 206107804 537352489 242912769 544713482 235551776 559435468 228190783 581518447 235551776 581518447 242912769 552074475 272356741 559435468 287078727 574157454 301800713 529991496 272356...
output:
331244685 220829790 147563024 119894957 367787955 318278038 557645482 246233070
result:
ok 4 lines
Test #67:
score: 0
Accepted
time: 6ms
memory: 3788kb
input:
4 500 370365926700724210 281595720 574924595 375460960 551458285 363727805 551458285 516258820 539725130 516258820 527991975 434126735 539725130 422393580 539725130 527991975 516258820 481059355 516258820 492792510 492792510 492792510 481059355 422393580 516258820 363727805 516258820 316795185 55145...
output:
251565144 591917986 548552220 27427611 14622920 33962911 119285572 313909400
result:
ok 4 lines
Test #68:
score: 0
Accepted
time: 8ms
memory: 3816kb
input:
1 2000 232383214418332 28924020 26098110 29921400 29755170 29672055 28924020 29256480 27344835 28924020 26181225 29007135 26929260 29838285 30253860 30420090 32581080 30170745 31833045 30336975 32414850 29339595 29339595 28757790 27511065 28924020 28259100 29256480 29422710 28508445 26929260 2809287...
output:
31338106 26535643
result:
ok single line: '31338106 26535643'
Test #69:
score: 0
Accepted
time: 4ms
memory: 3604kb
input:
1 2000 192243827418647557 34705075 161276525 28580650 120447025 48995400 155152100 55119825 169442425 22456225 69410150 38788025 126571450 18373275 57161300 30622125 61244250 44912450 81659000 51036875 112281125 53078350 142903250 63285725 136778825 79617525 138820300 77576050 110239650 83700475 138...
output:
631419335 748503715
result:
ok single line: '631419335 748503715'