QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#61189 | #2645. Collapse | eyiigjkn | 35 | 1294ms | 219476kb | C++14 | 2.9kb | 2022-11-11 13:16:17 | 2022-11-11 13:16:19 |
Judging History
answer
# include "collapse.h"
# include <bits/stdc++.h>
using namespace std;
int U[100010],V[100010],lc[200010],rc[200010],tot=0;
vector<int> ans;
map<pair<int,int>,int> mp;
forward_list<int> edge[200010];
struct Update
{
int x1,x2,y1,y2,id;
Update(){}
Update(int x1,int x2,int y1,int y2,int i):x1(x1),x2(x2),y1(y1),y2(y2),id(i){}
}upd[200010];
struct Query
{
int x,y,id;
Query(){}
Query(int x,int y,int i):x(x),y(y),id(i){}
}qry[100010];
struct Node
{
int x1,x2,y1,y2;
Node(){}
Node(int x1,int x2,int y1,int y2):x1(x1),x2(x2),y1(y1),y2(y2){}
inline Node operator+(const Node &t)const
{
return Node(min(x1,t.x1),max(x2,t.x2),min(y1,t.y1),max(y2,t.y2));
}
}tr[200010];
namespace DSU
{
int cnt,fa[100010],rnk[100010],tp=0;
pair<int,int> upd[20000010];
void init(int n){cnt=n;iota(fa,fa+n,0);}
int getF(int u){return u==fa[u]?u:getF(fa[u]);}
void merge(int u,int v)
{
u=getF(u);v=getF(v);
if(u==v) return;
cnt--;
if(rnk[u]>rnk[v]) swap(u,v);
upd[++tp]={u,rnk[u]==rnk[v]};
fa[u]=v;rnk[v]=max(rnk[u]+1,rnk[v]);
}
void undo(int ttp)
{
for(;tp>ttp;tp--)
{
int u=upd[tp].first,v=upd[tp].second;
cnt++;fa[u]=u;
if(v) rnk[v]=rnk[u];
}
}
}
int build(int l,int r,int d)
{
if(l==r) return tr[++tot]=Node(qry[l].x,qry[l].x,qry[l].y,qry[l].y),tot;
int rt=++tot,mid=(l+r)/2;
if(d) nth_element(qry+l,qry+mid,qry+r+1,[](const auto &a,const auto &b){return a.x<b.x;});
else nth_element(qry+l,qry+mid,qry+r+1,[](const auto &a,const auto &b){return a.y<b.y;});
lc[rt]=build(l,mid,d^1);
rc[rt]=build(mid+1,r,d^1);
tr[rt]=tr[lc[rt]]+tr[rc[rt]];
return rt;
}
void update(int rt,Update &x)
{
if(tr[rt].x1>x.x2 || tr[rt].x2<x.x1 || tr[rt].y1>x.y2 || tr[rt].y2<x.y1) return;
if(tr[rt].x1>=x.x1 && tr[rt].x2<=x.x2 && tr[rt].y1>=x.y1 && tr[rt].y2<=x.y2) return assert(++tot<=20000000),edge[rt].push_front(x.id),void();
update(lc[rt],x);update(rc[rt],x);
}
void slv(int rt,int l,int r)
{
int ttp=DSU::tp;
for(int i:edge[rt]) DSU::merge(U[i],V[i]);
if(l==r) ans[qry[l].id]=DSU::cnt;
else
{
int mid=(l+r)/2;
slv(lc[rt],l,mid);
slv(rc[rt],mid+1,r);
}
DSU::undo(ttp);
}
vector<int> simulateCollapse(int n,vector<int> T,vector<int> X,vector<int> Y,vector<int> W,vector<int> P)
{
int N=T.size(),m=0,q=W.size();
ans.resize(q);
for(int i=0;i<N;i++)
{
if(X[i]>Y[i]) swap(X[i],Y[i]);
U[i]=X[i];V[i]=Y[i];
if(T[i]==0) mp[{X[i],Y[i]}]=i;
else
{
int le=mp[{X[i],Y[i]}];
mp.erase({X[i],Y[i]});
if(X[i]) upd[++m]=Update(le,i-1,0,X[i]-1,le);
if(Y[i]<=n-2) upd[++m]=Update(le,i-1,Y[i],n-2,le);
}
}
for(auto p:mp)
{
int u=p.first.first,v=p.first.second,le=p.second;
if(u) upd[++m]=Update(le,N-1,0,u-1,le);
if(v<=n-2) upd[++m]=Update(le,N-1,v,n-2,le);
}
for(int i=0;i<q;i++) qry[i]=Query(W[i],P[i],i);
int rt=build(0,q-1,0);
tot=0;
for(int i=1;i<=m;i++) update(rt,upd[i]);
DSU::init(n);
slv(rt,0,q-1);
return ans;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 1ms
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 7 5 5 5 6 10 10 4 10 7 5 9 9 8 2 2 6 8 2 6 2 2 6 6 2 8 3 2 2 5 4 3 9 2 8 5 3 9 4 9 2 3 6 8 8 3 3 7 3 6 8 7 10 4 3 2 5 2 ...
result:
ok 5000 lines
Test #6:
score: 0
Accepted
time: 73ms
memory: 21272kb
input:
100 4950 5000 0 38 3 0 56 61 0 87 71 0 64 10 0 92 60 0 44 11 0 3 7 0 81 41 0 43 72 0 73 61 0 77 23 0 63 20 0 64 16 0 11 37 0 51 97 0 80 10 0 56 2 0 76 42 0 69 74 0 26 28 0 40 37 0 5 35 0 25 22 0 95 35 0 89 34 0 3 88 0 26 17 0 40 8 0 8 79 0 48 6 0 18 94 0 76 75 0 44 22 0 30 94 0 50 41 0 92 45 0 11 20...
output:
2 2 2 2 2 2 2 2 2 3 2 2 5 2 2 7 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 4 2 2 3 2 2 2 68 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 7 3 2 2 2 2 2 2 2 2 2 13 2 2 2 9 9 71 3 2 7 2 2 2 13 2 9 3 2 2 2 2 2 3 2 2 8 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 7 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 5000 lines
Test #7:
score: 0
Accepted
time: 5ms
memory: 7260kb
input:
5000 1 5000 0 4285 4296 0 174 0 1012 0 3399 0 3238 0 1816 0 4133 0 3019 0 4260 0 2930 0 4630 0 1081 0 2725 0 4468 0 3870 0 1078 0 2021 0 2532 0 4271 0 3007 0 4647 0 3279 0 1541 0 4631 0 2309 0 2625 0 1049 0 3253 0 1274 0 4488 0 4202 0 885 0 2684 0 2656 0 1036 0 2263 0 2196 0 4410 0 1974 0 2852 0 113...
output:
4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 4999 ...
result:
ok 5000 lines
Test #8:
score: 0
Accepted
time: 1ms
memory: 6476kb
input:
5000 13 5000 0 1437 2917 0 4619 3686 0 4797 4454 0 3445 4933 0 561 1988 1 4797 4454 1 1988 561 0 1409 339 0 2874 2680 0 1266 4421 0 803 4698 0 3886 2422 1 3686 4619 1 2249 7 4184 3 4331 3 1568 4 4846 1 3533 12 2754 6 232 4 3193 9 2272 7 2268 10 4048 8 4216 6 3985 0 4840 12 3065 5 2887 12 592 2 1092 ...
output:
4999 4998 4998 4997 4996 4998 4998 4997 4995 4996 4997 4997 4997 4999 4999 4996 4997 4994 4997 4996 4999 4997 4996 4995 4995 4997 4998 4996 4998 4996 4999 4998 4995 4996 4997 4996 4998 4996 4994 4996 4996 4998 4997 4996 4999 4998 4993 4997 4997 4998 4997 4999 4996 4992 4998 5000 4993 4998 4997 4997 ...
result:
ok 5000 lines
Test #9:
score: 0
Accepted
time: 9ms
memory: 8088kb
input:
5000 5000 5000 0 975 2469 1 2469 975 0 3116 3798 0 2112 4747 0 1861 3986 1 3798 3116 0 2915 1795 0 1550 3770 0 433 3583 1 4747 2112 0 1153 4006 0 2233 3268 1 4006 1153 0 4456 1149 0 4 655 0 4058 2897 1 2915 1795 0 1725 1423 0 2206 1507 1 4058 2897 1 1423 1725 1 4 655 1 433 3583 0 4821 1327 0 1407 24...
output:
4961 4981 4994 4986 4974 4993 4987 4987 4981 4998 4986 4994 4997 4974 4986 4998 5000 4988 4993 4982 4993 4984 4993 4965 4996 4968 4997 4963 4986 4996 4996 4982 4996 4993 4998 4992 4972 4999 4999 4991 4996 5000 4999 4987 4961 4991 4993 4979 4994 4981 4999 4983 4989 4975 4996 4993 4989 4998 5000 4991 ...
result:
ok 5000 lines
Test #10:
score: 0
Accepted
time: 22ms
memory: 15248kb
input:
5000 5000 5000 0 3449 1421 1 1421 3449 0 253 3884 1 253 3884 0 2908 3268 0 4948 3871 0 2908 3908 1 2908 3268 0 4186 1306 1 3871 4948 1 2908 3908 1 4186 1306 0 3741 2117 0 1391 4186 0 778 509 0 1597 2117 1 4186 1391 0 2908 4020 1 4020 2908 1 1597 2117 0 4948 3179 0 196 4186 0 2117 1579 1 778 509 1 41...
output:
4464 4508 4509 4635 4763 4516 4646 4766 4525 4772 4789 4388 4910 4779 4907 4409 4907 4724 4669 4873 4850 4545 4383 4438 4509 4850 4537 4859 4725 4828 4532 4826 4629 4299 4957 4477 4992 4543 4805 4656 4996 4832 4465 4729 4923 4717 4364 4564 4456 4388 4680 4534 4800 4457 4734 4747 4793 4740 4926 4532 ...
result:
ok 5000 lines
Test #11:
score: 0
Accepted
time: 85ms
memory: 21796kb
input:
5000 5000 5000 0 1900 2340 0 4130 1922 0 4969 1233 0 2827 3942 0 3982 1431 0 3486 3980 0 3997 2929 0 2449 3118 0 3060 2285 0 971 2628 0 1938 1814 0 240 4209 0 2249 2974 0 2372 1784 0 3729 4064 0 3636 2763 0 3518 2722 0 3948 2501 0 200 1592 0 3783 1348 0 3343 1642 0 4576 3200 0 1460 1735 0 3938 2178 ...
output:
4740 2997 3403 4239 2531 4424 2465 2519 3310 2420 3799 1923 3777 2055 3063 3748 2640 4713 4792 3263 3068 3434 4461 2712 3717 1634 1751 2536 4249 4870 4382 3349 3591 4942 3143 2777 4796 4931 1675 3006 3737 3628 1197 2662 2059 3752 3720 3887 4469 4127 4526 1813 4369 4559 4582 3506 4054 3771 3815 2561 ...
result:
ok 5000 lines
Test #12:
score: 0
Accepted
time: 82ms
memory: 21816kb
input:
5000 5000 5000 0 976 1107 0 2771 4969 0 976 3008 0 155 976 0 3048 3929 0 4548 2155 0 3811 3048 0 4982 3048 0 4308 976 0 3048 2390 0 3048 3912 0 3250 2339 0 2660 976 0 976 2307 0 3048 4635 0 3048 1329 0 952 1913 0 4996 8 0 3717 976 0 2022 4914 0 3048 457 0 976 740 0 976 991 0 2989 3048 0 976 4925 0 3...
output:
3578 2489 4843 4622 3701 3077 4881 2925 2394 2513 3902 2867 4299 4769 4021 2773 3530 3958 4462 4306 4707 2657 4068 4490 2105 3627 3887 2680 4428 4258 3269 4525 4126 2759 3107 4294 2508 2012 3755 3588 4804 3768 3122 2763 3570 1818 3020 4546 3826 3357 2310 3197 3512 3293 3145 3089 4023 3132 4052 2462 ...
result:
ok 5000 lines
Subtask #2:
score: 30
Accepted
Test #13:
score: 30
Accepted
time: 23ms
memory: 12788kb
input:
2 1 100000 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 100000 lines
Test #14:
score: 0
Accepted
time: 23ms
memory: 12864kb
input:
5 10 100000 0 3 2 1 2 3 0 2 1 0 2 3 0 0 3 1 3 2 1 1 2 0 2 4 0 0 2 0 4 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2 5 5 5 4 2 2 2 2 2 2 3 2 2 5 3 2 2 10 2 2 10 2 8 2 6 3 3 2 2 6 4 2 5 10 2 2 2 4 4 9 3 2 2 2 5 2 10 8 5 2 3 2 2 2 2 2 2 8 4 9 2 2 2 2 2 3 2 2 5 2 9 2 6 4 4...
result:
ok 100000 lines
Test #16:
score: 0
Accepted
time: 23ms
memory: 13196kb
input:
10 45 100000 0 9 7 0 0 6 0 3 2 0 7 8 0 3 7 0 1 0 0 2 8 0 8 3 0 0 4 0 8 4 0 7 0 0 6 1 0 0 3 0 8 1 0 5 8 0 5 1 0 7 6 0 4 2 0 9 3 0 0 9 0 3 1 0 3 6 0 5 3 0 9 8 0 2 9 0 7 1 0 4 6 0 0 8 0 9 5 0 6 2 0 4 5 0 4 7 0 0 2 0 6 9 0 5 6 0 5 0 0 8 6 0 1 9 0 1 2 0 1 4 0 4 3 0 9 4 0 5 7 0 2 7 0 5 2 1 6 14 6 26 6 6 6...
output:
8 3 2 5 3 2 2 5 2 2 2 2 5 2 2 9 5 2 2 2 2 2 2 2 3 2 2 3 2 2 4 4 2 2 2 5 3 2 4 2 2 3 2 3 2 3 5 3 9 5 2 4 4 3 2 2 7 2 4 2 6 7 4 2 2 4 3 2 2 2 2 2 2 6 4 2 2 9 4 7 4 2 2 3 6 2 2 2 4 2 2 2 2 2 2 4 9 2 9 2 3 2 2 2 2 2 3 2 2 3 2 2 2 2 2 2 2 2 2 2 2 6 2 2 2 5 2 2 4 2 2 2 2 2 4 2 2 6 2 2 2 2 6 2 2 4 2 2 2 5 ...
result:
ok 100000 lines
Test #17:
score: 0
Accepted
time: 344ms
memory: 67948kb
input:
100 100000 100000 0 12 26 1 12 26 0 44 29 1 44 29 0 21 32 1 21 32 0 81 30 1 30 81 0 93 39 0 26 5 1 39 93 0 93 87 0 60 13 1 87 93 1 13 60 1 26 5 0 26 84 1 26 84 0 26 50 0 44 32 1 26 50 0 61 86 1 61 86 1 32 44 0 69 59 0 68 92 0 37 21 0 5 53 1 37 21 0 87 78 0 64 9 1 64 9 1 53 5 1 92 68 0 31 66 1 66 31 ...
output:
19 25 62 11 13 61 20 31 79 83 63 50 94 9 35 31 17 17 86 56 98 9 69 38 54 91 78 11 69 30 8 41 10 33 5 45 48 70 76 80 9 59 7 58 24 15 35 97 96 46 88 38 19 38 86 18 49 70 61 14 37 58 5 91 35 23 30 29 61 56 13 55 12 63 56 74 67 40 92 12 81 14 42 29 68 93 10 10 19 84 60 32 77 67 44 96 38 98 9 13 21 97 60...
result:
ok 100000 lines
Test #18:
score: 0
Accepted
time: 66ms
memory: 23216kb
input:
100 4950 100000 0 84 47 0 31 87 0 62 83 0 54 79 0 41 94 0 87 43 0 46 70 0 84 93 0 33 91 0 0 87 0 36 88 0 8 74 0 86 39 0 99 23 0 74 33 0 86 11 0 29 8 0 24 23 0 5 97 0 7 68 0 9 8 0 17 22 0 75 55 0 61 35 0 32 18 0 20 38 0 99 89 0 89 80 0 96 29 0 5 27 0 90 6 0 36 1 0 83 49 0 69 33 0 70 36 0 4 94 0 51 74...
output:
8 2 2 2 2 2 2 2 2 2 2 2 2 9 2 2 2 2 2 2 2 2 2 6 2 2 2 2 2 2 2 2 2 2 2 2 2 2 9 2 2 2 2 12 2 2 2 19 65 2 2 2 2 2 2 58 9 2 2 2 2 7 2 11 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 8 89 2 2 2 2 2 2 2 2 9 2 2 2 2 2 2 2 2 2 2 2 2 2 2 87 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 21 2 2 2 2 65 2 2 2 2 2 2 2 2 2 2...
result:
ok 100000 lines
Test #19:
score: 0
Accepted
time: 1283ms
memory: 219476kb
input:
1000 100000 100000 0 401 876 0 420 792 0 965 268 0 909 871 0 736 337 0 341 634 0 112 317 0 685 606 0 778 506 0 162 289 0 375 590 0 874 77 0 434 986 0 78 804 0 743 760 0 290 466 0 721 828 0 44 145 0 601 101 0 223 651 0 327 860 0 105 727 0 447 93 0 680 298 0 868 502 0 130 527 0 567 523 0 871 862 0 423...
output:
9 2 2 2 166 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 483 2 2 2 2 2 2 2 49 2 2 2 2 2 2 2 2 2 2 2 198 804 2 2 3 2 9 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 9 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 200 2 2 2 2 2...
result:
ok 100000 lines
Test #20:
score: 0
Accepted
time: 348ms
memory: 66800kb
input:
10000 100000 100000 0 3029 6081 0 8203 8589 1 3029 6081 1 8203 8589 0 5644 5052 0 7453 4217 1 4217 7453 0 411 1437 0 6129 6204 1 6129 6204 1 411 1437 1 5052 5644 0 3706 3648 1 3648 3706 0 4124 255 1 4124 255 0 6254 1238 1 6254 1238 0 315 9450 0 3482 4345 0 5779 9692 0 8499 9981 0 9054 4198 1 3482 43...
output:
9954 9868 9838 9950 9998 9870 9919 9954 9980 9949 9944 9911 9836 9904 9970 9943 9890 9903 9871 9984 9998 9934 9950 9885 9922 9997 9981 9953 9870 9942 9924 9916 9996 9899 9995 9937 9901 9878 9986 9854 9928 9981 9966 9990 9926 9974 9977 9881 9908 9996 9980 9843 9940 9944 9887 9903 9860 9897 9952 9880 ...
result:
ok 100000 lines
Test #21:
score: 0
Accepted
time: 63ms
memory: 13624kb
input:
100000 1 100000 0 82807 93097 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 73456 0 7345...
output:
99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 ...
result:
ok 100000 lines
Test #22:
score: 0
Accepted
time: 38ms
memory: 13272kb
input:
100000 13 100000 0 1439 16071 0 77126 71233 0 65676 31466 0 46411 63728 0 89638 56713 0 87375 51822 1 51822 87375 0 8857 81973 1 46411 63728 0 3682 72818 0 99222 1242 0 9034 60037 1 8857 81973 9 24572 11 24572 11 24572 9 24572 10 24572 12 24572 12 24572 9 24572 9 24572 1 24572 5 24572 1 24572 10 245...
output:
99996 99996 99996 99996 99996 99996 99996 99996 99996 99998 99994 99998 99996 99995 99998 99996 99996 99996 99996 99996 99997 99996 99996 99995 99996 99998 99996 99995 99996 99997 99996 99999 99996 99995 99995 99998 99998 99996 99995 99997 99995 99996 99995 99996 99996 99995 99996 99995 99996 99996 ...
result:
ok 100000 lines
Test #23:
score: 0
Accepted
time: 42ms
memory: 15972kb
input:
100000 1300 100000 0 89356 81602 0 25968 71253 1 71253 25968 1 81602 89356 0 9552 48034 1 48034 9552 0 60781 48013 1 48013 60781 0 37834 44402 1 44402 37834 0 65946 49304 0 18516 23388 0 29228 56191 1 23388 18516 0 59336 2420 0 93358 56425 1 56425 93358 1 65946 49304 0 54778 99482 1 54778 99482 1 29...
output:
100000 99959 99919 99844 99931 99870 99885 99972 99848 99619 99897 99730 99916 99947 99926 99796 99832 99920 99620 99880 99690 99888 99888 99865 99730 99914 99690 99916 99681 99757 99720 99962 99864 99795 99685 99962 99618 99915 99752 99681 99962 99687 99622 99798 99795 99877 99786 99796 99756 99963...
result:
ok 100000 lines
Test #24:
score: 0
Accepted
time: 389ms
memory: 73568kb
input:
100000 100000 100000 0 17804 63065 1 63065 17804 0 45575 88403 1 45575 88403 0 80699 2416 1 80699 2416 0 31614 61013 0 56546 21713 1 31614 61013 1 56546 21713 0 62497 35703 1 35703 62497 0 31149 60185 1 60185 31149 0 78537 84342 1 78537 84342 0 32132 70924 1 70924 32132 0 43661 10068 0 347 91377 0 5...
output:
99867 99992 99898 99888 99915 99975 99864 99877 99876 99861 99866 99864 99986 99997 99908 99990 99835 99886 99819 99894 99918 99844 99877 99982 99887 99900 99867 99886 99910 99988 99918 99936 99913 99961 99891 99928 99850 99948 99974 99865 99800 99895 99953 99863 99958 99836 99961 99841 99945 99867 ...
result:
ok 100000 lines
Test #25:
score: 0
Accepted
time: 1060ms
memory: 184448kb
input:
100000 100000 100000 0 24907 27865 1 27865 24907 0 52274 52157 0 33 31159 0 55043 23321 0 82744 42837 1 31159 33 1 82744 42837 0 88688 98999 1 52274 52157 0 51278 31159 1 88688 98999 1 55043 23321 0 61377 31159 0 26891 98999 0 98999 45687 0 43623 39111 0 89515 31159 1 45687 98999 0 38524 94012 0 152...
output:
93423 87123 82099 95363 93522 88616 96001 88490 87910 87114 90029 84266 89936 98685 84402 88903 96346 86243 89791 84715 95956 98159 84744 93347 99490 83760 96070 86758 89011 82768 88238 81508 92733 84987 93386 94883 84738 97333 86359 81562 92756 85568 85310 88344 93250 81356 83659 99905 82166 85746 ...
result:
ok 100000 lines
Test #26:
score: 0
Accepted
time: 1294ms
memory: 211596kb
input:
100000 100000 100000 0 51121 62431 0 99918 74056 0 60825 71018 0 7595 24939 0 98355 56680 0 53097 32198 0 6546 74840 0 53620 67586 0 32747 14603 0 15566 41025 0 10663 7997 0 63554 41417 0 86524 78350 0 93313 23614 0 48984 86305 0 29296 37851 0 69475 8084 0 58875 73654 0 92009 45536 0 89865 67813 0 2...
output:
88708 54743 74756 52508 82115 60826 55492 61928 78480 88881 70276 64099 96761 54320 52627 75089 79098 65142 56337 53275 72623 96839 73044 72228 96403 94337 55788 79638 55339 84654 73149 87995 94910 86555 92763 77829 51834 93682 60263 75213 92260 83673 80054 70258 86209 97431 58540 95354 77864 65201 ...
result:
ok 100000 lines
Test #27:
score: 0
Accepted
time: 990ms
memory: 169260kb
input:
100000 100000 100000 0 89314 98452 0 72955 89314 0 95887 89314 0 28546 37614 0 67761 89314 0 57217 89314 0 13498 89314 0 19464 89314 0 89314 75998 0 89314 3870 0 29915 89314 0 54647 89314 0 29791 89314 0 89314 67142 0 97782 89314 0 71818 89314 0 89314 81825 0 89314 5179 0 89314 11827 0 89314 29810 0...
output:
76456 55592 70239 93604 83773 96733 56888 88513 99477 65201 78604 64096 93431 78182 99725 88413 81654 67948 82865 82661 97307 78239 92785 68980 74987 62001 80105 84208 93063 78936 58274 82054 82905 91269 57440 79094 98253 72375 65912 98241 61274 67790 94902 86726 87733 92843 83379 61042 76099 82396 ...
result:
ok 100000 lines
Subtask #3:
score: 0
Memory Limit Exceeded
Test #28:
score: 30
Accepted
time: 28ms
memory: 13176kb
input:
2 1 100000 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok 100000 lines
Test #29:
score: 0
Accepted
time: 32ms
memory: 12652kb
input:
5 7 100000 0 3 1 0 4 1 0 2 3 0 2 1 0 2 4 0 2 0 0 4 0 1 0 3 0 4 0 0 3 1 2 2 0 4 0 2 1 5 1 4 0 2 3 0 2 0 3 6 0 4 2 5 2 4 3 5 0 0 0 5 3 0 1 4 0 4 0 3 1 3 0 1 1 6 3 0 0 0 0 0 3 5 3 3 2 6 0 5 0 4 1 0 0 5 0 0 3 2 3 1 2 2 1 6 2 0 0 3 2 0 0 2 2 1 0 1 1 0 2 1 0 5 3 5 2 2 1 2 2 3 0 2 3 1 3 1 0 3 1 5 2 1 2 5 0...
output:
3 2 2 4 5 2 2 4 3 2 3 5 4 2 4 3 3 2 4 2 5 2 2 4 2 5 2 4 4 4 2 4 2 2 3 4 2 4 3 5 4 3 4 4 4 5 3 5 5 3 2 3 4 5 2 3 4 3 4 3 5 2 5 4 5 2 4 2 5 2 4 5 4 3 2 3 3 3 2 4 5 4 5 4 4 2 3 4 3 3 2 3 2 3 3 2 4 4 4 5 3 3 4 5 4 4 5 3 3 2 5 3 5 4 3 2 5 4 4 5 3 3 4 4 3 5 4 2 4 2 2 4 2 3 4 2 5 5 4 4 2 2 3 3 4 2 2 5 5 4 ...
result:
ok 100000 lines
Test #30:
score: 0
Accepted
time: 32ms
memory: 13032kb
input:
10 20 100000 0 5 6 0 5 0 0 0 9 0 0 6 0 3 4 0 4 0 0 7 9 0 3 1 0 4 1 0 6 1 0 3 0 0 8 7 0 1 2 0 5 1 0 3 2 0 8 4 0 8 6 0 2 0 0 4 6 0 9 3 11 6 13 5 19 8 11 4 13 7 5 8 12 6 9 0 9 5 3 4 7 2 18 4 19 0 0 3 4 8 11 4 17 8 4 7 11 3 8 5 0 7 4 5 4 5 10 5 4 6 11 8 9 3 17 7 3 2 17 7 12 5 14 5 12 4 8 4 3 4 12 7 8 1 ...
output:
3 3 2 4 4 6 2 5 5 9 7 2 2 9 7 4 2 7 5 5 9 8 8 5 7 4 7 4 9 4 3 3 3 5 9 4 7 5 3 3 5 9 5 3 8 5 4 8 7 7 4 9 9 7 3 9 5 8 8 4 3 6 8 4 8 8 5 2 4 10 3 2 7 2 3 8 9 8 2 7 4 9 2 3 4 4 4 9 9 7 5 2 3 9 2 8 9 8 6 7 9 8 8 2 8 5 6 3 9 2 9 4 9 6 4 7 4 3 5 3 9 7 7 2 5 8 4 7 8 6 2 8 9 5 2 8 7 10 5 9 5 2 5 7 9 3 10 4 2...
result:
ok 100000 lines
Test #31:
score: 0
Accepted
time: 33ms
memory: 13244kb
input:
10 45 100000 0 5 7 0 2 1 0 3 5 0 4 2 0 4 8 0 7 3 0 0 8 0 1 4 0 6 2 0 9 8 0 7 2 0 5 0 0 1 3 0 6 4 0 9 1 0 4 3 0 8 6 0 2 8 0 5 1 0 3 2 0 7 9 0 4 5 0 0 2 0 0 3 0 8 5 0 1 8 0 0 1 0 0 7 0 1 7 0 6 0 0 6 5 0 7 6 0 4 7 0 7 8 0 2 9 0 9 3 0 1 6 0 6 9 0 0 9 0 9 4 0 3 8 0 5 2 0 3 6 0 9 5 0 0 4 17 8 32 2 8 0 29 ...
output:
2 2 4 2 2 2 2 2 9 2 2 4 2 2 2 2 2 2 6 4 5 2 7 3 3 2 2 8 2 2 3 2 9 5 6 3 3 4 6 7 4 6 2 2 7 7 2 5 2 2 2 2 2 2 3 2 2 6 8 2 2 10 9 6 2 5 2 2 2 2 7 3 6 8 2 2 2 7 2 2 2 2 2 9 4 2 2 3 2 2 2 2 2 7 2 7 3 5 2 3 2 2 2 2 2 6 5 2 2 3 7 2 7 2 6 3 8 5 7 2 5 4 3 2 3 2 2 9 4 2 2 2 2 3 9 2 2 3 3 4 6 2 5 2 3 5 2 6 2 2...
result:
ok 100000 lines
Test #32:
score: 0
Accepted
time: 72ms
memory: 19896kb
input:
100 500 100000 0 75 20 0 23 42 0 53 70 0 11 28 0 23 67 0 74 63 0 93 4 0 13 43 0 96 72 0 2 65 0 43 96 0 86 52 0 77 38 0 89 33 0 85 84 0 55 48 0 8 20 0 7 18 0 43 62 0 38 44 0 42 24 0 98 6 0 92 66 0 17 33 0 4 70 0 12 74 0 13 99 0 79 63 0 53 14 0 38 22 0 54 41 0 61 44 0 85 21 0 25 38 0 38 28 0 81 87 0 7...
output:
8 19 7 7 5 51 5 8 16 8 3 6 5 3 42 3 6 5 9 15 3 9 7 6 5 26 12 4 22 22 3 13 11 6 99 3 79 2 30 3 2 9 56 5 67 2 43 4 12 3 28 26 11 6 5 18 2 6 72 6 17 2 11 18 48 86 3 3 85 6 10 3 7 36 5 3 6 12 5 3 38 3 3 11 9 93 54 60 8 22 35 4 34 16 48 6 11 5 5 31 99 43 60 5 11 8 2 21 69 3 94 50 8 3 8 3 8 6 25 28 3 6 2 ...
result:
ok 100000 lines
Test #33:
score: 0
Accepted
time: 355ms
memory: 83464kb
input:
100 4950 100000 0 50 40 0 87 50 0 72 73 0 74 65 0 2 4 0 29 28 0 20 28 0 15 99 0 13 56 0 31 5 0 5 89 0 28 10 0 84 6 0 19 92 0 38 96 0 89 86 0 21 10 0 18 35 0 84 28 0 86 80 0 69 45 0 33 62 0 3 45 0 81 22 0 0 43 0 12 41 0 81 58 0 34 4 0 53 65 0 55 43 0 71 18 0 60 17 0 44 18 0 12 6 0 55 94 0 87 41 0 42 ...
output:
2 4 2 2 2 2 4 2 2 3 2 2 2 2 2 2 5 2 2 2 2 2 2 2 2 2 2 4 2 2 5 2 2 2 14 2 16 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 41 2 2 2 2 2 14 2 2 2 2 2 2 2 2 6 2 2 2 2 2 2 2 2 8 2 2 2 2 2 2 2 2 2 28 2 2 2 2 2 14 2 2 12 2 2 2 2 2 2 2 2 2 3 2 2 2 2 10 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2 2 2 2 6 78 2 2 2 2 2 2 2 2 2 2 1...
result:
ok 100000 lines
Test #34:
score: -30
Memory Limit Exceeded
input:
1000 75000 100000 0 312 514 0 320 439 0 100 448 0 646 280 0 535 701 0 199 217 0 178 777 0 843 287 0 996 52 0 587 444 0 728 395 0 882 610 0 875 656 0 971 990 0 656 990 0 549 684 0 766 968 0 969 956 0 15 757 0 978 467 0 736 621 0 673 44 0 911 944 0 555 47 0 385 922 0 897 648 0 352 936 0 157 311 0 645 ...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%