QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#839152 | #8703. 天气预测 | Meatherm | 100 ✓ | 668ms | 141376kb | C++14 | 7.3kb | 2025-01-01 12:42:33 | 2025-01-01 12:42:33 |
Judging History
answer
# include <bits/stdc++.h>
const int N=300010,INF=0x3f3f3f3f,mod=998244353;
namespace PolyNomial{
# define ull unsigned long long
# define ll long long
# define mo MOD
# define poly std::vector <int>
const int FFTN=1<<18,MOD=998244353;
int w[FFTN+10],W[FFTN+10],rev[FFTN+10];
int pinv[30];
inline void qadd(int &x,int v){
x+=v,((x>=mo)&&(x-=mo));
return;
}
inline int qpow(int d,int p){
int ans=1;
for(;p;p>>=1,d=1ll*d*d%mo) (p&1)&&(ans=1ll*ans*d%mo);
return ans;
}
inline void initW(void){
W[0]=1,W[1]=qpow(3,(mo-1)/FFTN);
for(int i=2;i<=FFTN;++i) W[i]=1ll*W[i-1]*W[1]%mo;
pinv[0]=1; for(int i=1;i<=25;++i) pinv[i]=qpow((1<<i),mod-2);
return;
}
inline int initRev(int len){
int n=1;
while(n<=len) n<<=1;
for(int i=0;i<n;++i) rev[i]=(rev[i>>1]>>1)|((i&1)?(n>>1):0);
return n;
}
int A[FFTN+10],B[FFTN+10],C[FFTN+10];
ull va[FFTN+10];
inline void NTT(int *F,int len){
for(int i=0;i<len;++i) va[rev[i]]=F[i];
for(int l=1;l<len;l<<=1){ // 2 * l -> 1 * 2l
int siz=FFTN/(l<<1);
for(int i=0,j=0;i<l;++i,j+=siz) w[i]=W[j]; // omega_{n}^{i} = W_j
for(int s=0;s<len;s+=(l<<1))
for(int j=0;j<l;++j){
int v=va[s+j+l]*w[j]%mo;
va[s+j+l]=va[s+j]+mo-v,va[s+j]+=v;
}
if(l==(1<<15)) for(int i=0;i<len;++i) va[i]%=mo;
}
for(int i=0;i<len;++i) F[i]=va[i]%mo;
return;
}
inline void INTT(int *F,int len){
for(int i=0;i<len;++i) va[rev[i]]=F[i];
for(int l=1;l<len;l<<=1){ // 2 * l -> 1 * 2l
int siz=FFTN/(l<<1);
for(int i=0,j=FFTN;i<l;++i,j-=siz) w[i]=W[j]; // omega_{n}^{i} = W_j
for(int s=0;s<len;s+=(l<<1))
for(int j=0;j<l;++j){
int v=va[s+j+l]*w[j]%mo;
va[s+j+l]=va[s+j]+mo-v,va[s+j]+=v;
}
if(l==(1<<15)) for(int i=0;i<len;++i) va[i]%=mo;
}
int invn=pinv[std::__lg(len)];
for(int i=0;i<len;++i) F[i]=va[i]*invn%mo;
return;
}
inline poly Mul(const poly &a,int k){
int dea=a.size();
poly ans(dea+1);
for(int i=0;i<=dea;++i) ans[i]=1ll*a[i]*k%mo;
return ans;
}
inline poly Mul(const poly &a,const poly &b){
int dea=a.size()-1,deb=b.size()-1;
assert(dea>=0&&deb>=0);
poly ans(dea+deb+1);
int blen=initRev(dea+deb);
for(int i=0;i<blen;++i) A[i]=((i<=dea)?a[i]:0),B[i]=((i<=deb)?b[i]:0);
NTT(A,blen),NTT(B,blen);
for(int i=0;i<blen;++i) A[i]=1ll*A[i]*B[i]%mo;
INTT(A,blen);
for(int i=0;i<=dea+deb;++i) ans[i]=A[i];
return ans;
}
# undef ull
# undef ll
# undef mo
}
inline int read(void){
int res,f=1;
char c;
while((c=getchar())<'0'||c>'9')
if(c=='-')f=-1;
res=c-48;
while((c=getchar())>='0'&&c<='9')
res=res*10+c-48;
return res*f;
}
std::vector <int> G[N];
int w[N];
int n,q;
int idx[N];
int f[N];
int L[N];
inline int lc(int x){return x<<1;}
inline int rc(int x){return x<<1|1;}
inline int adc(int a,int b){return (a+b>=mod)?(a+b-mod):(a+b);}
inline int dec(int a,int b){return (a<b)?(a-b+mod):(a-b);}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline void add(int &a,int b){a=adc(a,b);}
inline void del(int &a,int b){a=dec(a,b);}
namespace SEG{
int n;
poly F[N<<2];
int len[N<<2];
std::vector <int> ws[N<<2];
int tic[2*N],tc,qc;
inline void clear(int k,int l,int r){
std::vector <int> ().swap(ws[k]),std::vector <int> ().swap(F[k]),len[k]=0;
if(l==r) return;
int mid=(l+r)>>1;
clear(lc(k),l,mid),clear(rc(k),mid+1,r);
return;
}
inline poly multi(poly &p,int l,int r){
if(l==r) return (poly){dec(1,p[l]),p[l]};
int mid=(l+r)>>1;
return PolyNomial::Mul(multi(p,l,mid),multi(p,mid+1,r));
}
inline void modify(int k,int l,int r,int L,int R,int w){
if(L<=l&&r<=R) return ws[k].push_back(w),void();
int mid=(l+r)>>1;
if(L<=mid) modify(lc(k),l,mid,L,R,w);
if(mid<R) modify(rc(k),mid+1,r,L,R,w);
return;
}
inline void calc(int k,int l,int r){
if(ws[k].size()) F[k]=multi(ws[k],0,ws[k].size()-1);
if(l==r) return len[k]=1,void();
int mid=(l+r)>>1;
calc(lc(k),l,mid),calc(rc(k),mid+1,r),len[k]=len[lc(k)]+ws[lc(k)].size();
return;
}
int ans[N],fm[N];
inline void solve(int k,int l,int r,int d,poly A,int cur){ // F'[x] = F[x+d]
poly B=(F[k].size())?PolyNomial::Mul(A,F[k]):A,C=poly(len[k]);
for(int i=0;i<(int)B.size();++i){
if(i+d<=n/2-len[k]) add(cur,B[i]);
else if(i+d<=n/2) C[i+d-1-(n/2-len[k])]=B[i];
else break;
}
if(l==r) return ans[l]=cur,fm[l]=C[0],void();
int mid=(l+r)>>1;
solve(lc(k),l,mid,(n/2-len[k])+1,C,cur);
solve(rc(k),mid+1,r,(n/2-len[k])+1,C,cur);
return;
}
int pl[N*2],pr[N*2],pw[N*2];
inline void ins(int l,int r,int w){
++tc,tic[tc]=pl[tc]=l,pr[tc]=r,pw[tc]=w;
return;
}
inline void gclear(void){
clear(1,1,tc),tc=0;
return;
}
inline void gsolve(int _n){
n=_n,qc=tc;
std::sort(tic+1,tic+1+tc),tc=std::unique(tic+1,tic+tc+1)-(tic+1),tic[++tc]=q+1;
for(int i=1;i<=qc;++i){
int l=std::lower_bound(tic+1,tic+1+tc,pl[i])-tic;
int r=std::lower_bound(tic+1,tic+1+tc,pr[i])-tic-1;
modify(1,1,tc-1,l,r,pw[i]);
}
calc(1,1,tc-1);
solve(1,1,tc-1,0,{1},0);
return;
}
}
int dep[N],siz[N],son[N];
int pos[N];
void predfs(int x){
dep[x]=dep[f[x]]+1,siz[x]=1;
for(auto y:G[x]){
predfs(y),siz[x]+=siz[y]; if(siz[son[x]]<siz[y]) son[x]=y;
}
return;
}
namespace SGT{
struct Node{
int k,b; // x -> k*x + b
Node(int _k=1,int _b=0): k(_k),b(_b){}
inline Node operator + (const Node &rhs) const{ // k1(k2x+b2) + b1
return Node(mul(k,rhs.k),adc(mul(k,rhs.b),b));
}
}tr[N<<2];
void build(int k,int l,int r){
tr[k]=Node();
if(l==r) return;
int mid=(l+r)>>1;
return build(lc(k),l,mid),build(rc(k),mid+1,r);
}
void modify(int k,int l,int r,int x,Node w){
if(l==r) return tr[k]=w,void();
int mid=(l+r)>>1;
if(x<=mid) modify(lc(k),l,mid,x,w); else modify(rc(k),mid+1,r,x,w);
tr[k]=tr[lc(k)]+tr[rc(k)];
return;
}
}
std::vector <std::array <int,2> > S[N],T[N]; // (a,b) in S[x]: tick a, val to b
void ddp(int x){
std::vector <std::array <int,4> > W;
std::vector <int> po(1);
int len=0,u=x;
while(u) pos[u]=++len,po.push_back(u),u=son[u];
if(len==1) return T[x].swap(S[x]),void();
for(int i=0,u=po[len];i<(int)T[u].size();++i) // bottom
W.push_back({T[u][i][0],len,dec(1,T[u][i][1]),0});
for(int idx=len-1;idx;--idx){
u=po[idx];
for(auto v:G[u]) if(son[u]!=v) ddp(v);
for(auto v:G[u]) if(son[u]!=v){
for(int i=0;i<(int)S[v].size();++i){
SEG::ins(S[v][i][0],(i==(int)S[v].size()-1)?q+1:S[v][i+1][0],S[v][i][1]);
}
}
for(int i=0;i<(int)T[u].size();++i){
SEG::ins(T[u][i][0],(i==(int)T[u].size()-1)?q+1:T[u][i+1][0],T[u][i][1]);
}
SEG::gsolve(G[u].size()+1);
for(int i=1;i<SEG::tc;++i){
W.push_back({SEG::tic[i],idx,SEG::ans[i],SEG::fm[i]});
}
SEG::gclear();
}
std::sort(W.begin(),W.end());
int wlen=(int)W.size();
SGT::build(1,1,len);
for(int l=0,r;l<wlen;l=r+1){
r=l; while(r<wlen&&W[r][0]==W[l][0]) ++r; --r;
for(int i=l;i<=r;++i) SGT::modify(1,1,len,W[i][1],SGT::Node(W[i][3],W[i][2]));
S[x].push_back({W[r][0],dec(1,SGT::tr[1].b)});
}
return;
}
int main(void){
PolyNomial::initW();
n=read(),q=read();
for(int i=2;i<=n;++i) f[i]=read(),G[f[i]].push_back(i);
for(int i=1;i<=n;++i) w[i]=read(),T[i].push_back({0,w[i]});
for(int i=1;i<=q;++i){
int x=read(),y=read(); T[x].push_back({i,y});
}
predfs(1);
ddp(1);
for(auto v:S[1]) printf("%d\n",v[1]);
return 0;
}
详细
Subtask #1:
score: 12
Accepted
Test #1:
score: 12
Accepted
time: 11ms
memory: 117872kb
input:
99 100 1 1 3 3 5 5 7 7 7 7 10 10 5 5 3 3 7 7 9 9 2 2 5 5 12 12 11 11 25 25 8 8 1 1 19 19 9 9 7 7 29 29 34 34 31 31 44 44 28 28 9 9 14 14 12 12 25 25 37 37 52 52 47 47 59 59 35 35 10 10 31 31 7 7 50 50 5 5 37 37 64 64 63 63 59 59 44 44 22 22 75 75 90 90 21 21 97 97 1 998244353 0 173041973 261455511 0...
output:
369498410 340301428 340301428 340301428 818250570 818250570 582814186 495589000 495589000 495589000 832775204 544932267 544932267 973379985 603834630 639346291 639346291 639346291 740840982 740840982 11776873 299072990 299072990 643290485 643290485 780724694 274914018 274914018 439117962 439117962 4...
result:
ok 101 numbers
Test #2:
score: 12
Accepted
time: 7ms
memory: 117228kb
input:
99 100 19 70 81 78 37 87 32 41 81 1 51 70 69 78 15 77 1 7 32 32 18 63 92 35 25 1 10 26 69 18 81 1 60 1 70 11 10 26 10 78 26 78 71 22 38 81 31 80 82 11 68 35 68 22 23 77 18 31 81 71 69 81 70 26 78 32 51 63 87 10 51 69 68 23 70 81 35 7 60 25 92 18 41 37 51 26 35 1 26 80 81 19 68 82 70 78 15 38 8469458...
output:
428244814 510533160 129507715 885061583 572657935 985072366 379262767 138504830 649419017 418455745 388969503 332508037 987908164 925068560 211309565 860587112 147832578 732985825 783166357 372053450 935348035 230461153 535115759 213482690 794049971 240025880 823373503 236792425 899371097 295636143 ...
result:
ok 101 numbers
Test #3:
score: 12
Accepted
time: 12ms
memory: 117928kb
input:
99 100 23 46 8 41 40 43 43 52 13 41 17 50 74 1 15 61 52 1 76 73 74 15 7 53 91 15 73 62 22 76 91 15 41 11 43 46 41 67 48 1 7 15 52 46 61 14 15 92 73 98 43 49 43 46 41 73 43 62 52 67 11 40 50 55 48 22 48 12 23 49 22 91 41 76 23 8 55 23 15 53 98 43 17 92 48 12 76 15 89 1 22 89 14 13 14 14 91 43 8041012...
output:
361142660 365230506 904328048 336812265 770511159 784105929 2408672 166085969 784765927 136619370 767345952 705341930 2727349 592969737 145624071 655786225 290556554 381646839 814157883 370725508 750013496 902486256 265686605 872136534 890293862 374019071 516266124 445150632 694263226 728053514 5912...
result:
ok 101 numbers
Subtask #2:
score: 20
Accepted
Test #4:
score: 20
Accepted
time: 294ms
memory: 128896kb
input:
199999 50000 1 1 3 3 1 1 7 7 9 9 2 2 3 3 5 5 15 15 11 11 8 8 23 23 15 15 23 23 2 2 16 16 12 12 23 23 6 6 25 25 24 24 23 23 15 15 14 14 28 28 23 23 1 1 24 24 6 6 31 31 21 21 47 47 4 4 15 15 43 43 45 45 46 46 35 35 14 14 26 26 8 8 34 34 26 26 35 35 69 69 78 78 20 20 57 57 79 79 36 36 18 18 21 21 18 18...
output:
958227875 932169996 598799612 53627328 255190446 505984500 726445986 944211695 364601773 867632799 198331171 995503042 526487290 307800857 390094823 95968601 671395433 349799633 205968415 63541551 531733029 713234055 956810723 466175633 508840687 314880002 271439009 372143095 519045723 912560909 452...
result:
ok 50001 numbers
Test #5:
score: 20
Accepted
time: 303ms
memory: 130616kb
input:
199999 50000 1 1 3 3 3 3 1 1 1 1 9 9 1 1 3 3 17 17 16 16 15 15 18 18 5 5 19 19 24 24 14 14 19 19 5 5 37 37 33 33 18 18 35 35 24 24 38 38 5 5 7 7 2 2 6 6 7 7 56 56 13 13 3 3 34 34 24 24 3 3 62 62 53 53 10 10 41 41 45 45 75 75 79 79 21 21 85 85 27 27 31 31 16 16 42 42 72 72 16 16 84 84 26 26 105 105 9...
output:
497862503 124294660 397176378 994338425 592189640 582694334 330999356 142630828 51902965 568014727 609802320 567361977 997960225 359297070 580215422 300680570 710907948 416602899 445560241 751616830 105103171 625792481 476333230 733633325 503143337 310644436 732964975 255388231 672739100 14400954 69...
result:
ok 50001 numbers
Test #6:
score: 20
Accepted
time: 310ms
memory: 129620kb
input:
199999 50000 1 1 3 3 3 3 3 3 2 2 8 8 7 7 15 15 1 1 15 15 2 2 10 10 7 7 11 11 20 20 12 12 1 1 25 25 24 24 23 23 17 17 21 21 34 34 20 20 41 41 41 41 45 45 38 38 57 57 2 2 1 1 23 23 60 60 66 66 47 47 57 57 29 29 31 31 63 63 1 1 2 2 36 36 17 17 47 47 85 85 57 57 11 11 27 27 48 48 95 95 38 38 88 88 66 66...
output:
59341305 234159629 609344079 568914547 586098704 745910681 356996082 811890356 857293891 603284868 906665674 312284189 284249729 384492786 239069280 43635565 865803894 485905490 812189212 567364781 786615423 7210307 402636568 328079051 490971982 516649997 931760949 552962500 697476989 358140695 3672...
result:
ok 50001 numbers
Subtask #3:
score: 20
Accepted
Test #7:
score: 20
Accepted
time: 230ms
memory: 129356kb
input:
199999 50000 61948 108267 62334 187137 73931 128171 146929 515 59063 151584 168181 118250 154156 78613 150376 141031 153356 25507 91665 56550 74381 58980 196150 69373 28220 86497 83997 152674 10799 19541 178502 22696 129859 169734 189423 55294 60383 6307 58732 28821 131519 116542 60216 159381 76503 ...
output:
256430907 58358124 390150162 430393809 838988907 823861965 245891257 314111749 214578827 420801465 889256236 471146384 81007642 657936630 985796974 239152176 697225398 936151354 439761224 563460419 551309103 370934319 695905796 117444954 475683157 832042601 946476212 980777193 783734944 140540383 70...
result:
ok 50001 numbers
Test #8:
score: 20
Accepted
time: 237ms
memory: 129184kb
input:
199999 50000 131563 57736 79468 155533 10876 53666 133631 153321 81124 91860 68627 12079 158469 19047 96739 88887 109962 189448 15608 128108 37806 26874 107534 175334 68721 145773 158935 127058 148071 194863 40902 89738 50553 39157 121661 22623 181574 68280 1329 193189 57869 79914 57945 127010 14889...
output:
28585329 491632865 232264787 685183355 278117064 117140409 97499034 197958991 911355135 385173106 513788474 251450451 250515596 111485225 567967394 414219823 108237780 239083116 255465648 362148423 158171929 776697819 450869003 695779974 874969155 126983388 724061080 116947925 784795834 975023813 41...
result:
ok 50001 numbers
Test #9:
score: 20
Accepted
time: 232ms
memory: 129264kb
input:
199999 50000 45200 13523 181985 183538 166452 85999 134527 47475 72871 195278 135883 127003 22380 166550 180505 117448 170810 141024 20471 49999 189601 54910 14389 126992 32713 18863 164232 95054 127642 150914 172250 186575 66898 9069 46448 135213 55536 64972 7021 81770 50499 152131 187662 98604 193...
output:
157748594 554562246 511082125 202253489 53970961 903222635 551350083 867843376 745538107 447204866 375055707 919404699 804918658 870601426 581052417 684251141 857448342 135810932 945639061 864307830 650604589 389248187 299223902 927769525 634189364 619686266 646647154 933251868 253902183 919980678 8...
result:
ok 50001 numbers
Subtask #4:
score: 23
Accepted
Test #10:
score: 23
Accepted
time: 651ms
memory: 140052kb
input:
199999 50000 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
836793342 398644200 538473237 207527576 23529262 836590067 589366956 422145168 247485022 825943836 727487193 435961156 658460261 245160473 114059086 987276150 713455239 40763976 437064352 858938272 658666248 325867212 225680431 818940949 35398398 305271396 324524364 146184818 924730014 788309254 328...
result:
ok 50001 numbers
Test #11:
score: 23
Accepted
time: 668ms
memory: 141112kb
input:
199999 50000 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
143669108 392135228 272032604 190269198 969520645 29333662 960523309 114783947 919980481 435161951 426397443 684910791 453402615 297888660 672412203 873421593 972654481 167929065 422565595 686003972 980039018 278451003 495743948 516604835 789697622 305509325 601799147 268256955 734798831 176971086 6...
result:
ok 50001 numbers
Test #12:
score: 23
Accepted
time: 641ms
memory: 141376kb
input:
199999 50000 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
277039708 44545963 375743538 43048293 817444850 212957954 990652202 55333625 213272345 128893971 885913700 408046727 235414837 836970003 963273237 627152441 143202927 954718912 56532720 971245119 924560590 92957203 800149262 198239317 68125805 289347776 788224202 866614081 460879594 756761837 225348...
result:
ok 50001 numbers
Subtask #5:
score: 25
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #13:
score: 25
Accepted
time: 11ms
memory: 117492kb
input:
999 1000 1 1 1 1 2 2 4 4 3 3 5 5 2 2 15 15 1 1 17 17 17 17 6 6 12 12 5 5 14 14 26 26 27 27 33 33 9 9 31 31 30 30 32 32 21 21 40 40 38 38 36 36 30 30 31 31 26 26 1 1 53 53 57 57 17 17 30 30 32 32 62 62 35 35 26 26 63 63 53 53 42 42 3 3 53 53 2 2 37 37 70 70 53 53 91 91 64 64 25 25 12 12 53 53 49 49 8...
output:
800998417 934499712 598135816 870153386 870153386 870153386 870153386 870153386 870153386 683102919 683102919 683102919 527618560 527618560 279638132 990357115 23946416 509003805 7935919 7935919 7935919 7935919 666851061 654243945 654243945 654243945 723684318 723684318 723684318 575102137 575102137...
result:
ok 1001 numbers
Test #14:
score: 25
Accepted
time: 453ms
memory: 128176kb
input:
199999 50000 112341 58088 26287 111958 182799 187282 58088 111958 111958 111958 24835 129152 187282 69504 163611 192301 24835 187282 90543 139747 112341 139747 174538 187282 26287 87631 139747 78699 129152 90155 90543 19247 13983 187282 111958 185038 1 79911 185590 78699 187282 58088 185590 152740 6...
output:
150164818 390266611 255705034 968130248 647683692 968602098 441076013 836159224 59525886 249816336 63623372 635660040 818517587 885757949 608597664 733285683 479462637 629263142 756587679 728497194 658225799 388379097 106017385 68609038 41202973 641351160 422531466 415231133 793799817 115845807 3905...
result:
ok 50001 numbers
Test #15:
score: 25
Accepted
time: 400ms
memory: 132692kb
input:
199999 50000 27158 168774 199171 144279 49095 10561 92884 120481 168578 88479 60405 92517 158850 165091 53047 113990 6973 124423 1772 135081 54194 176694 97952 147067 33656 25031 127449 153640 34650 12195 158205 190435 177446 100256 188273 48688 172457 48161 88195 126177 197010 46455 184323 25031 27...
output:
586251257 951789762 385069545 767070914 250456939 178541769 861181190 771175700 930312139 865073045 169313516 75310210 639953115 585636778 136314381 748069760 181907277 424395594 853559209 707129027 417063323 961744202 609112421 561591423 760792989 176730194 258473510 757022484 856762342 731760683 2...
result:
ok 50001 numbers
Test #16:
score: 25
Accepted
time: 648ms
memory: 141196kb
input:
199999 50000 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
594772140 344991760 831850489 795203512 993784467 153623279 612548494 696662341 764319485 37553321 246421336 945492817 433929129 511373035 59447716 183720207 117141876 259878154 789719850 957196189 357026449 412593981 776657074 716565672 35493181 228999567 977029864 172752492 70816607 112324893 2585...
result:
ok 50001 numbers
Test #17:
score: 25
Accepted
time: 237ms
memory: 131216kb
input:
199999 50000 63791 146420 39482 28225 108863 118458 184020 101028 147676 55523 71931 155043 120114 173931 157917 132136 134098 30176 182942 183716 43910 79398 137627 82912 86504 163777 160131 1015 171862 31129 118842 142818 181596 14645 147745 26674 163539 115944 80765 156296 20499 3786 85561 116055...
output:
937999161 781910036 675395115 53609281 692429190 27508676 122283528 713513706 79291555 816893105 145138748 820130001 289999940 266907736 268375087 699056063 344726719 968797400 780052309 365077637 399658069 870545247 681316172 775493608 786787048 428836704 378680497 559318351 306014877 177014251 103...
result:
ok 50001 numbers
Test #18:
score: 25
Accepted
time: 284ms
memory: 126336kb
input:
199999 50000 1 1 3 3 2 2 2 2 3 3 9 9 3 3 10 10 17 17 10 10 11 11 2 2 12 12 25 25 11 11 15 15 33 33 30 30 37 37 23 23 12 12 12 12 17 17 41 41 17 17 31 31 16 16 43 43 49 49 50 50 46 46 50 50 13 13 51 51 68 68 28 28 36 36 62 62 26 26 35 35 23 23 16 16 74 74 1 1 5 5 52 52 83 83 87 87 36 36 36 36 36 36 8...
output:
951814818 259134271 794189609 604754973 457117291 436587386 416391255 950342369 756449745 464785130 774733929 202522080 422076912 921620227 826832402 907958123 831063915 847134054 241501846 489668727 458748303 917602580 286577518 218965332 42715631 764527954 879366367 7592277 418221345 469556845 140...
result:
ok 50001 numbers
Test #19:
score: 25
Accepted
time: 555ms
memory: 134116kb
input:
199999 50000 1715 90155 1715 1715 129152 129152 1 1715 1715 1715 1715 1715 129152 1 90155 1 129152 129152 1715 90155 129152 90155 1715 129152 1 90155 1 1 129152 1 129152 90155 1715 129152 90155 1715 1 1715 90155 1715 129152 90155 1 129152 90155 1715 1715 1 129152 1 90155 1 1715 129152 90155 1715 129...
output:
737817984 508008846 595987552 80373711 224809325 260861874 479895966 99672969 726653424 178610841 339898889 917536705 426405119 502433556 939101968 903920032 680529250 632715304 977094551 477581613 121944082 708467909 936448537 624027674 509037020 868431797 814696317 731736643 456337046 651129100 44...
result:
ok 50001 numbers