QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#88813 | #2564. Two Trees | s8194272 | AC ✓ | 459ms | 52908kb | C++14 | 5.0kb | 2023-03-17 16:08:05 | 2023-03-17 16:08:06 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<random>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>
#define uint unsigned int
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define pb(x) push_back(x)
#define lowbit(x) ((x)&(-(x)))
#define fan(x) ((((x)-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
#define SZ(x) ((int)(x.size()))
#define INF 0x3f3f3f3f
using namespace std;
inline int read()
{
int ans=0,f=1;
char c=getchar();
while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
return ans*f;
}
inline void write(uint x)
{
if(x/10) write(x/10);
putchar((char)(x%10)+'0');
}
template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a<b?a:b;}
template<typename T,typename TT> inline T Max(T a,TT b){return a<b?b:a;}
const int N=2e5+5;
int n,vis[N],dep[N],a[N<<1],b[N],Cnt,St[20][N<<1],dfn[N],cnt;
uint ans;
struct Edge
{
int v,w,ne;
}e[2][N];
int head[2][N],tot[2];
inline void add(int p,int u,int v,int w=0)
{
e[p][++tot[p]]=(Edge){v,w,head[p][u]};
head[p][u]=tot[p];
}
int mn,ps,sz[N],all;
void dfs0(int u,int fa)
{
all++;
for(int i=head[0][u];i;i=e[0][i].ne)
{
int v=e[0][i].v;
if(v==fa||vis[v])
continue;
dfs0(v,u);
}
}
void dfs1(int u,int fa)
{
sz[u]=1;int tmp=0;
for(int i=head[0][u];i;i=e[0][i].ne)
{
int v=e[0][i].v;
if(v==fa||vis[v])
continue;
dfs1(v,u);sz[u]+=sz[v];
tmp=max(tmp,sz[v]);
}
tmp=max(tmp,all-sz[u]);
if(tmp<mn) mn=tmp,ps=u;
}
inline int findrt(int u)
{
all=0;mn=INF;ps=-1;
dfs0(u,0);dfs1(u,0);
return ps;
}
void dfs(int u,int fa)
{
dfn[u]=++cnt;
dep[u]=dep[fa]+1;
a[++Cnt]=u;b[u]=Cnt;
for(int i=head[1][u];i;i=e[1][i].ne)
{
int v=e[1][i].v;
if(v==fa) continue;
dfs(v,u);
a[++Cnt]=u;
}
}
inline int LCA(int x,int y)
{
x=b[x];y=b[y];
if(x>y) swap(x,y);
int k=__lg(y-x+1);
if(dep[St[k][x]]<dep[St[k][y-(1<<k)+1]])
return St[k][x];
return St[k][y-(1<<k)+1];
}
vector<int> hv;
int val[N],st[N],top;
inline void insert(int x)
{
int lst=st[top];top--;
while(top&&LCA(st[top],x)!=st[top])
{
add(1,st[top],lst,dep[lst]-dep[st[top]]);
lst=st[top];top--;
}
int lca=LCA(lst,x);
if(lca!=lst)
{
add(1,lca,lst,dep[lst]-dep[lca]);
hv.push_back(lca);
}
if(st[top]!=lca)
st[++top]=lca;
hv.push_back(x);
st[++top]=x;
}
uint f0[N],f1[N],f2[N],res;
void DP(int u,int fa)
{
if(val[u]!=-1)
{
f0[u]=1,f1[u]=val[u],f2[u]=val[u]*1u*val[u];
res+=val[u]*1u*val[u];
}
else f0[u]=0,f1[u]=0,f2[u]=0;
for(int i=head[1][u];i;i=e[1][i].ne)
{
int v=e[1][i].v;
if(v==fa) continue;
DP(v,u);
uint F0=f0[v],F1=f1[v]+f0[v]*e[1][i].w;
uint F2=f2[v]+2*f1[v]*e[1][i].w+f0[v]*e[1][i].w*e[1][i].w;
res+=f0[u]*F2+2*f1[u]*F1+f2[u]*F0;
f2[u]+=F2;f1[u]+=F1;f0[u]+=F0;
}
}
inline uint query(vector<int> nd)
{
st[++top]=1;hv.push_back(1);res=0;
for(auto i:nd) if(i!=1) insert(i);
for(int i=1;i<top;++i)
add(1,st[i],st[i+1],dep[st[i+1]]-dep[st[i]]);
DP(1,0);
for(auto i:hv)
head[1][i]=0,val[i]=-1;
tot[1]=0;nd.clear();hv.clear();top=0;
return res;
}
void dfs2(int u,int fa,int len)
{
val[u]=len;
for(int i=head[0][u];i;i=e[0][i].ne)
{
int v=e[0][i].v;
if(v==fa||vis[v]) continue;
dfs2(v,u,len+1);
}
}
struct node
{
int u,w;
bool operator < (const node &x)const
{
return dfn[w]>dfn[x.w];
}
};
int lim[N];
vector<int> solve(int u)
{
u=findrt(u);vis[u]=1;
vector<int> now;
vector<vector<int> > merg;
for(int i=head[0][u];i;i=e[0][i].ne)
{
int v=e[0][i].v;
if(vis[v]) continue;
vector<int> tmp=solve(v);
dfs2(v,u,1);ans-=query(tmp);
merg.push_back(tmp);
}
priority_queue<node> qu;
for(int i=0;i<SZ(merg);++i)
lim[i]=0,qu.push((node){i,merg[i][lim[i]++]});
int flg=0;
while(!qu.empty())
{
int U=qu.top().u;
int w=qu.top().w;
if(!flg&&dfn[u]<dfn[w])
now.push_back(u),flg=1;
now.push_back(w);qu.pop();
if(lim[U]<SZ(merg[U]))
qu.push((node){U,merg[U][lim[U]++]});
}
if(!flg) now.push_back(u);
vis[u]=0;
dfs2(u,0,0);
ans+=query(now);
return now;
}
signed main()
{
n=read();
for(int i=1;i<n;++i)
{
int u=read(),v=read();
add(0,u,v);add(0,v,u);
}
for(int i=1;i<n;++i)
{
int u=read(),v=read();
add(1,u,v);add(1,v,u);
}
dfs(1,0);
for(int i=1;i<=Cnt;++i)
St[0][i]=a[i];
for(int j=1;j<20;++j)
for(int i=1;i+(1<<j)-1<=Cnt;++i)
if(dep[St[j-1][i]]<dep[St[j-1][i+(1<<(j-1))]])
St[j][i]=St[j-1][i];
else St[j][i]=St[j-1][i+(1<<(j-1))];
for(int i=1;i<=n;++i)
head[1][i]=0;tot[1]=0;
memset(val,-1,sizeof(val));
solve(1);
write(ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 11580kb
input:
3 1 2 1 3 1 2 1 3
output:
24
result:
ok 1 number(s): "24"
Test #2:
score: 0
Accepted
time: 0ms
memory: 17708kb
input:
3 1 2 1 3 1 2 2 3
output:
22
result:
ok 1 number(s): "22"
Test #3:
score: 0
Accepted
time: 4ms
memory: 28020kb
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: 4ms
memory: 28056kb
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: 0ms
memory: 27912kb
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: 3ms
memory: 21832kb
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: 1ms
memory: 25884kb
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: 3ms
memory: 27928kb
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: 3ms
memory: 25900kb
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: 3ms
memory: 27984kb
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: 2ms
memory: 25884kb
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: 1ms
memory: 25960kb
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: 3ms
memory: 32212kb
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: 1ms
memory: 32248kb
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: 0ms
memory: 30036kb
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: 1ms
memory: 28088kb
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: 1ms
memory: 32320kb
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: 30120kb
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: 4ms
memory: 26032kb
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: 3ms
memory: 32268kb
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: 2ms
memory: 30104kb
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: 30220kb
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: 22ms
memory: 36580kb
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: 13ms
memory: 35328kb
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: 15ms
memory: 32540kb
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: 8ms
memory: 36952kb
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: 5ms
memory: 36824kb
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: 10ms
memory: 35236kb
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: 4ms
memory: 33340kb
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: 3ms
memory: 33124kb
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: 4ms
memory: 35096kb
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: 5ms
memory: 33148kb
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: 235ms
memory: 44304kb
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: 243ms
memory: 48036kb
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: 241ms
memory: 45080kb
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: 78ms
memory: 46968kb
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: 63ms
memory: 51232kb
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: 75ms
memory: 45248kb
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: 81ms
memory: 50348kb
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: 83ms
memory: 46708kb
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: 64ms
memory: 46956kb
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: 77ms
memory: 46448kb
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: 0
Accepted
time: 412ms
memory: 51004kb
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...
output:
3627570396
result:
ok 1 number(s): "3627570396"
Test #44:
score: 0
Accepted
time: 407ms
memory: 49356kb
input:
100000 4343 58674 58674 58632 58632 10965 10965 87530 87530 88672 88672 8622 8622 31116 31116 31986 31986 40342 40342 47913 47913 3981 3981 9749 9749 27195 27195 19851 19851 70481 70481 35616 35616 41405 41405 3356 3356 27393 27393 32075 32075 28580 28580 73018 73018 36605 36605 90829 90829 72044 72...
output:
730927472
result:
ok 1 number(s): "730927472"
Test #45:
score: 0
Accepted
time: 409ms
memory: 52636kb
input:
100000 35112 26231 26231 90266 90266 63611 63611 28844 28844 83983 83983 38547 38547 79616 79616 96199 96199 93465 93465 64559 64559 84214 84214 5302 5302 86491 86491 96278 96278 63022 63022 82190 82190 32600 32600 79601 79601 30267 30267 9889 9889 21277 21277 94805 94805 72148 72148 14449 14449 544...
output:
1259628448
result:
ok 1 number(s): "1259628448"
Test #46:
score: 0
Accepted
time: 405ms
memory: 49872kb
input:
100000 16294 38110 38110 63174 63174 36868 36868 58408 58408 88754 88754 12774 12774 88351 88351 39520 39520 82639 82639 74187 74187 82768 82768 666 666 3385 3385 65093 65093 20971 20971 604 604 10147 10147 86733 86733 32006 32006 69093 69093 73952 73952 83162 83162 60027 60027 25661 25661 44872 448...
output:
1273095076
result:
ok 1 number(s): "1273095076"
Test #47:
score: 0
Accepted
time: 395ms
memory: 51816kb
input:
100000 60214 63940 63940 172 172 51014 51014 80593 80593 78749 78749 30858 30858 54510 54510 5567 5567 37136 37136 81179 81179 48782 48782 10044 10044 93991 93991 53590 53590 74481 74481 61436 61436 53635 53635 90024 90024 47651 47651 72258 72258 16735 16735 79900 79900 8795 8795 47921 47921 51373 5...
output:
4130099000
result:
ok 1 number(s): "4130099000"
Test #48:
score: 0
Accepted
time: 420ms
memory: 50708kb
input:
100000 75730 80175 80175 91271 91271 7284 7284 41176 41176 13398 13398 28227 28227 31156 31156 40562 40562 68929 68929 26206 26206 99771 99771 12055 12055 77186 77186 60414 60414 86108 86108 67878 67878 24037 24037 33910 33910 45741 45741 87071 87071 96944 96944 34886 34886 19730 19730 96906 96906 2...
output:
3056595692
result:
ok 1 number(s): "3056595692"
Test #49:
score: 0
Accepted
time: 410ms
memory: 50600kb
input:
100000 39513 26448 26448 95847 95847 56265 56265 69957 69957 50826 50826 32023 32023 10801 10801 44258 44258 85238 85238 77549 77549 29244 29244 9974 9974 67521 67521 77683 77683 28011 28011 75844 75844 66864 66864 52581 52581 66813 66813 13655 13655 66578 66578 50706 50706 78866 78866 39074 39074 8...
output:
2247024664
result:
ok 1 number(s): "2247024664"
Test #50:
score: 0
Accepted
time: 395ms
memory: 51312kb
input:
100000 55701 49454 49454 27126 27126 26558 26558 84437 84437 99536 99536 20963 20963 93278 93278 60181 60181 48228 48228 79994 79994 519 519 21348 21348 86098 86098 97249 97249 60685 60685 70510 70510 80213 80213 85805 85805 30882 30882 57837 57837 54237 54237 44612 44612 97229 97229 10359 10359 540...
output:
2662982392
result:
ok 1 number(s): "2662982392"
Test #51:
score: 0
Accepted
time: 413ms
memory: 52908kb
input:
100000 57212 4895 4895 32217 32217 49322 49322 33823 33823 56919 56919 51412 51412 89595 89595 89250 89250 49349 49349 43162 43162 99403 99403 29736 29736 9682 9682 86781 86781 86577 86577 65745 65745 85626 85626 90319 90319 25899 25899 93510 93510 30846 30846 58858 58858 92673 92673 32336 32336 138...
output:
2277266868
result:
ok 1 number(s): "2277266868"
Test #52:
score: 0
Accepted
time: 420ms
memory: 52680kb
input:
100000 1775 8213 8213 34408 34408 88734 88734 49434 49434 19027 19027 44091 44091 73403 73403 97298 97298 42697 42697 11553 11553 40000 40000 97001 97001 65276 65276 30357 30357 74306 74306 95060 95060 35390 35390 52009 52009 81102 81102 68489 68489 98392 98392 37602 37602 3498 3498 46309 46309 5802...
output:
1255633168
result:
ok 1 number(s): "1255633168"
Test #53:
score: 0
Accepted
time: 456ms
memory: 45996kb
input:
100000 62053 7621 7621 18792 7621 82000 18792 92373 18792 17577 82000 15127 82000 65838 92373 1531 92373 99271 17577 36738 17577 58904 15127 5308 15127 36971 65838 96190 65838 8173 1531 53584 1531 92361 99271 71273 99271 12059 36738 74599 36738 54527 58904 12386 58904 65659 5308 99737 5308 8425 3697...
output:
1639074660
result:
ok 1 number(s): "1639074660"
Test #54:
score: 0
Accepted
time: 364ms
memory: 50964kb
input:
100000 70055 72233 72233 61566 72233 67466 61566 23084 61566 46399 67466 63258 67466 59258 23084 14881 23084 50035 46399 46510 46399 43512 63258 27103 63258 99916 59258 56097 59258 43484 14881 50154 14881 75095 50035 2042 50035 1657 46510 66821 46510 12193 43512 23804 43512 32380 27103 57120 27103 2...
output:
1278668623
result:
ok 1 number(s): "1278668623"
Test #55:
score: 0
Accepted
time: 306ms
memory: 45244kb
input:
100000 44503 86934 86934 75410 86934 48972 75410 14546 75410 26243 48972 4054 48972 7150 14546 31414 14546 14132 26243 98163 26243 52290 4054 79241 4054 19933 7150 42057 7150 35042 31414 74730 31414 16571 14132 83534 14132 36026 98163 86769 98163 98727 52290 55637 52290 81249 79241 75133 79241 1807 ...
output:
1413380224
result:
ok 1 number(s): "1413380224"
Test #56:
score: 0
Accepted
time: 85ms
memory: 48872kb
input:
100000 29759 60349 60349 29001 60349 8504 60349 54208 60349 79858 60349 78883 60349 43138 60349 28126 60349 18752 60349 4516 60349 51206 60349 33773 60349 89784 60349 21526 60349 47218 60349 7589 60349 38538 60349 96567 60349 1801 60349 45418 60349 48797 60349 88255 60349 86244 60349 70049 60349 864...
output:
3097292640
result:
ok 1 number(s): "3097292640"
Test #57:
score: 0
Accepted
time: 84ms
memory: 50440kb
input:
100000 6685 17839 17839 74530 17839 1175 17839 11113 17839 14244 17839 50400 17839 12904 17839 41014 17839 19595 17839 90818 17839 40373 17839 32820 17839 63056 17839 51705 17839 97341 17839 67669 17839 31131 17839 71079 17839 45705 17839 81291 17839 69888 17839 50950 17839 87858 17839 30531 17839 4...
output:
3057487700
result:
ok 1 number(s): "3057487700"
Test #58:
score: 0
Accepted
time: 94ms
memory: 51380kb
input:
100000 92890 81301 81301 38189 81301 13421 81301 33485 81301 19089 81301 30837 81301 57530 81301 66188 81301 78502 81301 70625 81301 4060 81301 33618 81301 25756 81301 7550 81301 34360 81301 42064 81301 48067 81301 29312 81301 35958 81301 36819 81301 18271 81301 18436 81301 86437 81301 18009 81301 7...
output:
3880729795
result:
ok 1 number(s): "3880729795"
Test #59:
score: 0
Accepted
time: 94ms
memory: 48492kb
input:
100000 37023 65956 65956 78926 65956 14586 65956 21579 65956 83136 65956 56261 65956 32361 65956 92113 65956 5750 65956 39922 65956 22881 65956 64724 65956 16731 65956 956 65956 9253 65956 28932 65956 96024 65956 71884 65956 65967 65956 53985 65956 70927 65956 74777 65956 78856 65956 67674 65956 167...
output:
2211066931
result:
ok 1 number(s): "2211066931"
Test #60:
score: 0
Accepted
time: 94ms
memory: 46972kb
input:
100000 26809 77612 77612 30157 77612 37853 77612 62699 77612 11399 77612 205 77612 83910 77612 90752 77612 84762 77612 48830 77612 24573 77612 36307 77612 97577 77612 81582 77612 3265 77612 73666 77612 38222 77612 56446 77612 53390 77612 92064 77612 69955 77612 87516 77612 48522 77612 54801 77612 40...
output:
3874250240
result:
ok 1 number(s): "3874250240"
Test #61:
score: 0
Accepted
time: 128ms
memory: 47476kb
input:
100000 80913 54307 54307 16838 54307 28229 54307 4384 54307 20479 54307 55622 54307 38026 54307 11725 54307 47244 54307 82576 54307 40276 54307 71044 54307 5463 54307 98598 54307 68679 54307 22689 54307 47009 54307 69475 54307 71735 54307 43141 54307 97399 54307 57017 54307 10600 54307 94652 54307 8...
output:
2380502643
result:
ok 1 number(s): "2380502643"
Test #62:
score: 0
Accepted
time: 85ms
memory: 50648kb
input:
100000 33855 29890 29890 22436 29890 32059 29890 45880 29890 91667 29890 73059 29890 97121 29890 79621 29890 83726 29890 71418 29890 75330 29890 61475 29890 22167 29890 15458 29890 49848 29890 76215 29890 19564 29890 50042 29890 57621 29890 64691 29890 7927 29890 54019 29890 55851 29890 20999 29890 ...
output:
2581345519
result:
ok 1 number(s): "2581345519"
Test #63:
score: 0
Accepted
time: 459ms
memory: 44416kb
input:
100000 75428 92883 92883 24562 92883 11015 24562 40960 24562 93436 11015 80249 11015 40261 40960 27779 40960 2545 93436 58927 93436 47494 80249 88737 80249 93515 40261 23855 40261 18954 27779 16826 27779 53270 2545 52837 2545 56791 58927 22937 58927 24138 47494 16854 47494 55197 88737 45989 88737 64...
output:
1832723944
result:
ok 1 number(s): "1832723944"
Test #64:
score: 0
Accepted
time: 313ms
memory: 49248kb
input:
100000 22015 2316 2316 52040 2316 6656 52040 12304 52040 79130 6656 63176 6656 24183 12304 52543 12304 4832 79130 37353 79130 89082 63176 25034 63176 17601 24183 65258 24183 29745 52543 87156 52543 89796 4832 24868 4832 36768 37353 99224 37353 25014 89082 90491 89082 48986 25034 96814 25034 57190 17...
output:
1709042163
result:
ok 1 number(s): "1709042163"
Test #65:
score: 0
Accepted
time: 313ms
memory: 45056kb
input:
100000 50976 31097 31097 51476 31097 62376 51476 18990 51476 67558 62376 40828 62376 41981 18990 46817 18990 32449 67558 90738 67558 75215 40828 95313 40828 74236 41981 6831 41981 87254 46817 63015 46817 97251 32449 69788 32449 22189 90738 8628 90738 16100 75215 39341 75215 87661 95313 32672 95313 2...
output:
1003067500
result:
ok 1 number(s): "1003067500"
Test #66:
score: 0
Accepted
time: 101ms
memory: 45824kb
input:
100000 80959 47154 47154 38275 47154 83145 47154 36889 47154 31372 47154 31426 47154 35528 47154 57394 47154 58338 47154 95160 47154 40325 47154 53815 47154 61376 47154 54759 47154 77449 47154 60569 47154 71319 47154 52226 47154 4829 47154 7920 47154 52769 47154 45105 47154 49041 47154 87696 47154 8...
output:
521203387
result:
ok 1 number(s): "521203387"
Test #67:
score: 0
Accepted
time: 87ms
memory: 48272kb
input:
100000 21658 45620 45620 31249 45620 91884 45620 51279 45620 58789 45620 98330 45620 61718 45620 80497 45620 196 45620 98595 45620 86519 45620 59910 45620 66708 45620 87367 45620 11253 45620 81953 45620 33559 45620 85369 45620 49255 45620 2213 45620 22462 45620 82775 45620 80572 45620 69397 45620 29...
output:
2689803552
result:
ok 1 number(s): "2689803552"
Test #68:
score: 0
Accepted
time: 81ms
memory: 48644kb
input:
100000 62115 13393 13393 8889 13393 11378 13393 49834 13393 35005 13393 84490 13393 94211 13393 76842 13393 71843 13393 23107 13393 48991 13393 36010 13393 88798 13393 73877 13393 64207 13393 24120 13393 4285 13393 22206 13393 23575 13393 28702 13393 97348 13393 65714 13393 7582 13393 6758 13393 986...
output:
942642123
result:
ok 1 number(s): "942642123"
Test #69:
score: 0
Accepted
time: 91ms
memory: 51072kb
input:
100000 24096 89070 89070 6952 89070 52107 89070 83014 89070 31266 89070 56341 89070 83563 89070 15153 89070 94907 89070 43836 89070 21583 89070 89292 89070 83247 89070 26747 89070 68790 89070 45956 89070 41868 89070 56510 89070 89180 89070 21748 89070 80303 89070 16303 89070 22756 89070 41174 89070 ...
output:
862763444
result:
ok 1 number(s): "862763444"
Test #70:
score: 0
Accepted
time: 76ms
memory: 49172kb
input:
100000 47117 45662 45662 82099 45662 69420 45662 79911 45662 37522 45662 88064 45662 56849 45662 68143 45662 70133 45662 61049 45662 79435 45662 21401 45662 66458 45662 15347 45662 85922 45662 78845 45662 92741 45662 64441 45662 87049 45662 70574 45662 56924 45662 16889 45662 15287 45662 88186 45662...
output:
2812811823
result:
ok 1 number(s): "2812811823"
Test #71:
score: 0
Accepted
time: 86ms
memory: 47160kb
input:
100000 51936 52290 52290 62136 52290 36424 52290 74791 52290 12965 52290 41880 52290 81763 52290 71909 52290 39935 52290 74148 52290 90095 52290 35560 52290 61026 52290 42096 52290 38705 52290 31627 52290 5129 52290 41717 52290 19586 52290 57982 52290 70125 52290 16104 52290 94018 52290 61344 52290 ...
output:
3786485348
result:
ok 1 number(s): "3786485348"
Test #72:
score: 0
Accepted
time: 95ms
memory: 45748kb
input:
100000 81709 746 746 5874 746 14328 746 16426 746 43056 746 16572 746 11975 746 69304 746 73883 746 540 746 68696 746 18645 746 38427 746 75749 746 52221 746 24953 746 6755 746 76293 746 91250 746 22023 746 36280 746 81894 746 20169 746 85115 746 26627 746 85699 746 71107 746 60757 746 29074 746 425...
output:
1458410807
result:
ok 1 number(s): "1458410807"