QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#785351 | #9636. 签到题 | zhouhuanyi | 100 ✓ | 384ms | 99956kb | C++17 | 3.5kb | 2024-11-26 17:38:03 | 2024-11-26 17:38:12 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#define N 400000
#define M 1000000
using namespace std;
long long read()
{
char c=0;
long long sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int gcd(int x,int y)
{
if (!y) return x;
return gcd(y,x%y);
}
struct reads
{
int x,y;
};
struct rds
{
int num,data;
};
rds st[N+1];
struct node
{
int v,nxt;
};
node edge[M+1],edge2[M+1];
int C,n,m,q,len,len2,lengs,lg[M+1],head[N+1],head2[N+1],stk[N+1],top,sz[N+1],fa[N+1],dfn[N+1],low[N+1],lengz,a[N+1],s[N+1],tong[N+1],length,leng;
long long k,dp[N+1],maxn,ans[M+1],s2[N+1];
vector<reads>p[M+1];
bool vis[N+1];
void add(int x,int y)
{
edge[++len]=(node){y,head[x]},head[x]=len;
edge[++len]=(node){x,head[y]},head[y]=len;
return;
}
void add2(int x,int y)
{
edge2[++len2]=(node){y,head2[x]},head2[x]=len2;
return;
}
bool ops;
int dque[N+1],tops;
void tarjan(int x)
{
if (ops) dque[++tops]=x;
dfn[x]=low[x]=++lengz,stk[++top]=x;
for (int i=head[x];i>0;i=edge[i].nxt)
{
if (!dfn[edge[i].v])
{
tarjan(edge[i].v),low[x]=min(low[x],low[edge[i].v]);
if (low[edge[i].v]>=dfn[x])
{
++lengs;
while (stk[top]!=edge[i].v) add2(lengs,stk[top]),top--;
add2(lengs,stk[top]),top--,add2(x,lengs);
}
}
else low[x]=min(low[x],dfn[edge[i].v]);
}
return;
}
void dfs(int x)
{
sz[x]=(x<=n);
for (int i=head2[x];i>0;i=edge2[i].nxt) fa[edge2[i].v]=x,dfs(edge2[i].v),sz[x]+=sz[edge2[i].v];
return;
}
void dfs2(int x)
{
if (x<=n) maxn=max(maxn,dp[x]);
for (int i=head2[x];i>0;i=edge2[i].nxt) dp[edge2[i].v]+=dp[x],dfs2(edge2[i].v);
return;
}
int main()
{
int x,y,ps;
long long res,res2;
for (int i=2;i<=M;++i) lg[i]=lg[i>>1]+1;
C=read(),n=read(),m=read(),q=read();
for (int i=1;i<=n;++i) a[i]=read();
for (int i=1;i<=m;++i) x=read(),y=read(),p[gcd(a[x],a[y])].push_back((reads){x,y});
for (int i=M;i>=1;--i)
{
length=lengz=0,lengs=n,len=len2=maxn=0;
for (int j=i;j<=M;j+=i)
for (int k=0;k<p[j].size();++k)
{
add(p[j][k].x,p[j][k].y);
if (!vis[p[j][k].x]) vis[p[j][k].x]=1,tong[++length]=p[j][k].x;
if (!vis[p[j][k].y]) vis[p[j][k].y]=1,tong[++length]=p[j][k].y;
}
if (length)
{
for (int j=1;j<=length;++j)
if (!dfn[tong[j]])
{
top=0,ps=lengs,tarjan(tong[j]),dfs(tong[j]);
for (int k=ps+1;k<=lengs;++k)
{
leng=0;
for (int t=head2[k];t>0;t=edge2[t].nxt) st[++leng]=(rds){edge2[t].v,sz[edge2[t].v]};
st[++leng]=(rds){fa[k],sz[tong[j]]-sz[k]};
for (int t=1;t<=leng;++t) s[t]=s[t-1]+st[t].data,s2[t]=s2[t-1]+1ll*st[t].data*t;
for (int t=1;t<=leng;++t)
{
res=1ll*t*s[t]+1ll*(leng+t)*(s[leng]-s[t])-s2[leng];
res2=s2[leng]+1ll*(leng-t)*s[t-1]-1ll*t*(s[leng]-s[t-1]);
if (st[t].num!=fa[k]) dp[st[t].num]+=max(res,res2);
else dp[tong[j]]+=max(res,res2),dp[k]-=max(res,res2);
}
}
dfs2(tong[j]);
}
ans[i]=maxn;
for (int j=1;j<=length;++j) vis[tong[j]]=head[tong[j]]=head2[tong[j]]=dfn[tong[j]]=dp[tong[j]]=0;
for (int j=n+1;j<=lengs;++j) vis[j]=head[j]=head2[j]=dfn[j]=dp[j]=0;
}
}
for (int i=M-1;i>=1;--i) ans[i]=max(ans[i],ans[i+1]);
for (int qt=1;qt<=q;++qt)
{
k=read();
if (ans[1]<k) puts("-1");
else
{
ps=1;
for (int i=lg[M];i>=0;--i)
if (ps+(1<<i)<=M&&ans[ps+(1<<i)]>=k)
ps+=(1<<i);
printf("%d\n",ps);
}
}
return 0;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 40ms
memory: 61972kb
input:
1 5 5 1 17 5 4 7 1 1 3 1 4 2 4 3 4 3 5 10000000000
output:
-1
result:
ok single line: '-1'
Test #2:
score: 10
Accepted
time: 46ms
memory: 57096kb
input:
1 5 5 1 17 8 16 1 14 1 2 1 5 3 4 3 5 4 5 2
output:
1
result:
ok single line: '1'
Test #3:
score: 10
Accepted
time: 41ms
memory: 59780kb
input:
1 6 5 1 3 6 2 3 3 6 1 2 2 4 3 6 4 5 5 6 1
output:
3
result:
ok single line: '3'
Test #4:
score: 10
Accepted
time: 44ms
memory: 59748kb
input:
1 6 5 1 4 6 1 2 16 2 1 4 1 5 2 5 2 6 3 4 1
output:
4
result:
ok single line: '4'
Test #5:
score: 10
Accepted
time: 31ms
memory: 59716kb
input:
1 6 5 1 2 8 2 2 16 8 1 2 1 5 3 4 3 6 5 6 1
output:
8
result:
ok single line: '8'
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #6:
score: 10
Accepted
time: 46ms
memory: 54696kb
input:
2 20 22 20 4 3 3 2 12 4 3 1 4 6 4 6 3 1 6 4 1 3 12 2 1 3 1 19 2 5 2 6 2 7 3 17 4 8 4 11 5 19 6 10 7 10 9 12 10 14 10 15 10 18 11 16 11 20 12 18 13 17 15 18 15 20 16 20 1 1 25 2 3 146 4 26 3321 97015858 25 4 2937066794 439 96125173 146 3 1 1 26
output:
12 12 3 4 4 1 3 3 -1 -1 3 3 -1 -1 -1 1 4 12 12 3
result:
ok 20 lines
Test #7:
score: 10
Accepted
time: 41ms
memory: 55004kb
input:
2 20 22 20 1 1 2 6 4 2 1 2 6 3 2 1 4 1 12 6 12 12 12 4 1 11 1 20 2 9 3 6 3 10 4 14 4 19 5 8 5 11 7 8 7 13 9 13 9 14 10 15 10 17 12 16 12 19 13 14 15 17 15 18 16 19 17 20 5 2 1 4 149 6 7 3 6 3 5 7 7921394 388656207 4293018 3 4 43212 7 169367
output:
4 12 12 4 1 4 1 12 4 12 4 1 -1 -1 -1 12 4 -1 1 -1
result:
ok 20 lines
Test #8:
score: 10
Accepted
time: 43ms
memory: 59568kb
input:
2 20 23 20 16 8 1 8 16 8 1 4 16 2 2 2 1 16 2 8 2 8 8 16 1 13 1 20 2 16 2 18 3 12 3 15 4 17 4 20 5 9 5 15 6 16 6 19 6 20 7 8 7 10 7 13 8 13 8 14 9 18 11 19 12 15 13 20 17 19 2 39 1 88 87 1 40 179 6524175 458117 1895 8419414228 87 7385623974 66694 87 1 1 1 87
output:
8 8 16 1 2 16 8 1 -1 -1 -1 -1 2 -1 -1 2 16 16 16 2
result:
ok 20 lines
Test #9:
score: 10
Accepted
time: 35ms
memory: 56812kb
input:
2 19 22 20 16 1 2 4 8 4 2 4 1 16 1 16 4 2 8 8 2 2 2 1 7 1 9 1 11 2 3 2 17 3 6 4 6 4 11 4 16 5 13 5 18 6 17 7 11 7 14 8 10 8 17 11 13 11 16 11 19 12 15 13 18 15 17 22 23 3 111 1 2 1 2 67238 22 51659 805975 2 23 2 296 22 45 6770 1
output:
2 2 4 1 8 4 8 4 -1 2 -1 -1 4 2 4 -1 2 1 -1 8
result:
ok 20 lines
Test #10:
score: 10
Accepted
time: 42ms
memory: 57116kb
input:
2 20 22 20 1 4 8 4 4 4 2 2 16 16 2 1 8 2 2 2 8 8 1 4 1 5 1 13 2 14 2 16 3 10 4 6 5 10 5 11 5 13 5 18 6 7 6 19 7 18 7 19 8 12 8 15 9 17 10 17 10 18 12 14 13 20 15 18 123 9 24 23 54 1 8 53 273 2 8 53 71956678 24 23 1958616724 8 8 1 54
output:
1 8 4 4 2 8 8 2 -1 8 8 2 -1 4 4 -1 8 8 8 2
result:
ok 20 lines
Subtask #3:
score: 20
Accepted
Test #11:
score: 20
Accepted
time: 377ms
memory: 71712kb
input:
3 200000 199999 200000 31680 1760 432 1232 90 1848 5 3520 15840 495 7560 4928 2160 33 32 7560 2160 84 264 440 665280 1512 1848 10080 270 221760 3024 192 16 960 64 1680 5040 385 216 210 3960 672 176 13860 231 18480 41580 33 1848 2640 180 616 160 20790 480 693 1760 41580 14784 6930 2640 3080 36 11880 ...
output:
12 1890 1 56 112 440 36 332640 132 880 24 1890 6 132 24 36 36 3 288 24 4 4 112 12320 1890 3 2 990 16632 24 12320 332640 16632 288 440 12 24 83160 288 112 83160 2 12320 880 880 24 6 288 12320 112 288 990 12320 24 6 24 12320 24 880 -1 1 2 440 12320 990 1890 -1 3 -1 880 1 1 12320 16632 132 12320 3 1 44...
result:
ok 200000 lines
Test #12:
score: 20
Accepted
time: 143ms
memory: 75584kb
input:
3 200000 199999 200000 10 5 2 8 2 5 4 1 1 1 1 5 40 40 10 1 1 20 10 40 4 20 1 20 10 10 5 2 2 40 4 40 10 40 40 20 5 4 5 40 10 8 1 40 8 1 1 20 10 8 5 40 40 10 1 20 10 20 4 40 8 8 1 4 8 4 4 20 20 10 1 20 40 40 5 1 8 1 20 40 40 5 40 10 8 10 40 8 8 5 1 40 1 20 8 40 4 10 1 1 40 40 2 5 5 40 5 8 4 2 5 4 4 40...
output:
4 4 40 1 20 5 20 2 10 40 5 20 10 2 5 40 10 4 1 1 2 20 1 -1 2 1 10 1 2 20 2 20 1 1 2 4 5 40 40 -1 20 1 2 20 10 1 40 1 -1 2 20 10 1 1 1 1 20 4 2 2 5 2 1 4 20 20 20 40 1 40 1 40 4 40 5 40 20 4 20 -1 1 20 1 4 10 4 2 10 2 40 1 5 2 2 2 20 10 5 1 10 20 5 20 2 10 2 10 40 2 -1 40 1 -1 40 -1 5 20 10 -1 10 5 4...
result:
ok 200000 lines
Test #13:
score: 20
Accepted
time: 158ms
memory: 73432kb
input:
3 200000 199999 200000 5 2 10 1 4 1 1 5 10 1 4 8 1 1 8 1 5 10 40 1 5 2 5 5 5 40 20 4 8 40 5 10 20 10 4 8 2 4 40 8 4 20 40 4 8 40 10 8 2 10 10 40 5 40 4 20 4 8 20 10 4 40 20 20 5 4 10 8 10 40 5 20 1 20 20 4 2 8 40 1 1 1 8 40 8 40 10 5 2 8 2 4 4 40 4 40 20 40 40 8 1 40 40 40 2 2 20 2 2 10 4 5 20 10 20...
output:
5 10 40 40 10 20 10 2 2 40 5 1 1 1 1 -1 1 1 1 20 1 2 1 5 10 10 1 40 2 -1 -1 20 1 1 1 1 1 10 5 5 -1 2 40 40 5 2 -1 5 -1 1 1 1 10 10 40 1 1 10 1 20 10 5 40 1 2 1 40 1 5 1 5 10 1 40 40 -1 40 1 2 40 -1 40 40 1 2 -1 20 20 1 10 1 10 40 2 1 2 5 1 40 5 20 1 10 1 40 1 1 2 10 5 40 2 20 2 40 20 10 20 5 40 5 1 ...
result:
ok 200000 lines
Test #14:
score: 20
Accepted
time: 320ms
memory: 69496kb
input:
3 200000 199999 200000 4290 4368 15015 364 624 117 6552 13104 45 210 693 220 560 2184 336 1092 12 1001 990 390 26 990 104 1144 7 6930 728 1716 1848 4290 28 20020 273 45 80 3003 132 10296 2772 720 18018 34320 18 2574 693 240240 39 252 90090 1001 1584 315 6930 48 2340 6864 520 1584 240 180180 13104 3 ...
output:
572 182 91 1092 1 91 572 91 3 143 1716 1716 12012 60060 720720 182 12012 4 572 26 52 13 4 91 26 26 1092 308 25740 182 1540 2 572 182 1540 720720 1092 3 182 13 91 91 25740 2 60060 182 182 2 1 182 4 2 182 -1 -1 52 52 91 26 2 1 1 1 1 4 3 26 13 1 1 572 1 720720 91 91 182 182 12012 182 52 12012 720720 25...
result:
ok 200000 lines
Test #15:
score: 20
Accepted
time: 382ms
memory: 76288kb
input:
3 200000 199999 200000 880 3 280 133056 77 704 1008 1260 2464 18 22176 35 1320 132 2376 990 80 420 864 84 448 27 270 594 495 22 280 6336 16632 11088 11 1320 665280 1056 264 2310 1848 264 20790 19008 66 2160 144 6720 3520 704 154 665280 60480 154 1485 2772 96 990 135 1848 10395 3960 1 462 224 56 2640...
output:
144 33 144 308 36960 16 96 6 231 96 33 2 1584 3 231 2640 144 1 665280 23760 6 110880 15840 36960 3 12 33 396 396 36 8 2 16 1232 33 15840 88 1584 4 8 144 231 110880 1232 396 33 308 8 4 23760 88 1584 36 1584 15840 2640 665280 308 2640 231 1232 231 33 15840 33 1 36960 2 8 1 16 1 15840 15840 1 -1 1 6 -1...
result:
ok 200000 lines
Test #16:
score: 20
Accepted
time: 256ms
memory: 77752kb
input:
3 200000 199999 200000 235620 4760 528 8976 132 942480 2142 630 11220 55 88 22 336 126 210 14 21420 3570 67320 210 264 28560 18 616 88 12240 13090 5610 693 90 13860 2142 210 6160 476 66 840 4620 1309 314160 72 630 120 3696 616 210 714 4 1122 693 55 35 17136 28 1008 1785 132 14 1980 3080 67320 3570 4...
output:
4 17 5236 942480 17 238 238 2 2 2142 4 1 1 1 1 1 1 1 2 238 1 2 1 4 238 17 1 942480 2 1 1 238 1 1 1 1 1 102 4 4 1 2 5236 5236 4 4 1 11 1 1 1 1 17 238 5236 1 1 17 1 238 17 4 78540 1 2 1 5236 1 4 1 4 17 1 942480 2142 1 2142 1 4 2142 1 5236 2142 1 4 1 238 238 1 17 1 17 942480 2 1 2 7 1 2142 4 238 1 17 1...
result:
ok 200000 lines
Test #17:
score: 20
Accepted
time: 291ms
memory: 99956kb
input:
3 200000 199999 200000 16 3150 40 1950 11700 936 3276 144 50 14040 13104 6552 468 9360 54 7800 756 13104 1008 135 40950 7020 1755 585 936 2800 6 1680 2800 36400 42 36400 54600 1260 6825 130 189 7 91 2160 1872 25200 2520 312 491400 163800 3900 1365 9100 1092 10920 8 600 50 260 189 1512 720 144 240 35...
output:
9828 1950 1 3 163800 10 300 300 3 300 819 819 9828 21 5 15 982800 300 819 1950 163800 982800 3 300 9828 36 15 1 2 5 1950 9828 1 300 1 2 36 1 163800 300 195 163800 195 819 1 1 21 10 1950 3 163800 163800 15 3 1 1 10 300 2 300 1 1 300 9828 1 163800 1 1 9828 1950 163800 10 1 9828 300 1950 1 1 1 1 1 1638...
result:
ok 200000 lines
Subtask #4:
score: 20
Accepted
Dependency #3:
100%
Accepted
Test #18:
score: 20
Accepted
time: 315ms
memory: 69220kb
input:
4 200000 200000 200000 140 561 55440 990 1530 840 180 33 7480 51 23562 80 315 2142 16 126 70 14 18480 80 176 360 12240 21 1680 2 104720 22440 748 8 264 22440 22440 4284 231 85680 693 47124 28560 134640 7920 1496 13860 20 765 17136 28 33660 1232 17136 11 560 495 3060 68 22440 14 231 2640 1870 16830 6...
output:
471240 17 119 2618 14 17 11220 374 374 2618 6 51 11 374 2618 3 374 187 1122 51 2618 942480 14 11220 11220 1122 6 2618 374 942480 187 3 2618 22 11 119 78540 374 4 4 51 1 2 78540 471240 22 561 471240 78540 78540 561 471240 51 2 2618 942480 11220 1 561 1 1 1 1 2618 51 51 2618 374 1 1 374 -1 17 1 1 17 1...
result:
ok 200000 lines
Test #19:
score: 20
Accepted
time: 271ms
memory: 75732kb
input:
4 200000 200000 200000 7760 20 403520 201760 3104 776 26 160 25220 12416 20176 640 2 970 12610 194 100880 50440 2080 2 80 97 4 8 208 1552 40 5 1040 1940 1040 40352 1261 128 6208 10088 80704 100880 8320 640 8320 1940 1040 2 1664 1 161408 25220 104 25220 65 62080 194 640 100880 6208 640 201760 320 194...
output:
403520 80704 5044 2522 776 3104 776 807040 807040 3104 1261 201760 5044 776 201760 5044 1 97 4 194 194 8 4 2 50440 403520 1261 201760 776 40352 40352 3104 8 201760 2 97 2 97 3104 403520 1 1 50440 3104 40352 5044 776 5044 403520 3104 -1 -1 1 403520 1 -1 1 403520 -1 1 201760 1 97 776 1261 1 2 4 40352 ...
result:
ok 200000 lines
Test #20:
score: 20
Accepted
time: 270ms
memory: 71412kb
input:
4 200000 200000 200000 2 2 64 20176 25220 40352 12610 4 80704 160 403520 161408 20 8320 20176 161408 208 6208 208 161408 16 6305 520 403520 52 160 776 260 32 1261 25220 2080 50440 26 12416 6208 52 640 7760 485 8320 1261 40 320 10 80704 320 388 12416 64 1261 130 40 12610 1 6208 1552 2522 1261 161408 ...
output:
388 100880 6208 6208 8 776 2522 3104 194 1 4 16 20176 97 776 7760 16 2522 97 2 40352 16 7760 5044 20176 388 6208 16 2522 807040 403520 403520 8 807040 1552 97 100880 2 4 2522 100880 10088 16 388 6208 2 100880 -1 1 -1 2 3104 8 807040 8 776 5044 8 8 1 2 -1 807040 3104 1 1 6208 194 1552 -1 807040 10088...
result:
ok 200000 lines
Test #21:
score: 20
Accepted
time: 326ms
memory: 69076kb
input:
4 200000 200000 200000 154 6240 2184 240 1232 546 24024 960960 160160 6006 20020 29120 1092 6 840 1232 66 546 43680 80 1120 1456 8 2640 9152 1716 16 208 13728 40040 2496 4576 64 33 858 16 36960 770 2860 1144 520 27456 616 715 6864 6006 80080 3120 84 14560 2912 143 3432 6006 429 68640 120 140 3640 33...
output:
1 616 26 8008 308 2 308 16 4 2 616 960960 4004 8 8 5720 88 960960 5720 104 5720 96096 52 96096 52 88 8008 52 308 4004 26 40040 308 26 40040 616 4 32032 26 26 26 104 52 616 16 32032 1 960960 1 8008 1 4004 52 2 2 8 308 308 96096 1 1 960960 -1 1 96096 104 308 88 96096 308 1 1 1 1 4 2 8008 1 1 1 -1 1 57...
result:
ok 200000 lines
Test #22:
score: 20
Accepted
time: 384ms
memory: 69052kb
input:
4 200000 200000 200000 10 468 4320 560 910 936 4032 144 4914 2520 3 1680 3120 468 45 36 624 585 78 312 2340 432 4368 104 78624 8640 1456 40 2520 180 2496 6552 5460 64 4032 5 4095 28 8736 32 756 520 540 468 840 30240 54 364 312 28 21840 945 4095 3024 5040 840 18720 160 5 192 840 36 48 16380 16 1008 1...
output:
8190 4680 1 12 393120 52 624 624 13 504 2016 1092 10080 156 26 52 786240 624 2016 4680 39312 786240 12 312 8190 156 52 2 6 26 4680 10080 3 624 4 6 156 4 39312 624 252 393120 252 1092 2 3 156 52 2184 13 56160 56160 52 13 1 1 52 504 6 504 -1 2 624 10080 -1 393120 1 -1 8190 2184 56160 52 1 10080 624 46...
result:
ok 200000 lines
Test #23:
score: 20
Accepted
time: 277ms
memory: 76528kb
input:
4 200000 200000 200000 120 65 39 28 3360 480 4290 12 60 1001 1430 13728 1560 320320 40 2112 80080 10560 220 858 27456 120120 1092 4576 5824 1456 4 448 18480 192 88 840 80080 29120 2912 624 2496 24024 68640 77 12012 1155 176 192 5824 48 60 1 960960 66 17160 64 770 22 9152 65 60060 84 260 6 560 3080 4...
output:
16016 8008 1 8 480480 20 2002 2002 8 440 2002 2002 34320 56 11 26 960960 2002 2002 8008 45760 960960 8 440 16016 364 26 1 4 11 8008 34320 2 2002 2 4 364 2 45760 2002 364 480480 364 2002 1 2 91 20 8008 8 80080 80080 52 8 1 1 20 440 4 440 1 2 2002 34320 1 480480 1 1 16016 8008 80080 20 1 34320 2002 80...
result:
ok 200000 lines
Test #24:
score: 20
Accepted
time: 252ms
memory: 94992kb
input:
4 200000 200000 200000 612 238 6160 176 1 235620 11 238 8415 154 18 1008 10 119 264 1870 528 112 7 20 20 1386 60 8568 154 8976 2040 80 33660 136 9 7480 2805 476 770 765 990 560 102 2520 5236 1540 6120 20 8415 104720 28 52360 157080 78540 765 3080 134640 561 68 51 14280 10710 280 1848 68 14280 51 314...
output:
7854 748 1 2 157080 11 374 374 2 374 561 561 7854 34 6 17 942480 374 561 748 26180 942480 2 308 7854 34 17 1 2 6 748 7854 1 374 1 2 34 1 26180 374 44 157080 44 561 1 1 34 11 748 2 26180 26180 17 2 1 1 11 374 2 374 1 1 374 7854 1 157080 1 1 7854 748 26180 11 1 7854 374 748 1 1 1 1 1 26180 1 1 7854 94...
result:
ok 200000 lines
Subtask #5:
score: 20
Accepted
Dependency #2:
100%
Accepted
Test #25:
score: 20
Accepted
time: 58ms
memory: 62132kb
input:
5 91 110 200000 80080 11440 2145 176 55 11440 4576 2080 4928 3120 1 715 1120 176 192192 440 2145 12480 12012 455 34320 91 39 840 672 2288 231 160 480480 672 15 5824 308 130 240 364 84 2464 110 24640 224 364 165 1155 30 6160 10010 2912 520 60 9240 960960 1716 910 140 4290 66 130 26 2002 2640 312 1848...
output:
28 13 4 16 154 572 4 34320 13 77 1 16 77 2 22 34320 77 77 572 2 154 22 308 16 308 308 -1 77 16 2 308 28 77 77 11 -1 308 4 22 22 572 4 13 77 -1 77 2 572 -1 -1 34320 154 572 -1 16 1 -1 77 1 -1 4 -1 13 -1 -1 16 13 77 -1 77 16 -1 77 -1 -1 -1 28 -1 -1 77 -1 -1 572 77 -1 77 4 -1 77 22 16 -1 -1 154 -1 16 -...
result:
ok 200000 lines
Test #26:
score: 20
Accepted
time: 56ms
memory: 58428kb
input:
5 92 110 200000 201760 52 12610 520 80 5 640 5044 2522 640 832 40352 3880 201760 832 194 7760 31040 2080 201760 26 20 20 776 97 25220 160 104 25220 50440 2 40352 10088 12416 25220 1664 260 4 100880 403520 104 52 130 8320 5044 40352 80704 1552 208 1040 807040 130 2080 130 97 5044 8320 6305 40 388 26 ...
output:
201760 20 26 2 260 4 1 13 260 2 2522 26 4 13 20 26 388 388 260 194 2522 52 194 201760 20 4 13 26 52 2 -1 1 201760 388 -1 20 -1 201760 -1 260 194 -1 20 260 2522 26 -1 2 -1 -1 4 26 20 194 2 -1 -1 -1 201760 -1 260 20 1 -1 -1 -1 -1 2 -1 -1 260 201760 201760 388 -1 4 4 194 13 -1 -1 260 1 26 -1 13 194 194...
result:
ok 200000 lines
Test #27:
score: 20
Accepted
time: 63ms
memory: 59848kb
input:
5 95 110 200000 6240 35 3120 1008 5616 2340 60480 72 6720 936 11232 288 156 195 2880 2496 288 36 1248 28080 3744 8 32 1755 65 6552 3780 168 416 6240 104 11232 11232 48 157248 112320 416 8640 45 540 2496 780 6 13104 21840 5616 30240 10080 18720 13 280 4680 6048 112 393120 5824 21840 135 45 2016 39 15...
output:
156 156 312 156 156 4 624 624 3744 112320 12 52 4 6 112320 1 13 1248 3744 12 1248 6 624 4 4 312 -1 624 -1 112320 -1 12 -1 3744 156 3744 156 156 -1 -1 -1 1248 2 -1 12 624 -1 6 112320 -1 1248 -1 156 -1 -1 624 -1 156 -1 156 -1 -1 12 1 1 1 1248 312 3744 -1 1 312 156 -1 -1 112320 156 3744 -1 -1 1248 156 ...
result:
ok 200000 lines
Test #28:
score: 20
Accepted
time: 57ms
memory: 59804kb
input:
5 92 110 200000 485 194 1664 80 12610 1940 32 640 1664 10 2522 97 1040 160 832 201760 8320 32 807040 320 5044 208 80704 26 16 485 6208 776 208 1552 10088 97 15520 1552 6208 52 3880 160 128 13 1664 7760 320 403520 320 20176 807040 40 416 15520 40352 1261 50440 1664 40 208 100880 12416 1940 8320 20 13...
output:
20176 52 104 52 13 8 10088 8 4 2 13 1261 1261 20176 1261 4 2 104 1 10088 1261 52 -1 -1 1261 8 -1 -1 4 20176 13 -1 -1 8 10088 104 -1 4 -1 -1 -1 52 8 -1 -1 104 4 -1 -1 52 4 1 13 2 -1 1261 1 -1 -1 -1 -1 -1 2 13 104 -1 -1 -1 52 -1 2 -1 -1 104 104 4 2 1 -1 4 1261 13 104 8 1 -1 -1 52 13 8 1 -1 4 20176 -1 ...
result:
ok 200000 lines
Test #29:
score: 20
Accepted
time: 66ms
memory: 55020kb
input:
5 94 110 200000 3 5 12 1 20 6 6 20 12 10 30 15 4 2 60 12 30 3 20 12 20 30 3 3 2 10 60 2 4 4 20 3 15 6 3 3 20 5 12 60 2 2 10 15 6 2 5 1 15 15 6 60 20 10 60 1 20 30 6 12 12 3 4 12 2 5 3 30 60 10 3 4 20 12 5 10 20 3 1 4 15 3 15 2 12 1 3 30 20 30 12 10 30 4 1 69 2 14 2 87 3 35 3 72 4 16 4 49 4 69 4 89 5...
output:
30 3 6 15 15 15 10 6 2 30 3 6 2 1 10 1 10 10 2 -1 6 6 -1 15 1 -1 -1 2 -1 3 6 15 -1 -1 -1 -1 2 30 -1 -1 6 -1 -1 15 10 15 -1 6 -1 1 10 15 -1 15 6 6 -1 3 1 -1 6 -1 -1 1 30 1 -1 10 1 -1 2 -1 1 -1 30 1 -1 1 2 2 30 30 -1 6 30 30 2 6 -1 15 1 15 3 1 1 15 2 3 3 6 2 -1 6 15 -1 -1 -1 6 3 -1 6 6 1 -1 3 10 10 -1...
result:
ok 200000 lines
Test #30:
score: 20
Accepted
time: 57ms
memory: 56944kb
input:
5 95 110 200000 10 2 20 4 2 20 5 4 2 2 4 5 10 4 4 5 4 1 4 2 20 20 20 2 10 10 5 10 1 4 10 1 10 20 1 20 20 4 5 5 5 5 5 20 20 20 10 5 1 2 1 5 4 1 1 10 4 10 1 1 20 20 1 10 20 10 5 4 20 5 20 5 10 1 20 2 20 4 1 1 1 4 1 10 20 20 4 5 5 2 2 5 10 1 1 1 2 2 3 3 4 4 5 4 11 4 13 5 6 5 11 6 7 7 8 8 9 9 10 9 12 10...
output:
10 2 2 10 1 20 10 20 1 -1 1 10 -1 2 20 1 10 -1 2 -1 2 20 2 2 2 -1 20 2 -1 -1 -1 1 -1 10 -1 1 2 -1 -1 -1 10 10 10 10 10 20 -1 -1 -1 10 20 -1 10 20 10 -1 20 -1 -1 20 1 -1 2 -1 -1 10 -1 -1 -1 -1 20 10 10 1 20 -1 -1 2 -1 -1 -1 2 -1 1 -1 -1 -1 1 20 1 20 -1 1 20 1 20 1 -1 -1 -1 20 1 -1 20 -1 10 -1 2 -1 -1...
result:
ok 200000 lines
Subtask #6:
score: 20
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Test #31:
score: 20
Accepted
time: 349ms
memory: 67792kb
input:
6 168316 200000 200000 166320 1344 1485 220 7560 432 1485 2016 88 420 1760 385 594 24640 20160 54 462 504 54 12 13860 1320 18 2160 35 840 2772 24640 110 594 7920 704 231 95040 11 28 9504 6048 30 665280 616 693 665280 1232 95040 64 9 4 1386 10395 108 864 166320 576 22 720 40 176 396 960 4032 2016 224...
output:
132 166320 44 308 2 27720 6 18480 3 48 2 231 12 665280 24 462 665280 24 1848 1848 462 2772 96 24 308 1848 3 5544 96 1 308 132 16 1848 27720 462 12 18480 24 5544 166320 1848 166320 1848 166320 1848 16 4 462 6 4 5544 4 1848 18480 -1 18480 -1 1 665280 1848 1 1 5544 2 -1 96 1 5544 1848 16 132 12 132 2 9...
result:
ok 200000 lines
Test #32:
score: 20
Accepted
time: 146ms
memory: 66752kb
input:
6 168547 200000 200000 12 15 10 4 10 15 4 15 6 1 6 2 2 15 15 5 20 30 2 30 6 15 1 5 5 1 15 12 30 6 6 4 30 15 3 5 15 10 12 4 20 2 12 2 2 60 15 10 20 10 20 10 20 15 30 10 1 3 1 2 60 5 20 10 2 30 2 5 12 10 1 60 3 6 2 3 15 12 30 30 10 20 20 60 12 12 2 1 6 15 30 2 15 15 2 12 15 5 30 1 5 2 1 3 3 60 60 3 12...
output:
30 20 10 10 2 5 60 15 60 30 2 20 1 15 5 10 60 10 -1 1 30 30 1 1 5 1 1 30 20 60 15 20 15 60 2 10 30 1 2 2 60 60 2 1 -1 20 1 20 -1 -1 10 1 60 1 1 10 60 1 2 30 60 1 1 -1 -1 1 30 1 2 1 1 1 30 1 30 15 60 -1 30 -1 5 5 1 5 60 20 30 10 10 30 15 1 15 60 1 10 15 1 15 1 20 10 1 2 1 15 1 1 5 1 1 1 2 60 1 20 30 ...
result:
ok 200000 lines
Test #33:
score: 20
Accepted
time: 246ms
memory: 72812kb
input:
6 168436 200000 200000 32 40 161408 62080 5044 832 128 16 485 4 104 416 16 15520 10 10088 3104 65 320 32 4160 80704 64 10088 50440 388 2080 31040 80 3104 25220 260 640 201760 130 62080 201760 388 12610 80 12416 520 2 50440 4 64 5 10 1040 7760 80704 80 32 201760 260 1040 65 4 160 65 62080 13 1552 403...
output:
40352 40352 50440 25220 388 388 80704 8 201760 10088 2 1261 201760 1261 97 13 10088 201760 807040 388 388 5044 807040 776 40352 100880 1552 20176 100880 5044 8 97 388 13 4 50440 10088 807040 1 25220 1261 4 2 807040 1552 4 -1 388 5044 388 201760 5044 1261 13 4 1 807040 388 807040 97 1 8 10088 1 80704...
result:
ok 200000 lines
Test #34:
score: 20
Accepted
time: 315ms
memory: 67192kb
input:
6 168292 200000 200000 24 80 910 240240 105 4290 2080 12480 43680 3 1820 6240 88 137280 80 60060 2640 6160 137280 143 220 7392 352 96096 8736 224 14 480480 4160 8008 2002 42 5460 4368 572 1760 77 2 528 9240 52 15 420 87360 18480 10010 704 160160 8008 480 2310 20020 273 56 672 43680 160160 33 6160 21...
output:
182 60060 11 110 22 22 182 22 14560 52 320320 1040 60060 960960 44 960960 65 8 320320 8 4 320320 572 286 572 4 182 16 8 3640 14560 3640 7280 2 3640 182 44 2 65 52 182 320320 3640 7280 14560 1 52 1 -1 8 1040 1 1 2 572 1 52 2 1040 65 1 60060 1 7280 8 4 2 -1 182 7280 22 8 2 1 320320 1 3640 960960 60060...
result:
ok 200000 lines
Test #35:
score: 20
Accepted
time: 350ms
memory: 70352kb
input:
6 168446 200000 200000 20 576 4320 216 30 1456 60 27 4160 39 210 52 728 7020 27 182 480 9828 9 9 91 29120 234 36 196560 4 320 40 180 4032 7020 936 448 240 1560 210 1728 30 3276 2160 39312 24570 5 1638 448 288 1755 252 8640 630 6240 6 630 182 5616 156 54 936 624 2080 960 108 4095 2808 9828 16380 4368...
output:
234 13104 3 4 234 52 15 2 234 4 13104 3276 80 26 13104 84 234 7280 6 7280 3 13 13 144 1638 312 2 157248 786240 65520 80 24 80 6552 234 117 26 234 52 52 12 1 13104 3276 819 65520 234 65520 6 786240 1638 15 157248 117 12 117 7280 6552 819 52 65520 13 26 -1 786240 1 117 80 65520 1 13104 1 1 786240 117 ...
result:
ok 200000 lines
Test #36:
score: 20
Accepted
time: 320ms
memory: 69236kb
input:
0 168269 200000 200000 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1...
output:
100 100 -1 100 100 100 -1 100 100 -1 -1 100 100 100 100 100 100 100 100 100 100 100 -1 100 100 100 100 100 100 100 100 100 100 -1 100 100 100 -1 -1 -1 100 100 100 100 100 100 100 100 100 100 100 100 100 -1 100 100 100 100 100 100 100 100 100 100 100 100 100 -1 100 100 -1 100 100 100 100 -1 -1 100 -1...
result:
ok 200000 lines
Test #37:
score: 20
Accepted
time: 126ms
memory: 72460kb
input:
6 168312 200000 200000 130390 55445 73556 100828 5662 81004 101258 110397 16734 113958 43256 94307 65250 118040 159385 14626 126526 83632 70785 143888 97805 33411 158386 71702 99026 71327 150975 105390 74071 80436 3372 111140 86172 60902 79835 2335 118974 130282 120429 159617 82957 55956 32711 16057...
output:
4 10 75 153 107542 2 153 7 107542 75 7 75 16 75 153 5 8 6 2 75 16 7 1 3 765 765 2 6 107542 107542 5 1 1 -1 75 1 765 75 75 153 1 16 8 7 1 2 -1 1 75 75 -1 7 1 1 75 1 -1 1 -1 4 1 75 -1 1 6 16 7 1 8 16 1 1 8 1 1 10 5 16 6 1 75 765 16 75 7 1 107542 7 2 7 1 1 107542 3 2 7 4 4 2 153 153 8 16 2 153 1 -1 107...
result:
ok 200000 lines