QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#264596 | #7737. Extending Distance | ucup-team087# | AC ✓ | 19ms | 4328kb | C++20 | 17.6kb | 2023-11-25 14:30:54 | 2023-11-25 14:30:55 |
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>
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 t>
t MIN(const vc<t>&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>
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,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);
}
template<class t,class u>
void fila(vc<t>&vs,const u&a){
fill(all(vs),a);
}
//work without define int ll
//maxflow with small constant
//CF Global11 G
//bfs を途中で打ち切る,dfs が逆順
//ae の 4th argument は逆辺の capacity
//無向辺を貼りたい場合などに,有効・・・
template<class d>
struct maxflow{
struct E{
int to,nx;
d cap;
};
vc<E> es;
vi head,q;
vc<pi> itr,lv;
int curt;
maxflow(int n):head(n,-1),q(n),itr(n),lv(n),curt(0){}
int ae(int s,int t,d c,d c2=0){
int pres=head[s];
int pret=head[t];
head[s]=si(es);
es.pb({t,pres,c});
head[t]=si(es);
es.pb({s,pret,c2});
return head[s];
}
void bfs(int s,int t=-1){
lv[s]=pi(0,curt);
int l=0,r=0;
q[r++]=s;
while(l<r){
int v=q[l++];
for(int id=head[v];id!=-1;id=es[id].nx){
auto e=es[id];
if(e.cap>0&&lv[e.to].b<curt){
lv[e.to]=pi(lv[v].a+1,curt);
q[r++]=e.to;
if(e.to==t)return;
}
}
}
}
d dfs(int v,int t,d f){
if(v==t)return f;
if(itr[v].b<curt)itr[v]=pi(head[v],curt);
d res=0;
while(itr[v].a!=-1){
E& e=es[itr[v].a];
E& rev=es[itr[v].a^1];
if(rev.cap>0&&lv[e.to].a==lv[v].a-1&&lv[e.to].b==curt){
d a=dfs(e.to,t,min(f,rev.cap));
if(a>0){
rev.cap-=a;
e.cap+=a;
res+=a;
f-=a;
if(f<=0)break;
}
}
itr[v].a=e.nx;
}
return res;
}
d calc(int s,int t,d mx=inf){
d f=0;
while(f<mx){
curt++;
bfs(s,t);
if(lv[t].b<curt)
return f;
f+=dfs(t,s,mx-f);
}
return f;
}
};
//以下のパラメータを問題に応じていじって最強の定数倍を手に入れよう!
//- eps を割る scale
//- refine の必要性を確かめる嘘 bellman-ford のループ回数
//- dfs を途中で打ち切る深さ
//VERIFY:
//yosupo mincost b flow
//AGC034D
//work without define int ll
//captype=O(cap*max(n,m))
//costtype=O(cost*n*max(n,m))
//あらゆる関数が破壊的
//よくわからないが cap=inf だとTLEする(overflow?)ことがあるので,10^9 とかでお茶を濁す
template<class captype,class costtype,class anstype>
struct costscaling{
struct E{
int to,rev;
captype cap;
costtype cost;
};
int n;
costtype eps;
vvc<E> g;
vc<pi> idx;
vi itr,q;
vc<bool> inq,vis;
vc<captype> fl,off;
vc<costtype> p;
maxflow<captype> mf;
anstype ans;
costscaling(int nn):n(nn),g(n),itr(n),inq(n),vis(n),fl(n),p(n),mf(n+2),ans(0){}
void ae(int s,int t,captype l,captype r,costtype c){
assert(l<=r);
if(s==t){
idx.eb(-1,-1);
captype f=c>0?l:r;
ans+=anstype(c)*f;
off.pb(f);
}else{
c*=(n+1);
idx.eb(s,si(g[s]));
off.pb(r);
fl[s]-=l;
fl[t]+=l;
g[s].pb({t,si(g[t]),r-l,c});
g[t].pb({s,si(g[s])-1,0,-c});
}
mf.ae(s,t,r-l);
}
void add_excess(int v,captype c){
fl[v]+=c;
}
void add_demand(int v,captype c){
fl[v]-=c;
}
costtype getcost(int v,const E&e){
return e.cost-p[e.to]+p[v];
}
void addq(int v){
if(fl[v]>0&&!inq[v]){
q.pb(v);
inq[v]=true;
}
}
void push(int v,E&e,captype a){
int to=e.to,j=e.rev;
assert(0<=a);
assert(a<=e.cap);
e.cap-=a;
g[to][j].cap+=a;
fl[v]-=a;
fl[to]+=a;
addq(to);
}
void relabel(int v){
p[v]=numeric_limits<costtype>::min()/2;
for(const auto&e:g[v]){
if(e.cap>0){
chmax(p[v],-eps-e.cost+p[e.to]);
}
}
itr[v]=0;
}
bool dfs(int v,int dep,captype come){
if(vis[v])return false;
vis[v]=true;
if(fl[v]<0||dep==4){
vis[v]=false;
return true;
}else{
while(itr[v]<si(g[v])){
auto&e=g[v][itr[v]];
if(e.cap&&getcost(v,e)<0){
auto u=min(e.cap,fl[v]+come);
if(dfs(e.to,dep+1,u)){
push(v,e,u);
vis[v]=false;
return true;
}
}
itr[v]++;
}
relabel(v);
vis[v]=false;
return false;
}
}
bool slv(){
int m=si(idx);
{
if(accumulate(all(fl),captype(0))){
//demand and excess don't match
return false;
}
captype f=0;
rep(i,n)if(fl[i]>0){
f+=fl[i];
mf.ae(n,i,fl[i]);
}else if(fl[i]<0){
mf.ae(i,n+1,-fl[i]);
}
captype did=mf.calc(n,n+1,f);
if(did<f)return false;
rep(k,m)if(idx[k].a!=-1){
auto&e=g[idx[k].a][idx[k].b];
e.cap=mf.es[k*2].cap;
g[e.to][e.rev].cap=mf.es[k*2+1].cap;
}
rep(i,n)fl[i]=0;
}
while(1){
//now eps-optimal
rep(i,n)assert(fl[i]==0);
eps=0;
rep(v,n)for(const auto&e:g[v])if(e.cap>0)chmax(eps,-getcost(v,e));
if(eps<=1)break;
eps=max(eps/8,costtype(1));
bool need=true;
rep(_,5){
bool upd=false;
rep(v,n)for(const auto&e:g[v])if(e.cap>0){
if(chmin(p[e.to],p[v]+e.cost+eps))
upd=true;
}
if(!upd){
need=false;
break;
}
}
if(!need)continue;
rep(v,n)for(auto&e:g[v])if(getcost(v,e)<0)
push(v,e,e.cap);
q.clear();
rep(i,n){
itr[i]=0;
inq[i]=false;
}
int qb=0;
rep(i,n)addq(i);
while(qb<si(q)){
int v=q[qb++];
inq[v]=false;
while(fl[v]>0)dfs(v,0,0);
/*while(fl[v]>0){
if(itr[v]==si(g[v]))
relabel(v);
while(itr[v]<si(g[v])){
auto&e=g[v][itr[v]];
if(e.cap&&getcost(v,e)<0){
push(v,e,min(e.cap,fl[v]));
if(fl[v]==0)break;
}
itr[v]++;
}
}*/
}
}
rep(i,n)assert(fl[i]==0);
rep(v,n)for(const auto&e:g[v])if(e.cap>0)assert(getcost(v,e)>=-1);
rep(v,n)for(auto&e:g[v])e.cost/=(n+1);
return true;
}
pair<anstype,vc<captype>> get_solution(){
rep(i,si(off))if(idx[i].a!=-1){
const auto&e=g[idx[i].a][idx[i].b];
off[i]-=e.cap;
ans+=anstype(e.cost)*off[i];
}
return mp(ans,off);
}
vc<costtype> get_potential(){
rep(i,n)p[i]/=(n+1);
rep(_,n+1){
bool upd=false;
rep(v,n)for(const auto&e:g[v])if(e.cap>0){
if(chmin(p[e.to],p[v]+e.cost))
upd=true;
}
if(!upd)break;
assert(_<n);
}
return p;
}
};
//dist の初期値が long long になってる
template<class E,class D=ll>
pair<vc<D>,vi> dijkstra(const vvc<E>& g,int s){
const int n=g.size();
using P=pair<D,int>;
priority_queue<P,vc<P>,greater<P>> pq;
vc<D> dist(n,infLL);
vi from(n,-1);
const auto ar=[&](int v,D d,int f){
if(chmin(dist[v],d)){
pq.emplace(d,v);
from[v]=f;
}
};
ar(s,0,-1);
while(pq.size()){
auto [d,v]=pq.top();pq.pop();
if(dist[v]!=d)continue;
for(auto e:g[v])
ar(e.to,d+e.cost,v);
}
return mp(dist,from);
}
struct E{
int to,cost;
operator int()const{return to;}
};
bool dbg=false;
void slv(){
int n,m,k;cin>>n>>m>>k;
vvc<int> r(n);
rep(i,n)r[i]=readvi(m-1);
vvc<int> c(n-1);
rep(i,n-1)c[i]=readvi(m);
int V=n*m+2;
int s=V-2,t=V-1;
costscaling<int,int,int> cs(V);
vvc<E> g(V);
auto aeu=[&](int a,int b,int w){
g[a].pb({b,w});
g[b].pb({a,w});
cs.ae(a,b,0,1,w);
cs.ae(b,a,0,1,w);
};
auto ae=[&](int a,int b){
g[a].pb({b,0});
cs.ae(a,b,0,V,0);
};
rep(i,n)rep(j,m-1)aeu(i*m+j,i*m+j+1,r[i][j]);
rep(i,n-1)rep(j,m)aeu(i*m+j,(i+1)*m+j,c[i][j]);
rep(i,n)ae(s,i*m);
rep(i,n)ae(i*m+m-1,t);
int D=dijkstra(g,s).a[t];
cs.ae(t,s,0,V,-(D+k));
bool tmp=cs.slv();
assert(tmp);
auto [ans,flow]=cs.get_solution();
vi p=cs.get_potential();
print(-ans);
rep(i,n)rep(j,m-1){
chmax(r[i][j],abs(p[i*m+j]-p[i*m+j+1]));
}
rep(i,n-1)rep(j,m){
chmax(c[i][j],abs(p[i*m+j]-p[(i+1)*m+j]));
}
rep(i,n)print(r[i]);
rep(i,n-1)print(c[i]);
}
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();
}
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
2 3 4 6 2 1 15 7 1 9 13 3 2 3 6 1 2 5 2 15 3 3 3 3 1 1 2 2 3 3 1 1 1 2 2 2
output:
9 7 1 15 10 1 9 13 3 3 3 6 1 2 5 2 15 3 4 4 1 3 2 3 3 1 1 1 2 2 2
result:
ok Correct. (2 test cases)
Test #2:
score: 0
Accepted
time: 3ms
memory: 3616kb
input:
125 4 4 48 33 9 39 38 74 3 18 44 9 20 91 19 76 95 17 16 61 88 50 49 68 18 33 84 4 4 14 54 69 42 47 90 28 2 73 59 1 20 90 43 22 74 19 27 67 46 43 42 21 78 80 4 4 93 12 67 38 13 85 39 74 68 77 71 80 64 92 97 53 46 66 6 30 20 66 70 71 24 4 4 34 43 86 55 49 34 73 78 77 90 99 49 5 55 4 63 47 80 24 15 3 8...
output:
87 81 9 39 38 74 3 27 74 9 20 91 19 76 95 17 16 61 88 50 49 68 18 33 84 14 54 69 42 47 90 28 2 73 59 15 20 90 43 22 74 19 27 67 46 43 42 21 78 80 166 105 67 38 75 96 39 74 68 77 71 80 64 92 97 53 46 66 6 30 20 66 70 71 24 34 44 86 55 49 63 73 78 77 90 99 49 8 55 5 63 47 80 24 15 3 85 12 6 31 45 55 2...
result:
ok Correct. (125 test cases)
Test #3:
score: 0
Accepted
time: 2ms
memory: 3624kb
input:
80 5 5 97 10 18 14 13 17 15 16 11 15 10 14 15 12 17 12 15 12 11 15 15 19 19 13 19 19 19 17 10 10 19 12 13 18 11 20 12 17 14 13 12 5 5 65 13 15 13 20 18 19 13 20 10 19 18 17 19 19 11 14 12 18 11 10 18 14 18 19 18 20 11 17 11 17 16 13 19 18 13 16 14 17 11 18 5 5 3 15 10 10 18 17 17 17 14 13 15 15 19 1...
output:
473 105 18 14 13 107 15 16 12 110 10 14 16 106 17 12 15 107 13 15 15 19 19 13 19 19 19 17 10 10 19 12 13 18 11 20 12 17 14 13 12 271 67 16 13 20 61 19 16 20 59 21 19 17 70 21 11 14 77 18 11 10 18 14 18 19 18 20 11 17 11 17 16 13 19 18 13 16 14 17 11 18 3 18 10 10 18 17 17 17 14 13 15 15 19 10 18 16 ...
result:
ok Correct. (80 test cases)
Test #4:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
55 6 6 98 943830625 154853276 396311720 585129723 216006508 789713291 522861691 174874210 616414184 931597164 831871942 149821142 520941619 814161584 200419736 646044877 574761262 188910317 673355715 723256093 264106685 163628126 318085983 226850181 101764170 179381345 486537031 346100002 805792579 ...
output:
98 943830625 154853276 396311720 585129723 216006508 789713291 522861691 174874210 616414184 931597164 831871942 149821142 520941619 814161584 200419736 646044877 574761262 188910317 673355715 723256093 264106775 163628134 318085983 226850181 101764170 179381345 486537031 346100002 805792579 5081942...
result:
ok Correct. (55 test cases)
Test #5:
score: 0
Accepted
time: 3ms
memory: 3652kb
input:
55 6 6 96 16739843 17336211 10384494 17185421 10646458 18552039 13790956 13642043 10307995 14193711 19297204 12810329 18681558 18724838 16636750 11505737 19658923 19307194 12241535 15070027 16123862 17524159 19471242 14316479 10954501 10604286 17691735 17352365 14092770 19909253 11761060 19372581 16...
output:
96 16739843 17336211 10384494 17185421 10646458 18552131 13790960 13642043 10307995 14193711 19297204 12810329 18681558 18724838 16636750 11505737 19658923 19307194 12241535 15070027 16123862 17524159 19471242 14316479 10954501 10604286 17691735 17352365 14092770 19909253 11761060 19372581 16863139 ...
result:
ok Correct. (55 test cases)
Test #6:
score: 0
Accepted
time: 3ms
memory: 3728kb
input:
40 7 7 17 27500 8466 7754 5254 45204 36821 35457 23725 45494 26962 24728 31437 46232 38720 23756 17265 21004 25959 29727 6060 23244 45236 39610 23968 17068 14954 9745 28949 20957 30885 8272 49710 28660 17038 12058 48058 10306 5065 45011 25264 25765 17423 21072 22743 17503 11324 10214 6879 22253 1729...
output:
17 27515 8467 7754 5255 45204 36821 35457 23725 45494 26962 24728 31437 46232 38720 23756 17265 21004 25959 29727 6060 23244 45236 39610 23968 17068 14954 9745 28949 20957 30885 8272 49710 28660 17038 12058 48058 10306 5065 45011 25264 25765 17423 21072 22743 17503 11324 10214 6879 22253 17295 49299...
result:
ok Correct. (40 test cases)
Test #7:
score: 0
Accepted
time: 3ms
memory: 3756kb
input:
31 8 8 84 82373 175391 615535 844446 885043 54908 235817 174599 782716 140021 505505 551220 980613 844864 490309 720051 436451 436322 357173 349094 303200 428983 865478 890817 50236 172208 96832 261006 265321 413840 490656 677420 172238 872751 182871 957260 978182 971447 603592 37811 282590 470570 1...
output:
84 82373 175391 615535 844446 885043 54908 235817 174599 782716 140021 505505 551220 980613 844864 490309 720051 436451 436322 357173 349094 303200 428983 865478 890817 50286 172216 96841 261014 265321 413840 490656 677420 172238 872751 182871 957260 978182 971447 603592 37811 282590 470570 134871 3...
result:
ok Correct. (31 test cases)
Test #8:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
24 9 9 80 178 146 100 118 196 180 100 110 153 125 200 139 174 169 163 196 173 167 120 182 172 142 188 132 160 150 148 171 162 125 180 152 159 152 161 177 106 129 152 114 179 132 146 126 107 148 141 151 165 123 151 153 112 151 148 182 105 188 136 199 173 192 117 118 116 190 103 198 125 150 105 118 15...
output:
227 232 148 100 119 196 180 100 110 153 125 200 139 174 169 163 196 173 167 120 182 172 142 188 132 160 150 148 171 162 125 180 152 163 152 161 208 106 129 152 114 183 132 146 177 107 148 141 151 165 123 151 153 112 151 148 182 105 188 136 199 173 192 117 118 189 192 105 200 125 150 106 118 157 130 ...
result:
ok Correct. (24 test cases)
Test #9:
score: 0
Accepted
time: 3ms
memory: 3780kb
input:
20 10 10 91 90000001 90000000 90000001 90000000 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000001 90000000 90000001 90000001 90000001 90000001 90000001 90000001 90000001 90000000 90000000 90000000 90000001 90000000 90000000 90000000 90000001 90000001 90000001 90000000 ...
output:
886 90000057 90000006 90000007 90000006 90000007 90000006 90000000 90000001 90000004 90000057 90000007 90000007 90000007 90000006 90000007 90000001 90000001 90000001 90000057 90000007 90000007 90000006 90000006 90000006 90000001 90000000 90000004 90000056 90000007 90000007 90000007 90000006 90000007...
result:
ok Correct. (20 test cases)
Test #10:
score: 0
Accepted
time: 3ms
memory: 3808kb
input:
10 14 14 68 20 23 20 22 23 26 23 22 28 30 25 20 29 22 30 26 20 22 21 26 23 23 22 22 22 21 24 29 30 30 24 20 25 23 30 27 27 26 24 30 25 25 24 26 26 23 22 22 30 24 20 23 27 24 29 24 22 24 21 20 20 28 24 21 28 20 24 25 29 20 30 30 30 30 24 27 23 28 29 25 25 26 21 27 23 25 25 27 23 27 23 23 22 27 27 29 ...
output:
607 69 26 21 22 24 27 24 22 28 30 26 20 29 45 30 26 61 22 21 29 23 23 23 22 22 21 47 29 31 31 24 21 26 23 31 28 27 26 24 75 26 26 24 26 26 24 22 22 30 24 20 23 62 24 29 24 22 25 21 39 21 28 24 21 28 42 24 29 29 20 31 30 30 30 25 27 23 28 29 25 62 31 21 27 23 25 25 27 23 27 23 51 23 28 27 30 30 26 24...
result:
ok Correct. (10 test cases)
Test #11:
score: 0
Accepted
time: 3ms
memory: 3888kb
input:
10 10 20 79 1001 1003 1000 1003 1001 1003 1002 1003 1001 1003 1003 1000 1001 1001 1001 1002 1002 1003 1002 1001 1003 1001 1001 1001 1000 1003 1002 1000 1002 1001 1001 1003 1000 1001 1003 1001 1001 1000 1001 1003 1000 1002 1003 1003 1003 1001 1002 1002 1000 1002 1003 1001 1003 1000 1002 1000 1002 100...
output:
732 1001 1004 1063 1003 1002 1004 1002 1004 1001 1004 1003 1000 1001 1001 1001 1002 1002 1003 1002 1073 1004 1001 1002 1001 1001 1003 1003 1001 1002 1002 1001 1003 1000 1001 1003 1001 1001 1000 1001 1004 1063 1002 1004 1004 1003 1002 1002 1003 1000 1003 1004 1001 1003 1000 1002 1000 1002 1002 1004 1...
result:
ok Correct. (10 test cases)
Test #12:
score: 0
Accepted
time: 4ms
memory: 3780kb
input:
10 20 10 21 777601561 917773453 313011120 861769383 651010533 771534309 418153755 749795307 939533489 769621271 705696594 863041783 330858635 136276987 569175453 21935211 559486868 264609946 30013079 725693020 492377730 630078388 365743281 693415122 589281054 690370363 47310510 125777481 136448711 5...
output:
21 777601561 917773453 313011120 861769383 651010533 771534309 418153755 749795307 939533489 769621271 705696594 863041783 330858635 136276987 569175453 21935211 559486868 264609946 30013079 725693020 492377730 630078388 365743281 693415122 589281054 690370363 47310510 125777499 136448711 508925654 ...
result:
ok Correct. (10 test cases)
Test #13:
score: 0
Accepted
time: 2ms
memory: 4096kb
input:
24 6 2 37 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 18 13 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
222 38 38 38 38 38 38 1 1 1 1 1 1 1 1 1 1 117 8 2 1 2 1 2 1 1 2 1 2 1 2 1 1 1 1 8 2 1 2 1 2 1 1 2 1 2 1 2 1 1 1 1 8 2 1 2 1 2 1 1 2 1 2 1 2 1 1 1 1 8 2 1 2 1 2 1 1 2 1 2 1 2 1 1 1 1 8 2 1 2 1 2 1 1 2 1 2 1 2 1 1 1 1 8 2 1 2 1 2 1 1 2 1 2 1 2 1 1 1 1 8 2 1 2 1 2 1 1 2 1 2 1 2 1 1 1 1 8 2 1 2 1 2 1 1 ...
result:
ok Correct. (24 test cases)
Test #14:
score: 0
Accepted
time: 3ms
memory: 4152kb
input:
31 9 3 33 1 5 4 5 3 4 4 2 5 3 4 3 2 5 5 5 4 3 5 1 4 2 1 2 1 5 3 5 3 2 2 3 2 3 5 3 4 4 3 1 4 2 2 3 4 3 2 5 2 1 3 5 12 6 72 2 2 1 1 5 1 2 5 1 4 5 5 1 2 3 4 1 4 4 4 1 2 2 2 5 5 5 3 5 3 2 1 1 3 5 4 1 4 2 1 4 2 1 5 3 3 3 2 4 5 5 5 2 3 3 4 3 4 5 1 3 5 5 5 1 1 5 5 3 2 5 3 5 3 1 4 3 3 5 4 5 1 3 5 2 3 3 5 4 ...
output:
284 31 8 31 8 31 8 36 3 34 5 32 7 29 10 25 14 29 10 5 1 4 2 1 2 1 5 3 5 3 2 2 3 2 3 5 3 4 4 3 1 4 2 6 7 2 5 4 1 3 5 803 71 3 2 1 5 68 4 5 1 4 63 7 7 2 3 64 6 4 4 4 67 5 3 2 5 64 5 4 5 4 68 5 1 3 5 67 5 5 2 3 66 7 1 5 3 63 7 2 5 5 62 5 5 5 5 60 6 6 9 1 3 5 5 5 1 1 5 5 3 2 5 3 5 3 1 4 3 3 5 4 5 1 3 5 ...
result:
ok Correct. (31 test cases)
Test #15:
score: 0
Accepted
time: 3ms
memory: 3864kb
input:
27 14 3 50 998244355 998244354 998244353 998244355 998244355 998244354 998244353 998244353 998244353 998244354 998244353 998244354 998244355 998244353 998244354 998244354 998244355 998244354 998244354 998244354 998244355 998244355 998244354 998244355 998244354 998244355 998244354 998244353 998244354...
output:
670 998244359 998244397 998244357 998244399 998244359 998244397 998244357 998244399 998244357 998244399 998244357 998244399 998244359 998244397 998244358 998244398 998244359 998244397 998244358 998244398 998244359 998244397 998244358 998244398 998244358 998244398 998244403 998244353 998244354 998244...
result:
ok Correct. (27 test cases)
Test #16:
score: 0
Accepted
time: 3ms
memory: 3872kb
input:
23 20 8 97 65608 5872 94352 46988 59846 12493 44992 76156 71668 37922 41038 63074 89348 52169 86215 13124 34107 56625 89609 74457 68595 4701 48937 41711 40122 4771 27822 49478 44146 33934 94003 46579 70799 92669 73897 74846 46044 73186 49298 7012 81846 33315 73703 6101 59247 53180 31956 19735 66252 ...
output:
97 65608 5872 94352 46988 59846 12493 44992 76156 71668 37922 41038 63074 89348 52169 86215 13124 34107 56625 89609 74457 68595 4778 48943 41718 40129 4771 27822 49478 44146 33934 94003 46579 70799 92669 73897 74846 46044 73186 49298 7012 81846 33315 73703 6101 59247 53180 31956 19735 66252 16794 81...
result:
ok Correct. (23 test cases)
Test #17:
score: 0
Accepted
time: 14ms
memory: 3884kb
input:
19 8 19 24 902387291 907620818 994686428 993181541 945788800 985461854 930840176 976723143 978273460 908804932 947598154 948392387 906663045 945746194 935677070 906756920 944967394 995192049 971027077 958873510 947130283 938614195 938536007 978161927 948149370 943899083 936971628 979751238 924273778...
output:
24 902387291 907620818 994686428 993181541 945788800 985461854 930840176 976723143 978273460 908804934 947598154 948392387 906663045 945746194 935677070 906756920 944967394 995192049 971027077 958873510 947130283 938614195 938536007 978161927 948149370 943899083 936971628 979751238 924273778 9948463...
result:
ok Correct. (19 test cases)
Test #18:
score: 0
Accepted
time: 3ms
memory: 3852kb
input:
17 8 6 73 454 453 255 154 145 234 372 334 453 446 475 154 423 475 172 348 129 504 471 299 381 454 313 281 135 313 366 411 397 449 137 361 216 132 284 231 127 338 217 508 7722 2335 6535 3174 7625 7253 1724 4688 3487 5118 746 2569 1333 8705 5312 7854 7121 8830 1497 1091 1873 8673 7066 9654 6715 1904 6...
output:
73 454 453 255 154 145 234 372 334 453 446 475 154 423 475 172 348 129 504 471 299 381 454 313 281 135 313 366 411 397 449 208 363 216 132 284 231 127 338 217 508 7722 2335 6535 3174 7625 7253 1724 4688 3487 5118 746 2569 1333 8705 5312 7854 7121 8830 1497 1091 1873 8673 7066 9654 6715 1904 6931 130...
result:
ok Correct. (17 test cases)
Test #19:
score: 0
Accepted
time: 3ms
memory: 3928kb
input:
23 88 2 97 841315194 845068923 970975198 957201780 251777303 404708591 2727155 669564257 336704019 803214539 649487089 931208031 194958628 208113257 766983395 773886317 969081031 767526283 94213588 872004907 742843321 70045653 828417878 78044768 948026239 74041166 698029055 507301238 56824543 257615...
output:
97 841315194 845068923 970975198 957201780 251777303 404708591 2727252 669564257 336704019 803214539 649487089 931208031 194958628 208113257 766983395 773886317 969081031 767526283 94213588 872004907 742843321 70045653 828417878 78044768 948026239 74041166 698029055 507301238 56824543 257615587 9794...
result:
ok Correct. (23 test cases)
Test #20:
score: 0
Accepted
time: 7ms
memory: 4120kb
input:
19 2 75 29 919738918 817415784 547071389 765591923 840765371 272558012 857925393 355491607 630197873 232681522 488447662 651935225 655063717 94077244 436556672 393624718 961794361 486877806 959891293 894435244 411013650 92339205 12625243 190596368 124067993 451522398 927510612 174581723 914056251 79...
output:
29 919738918 817415784 547071389 765591923 840765371 272558012 857925393 355491607 630197873 232681522 488447662 651935225 655063717 94077244 436556672 393624718 961794362 486877806 959891293 894435244 411013650 92339205 12625243 190596368 124067993 451522398 927510612 174581723 914056251 791511418 ...
result:
ok Correct. (19 test cases)
Test #21:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
1 5 6 10 1 1 1 1 100 1 1 2 100 100 100 1 1 1 100 100 100 2 1 1 100 1 1 1 1 1 100 100 100 1 100 100 100 100 2 1 100 100 1 2 100 100 100 100 1 100 100 100 1
output:
10 1 1 1 1 100 2 1 2 100 100 100 1 10 1 100 100 100 2 1 1 100 1 1 1 1 1 100 100 100 1 100 100 100 100 2 1 100 100 1 2 100 100 100 100 1 100 100 100 1
result:
ok Correct. (1 test case)
Test #22:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
2 5 6 100 1 2 1 1 100 1 1 2 100 100 100 1 1 1 100 100 100 2 1 1 100 1 1 1 1 2 100 100 100 1 100 100 100 100 2 1 100 100 1 2 100 100 100 100 1 100 100 100 2 6 5 100 1 100 100 100 100 100 2 1 100 100 2 100 100 2 100 100 1 1 100 100 100 100 100 1 2 1 100 100 100 1 1 1 100 1 1 2 2 2 1 1 100 1 1 1 100 10...
output:
117 2 2 1 8 100 6 1 6 100 100 100 1 86 1 100 100 100 2 6 1 100 1 1 9 2 2 100 100 100 1 100 100 100 100 2 1 100 100 1 3 100 100 100 100 1 100 100 100 2 101 2 100 100 100 100 100 3 3 100 100 2 100 100 2 100 100 4 3 100 100 100 100 100 1 2 1 100 100 100 1 1 1 100 1 1 2 94 2 1 1 100 1 1 1 100 100 100 1 1
result:
ok Correct. (2 test cases)
Test #23:
score: 0
Accepted
time: 4ms
memory: 3940kb
input:
55 6 6 98 396311720 585129723 216006508 789713291 522861691 585129723 216006508 789713291 522861691 174874210 216006508 789713291 522861691 174874210 616414184 789713291 522861691 174874210 616414184 931597164 522861691 174874210 616414184 931597164 831871942 174874210 616414184 931597164 831871942 ...
output:
98 396311720 585129723 216006508 789713291 522861691 585129723 216006508 789713291 522861691 174874210 216006508 789713291 522861691 174874308 616414184 789713291 522861691 174874210 616414184 931597164 522861691 174874210 616414184 931597164 831871942 174874210 616414184 931597164 831871942 1498211...
result:
ok Correct. (55 test cases)
Test #24:
score: 0
Accepted
time: 3ms
memory: 3948kb
input:
55 6 6 96 10384494 17185421 10646458 18552039 13790956 17185421 10646458 18552039 13790956 13642043 10646458 18552039 13790956 13642043 10307995 18552039 13790956 13642043 10307995 14193711 13790956 13642043 10307995 14193711 19297204 13642043 10307995 14193711 19297204 12810329 10384494 17185421 10...
output:
96 10384494 17185421 10646458 18552039 13790956 17185421 10646458 18552039 13790956 13642043 10646550 18552043 13790956 13642043 10307995 18552039 13790956 13642043 10307995 14193711 13790956 13642043 10307995 14193711 19297204 13642043 10307995 14193711 19297204 12810329 10384494 17185421 10646458 ...
result:
ok Correct. (55 test cases)
Test #25:
score: 0
Accepted
time: 4ms
memory: 3736kb
input:
31 8 8 84 615535 844446 885043 54908 235817 174599 782716 844446 885043 54908 235817 174599 782716 140021 885043 54908 235817 174599 782716 140021 505505 54908 235817 174599 782716 140021 505505 551220 235817 174599 782716 140021 505505 551220 980613 174599 782716 140021 505505 551220 980613 844864 ...
output:
84 615535 844446 885043 54932 235817 174599 782716 844446 885043 54914 235817 174599 782716 140021 885043 54914 235817 174599 782716 140021 505505 54938 235817 174599 782716 140021 505505 551220 235817 174599 782716 140021 505505 551220 980613 174599 782716 140021 505505 551220 980613 844864 782716 ...
result:
ok Correct. (31 test cases)
Test #26:
score: 0
Accepted
time: 3ms
memory: 3748kb
input:
24 9 9 80 100 118 196 180 100 110 153 125 118 196 180 100 110 153 125 200 196 180 100 110 153 125 200 139 180 100 110 153 125 200 139 174 100 110 153 125 200 139 174 169 110 153 125 200 139 174 169 163 153 125 200 139 174 169 163 196 125 200 139 174 169 163 196 173 200 139 174 169 163 196 173 167 10...
output:
80 171 120 198 183 102 110 153 125 118 196 180 100 110 153 125 200 196 180 100 110 153 125 200 139 180 100 110 153 125 200 139 174 100 110 153 125 200 139 174 169 110 153 125 200 139 174 169 163 153 125 200 139 174 169 163 196 125 200 139 174 169 163 196 173 200 139 174 169 163 196 173 167 100 118 1...
result:
ok Correct. (24 test cases)
Test #27:
score: 0
Accepted
time: 3ms
memory: 3800kb
input:
20 10 10 91 90000001 90000000 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000000 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000001 90000000 90000000 90000001 90000000 90000001 ...
output:
895 90000059 90000006 90000007 90000006 90000006 90000007 90000000 90000001 90000004 90000058 90000007 90000006 90000006 90000007 90000006 90000001 90000001 90000004 90000059 90000006 90000006 90000007 90000006 90000007 90000001 90000001 90000003 90000058 90000006 90000007 90000006 90000007 90000007...
result:
ok Correct. (20 test cases)
Test #28:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
10 14 14 68 20 22 23 26 23 22 28 30 25 20 29 22 30 22 23 26 23 22 28 30 25 20 29 22 30 26 23 26 23 22 28 30 25 20 29 22 30 26 20 26 23 22 28 30 25 20 29 22 30 26 20 22 23 22 28 30 25 20 29 22 30 26 20 22 21 22 28 30 25 20 29 22 30 26 20 22 21 26 28 30 25 20 29 22 30 26 20 22 21 26 23 30 25 20 29 22 ...
output:
755 64 23 24 27 23 22 29 30 25 20 29 22 30 61 23 27 24 23 28 30 25 20 29 22 30 26 62 26 24 23 29 30 26 20 29 23 30 26 20 65 23 23 29 31 25 21 30 22 30 27 20 22 67 23 29 31 25 21 30 22 30 26 20 22 22 61 29 31 25 21 30 23 30 27 21 22 22 26 67 30 26 21 30 22 31 27 20 23 22 26 23 74 26 21 30 22 31 27 20...
result:
ok Correct. (10 test cases)
Test #29:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
178 3 3 53 5 2 4 5 4 2 2 5 1 3 3 1 2 2 90 2 1 2 4 4 5 77 2 3 5 5 5 5 5 3 1 4 4 5 5 3 3 5 2 3 5 4 2 4 4 5 2 3 5 2 4 5 3 3 3 57 4 3 5 3 1 1 5 4 2 1 5 4 2 4 54 4 3 4 3 3 4 1 3 3 5 5 4 89 1 2 3 2 3 3 1 5 1 1 5 4 4 4 4 2 5 1 3 1 1 1 1 5 5 4 3 4 5 3 4 3 3 71 2 2 2 4 3 5 2 1 1 3 1 3 2 2 28 4 5 5 3 2 4 67 2...
output:
155 49 10 54 5 57 2 2 5 1 3 3 1 179 91 91 2 4 301 77 4 5 5 74 8 6 3 77 5 4 5 78 5 3 5 2 3 5 4 2 4 4 5 2 3 5 2 4 5 3 160 56 3 56 3 58 1 5 4 2 1 5 4 107 57 3 4 54 3 7 1 3 3 5 432 83 8 4 88 4 3 87 6 2 86 5 4 87 4 4 2 5 1 3 1 1 1 1 5 5 4 3 4 5 3 4 207 72 3 71 4 70 5 2 1 1 3 1 3 55 32 32 5 3 132 66 2 5 6...
result:
ok Correct. (178 test cases)
Test #30:
score: 0
Accepted
time: 3ms
memory: 3920kb
input:
25 11 14 66 998244354 998244355 998244354 998244353 998244355 998244354 998244355 998244355 998244353 998244354 998244353 998244353 998244355 998244354 998244353 998244353 998244355 998244355 998244353 998244353 998244354 998244353 998244355 998244353 998244355 998244354 998244353 998244354 99824435...
output:
678 998244406 998244357 998244355 998244355 998244356 998244354 998244356 998244355 998244353 998244354 998244353 998244353 998244356 998244406 998244355 998244354 998244357 998244357 998244354 998244354 998244354 998244354 998244355 998244353 998244355 998244355 998244405 998244356 998244355 998244...
result:
ok Correct. (25 test cases)
Test #31:
score: 0
Accepted
time: 3ms
memory: 3872kb
input:
24 6 9 73 78341 926193143 45972 89662 44179 39258 14522 928569793 79027 37377 30172 71689 54024 923464835 924430887 51505 58776 28871 83814 38691 29833 97617 58712 28722 15902 86266 962252400 27827 905696913 918736501 95599 4669 958072131 65347 27295 68035 95757 92683 65837 2171 3624 17191 63486 455...
output:
73 78341 926193143 45972 89662 44179 39258 14522 928569793 79027 37377 30172 71689 54024 923464835 924430887 51505 58776 28871 83814 38691 29833 97617 58712 28722 15902 86266 962252400 27827 905696913 918736501 95599 4669 958072131 65347 27295 68035 95757 92683 65837 2171 3692 17192 63487 45595 3837...
result:
ok Correct. (24 test cases)
Test #32:
score: 0
Accepted
time: 13ms
memory: 3904kb
input:
25 11 9 68 988729312 978893803 906310688 920140739 959394993 998273729 949853986 924816006 990193010 966906539 937746446 937776039 977125396 935068953 909078120 915698548 43064 967374842 961307275 996408546 925562822 931560002 944384977 981282702 922700388 966488914 982858666 953842932 971076445 992...
output:
68 988729312 978893803 906310688 920140739 959394993 998273729 949853986 924816006 990193010 966906539 937746446 937776039 977125396 935068953 909078120 915698548 43064 967374842 961307275 996408546 925562822 931560002 944384977 981282702 922700388 966488914 982858666 953842932 971076445 992872616 9...
result:
ok Correct. (25 test cases)
Test #33:
score: 0
Accepted
time: 17ms
memory: 4328kb
input:
10 10 50 100 260372550 224370653 929271301 767967410 502284101 349384009 202940941 154783885 145644362 966077435 743845691 149769897 507435023 60468873 659673803 389434862 715266673 14605135 188587870 63000907 442355443 785843949 982378871 22199344 584430140 772755653 965473791 989314835 231680916 9...
output:
100 260372550 224370653 929271301 767967410 502284101 349384009 202940941 154783885 145644362 966077436 743845691 149769897 507435023 60468873 659673803 389434862 715266673 14605137 188587872 63000909 442355443 785843949 982378871 22199346 584430142 772755653 965473791 989314835 231680916 945511294 ...
result:
ok Correct. (10 test cases)
Test #34:
score: 0
Accepted
time: 10ms
memory: 4060kb
input:
10 50 10 100 423572185 145436731 764686000 600633655 441415910 169443508 700789417 229288916 127363250 639533552 227845034 620956056 445675721 622306776 556528832 409465277 277492953 36493847 435349083 314519935 612191794 418296475 601945295 813525152 956721741 827242520 676200660 129973732 11311289...
output:
100 423572185 145436731 764686000 600633655 441415910 169443508 700789417 229288916 127363250 639533552 227845034 620956056 445675721 622306776 556528832 409465277 277492953 36493847 435349083 314519935 612191794 418296475 601945295 813525152 956721741 827242520 676200660 129973732 113112898 8339529...
result:
ok Correct. (10 test cases)
Test #35:
score: 0
Accepted
time: 13ms
memory: 4068kb
input:
10 20 25 100 236319064 155794674 339813709 886024917 794289478 901052716 226506117 8788803 911893440 697579614 51349234 667886501 828088943 787487581 742960185 628606808 506112146 537589422 500076754 950636717 5354362 9412365 605409672 56983400 385937164 675984872 539434747 948264769 790467650 43340...
output:
100 236319064 155794674 339813709 886024917 794289478 901052716 226506117 8788803 911893440 697579614 51349234 667886501 828088943 787487581 742960185 628606808 506112146 537589422 500076755 950636718 5354362 9412365 605409672 56983400 385937164 675984872 539434747 948264769 790467650 433400290 8399...
result:
ok Correct. (10 test cases)
Test #36:
score: 0
Accepted
time: 6ms
memory: 4080kb
input:
10 25 20 100 90000254 90000042 90000073 90000730 90000827 90000755 90000252 90000268 90000739 90000086 90000095 90000941 90000949 90000931 90000696 90000502 90000250 90000492 90000583 90000647 90000476 90000372 90000296 90000374 90000595 90000720 90000922 90000985 90000474 90000983 90000381 90000961...
output:
100 90000254 90000042 90000073 90000730 90000827 90000755 90000252 90000268 90000739 90000086 90000095 90000941 90000949 90000931 90000696 90000502 90000250 90000492 90000583 90000647 90000476 90000372 90000296 90000374 90000595 90000720 90000922 90000985 90000474 90000983 90000381 90000961 90000417...
result:
ok Correct. (10 test cases)
Test #37:
score: 0
Accepted
time: 19ms
memory: 4160kb
input:
10 10 50 100 10000 10000 10000 10000 10003 10001 10005 10001 10003 10000 10005 10000 10002 10001 10005 10001 10000 10000 10003 10005 10001 10005 10004 10000 10003 10000 10005 10001 10002 10000 10002 10005 10002 10000 10005 10003 10002 10003 10001 10001 10003 10002 10004 10003 10000 10004 10003 10000...
output:
833 10000 10000 10000 10000 10099 10001 10005 10001 10003 10000 10005 10000 10002 10001 10005 10001 10000 10000 10003 10005 10001 10005 10004 10000 10003 10000 10005 10001 10002 10000 10002 10005 10002 10000 10005 10003 10002 10003 10001 10001 10003 10002 10004 10003 10000 10004 10003 10000 10004 10...
result:
ok Correct. (10 test cases)
Test #38:
score: 0
Accepted
time: 7ms
memory: 4024kb
input:
12 20 20 100 2 1 2 4 3 4 3 5 4 3 5 5 2 1 1 4 3 1 4 1 4 3 2 2 3 3 4 2 5 4 1 1 1 3 3 2 3 1 2 2 1 4 5 3 1 1 1 1 2 3 3 2 2 3 2 4 2 3 2 2 4 5 3 4 2 1 5 5 3 4 1 5 1 3 4 3 1 2 2 2 4 4 5 2 2 5 5 3 1 1 2 5 3 1 2 2 3 2 4 5 3 4 1 2 1 1 4 2 5 1 1 4 2 3 1 3 4 5 5 2 3 4 4 4 5 2 4 5 3 5 4 2 5 5 5 1 2 5 5 1 3 5 4 5...
output:
1637 55 5 5 6 4 4 3 5 4 3 6 5 16 1 2 4 3 3 4 55 4 9 3 4 4 4 4 2 6 4 7 12 1 5 5 4 3 2 57 2 4 6 5 7 3 5 2 4 5 8 7 3 6 3 3 6 2 56 3 5 4 5 5 4 5 3 5 6 8 7 1 6 4 4 4 3 57 2 5 3 5 4 5 2 2 6 5 9 6 6 2 10 5 2 2 55 3 6 4 6 3 4 4 2 4 5 4 9 7 2 9 4 4 3 54 3 4 6 6 5 3 4 4 4 7 2 5 5 5 7 6 3 5 54 5 2 3 5 5 4 4 5 ...
result:
ok Correct. (12 test cases)
Extra Test:
score: 0
Extra Test Passed