QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#862209#9677. 基础博弈练习题Nesraychan65 722ms264720kbC++143.3kb2025-01-18 22:59:142025-01-18 22:59:15

Judging History

你现在查看的是最新测评结果

  • [2025-01-18 22:59:15]
  • 评测
  • 测评结果:65
  • 用时:722ms
  • 内存:264720kb
  • [2025-01-18 22:59:14]
  • 提交

answer

#include<bits/stdc++.h>
#define IL inline
#define reg register
#define N 1000100
IL int read()
{
    reg int x=0,f=0; reg char ch=getchar();
    while(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return f?-x:x;
}

int n,m,k,a[N],b[N],mn[N];
std::vector<int>G[N],vec[N];

IL void add(reg int u,reg int v){G[u].push_back(v);}

int f[N],g[N],dfn[N],low[N],dfc,s[N],top;
bool vis[N];

IL void cmin(reg int &x,reg int y){x>y?x=y:0;}
IL int min(reg int x,reg int y){return x<y?x:y;}

int cnt,sz[N],blo[N],w[N];

void tarjan(reg int u)
{
    dfn[u]=low[u]=++dfc,vis[s[++top]=u]=1;
    for(auto v:G[u])
        if(!dfn[v])tarjan(v),cmin(low[u],low[v]);
        else if(vis[v])cmin(low[u],dfn[v]);
    if(dfn[u]==low[u])
    {
        ++cnt,w[cnt]=g[cnt]=k+1;
        reg int v;
        do
        {
            v=s[top--],blo[v]=cnt,vis[v]=0;
            ++sz[cnt],cmin(w[cnt],mn[a[v]]);
        }while(u!=v);
    }
}

int deg[N];
std::vector<int>E[N],IE[N],shelf[N];

IL void add2(reg int u,reg int v){E[u].push_back(v),IE[v].push_back(u),++deg[v];}

bool dp[N],coef[N],done[N];

IL bool query(reg int u)
{
    bool res=coef[u];
    if(!done[u])res^=dp[u];
    return res;
}

main()
{
    n=read(),m=read(),k=read();
    for(reg int i=1;i<=n;++i)a[i]=read();
    for(reg int i=1;i<=k;++i)b[i]=read();
    for(reg int i=1,x,y;i<=m;++i)
        x=read(),y=read(),add(x,y);
    for(reg int i=1;i<=n;++i)vec[a[i]].push_back(i);
    for(reg int i=1;i<=n;++i)mn[i]=k+1;
    for(reg int i=1;i<=k;++i)cmin(mn[b[i]],i);
    for(reg int i=1;i<=n;++i)if(!dfn[i])tarjan(i);
    for(reg int u=1;u<=n;++u)for(auto v:G[u])
        if(blo[u]!=blo[v])add2(blo[v],blo[u]);
    std::queue<int>q;
    for(reg int i=1;i<=cnt;++i)if(!deg[i])q.push(i);
    while(!q.empty())
    {
        reg int u=q.front(); q.pop();
        f[u]=min(g[u],w[u]);
        for(auto v:E[u])
        {
            cmin(g[v],f[u]);
            if(!--deg[v])q.push(v);
        }
    }
    for(reg int i=1;i<=n;++i)shelf[blo[i]].push_back(a[i]);
    for(reg int i=1,j;i<=cnt;++i)
    {
        static bool exist[N];
        for(auto x:shelf[i])exist[x]=1;
        bool ok=1;
        for(j=f[i];j<g[i];++j)
        {
            if(!exist[j])
            {
                ok=0;
                break;
            }
            coef[i]^=1;
        }
        if(sz[i]==1)ok&=f[i]==g[i],coef[i]=0;
        if(!ok)done[i]=1;
        for(auto x:shelf[i])exist[x]=0;
    }
    // for(reg int i=1;i<=n;++i)
    //     printf("[%d, %d]\n",f[blo[i]],g[blo[i]]);
    for(reg int i=1,u;i<=cnt;++i)
    {
        u=i;
        if(g[u]>=k)
        {
            dp[u]=g[u]==k;
            continue;
        }
        for(auto v:IE[u])
            if(g[v]==g[u])dp[u]|=dp[v];
            else if(f[v]==g[u])
            {
                if(sz[v]>1)dp[u]|=query(v);
                else dp[u]|=g[v]>f[v]+1||!dp[v];
            }
    }
    for(reg int i=1,x,w;i<=n;++i)
    {
        x=blo[i];
        if(sz[x]>1)
        {
            if(query(x))w=f[x];
            else w=f[x]+1;    
        }else
        {
            if(dp[x])w=g[x];
            else w=g[x]+1;
        }        
        printf("%d%c",w>k?-1:w-1," \n"[i==n]);
    }
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 16ms
memory: 138980kb

input:

83 93 13
8 9 10 7 7 7 6 3 1 10 6 2 5 7 1 3 4 2 1 10 7 4 8 9 2 2 1 9 2 5 1 7 8 6 1 9 9 10 4 1 2 9 2 3 4 2 9 10 8 1 4 1 8 4 1 4 4 7 4 8 2 9 2 5 2 2 3 3 8 5 2 9 3 10 8 8 1 6 6 1 6 7 10
7 5 10 3 2 2 7 4 8 7 6 6 5
56 36
33 41
32 62
37 7
6 53
41 13
9 36
44 77
38 62
76 16
72 5
40 13
55 60
5 78
72 45
13 44
...

output:

0 -1 -1 -1 2 0 -1 7 0 -1 3 -1 0 0 1 -1 0 -1 0 0 -1 0 -1 2 -1 -1 -1 -1 -1 -1 0 0 0 -1 0 -1 3 0 0 0 0 0 -1 -1 -1 -1 0 0 0 -1 0 0 3 0 0 0 -1 -1 3 -1 0 0 0 0 0 8 -1 -1 1 -1 -1 0 3 4 -1 3 -1 3 -1 0 0 0 -1

result:

ok 83 numbers

Test #2:

score: 10
Accepted
time: 12ms
memory: 143192kb

input:

95 33 40
1 1 1 1 3 3 1 1 2 1 1 2 3 3 2 2 2 1 2 3 1 2 1 2 2 1 2 2 3 3 1 1 2 3 1 2 1 3 2 1 1 1 3 2 1 1 1 2 3 2 3 1 1 3 2 3 1 2 1 3 1 2 1 1 1 1 2 1 2 3 1 1 3 3 2 1 3 3 3 1 2 3 1 2 2 1 3 2 1 1 1 2 2 3 1
2 2 3 1 3 3 2 3 3 2 2 2 2 1 1 1 1 2 1 1 1 1 1 2 3 1 3 2 2 3 1 3 3 1 2 2 3 2 1 3
11 95
57 80
22 89
56 ...

output:

2 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 3 -1 -1 -1 -1 -1 -1 -1 3 -1 3 -1 -1 0 -1 3 3 -1 0 0 -1 2 -1 -1 0 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 0 -1 -1 2 -1 -1 -1 3 3 -1 -1 -1 0 -1 -1 -1 -1 3 -1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 -1 3 0 -1 -1 -1 -1 2 -1 0 0

result:

ok 95 numbers

Test #3:

score: 10
Accepted
time: 16ms
memory: 139108kb

input:

94 34 89
20 7 5 8 18 12 5 15 19 1 15 7 5 6 14 19 9 19 11 11 16 20 17 5 12 8 14 2 10 19 10 1 1 6 19 18 9 14 19 16 1 6 8 10 18 8 1 17 3 9 17 9 1 16 9 15 1 15 20 10 6 14 11 9 5 18 14 20 13 18 13 18 8 1 1 8 10 5 14 5 8 16 1 14 9 7 3 20 9 20 18 17 11 18
14 2 20 16 9 12 9 4 15 4 9 20 16 18 20 7 18 19 15 5...

output:

-1 19 -1 -1 -1 -1 -1 13 -1 -1 17 -1 -1 -1 26 -1 -1 2 -1 13 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 33 2 -1 33 -1 -1 42 -1 -1 -1 -1 2 -1 -1 39 -1 -1 33 8 -1 -1 -1 -1 -1 -1 19 -1 -1 -1 4 15 1 -1 26 61 4 -1 -1 2 -1 -1 3 13 -1 13 -1 -1 -1 -1 -1 0 -1 -1 -1 8 -1 -1 61 -1 -1 2 -1 -1

result:

ok 94 numbers

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #4:

score: 0
Wrong Answer
time: 16ms
memory: 141252kb

input:

2498 1795 2498
63 29 161 58 131 5 165 91 155 175 6 60 113 130 5 114 127 138 143 161 1 53 6 168 21 7 120 88 141 2 126 117 128 156 140 3 138 66 102 77 23 58 1 53 167 64 84 9 65 4 39 162 155 140 137 139 159 140 150 149 69 85 22 102 2 35 87 89 171 162 18 93 151 22 96 98 98 101 51 108 10 98 59 87 65 94 7...

output:

-1 -1 1600 -1 -1 0 1599 -1 -1 -1 1 -1 -1 -1 1 -1 1200 -1 -1 -1 0 -1 -1 1599 -1 0 -1 -1 -1 -1 1200 -1 -1 -1 1299 0 1299 -1 -1 -1 200 499 0 499 -1 -1 -1 -1 -1 -1 -1 -1 -1 1299 1299 -1 -1 -1 -1 1400 600 -1 -1 -1 -1 300 -1 -1 -1 -1 -1 900 -1 -1 900 -1 899 -1 -1 999 1 -1 -1 -1 -1 -1 -1 899 -1 -1 -1 1699 ...

result:

wrong answer 3rd numbers differ - expected: '1599', found: '1600'

Subtask #3:

score: 30
Accepted

Test #6:

score: 30
Accepted
time: 74ms
memory: 160516kb

input:

100000 355071 10000
5 7 4 7 4 1 10 5 9 4 9 4 3 10 5 4 9 1 7 10 1 6 10 3 10 9 8 4 6 3 10 8 6 8 3 5 10 9 7 7 1 3 8 8 6 2 8 4 2 9 1 10 3 6 3 8 9 10 5 7 3 2 1 5 7 4 3 4 6 4 2 7 2 5 5 6 4 6 7 4 4 6 4 2 3 9 9 9 10 8 1 6 7 2 9 8 2 3 1 6 9 4 10 3 10 1 2 3 3 4 1 1 1 5 8 6 8 3 1 6 2 9 5 9 4 7 2 10 7 5 2 2 7 4...

output:

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 0 0 0 0 0 0 0 ...

result:

ok 100000 numbers

Test #7:

score: 30
Accepted
time: 78ms
memory: 158428kb

input:

100000 300561 10000
6 3 6 10 10 9 7 3 6 4 5 4 1 2 3 2 10 6 3 7 8 7 10 5 9 10 2 3 9 5 6 10 9 1 4 9 1 10 7 2 9 10 5 5 9 3 5 5 5 9 9 5 1 7 5 10 8 6 8 4 5 9 2 10 1 6 4 10 10 9 2 1 10 1 9 5 3 2 9 3 4 8 10 7 5 2 4 5 3 6 9 7 5 10 2 7 4 7 10 8 1 7 7 1 7 7 6 6 7 1 5 4 6 2 1 8 6 10 6 10 1 5 8 4 6 2 10 6 10 4 ...

output:

0 4 0 0 3 0 0 4 0 0 0 0 0 0 0 0 0 0 1 0 0 1 7 0 1 2 0 0 0 0 4 0 0 1 0 0 0 2 0 0 0 3 0 0 1 0 0 0 3 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 1 0 9 0 0 0 2 0 3 1 0 2 1 0 0 0 2 0 0 0 0 0 0 3 0 0 0 0 0 2 2 0 0 1 0 0 0 0 0 1 0 0 1 0 2 0 6 0 0 1 5 0 0 3 0 0 1 2 0 2 3 0 0 2 0 1 1 9 0 2 5 2 0 2 1 3 1 6 4 0 0 1 0 2 1 0 ...

result:

ok 100000 numbers

Test #8:

score: 30
Accepted
time: 363ms
memory: 232376kb

input:

500000 1770902 50000
4 7 2 3 6 10 8 2 2 6 2 3 3 7 3 1 5 2 1 10 2 6 3 4 2 8 10 6 6 10 9 3 3 2 9 10 4 5 3 9 7 10 4 3 6 6 4 9 4 4 4 1 9 5 6 10 3 7 5 8 10 1 6 5 1 7 9 10 2 4 6 9 6 2 2 8 4 7 9 1 9 4 6 4 6 3 9 2 2 1 1 1 8 3 10 10 2 2 5 15 20 18 17 15 12 11 11 11 11 12 13 19 18 20 15 11 11 20 10 14 13 14 1...

output:

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 1 0 0 0 0 4 1 1 1 4 1 10 1 1 1 4 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 -1 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

result:

ok 500000 numbers

Test #9:

score: 30
Accepted
time: 209ms
memory: 155980kb

input:

97492 1048555 7389
3662 9323 1040 3729 5469 2246 9668 8976 7059 3356 2928 638 8679 8067 7459 7820 7524 5287 9991 8218 1963 9730 4843 3911 8841 987 2108 5432 4594 7413 4805 9028 6812 8545 6618 2392 2003 2419 8568 9431 4910 3742 5678 1695 3643 1968 1937 4035 3765 6112 2186 1437 1768 5453 9988 1241 436...

output:

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 0 0 0 0 0 0 0 ...

result:

ok 97492 numbers

Test #10:

score: 30
Accepted
time: 142ms
memory: 161760kb

input:

278730 379825 208278
46 449 419 234 290 507 414 36 414 89 394 404 514 442 280 337 13 108 345 4 166 153 434 250 506 416 243 78 523 332 368 81 335 393 366 18 154 2 133 312 313 203 140 388 481 244 193 506 238 503 303 83 174 516 441 8 274 414 508 111 521 118 487 271 232 77 433 395 350 84 518 322 324 328...

output:

-1 454 -1 -1 -1 -1 -1 43 -1 -1 -1 -1 -1 -1 -1 341 -1 -1 418 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 304 -1 -1 470 397 -1 -1 -1 -1 -1 -1 -1 -1 -1 402 -1 -1 -1 -1 334 -1 -1 125 -1 -1 237 -1 -1 -1 -1 -1 363 325 -1 -1 -1 -1 -1 -1 -1 -1 91 -1 -1 -1 -1 -1 13 388 14 -1 -1 -1 -1 211 489 -...

result:

ok 278730 numbers

Test #11:

score: 30
Accepted
time: 144ms
memory: 176572kb

input:

342520 350951 72468
2854 2272 1901 7008 4269 7420 3024 4556 4543 2393 2485 3361 521 4015 2013 5423 6441 6009 6164 6835 4488 6277 5740 3206 3586 195 3964 6529 1540 914 3244 452 443 4278 4282 2131 4928 6052 2114 422 6680 6237 4688 6557 1515 6755 2257 664 2042 155 5154 6579 5787 5200 5712 1412 137 6432...

output:

-1 -1 -1 -1 -1 -1 6403 -1 -1 -1 -1 -1 4542 179 -1 5422 -1 -1 -1 -1 -1 5329 -1 4757 -1 -1 3965 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5600 2114 -1 -1 -1 -1 10 -1 -1 -1 28 -1 -1 -1 6586 -1 -1 465 -1 136 -1 -1 -1 -1 -1 3270 -1 -1 -1 -1 -1 5652 2289 -1 945 -1 -1 4002 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

result:

ok 342520 numbers

Subtask #4:

score: 25
Accepted

Dependency #3:

100%
Accepted

Test #12:

score: 25
Accepted
time: 647ms
memory: 255308kb

input:

870330 2060994 532990
11323 4959 13769 991 8623 5067 7946 7895 9068 10896 11853 6110 12738 242 9527 3290 8548 1823 11423 7291 6365 1331 13788 3557 11342 10901 12459 3346 9618 9474 11803 12573 10613 1126 4207 9059 7482 4666 5681 12028 488 4561 6622 6914 2092 496 13914 2722 12104 5906 8540 13295 654 6...

output:

1392 -1 -1 -1 -1 3363 566 -1 -1 -1 -1 -1 -1 -1 2807 -1 -1 -1 82 -1 -1 288 3748 3558 -1 10906 4465 -1 -1 -1 -1 6866 -1 690 -1 -1 -1 11931 791 12036 -1 -1 2421 -1 -1 -1 13920 2726 -1 -1 -1 -1 654 2924 -1 502 -1 7892 -1 -1 -1 3326 -1 -1 946 3908 -1 7997 67 -1 2834 13009 2425 4236 -1 -1 -1 485 -1 -1 202...

result:

ok 870330 numbers

Test #13:

score: 25
Accepted
time: 722ms
memory: 264720kb

input:

870330 1956977 532990
567991 12393 289749 575569 36051 159787 366266 101759 291866 508726 5601 118882 51060 276478 459815 279898 470674 225317 205543 456379 302525 19147 30212 38405 270446 38331 464221 249144 210642 15456 363477 303627 400735 82588 525861 331335 360248 126756 307541 297520 35856 440...

output:

462174 -1 -1 -1 -1 76078 49475 -1 -1 -1 -1 -1 -1 -1 353781 -1 -1 -1 211981 -1 -1 77005 59283 60889 -1 -1 22047 -1 -1 -1 -1 465752 -1 82591 -1 -1 -1 462713 12764 386717 -1 -1 35714 -1 -1 -1 25134 48777 -1 -1 -1 -1 424454 138004 -1 3452 -1 305570 -1 -1 -1 243125 -1 -1 10380 218621 -1 441596 262770 -1 ...

result:

ok 870330 numbers

Test #14:

score: 25
Accepted
time: 234ms
memory: 187016kb

input:

384204 780340 113841
9679 4728 7414 2977 4704 4784 8117 8549 8336 2540 8549 413 7588 1090 8730 1250 3372 7804 428 4754 2922 9590 833 9372 2329 1389 2901 667 4530 1898 4456 7149 4070 9043 4459 9405 9214 2839 8720 4194 1634 8228 374 1242 5556 5618 5466 2728 6803 460 7170 8385 1429 6301 7588 3249 3815 ...

output:

0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 4692 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 -1 478 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 0 -1 0 0 644 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 -1 0 0 -1 0 -1 0 0 0 3830 -1 -1 0 0 1545 0 469 6541 0 0 0 0 ...

result:

ok 384204 numbers

Test #15:

score: 25
Accepted
time: 245ms
memory: 185876kb

input:

365190 1545625 27765
201 62 266 230 212 421 87 385 307 384 104 212 34 376 172 417 125 15 330 106 181 331 115 91 179 274 244 169 352 302 63 37 390 290 33 44 8 259 307 41 242 413 269 20 255 430 270 154 276 243 3 427 179 239 260 80 63 73 415 36 17 423 74 307 278 410 307 422 119 41 244 309 60 305 241 28...

output:

199 59 259 219 209 419 79 380 299 380 99 209 29 369 169 411 119 9 319 99 179 329 109 89 169 269 239 159 349 299 59 29 380 289 29 39 0 249 299 39 239 409 259 9 249 419 259 149 269 239 0 419 169 229 249 79 59 70 409 29 9 419 70 299 269 399 299 419 109 39 239 299 49 299 239 269 9 329 209 409 229 380 9 ...

result:

ok 365190 numbers

Test #16:

score: 25
Accepted
time: 304ms
memory: 189892kb

input:

499384 1695273 37581
6262 9612 4764 3368 7152 495 3345 5034 9080 3000 8302 2703 4776 820 6046 8305 5846 5826 9753 3375 1063 4250 8307 5197 6858 6920 7930 1816 1314 6277 4484 3491 4992 8303 4161 8124 16 6272 3213 991 124 6520 8574 4501 3496 3224 6439 3498 4800 1849 8119 2431 6926 9800 5902 1993 6860 ...

output:

6259 9609 4759 3359 7149 490 3341 5029 9069 2989 8299 2709 4769 820 6040 8299 5839 5819 9749 3369 1059 4239 8299 5189 6849 6919 7919 1809 1309 6269 4480 3489 4990 8299 4160 8119 9 6269 3209 989 119 6519 8569 4499 3489 3219 6429 3489 4789 1839 8109 2429 6919 9799 5899 1990 6849 8299 1439 4619 6609 15...

result:

ok 499384 numbers

Test #17:

score: 25
Accepted
time: 194ms
memory: 176516kb

input:

365782 865315 250439
196 1933 252 1701 291 1054 1492 1438 1394 231 1253 1434 343 590 293 2018 1435 61 1885 1871 1530 540 472 400 537 2078 1380 1439 1434 345 1536 1198 1700 1278 1582 972 1394 289 960 358 879 346 548 1391 758 1484 330 535 1686 106 892 97 1289 19 1705 894 1039 1939 208 1568 837 424 176...

output:

0 0 0 1700 290 716 1491 1431 0 113 1251 1431 78 0 0 0 1431 61 0 1871 1521 531 471 391 531 2071 1370 1431 0 78 1152 1190 0 1271 -1 971 0 281 -1 353 871 78 -1 0 0 1481 321 531 350 0 891 0 1287 11 1701 891 1030 0 50 0 831 0 1761 -1 891 2011 1251 1431 131 0 0 78 1471 0 70 0 -1 0 1141 331 1481 1291 0 132...

result:

ok 365782 numbers

Test #18:

score: 25
Accepted
time: 187ms
memory: 174032kb

input:

356923 844784 103206
564 1225 1625 234 943 927 103 736 395 1175 1479 1223 1288 897 438 843 849 1454 1010 1405 1557 810 1637 933 40 777 48 215 1637 474 778 914 1642 220 1748 1543 123 567 313 1082 1227 1204 1225 1187 1824 752 1495 1131 400 964 1731 395 565 1628 923 1733 923 1228 1814 1006 1601 703 428...

output:

1 548 0 231 1 1 101 1 114 1170 1471 548 1 891 431 0 0 172 1001 1402 1551 801 1631 382 31 0 44 211 1631 9 0 0 1641 211 9 595 0 562 0 1081 548 969 548 1181 0 751 1 1131 114 9 -1 114 564 416 1 453 737 548 1811 1001 1600 701 421 1001 1 692 0 572 425 0 1750 114 1 114 1 9 1 114 1 0 -1 891 9 1 116 1631 0 1...

result:

ok 356923 numbers

Test #19:

score: 25
Accepted
time: 179ms
memory: 174436kb

input:

336414 810389 293332
10227 7343 6279 7719 6440 450 9346 7451 8349 3008 9346 4185 1745 1742 6172 954 1743 6835 3556 1748 1123 1277 10053 5058 11895 4109 6833 9523 9607 3004 2253 9609 8249 4938 584 12353 2484 1750 4107 7014 12781 3141 1747 236 8328 7251 437 1747 1167 7470 6544 9342 11734 2671 9347 211...

output:

561 7342 4 3711 72 441 7854 1 8341 3001 7854 72 1741 1741 6171 4 1741 0 0 1741 4 0 8205 5051 50 4101 0 0 8089 3001 72 8089 8241 623 581 2367 72 1741 4 7011 12781 3140 1741 1 8320 5817 4 1741 1161 0 72 7854 11731 2671 7854 72 -1 4731 72 4 72 1741 0 72 0 70 8341 -1 6631 7451 8341 4 9561 0 1741 72 0 47...

result:

ok 336414 numbers

Test #20:

score: 25
Accepted
time: 209ms
memory: 179076kb

input:

499004 856729 100649
9406 11257 3675 2794 2913 7462 9410 10410 5930 345 8869 10227 9894 2197 3901 5616 2852 1064 922 855 9860 4640 8603 7123 4789 2792 6459 3915 2674 8282 1135 5659 7268 2059 3292 994 2796 885 6458 9354 5790 9250 5791 5654 4953 5574 2794 7999 10313 2371 6347 3380 9276 6750 429 2196 2...

output:

9399 11251 3669 2790 2909 7459 9399 10409 5929 339 8860 10219 9889 2189 3899 5609 2850 1059 919 849 9859 4631 8600 7119 4781 2790 6449 3909 2671 8280 1130 5650 7260 2049 3289 989 2790 880 6449 9349 5789 9249 5789 5650 4950 5569 2790 7990 10309 2380 6339 3369 9269 6749 419 2189 2339 9840 10320 459 83...

result:

ok 499004 numbers

Test #21:

score: 25
Accepted
time: 517ms
memory: 222424kb

input:

917020 1473999 371282
35102 66044 7718 71209 73294 61075 51351 62954 75225 4063 48355 65118 44585 63799 73291 18747 35025 77269 19279 1623 65832 12293 63458 76299 13760 43822 62194 14399 73034 49490 67244 48778 53072 76136 15496 11705 72251 50044 33949 57097 44295 16044 7296 58986 13065 30234 24644 ...

output:

35101 -1 7711 69040 73291 61071 51351 -1 -1 4061 48350 58938 -1 895 73291 -1 35022 77261 19271 1620 -1 23125 63451 -1 13751 58776 62191 14391 73030 49481 67244 -1 53071 76131 15491 11702 68045 -1 33945 39062 44291 -1 -1 58980 -1 30234 24641 58341 12911 67011 -1 49283 4061 261 49791 58341 47430 -1 59...

result:

ok 917020 numbers

Test #22:

score: 25
Accepted
time: 557ms
memory: 225084kb

input:

917020 1471400 189291
281189 95450 66044 154501 18242 128664 28993 264320 13763 16146 147154 67091 136024 225446 5248 232909 117048 122605 160063 222138 41737 135700 142104 210145 205458 226148 193527 78879 279000 107140 118401 198583 191387 260526 179639 49090 60485 135698 151963 25504 46862 108422...

output:

-1 95441 -1 -1 18241 128661 -1 169163 13761 16141 158452 67090 136021 -1 5241 -1 117041 122601 66 -1 41731 135691 142103 -1 -1 -1 -1 78871 -1 -1 -1 166805 -1 -1 16763 49126 60481 135691 151961 18768 -1 108421 -1 -1 -1 -1 13171 109051 -1 3727 177750 78591 -1 -1 -1 -1 -1 70189 -1 -1 -1 42894 -1 -1 113...

result:

ok 917020 numbers

Subtask #5:

score: 0
Wrong Answer

Dependency #4:

100%
Accepted

Test #23:

score: 25
Accepted
time: 269ms
memory: 188612kb

input:

468890 1505974 468890
8 5 5 11 2 3 1 4 4 9 9 10 10 8 1 2 11 7 6 10 1 10 10 4 7 8 8 1 11 8 7 3 10 8 6 9 7 7 10 8 6 9 6 10 5 8 6 2 11 4 9 9 5 5 6 9 9 9 3 10 10 10 7 4 7 1 6 5 8 10 4 11 1 11 7 4 1 5 10 4 1 4 1 10 5 6 1 2 4 9 1 4 6 2 5 6 1 6 1 5 2 5 7 10 8 1 3 11 2 2 7 7 2 3 1 7 8 5 6 9 4 3 9 2 6 8 8 7 ...

output:

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 0 0 0 0 0 0 0 ...

result:

ok 468890 numbers

Test #24:

score: 25
Accepted
time: 357ms
memory: 190448kb

input:

801595 1451256 801595
3 4 6 2 7 4 3 4 11 6 6 10 4 4 10 4 8 6 2 8 10 8 9 9 8 3 8 1 11 5 8 2 2 3 6 9 10 5 2 3 5 4 6 7 5 9 2 11 3 8 2 5 9 10 9 8 8 9 3 4 8 4 1 4 10 2 2 11 9 1 6 6 1 9 3 4 3 6 3 9 1 11 8 11 10 2 7 2 11 3 10 10 10 2 2 6 4 9 4 10 10 3 11 7 5 10 9 8 4 4 11 8 9 9 8 1 10 7 5 8 8 8 11 2 2 7 1 ...

output:

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 0 0 0 0 0 0 0 ...

result:

ok 801595 numbers

Test #25:

score: 0
Wrong Answer
time: 381ms
memory: 197124kb

input:

793127 1590080 793127
5 5 2 5 2 2 2 2 3 1 2 5 1 4 3 4 5 4 4 1 1 6 3 4 6 6 3 3 2 4 6 6 1 5 3 1 3 5 1 5 6 2 1 6 1 1 6 2 5 5 4 4 4 6 5 2 4 5 3 1 1 3 2 3 6 1 6 3 3 2 3 5 5 2 2 1 2 2 6 1 5 1 6 5 3 2 6 5 6 3 6 4 4 1 2 1 4 1 1 5 1 6 6 6 6 3 3 6 5 3 3 5 2 3 1 4 4 6 4 1 5 2 1 2 1 1 4 1 1 2 5 4 4 3 5 2 2 5 2 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

wrong answer 1st numbers differ - expected: '0', found: '1'