QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#26832 | #2564. Two Trees | Irisu | TL | 348ms | 53628kb | C++14 | 7.2kb | 2022-04-08 17:46:22 | 2022-04-29 04:38:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;++i)
#define per(i,a,b) for(int i=(a),i##end=(b);i>=i##end;--i)
mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template<typename T>void chkmax(T&x,T y){if(x<y)x=y;}
template<typename T>void chkmin(T&x,T y){if(x>y)x=y;}
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define mem(x) memset((x),0,sizeof(x))
typedef double db;
typedef long long ll;
typedef vector<int>vi;
typedef pair<int,int>pii;
typedef unsigned u32;
typedef unsigned uint;
typedef unsigned long long u64;
namespace orzjk{
const int SZ=1e6;
char buf[SZ],*p1=buf,*p2=buf;
char nc(){
return p1==p2&&(p2=(p1=buf)+fread(buf,1,SZ,stdin),p1==p2)?EOF:*p1++;
}
char fub[SZ],*p3=fub,*p4=fub+SZ;
void pc(char c){
p3==p4&&(fwrite(fub,1,SZ,stdout),p3=fub);
*p3++=c;
}
void flush(){
fwrite(fub,1,p3-fub,stdout),p3=fub;
}
}
using orzjk::nc;
using orzjk::pc;
//#define nc getchar
//#define pc putchar
int read(){
int x=0,f=1;char c=nc();
while(c<48)c=='-'&&(f=-1),c=nc();
while(c>47)x=x*10+(c^48),c=nc();
return x*f;
}
void write(int x){
static char st[21];
if(!x)return pc(48),void();
char*p=st;
if(x<0)x=-x,pc('-');
for(;x;x/=10)*p++=x%10|48;
do{
pc(*--p);
}while(p!=st);
}
//const int P=1e9+7;
const int P=998244353;
int qp(int a,int k){
int res=1;for(;k;k>>=1,a=1ll*a*a%P)if(k&1)res=1ll*res*a%P;return res;
}
const int maxn=1e5+10;
int n;uint ans;u64 dt;
namespace T2{
struct edge{
int u,v;
}G[maxn];
vi E[maxn];int deg[maxn];
int lg[maxn];
pii st[17][maxn];
int dep[maxn],dfn[maxn],seq[maxn];
u64 sz[maxn],F1[maxn],F2[maxn],G1[maxn],G2[maxn];
void dfs1(int u,int f){
static int now;
st[0][now]={dfn[f],f},dfn[u]=++now,seq[now]=u;
sz[u]=1,dep[u]=dep[f]+1;
for(int v:E[u])if(v!=f){
dfs1(v,u),sz[u]+=sz[v];
F1[u]+=F1[v]+sz[v];
F2[u]+=F2[v]+2*F1[v]+sz[v];
}
}
void dfs2(int u,int f){
// printf("(%u %u) (%u %u)\n",F1[u],F2[u],G1[u],G2[u]);
dt+=G2[u];
for(int v:E[u])if(v!=f){
G1[v]=G1[u]-sz[v]+(n-sz[v]);
G2[v]=G2[u]-2*F1[v]-sz[v]+2*(G1[u]-F1[v]-sz[v])+n-sz[v];
dfs2(v,u);
}
}
int qlca(int u,int v){
if(u==v)return u;
u=dfn[u],v=dfn[v];
if(u>v)swap(u,v);
int k=lg[v-u];pii*seq=st[k];
return min(seq[u],seq[v-(1<<k)]).second;
}
int qdis(int u,int v){
return dep[u]+dep[v]-2*dep[qlca(u,v)];
}
void init(){
rep(i,1,n-1){
int u=read(),v=read();
G[i]={u,v},deg[u]++,deg[v]++;
}
rep(i,1,n)E[i].reserve(deg[i]);
rep(i,1,n-1){
int u=G[i].u,v=G[i].v;
E[u].pb(v),E[v].pb(u);
}
dfs1(1,0);
G1[1]=F1[1],G2[1]=F2[1];
dfs2(1,0);
// rep(i,1,n)printf("%d%c",dfn[i],"\n "[i<iend]);
// rep(i,1,n)printf("(%d %d)%c",st[0][i].first,st[0][i].second,"\n "[i<n]);
rep(i,2,n)lg[i]=lg[i>>1]+1;
rep(i,1,16)rep(j,1,n-(1<<i))st[i][j]=min(st[i-1][j],st[i-1][j+(1<<(i-1))]);
}
}
namespace virT{
int sumsz;
uint all,coef,D[maxn];
int m;
struct edge{
int u,v;
}H[maxn];
void addline(int u,int v){
H[++m]={u,v};
// printf("(%d %d)\n",u,v);
}
uint sz[maxn],G[maxn];
void calc(const vi&V,uint coef){
if(V.size()<8u){
for(int x:V){
u32 s=0;
for(int y:V)s+=T2::qdis(x,y);
ans+=2*coef*D[x]*s;
}
return;
}
all=m=0;
// puts("GG");
virT::coef=coef;
using T2::dfn;
using T2::qlca;
static int st[maxn];
int top=0;
sumsz=V.size();
for(int u:V){
// printf("[%d]\n",u);
sz[u]=1;
if(!top){
st[++top]=u;continue;
}
int anc=qlca(st[top],u);
if(anc!=st[top]){
while(top>1&&dfn[anc]<dfn[st[top-1]]){
addline(st[top-1],st[top]),top--;
}
if(top>1&&st[top-1]==anc){
addline(anc,st[top--]);
}else{
sz[anc]=0,addline(anc,st[top]),st[top]=anc;
}
}
st[++top]=u;
}
per(i,top-1,1)addline(st[i],st[i+1]);
for(int u:V)all+=T2::dep[u];
all-=sumsz*T2::dep[st[1]];
rep(_,1,m){
const auto e=H[_];
sz[e.u]+=sz[e.v];
}
G[st[1]]=all;
per(_,m,1){
const auto e=H[_];
G[e.v]=G[e.u]+(T2::dep[e.v]-T2::dep[e.u])*(sumsz-2*sz[e.v]);
}
for(int u:V)ans+=2*coef*D[u]*G[u];
// for(int u:V)printf("(%d), %d %d %d\n",u,D[u],G[u],sz[u]);
// puts("gg");
}
}
namespace T1{
using virT::D;
struct edge{
int u,v;
}G[maxn];
vi E[maxn];int deg[maxn];
u64 sz[maxn],F1[maxn],F2[maxn],G1[maxn],G2[maxn];
void dfs1(int u,int f){
sz[u]=1;
for(int v:E[u])if(v!=f){
dfs1(v,u),sz[u]+=sz[v];
F1[u]+=F1[v]+sz[v];
F2[u]+=F2[v]+2*F1[v]+sz[v];
}
}
void dfs2(int u,int f){
dt+=G2[u];
for(int v:E[u])if(v!=f){
G1[v]=G1[u]-sz[v]+(n-sz[v]);
G2[v]=G2[u]-2*F1[v]-sz[v]+2*(G1[u]-F1[v]-sz[v])+n-sz[v];
dfs2(v,u);
}
}
bool vis[maxn];
uint sck,sumsz;
uint tmp[maxn];
vi vec[maxn],son[maxn];
struct cmp{
bool operator()(int x,int y){
return vec[x].size()>vec[y].size();
}
};
void divide(int rt,int f){
// printf("!%d\n",rt);
// sumsz=0,dfs3(rt,0),dfs4(rt,0);
static int Q[maxn],pre[maxn],buk[maxn];
int l=1,r=1;Q[1]=rt,pre[rt]=0;
while(l<=r){
int u=Q[l++];sz[u]=1,buk[u]=0;
for(int v:E[u])if(v!=pre[u]&&!vis[v]){
Q[++r]=v,pre[v]=u;
}
}
sumsz=r;
per(i,r,1){
int u=Q[i];
sz[pre[u]]+=sz[u];
chkmax(buk[pre[u]],(int)sz[u]);
if(max(sumsz-sz[u],(u64)buk[u])*2<=sumsz)sck=rt;
}
rt=sck;
// printf("#%d\n",rt);
vis[rt]=1,D[rt]=tmp[rt]=0;
if(f)son[f].push_back(rt);
for(int ch:E[rt])if(!vis[ch]){
divide(ch,rt);
l=1,r=1,Q[1]=ch,pre[ch]=rt;
while(l<=r){
int u=Q[l++];tmp[u]=tmp[pre[u]]+1,D[u]-=tmp[u];
for(int v:E[u])if(v!=pre[u]&&!vis[v]){
Q[++r]=v,pre[v]=u;
}
}
}
priority_queue<int,vi,cmp>pq;
for(int v:son[rt]){
// printf("[%d : %d]\n",rt,v);
virT::calc(vec[v],1),pq.push(v);
}
vec[rt].push_back(rt);
pq.push(rt);
while(pq.size()>1u){
int x=pq.top();pq.pop();
int y=pq.top();pq.pop();
vi&A=vec[x],&B=vec[y];
int sx=A.size(),sy=B.size();
vi ano(sx+sy);
using T2::dfn;
for(int p=0,p1=0,p2=0;p<sx+sy;p++){
if(p2==sy||(p1<sx&&dfn[A[p1]]<dfn[B[p2]])){
ano[p]=A[p1++];
}else{
ano[p]=B[p2++];
}
}
vi tmp;
if(y!=rt){
A.swap(ano);
B.swap(tmp);
pq.push(x);
}else{
B.swap(ano);
A.swap(tmp);
pq.push(y);
}
}
// printf("@%d : ",rt);for(int x:vec[rt])printf("%d ",x);puts("");
for(int v:vec[rt])D[v]=tmp[v];
if(!f)virT::calc(vec[rt],1);
vis[rt]=0;
}
void init(){
rep(i,1,n-1){
int u=read(),v=read();
G[i]={u,v},deg[u]++,deg[v]++;
}
rep(i,1,n)E[i].reserve(deg[i]);
rep(i,1,n-1){
int u=G[i].u,v=G[i].v;
E[u].pb(v),E[v].pb(u);
}
dfs1(1,0);
G1[1]=F1[1],G2[1]=F2[1];
dfs2(1,0);
}
}
void solve(){
n=read();
T1::init();
T2::init();
ans=dt/2;
T1::divide(1,0);
cout<<ans<<endl;
}
signed main(){
// freopen("data.in","r",stdin);
// freopen(".out","w",stdout);
// int T;cin>>T;while(T--)solve();
solve();
orzjk::flush();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 32480kb
input:
3 1 2 1 3 1 2 1 3
output:
24
result:
ok 1 number(s): "24"
Test #2:
score: 0
Accepted
time: 1ms
memory: 33552kb
input:
3 1 2 1 3 1 2 2 3
output:
22
result:
ok 1 number(s): "22"
Test #3:
score: 0
Accepted
time: 3ms
memory: 37768kb
input:
500 30 198 198 333 198 17 333 430 333 44 17 99 17 19 430 160 430 162 44 154 44 253 99 466 99 397 19 301 19 101 160 416 160 446 162 375 162 174 154 256 154 170 253 67 253 248 466 462 466 216 397 104 397 306 301 460 301 464 101 226 101 50 416 137 416 456 446 443 446 465 375 92 375 266 174 209 174 84 2...
output:
75020868
result:
ok 1 number(s): "75020868"
Test #4:
score: 0
Accepted
time: 2ms
memory: 39032kb
input:
500 154 376 376 491 376 141 491 499 491 150 141 447 141 427 499 24 499 187 150 352 150 476 447 351 447 223 427 75 427 386 24 222 24 487 187 472 187 449 352 285 352 105 476 117 476 426 351 140 351 336 223 121 223 236 75 388 75 272 386 418 386 106 222 292 222 323 487 111 487 155 472 443 472 217 449 31...
output:
1435776283
result:
ok 1 number(s): "1435776283"
Test #5:
score: 0
Accepted
time: 5ms
memory: 39504kb
input:
500 445 27 27 137 27 105 137 129 137 341 105 431 105 86 129 290 129 292 341 70 341 376 431 206 431 63 86 330 86 324 290 291 290 463 292 200 292 199 70 204 70 476 376 474 376 356 206 260 206 279 63 185 63 459 330 67 330 323 324 266 324 430 291 434 291 242 463 276 463 333 200 493 200 372 199 14 199 12...
output:
29218852
result:
ok 1 number(s): "29218852"
Test #6:
score: 0
Accepted
time: 2ms
memory: 39576kb
input:
500 421 464 464 260 464 67 464 246 464 183 464 44 464 68 464 209 464 27 464 234 464 55 464 423 464 173 464 146 464 74 464 310 464 256 464 359 464 115 464 467 464 479 464 497 464 451 464 466 464 361 464 124 464 286 464 116 464 475 464 292 464 186 464 65 464 295 464 107 260 123 464 443 464 101 464 162...
output:
9330687
result:
ok 1 number(s): "9330687"
Test #7:
score: 0
Accepted
time: 2ms
memory: 39808kb
input:
500 500 213 213 492 213 45 213 438 213 225 213 207 213 134 213 328 213 192 213 167 213 419 213 96 213 270 213 262 213 487 213 294 213 169 213 166 213 130 213 61 213 86 213 450 213 165 213 473 213 140 213 137 213 206 213 317 213 341 213 219 213 297 213 437 213 127 213 298 213 25 213 31 213 3 213 174 ...
output:
4381036
result:
ok 1 number(s): "4381036"
Test #8:
score: 0
Accepted
time: 2ms
memory: 39252kb
input:
500 200 23 23 202 23 105 23 344 23 193 23 13 23 206 23 47 23 351 23 164 23 49 23 18 23 207 23 412 23 153 23 50 23 137 23 22 23 313 23 38 23 130 23 401 23 296 23 128 23 94 23 104 23 318 23 222 23 428 23 278 23 477 23 90 23 170 23 380 23 338 202 208 23 75 202 187 23 62 23 165 23 284 202 150 202 282 23...
output:
5567183
result:
ok 1 number(s): "5567183"
Test #9:
score: 0
Accepted
time: 2ms
memory: 39092kb
input:
500 405 193 193 290 193 406 193 401 193 203 193 361 193 202 193 243 193 416 193 34 193 80 193 234 193 53 193 433 193 170 193 275 193 146 193 140 193 356 193 434 193 354 193 292 193 54 193 247 193 420 193 377 193 346 193 102 193 98 193 142 193 12 193 270 193 33 193 107 193 35 193 173 193 386 193 190 ...
output:
4487471
result:
ok 1 number(s): "4487471"
Test #10:
score: 0
Accepted
time: 4ms
memory: 39084kb
input:
500 171 110 110 332 110 60 110 186 110 259 110 2 110 299 110 494 110 466 110 410 110 66 110 78 110 352 110 137 110 188 110 94 110 295 110 323 110 213 110 334 110 469 110 179 110 139 110 318 110 443 110 219 110 342 110 474 110 315 110 75 110 146 110 360 110 426 110 100 110 455 110 33 110 305 110 238 ...
output:
3701740
result:
ok 1 number(s): "3701740"
Test #11:
score: 0
Accepted
time: 4ms
memory: 35992kb
input:
500 277 29 29 442 29 335 29 20 29 358 29 460 29 465 29 471 29 478 29 22 29 126 29 320 29 427 29 166 29 387 29 321 29 14 29 379 29 238 29 173 29 78 29 302 29 333 29 108 29 472 29 481 29 287 29 269 29 202 29 255 29 284 29 304 29 354 29 492 29 310 29 251 29 293 442 123 442 444 442 3 442 394 29 298 29 2...
output:
6044048
result:
ok 1 number(s): "6044048"
Test #12:
score: 0
Accepted
time: 4ms
memory: 36444kb
input:
500 439 65 65 79 65 193 65 228 65 10 65 39 79 432 65 137 79 303 79 136 79 72 79 121 65 368 65 102 65 452 79 35 65 363 79 473 79 214 65 66 65 450 193 60 65 4 65 401 228 158 193 226 193 326 79 321 228 153 79 396 79 14 228 20 193 112 228 55 65 430 228 462 10 426 79 442 65 346 65 165 65 308 65 184 65 7 ...
output:
5949212
result:
ok 1 number(s): "5949212"
Test #13:
score: 0
Accepted
time: 4ms
memory: 38748kb
input:
2000 1487 1400 1400 970 1400 892 970 1775 970 304 892 72 892 32 1775 42 1775 1846 304 73 304 1485 72 648 72 1200 32 1544 32 1978 42 448 42 351 1846 1667 1846 1228 73 125 73 1118 1485 643 1485 1532 648 291 648 749 1200 823 1200 1122 1544 67 1544 1555 1978 281 1978 485 448 1683 448 191 351 331 351 427...
output:
2087128292
result:
ok 1 number(s): "2087128292"
Test #14:
score: 0
Accepted
time: 2ms
memory: 38696kb
input:
2000 963 1511 1511 1963 1511 1474 1963 19 1963 1805 1474 1107 1474 596 19 548 19 359 1805 744 1805 1176 1107 1394 1107 1065 596 1657 596 1207 548 210 548 1232 359 1340 359 1487 744 787 744 507 1176 1086 1176 1308 1394 1076 1394 214 1065 1347 1065 433 1657 913 1657 1993 1207 1403 1207 1824 210 1629 2...
output:
2082289167
result:
ok 1 number(s): "2082289167"
Test #15:
score: 0
Accepted
time: 6ms
memory: 38716kb
input:
2000 774 919 919 94 919 1486 94 839 94 288 1486 1037 1486 1779 839 1307 839 550 288 1902 288 527 1037 1412 1037 367 1779 349 1779 1169 1307 752 1307 548 550 1089 550 1018 1902 616 1902 69 527 897 527 1597 1412 1197 1412 1033 367 1646 367 1727 349 916 349 534 1169 1254 1169 41 752 410 752 853 548 139...
output:
780832696
result:
ok 1 number(s): "780832696"
Test #16:
score: 0
Accepted
time: 3ms
memory: 38672kb
input:
2000 1250 1654 1654 215 1654 494 1654 1229 1654 1822 1654 1256 1654 1681 1654 1745 1654 570 1654 523 1654 1651 1654 673 1654 615 1654 210 1654 922 1654 62 1654 1624 1654 231 1654 26 1654 1330 1654 403 1654 255 1654 1734 1654 1546 1654 1809 1654 213 1654 469 1654 1268 1654 918 1654 589 1654 1457 1654...
output:
86564484
result:
ok 1 number(s): "86564484"
Test #17:
score: 0
Accepted
time: 4ms
memory: 41564kb
input:
2000 1679 862 862 1229 862 1126 862 139 862 858 862 1730 862 854 862 323 862 896 862 1249 862 1048 862 1219 862 934 862 445 862 1732 862 1049 862 1735 862 1020 862 503 862 1207 862 1011 862 1272 862 1496 862 1962 862 691 862 274 862 915 862 1624 862 780 862 350 862 455 862 505 862 1293 862 100 862 6...
output:
61198783
result:
ok 1 number(s): "61198783"
Test #18:
score: 0
Accepted
time: 1ms
memory: 38368kb
input:
2000 1650 387 387 806 387 577 387 1798 387 1887 387 346 387 1655 387 948 387 250 387 311 387 284 387 1930 387 1333 387 1775 387 1361 387 397 387 1923 387 1822 387 1625 387 529 387 1321 387 1241 387 1059 387 13 387 370 387 179 387 1365 387 755 387 1537 387 1105 387 428 387 867 387 1824 387 709 387 19...
output:
78140503
result:
ok 1 number(s): "78140503"
Test #19:
score: 0
Accepted
time: 1ms
memory: 38572kb
input:
2000 32 1266 1266 33 1266 1006 1266 1942 1266 1886 1266 148 1266 1180 1266 485 1266 1009 1266 1237 1266 1529 1266 1085 1266 103 1266 389 1266 1890 1266 173 1266 1479 1266 220 1266 1356 1266 1798 1266 1698 1266 1461 1266 271 1266 830 1266 1490 1266 1183 1266 1799 1266 975 1266 1550 1266 1802 1266 324...
output:
90345056
result:
ok 1 number(s): "90345056"
Test #20:
score: 0
Accepted
time: 8ms
memory: 40012kb
input:
2000 1588 1435 1435 963 1435 1995 1435 871 1435 1379 1435 634 1435 1822 1435 131 1435 1807 1435 704 1435 1629 1435 1096 1435 1667 1435 493 1435 402 1435 1029 1435 860 1435 859 1435 1446 1435 637 1435 339 1435 1895 1435 1329 1435 989 1435 839 1435 759 1435 260 1435 1935 1435 1304 1435 117 1435 435 14...
output:
62856991
result:
ok 1 number(s): "62856991"
Test #21:
score: 0
Accepted
time: 0ms
memory: 39580kb
input:
2000 830 1297 1297 1345 1297 419 1297 774 1297 303 1297 974 1297 1389 1297 991 1297 1979 1297 810 1297 1831 1297 1808 1297 1921 1297 337 1297 1950 1297 1757 1297 1534 1297 1000 1297 1651 1297 1075 1297 687 1297 1998 1297 336 1297 220 1297 102 1297 675 1297 1527 1297 705 1297 1431 1297 735 1297 1066 ...
output:
70817596
result:
ok 1 number(s): "70817596"
Test #22:
score: 0
Accepted
time: 2ms
memory: 41416kb
input:
2000 518 1352 1352 1293 1352 308 1352 433 1352 1135 1352 404 1352 429 1352 375 1352 1654 1352 710 1352 984 1352 1639 1352 1972 1352 107 1352 1494 1352 1615 1352 1796 1352 584 1352 1339 1352 1171 1352 185 1352 1803 1352 526 1352 1918 1352 788 1352 660 1352 23 1352 1622 1352 1619 1352 932 1352 1487 13...
output:
57316912
result:
ok 1 number(s): "57316912"
Test #23:
score: 0
Accepted
time: 15ms
memory: 44516kb
input:
10000 3222 9327 9327 5629 9327 1730 5629 1822 5629 6427 1730 7478 1730 1148 1822 5482 1822 6681 6427 9351 6427 1330 7478 5688 7478 2987 1148 7077 1148 5697 5482 2819 5482 2593 6681 2161 6681 7664 9351 434 9351 6702 1330 7324 1330 2048 5688 9346 5688 5530 2987 3562 2987 9939 7077 2484 7077 6011 5697 ...
output:
127312748
result:
ok 1 number(s): "127312748"
Test #24:
score: 0
Accepted
time: 17ms
memory: 44868kb
input:
10000 8195 6687 6687 4204 6687 5043 4204 1862 4204 2392 5043 6678 5043 3475 1862 2571 1862 1952 2392 7459 2392 5549 6678 2176 6678 6854 3475 7061 3475 690 2571 7983 2571 5976 1952 4006 1952 8776 7459 45 7459 2102 5549 4631 5549 8909 2176 2167 2176 5370 6854 9230 6854 9186 7061 7277 7061 4671 690 107...
output:
4058679703
result:
ok 1 number(s): "4058679703"
Test #25:
score: 0
Accepted
time: 9ms
memory: 44420kb
input:
10000 8026 5261 5261 8509 5261 7945 8509 9512 8509 5899 7945 8425 7945 4437 9512 8552 9512 1136 5899 97 5899 7664 8425 7400 8425 5315 4437 1435 4437 8805 8552 3996 8552 2088 1136 496 1136 5929 97 8523 97 814 7664 571 7664 5359 7400 668 7400 9411 5315 2435 5315 2976 1435 1942 1435 6090 8805 4207 8805...
output:
2541832816
result:
ok 1 number(s): "2541832816"
Test #26:
score: 0
Accepted
time: 12ms
memory: 41476kb
input:
10000 9079 8926 8926 3106 8926 4034 8926 4490 8926 7830 8926 9466 8926 8259 8926 5261 8926 653 8926 2701 8926 7937 8926 1357 8926 517 8926 5169 8926 1511 8926 8923 8926 5462 8926 6831 8926 8123 8926 7847 8926 7247 8926 8510 8926 9502 8926 650 8926 3166 8926 7338 8926 302 8926 4674 8926 7329 8926 717...
output:
2214990244
result:
ok 1 number(s): "2214990244"
Test #27:
score: 0
Accepted
time: 6ms
memory: 41048kb
input:
10000 3229 966 966 3874 966 6097 966 5106 966 4887 966 3210 966 2748 966 1362 966 8874 966 1845 966 1117 966 5485 966 3085 966 3294 966 1666 966 6614 966 3942 966 1925 966 8560 966 7374 966 2344 966 5314 966 1821 966 1466 966 2053 966 798 966 5113 966 1956 966 7243 966 3916 966 9402 966 2152 966 103...
output:
2047792952
result:
ok 1 number(s): "2047792952"
Test #28:
score: 0
Accepted
time: 14ms
memory: 41304kb
input:
10000 5421 3473 3473 541 3473 1328 3473 3661 3473 9100 3473 5784 3473 4582 3473 7830 3473 6170 3473 1560 3473 8507 3473 6024 3473 1384 3473 471 3473 7072 3473 7591 3473 28 3473 7800 3473 714 3473 8466 3473 4835 3473 4889 3473 3694 3473 1844 3473 37 3473 2961 3473 8002 3473 2335 3473 5547 3473 7880 3...
output:
1778402628
result:
ok 1 number(s): "1778402628"
Test #29:
score: 0
Accepted
time: 10ms
memory: 43992kb
input:
10000 8755 2482 2482 2269 2482 9229 2482 1805 2482 7504 2482 7176 2482 9437 2482 61 2482 7772 2482 8867 2482 6731 2482 4509 2482 399 2482 7133 2482 3850 2482 3302 2482 3728 2482 9556 2482 639 2482 2473 2482 5369 2482 4558 2482 2788 2482 3939 2482 2136 2482 3237 2482 7625 2482 8655 2482 7158 2482 266...
output:
1476816444
result:
ok 1 number(s): "1476816444"
Test #30:
score: 0
Accepted
time: 9ms
memory: 41296kb
input:
10000 1433 9864 9864 8607 9864 4380 9864 2668 9864 3445 9864 4453 9864 244 9864 1780 9864 2840 9864 7472 9864 8137 9864 715 9864 5541 9864 1853 9864 5449 9864 2125 9864 7839 9864 9804 9864 958 9864 7430 9864 3286 9864 5079 9864 248 9864 1184 9864 9316 9864 2378 9864 1905 9864 6236 9864 5181 9864 343...
output:
1909921379
result:
ok 1 number(s): "1909921379"
Test #31:
score: 0
Accepted
time: 7ms
memory: 44460kb
input:
10000 5737 7004 7004 3973 7004 5109 7004 8412 7004 1826 7004 7439 7004 1775 7004 2415 7004 233 7004 5694 7004 2963 7004 896 7004 1502 7004 7449 7004 9309 7004 6633 7004 3099 7004 5234 7004 9988 7004 9730 7004 5316 7004 8390 7004 1988 7004 1896 7004 9084 7004 4711 7004 2695 7004 1799 7004 5883 7004 1...
output:
1993864768
result:
ok 1 number(s): "1993864768"
Test #32:
score: 0
Accepted
time: 3ms
memory: 43740kb
input:
10000 8231 6009 6009 2197 6009 963 6009 8284 6009 6529 6009 14 6009 5526 6009 1262 6009 3639 6009 5070 6009 8154 6009 8861 6009 9843 6009 4574 6009 2154 6009 3650 6009 4545 6009 5018 6009 6272 6009 6512 6009 2666 6009 6640 6009 3777 6009 6430 6009 2691 6009 2733 6009 3939 6009 6391 6009 5575 6009 62...
output:
1782412196
result:
ok 1 number(s): "1782412196"
Test #33:
score: 0
Accepted
time: 309ms
memory: 52516kb
input:
100000 19187 74623 74623 42223 74623 56692 42223 46913 42223 15374 56692 90257 56692 43633 46913 73617 46913 93320 15374 71891 15374 54871 90257 45786 90257 660 43633 3 43633 92521 73617 68648 73617 97397 93320 27680 93320 37692 71891 35021 71891 43497 54871 15579 54871 23785 45786 1431 45786 95771 ...
output:
3291351660
result:
ok 1 number(s): "3291351660"
Test #34:
score: 0
Accepted
time: 322ms
memory: 52628kb
input:
100000 87552 91365 91365 29249 91365 58276 29249 88458 29249 51472 58276 19502 58276 91551 88458 35134 88458 99730 51472 2125 51472 7556 19502 15297 19502 26001 91551 53466 91551 27895 35134 83444 35134 66839 99730 92196 99730 36753 2125 55499 2125 88750 7556 47079 7556 75398 15297 99431 15297 83164...
output:
3291351660
result:
ok 1 number(s): "3291351660"
Test #35:
score: 0
Accepted
time: 348ms
memory: 52524kb
input:
100000 52894 34911 34911 34999 34911 33644 34999 71571 34999 11345 33644 51203 33644 54293 71571 28920 71571 46391 11345 20123 11345 55592 51203 95845 51203 91542 54293 10733 54293 17384 28920 39191 28920 84727 46391 32690 46391 68225 20123 21113 20123 82453 55592 3534 55592 40436 95845 90374 95845 ...
output:
3291351660
result:
ok 1 number(s): "3291351660"
Test #36:
score: 0
Accepted
time: 128ms
memory: 52684kb
input:
100000 11671 98756 98756 98218 98756 89214 98756 55036 98756 16416 98756 9609 98756 59309 98756 81146 98756 2044 98756 95394 98756 62903 98756 57847 98756 14089 98756 95088 98756 33989 98756 51155 98756 70300 98756 39271 98756 46957 98756 41599 98756 98472 98756 86758 98756 3779 98756 53454 98756 88...
output:
3777870412
result:
ok 1 number(s): "3777870412"
Test #37:
score: 0
Accepted
time: 124ms
memory: 52836kb
input:
100000 88653 49885 49885 19668 49885 55216 49885 98048 49885 31321 49885 37266 49885 84099 49885 3316 49885 95236 49885 82487 49885 87086 49885 90581 49885 24272 49885 43792 49885 614 49885 37674 49885 37268 49885 46305 49885 50966 49885 22502 49885 33226 49885 65755 49885 43088 49885 73216 49885 45...
output:
3185599712
result:
ok 1 number(s): "3185599712"
Test #38:
score: 0
Accepted
time: 126ms
memory: 52472kb
input:
100000 41085 381 381 30092 381 81120 381 59809 381 2017 381 49028 381 64051 381 4263 381 78527 381 68530 381 40492 381 15218 381 45169 381 85249 381 99064 381 64273 381 43528 381 47605 381 59210 381 37477 381 7750 381 33683 381 73984 381 69646 381 58207 381 32046 381 60721 381 37705 381 70529 381 17...
output:
605374476
result:
ok 1 number(s): "605374476"
Test #39:
score: 0
Accepted
time: 108ms
memory: 53628kb
input:
100000 38818 86778 86778 93635 86778 41322 86778 94078 86778 21657 86778 19439 86778 21734 86778 86788 86778 7467 86778 42917 86778 86119 86778 49385 86778 56925 86778 72600 86778 65222 86778 93201 86778 16222 86778 7112 86778 66418 86778 85027 86778 1190 86778 71016 86778 418 86778 21582 86778 7828...
output:
4024919312
result:
ok 1 number(s): "4024919312"
Test #40:
score: 0
Accepted
time: 117ms
memory: 52344kb
input:
100000 75639 40689 40689 18667 40689 33856 40689 19365 40689 40599 40689 21566 40689 54099 40689 23484 40689 82297 40689 42516 40689 84398 40689 90288 40689 55321 40689 57082 40689 7969 40689 15387 40689 19461 40689 49804 40689 67071 40689 26474 40689 21696 40689 69200 40689 56357 40689 25164 40689 ...
output:
3589521980
result:
ok 1 number(s): "3589521980"
Test #41:
score: 0
Accepted
time: 102ms
memory: 52524kb
input:
100000 42422 82145 82145 82237 82145 52771 82145 14034 82145 75408 82145 30106 82145 69880 82145 71872 82145 18481 82145 20443 82145 24718 82145 20116 82145 47330 82145 76135 82145 16413 82145 20281 82145 55200 82145 39682 82145 45005 82145 30995 82145 53959 82145 81186 82145 7560 82145 81980 82145 ...
output:
1254302300
result:
ok 1 number(s): "1254302300"
Test #42:
score: 0
Accepted
time: 120ms
memory: 52508kb
input:
100000 18622 90686 90686 5261 90686 85426 90686 95799 90686 36131 90686 44437 90686 57379 90686 78395 90686 99573 90686 55752 90686 5825 90686 79694 90686 14074 90686 87942 90686 46615 90686 20125 90686 41443 90686 58475 90686 5524 90686 98061 90686 93016 90686 74686 90686 63439 90686 82398 90686 81...
output:
3975712240
result:
ok 1 number(s): "3975712240"
Test #43:
score: -100
Time Limit Exceeded
input:
100000 38321 22753 22753 72588 72588 61185 61185 15684 15684 37991 37991 17060 17060 54894 54894 13242 13242 95416 95416 55884 55884 53594 53594 32333 32333 16032 16032 99011 99011 44729 44729 20016 20016 81825 81825 32940 32940 26023 26023 57351 57351 65403 65403 27309 27309 82962 82962 70229 70229...