Submission #273959

# Submission time Handle Problem Language Result Execution time Memory
273959 2020-08-19T08:00:36 Z 최은수(#5105) Mountains and Valleys (CCO20_day1problem3) C++17
21 / 25
6146 ms 396616 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
struct max4
{
    int a,b,c,d;
    max4(){a=b=c=d=0;}
    inline void upd(int x)
    {
        if(x>a)
            d=c,c=b,b=a,a=x;
        else if(x>b)
            d=c,c=b,b=x;
        else if(x>c)
            d=c,c=x;
        else if(x>d)
            d=x;
        return;
    }
    inline int get()
    {
        return a;
    }
    inline int get(int x)
    {
        return x==a?b:a;
    }
    inline int get(int x,int y)
    {
        if(x<y)
            swap(x,y);
        return x==a?(y==b?c:b):(y==a?b:a);
    }
    inline int get(int x,int y,int z)
    {
        if(x<y)
            swap(x,y);
        if(x<z)
            swap(x,z);
        if(y<z)
            swap(y,z);
        return x==a?(y==b?(z==c?d:c):(z==b?c:b)):(y==a?(z==b?c:b):(z==a?b:a));
    }
};
vector<int>adj[500010];
int depth[500010];
void ddfs(int x,int p)
{
    depth[x]=depth[p]+1;
    for(int&t:adj[x])
        if(t!=p)
            ddfs(t,x);
    return;
}
int dep[500010];
int spa[500010][19];
inline int kpa(int x,int k)
{
    for(;k>0;k^=k&-k)
        x=spa[x][__builtin_ctz(k)];
    return x;
}
inline int lca(int x,int y)
{
    if(dep[x]>dep[y])
        x=kpa(x,dep[x]-dep[y]);
    else
        y=kpa(y,dep[y]-dep[x]);
    if(x==y)
        return x;
    for(int i=19;i-->0;)
        if(spa[x][i]!=spa[y][i])
            x=spa[x][i],y=spa[y][i];
    return spa[x][0];
}
max4 dp1[500010],dp2[500010];
max4 dp3[500010],dp4[500010];
void sdfs(int x,int p)
{
    spa[x][0]=p;
    for(int i=0;i<18;i++)
        spa[x][i+1]=spa[spa[x][i]][i];
    dep[x]=dep[p]+1;
    for(int&t:adj[x])
        if(t!=p)
            sdfs(t,x),dp1[x].upd(dp1[t].get()+1),
            dp2[x].upd(max(dp2[t].get(),dp1[t].get()+dp1[t].get(dp1[t].get())));
    dp3[x]=dp1[x];
    dp4[x]=dp2[x];
    return;
}
int child[500010][19];
int spd[500010][19];
int dpth(int x,int k)
{
    int ret=max({dp2[x].get(),dp1[x].get()+dp1[x].get(dp1[x].get())});
    bool chk=0;
    int y=x;
    while(k>0)
    {
        int i=__builtin_ctz(k);
        k^=k&-k;
        if(!chk)
        {
            chk=1;
            ret=max(ret,spd[x][i]);
            y=child[x][i];
            x=spa[x][i];
            continue;
        }
        {
            int fc1=dp1[y].get()+1;
            int fc2=max(dp2[y].get(),dp1[y].get()+dp1[y].get(dp1[y].get()));
            ret=max({ret,spd[x][i],dp2[x].get(fc2),
            dp1[x].get(fc1)+dp1[x].get(dp1[x].get(fc1),fc1)});
        }
        y=child[x][i];
        x=spa[x][i];
    }
    return ret;
}
int cm[500010][19];
pi cut[500010][19];
pair<pi,int>pth(int x,int k)
{
    pair<pi,int>ret;
    ret.fi.fi=ret.fi.se=dp1[x].get();
    int len=0;
    int y=x;
    while(k>0)
    {
        int i=__builtin_ctz(k);
        k^=k&-k;
        if(len==0)
        {
            len=1<<i;
            ret.se=max(cm[x][i],ret.fi.fi+cut[x][i].se);
            ret.fi.fi=max(ret.fi.fi,cut[x][i].fi);
            ret.fi.se=max(ret.fi.se+len,cut[x][i].se);
            y=child[x][i];
            x=spa[x][i];
            continue;
        }
        {
            pi c1=ret.fi;
            pi c2=cut[x][i];
            int cur=dp1[x].get(dp1[y].get()+1);
            ret.se=max({ret.se+(1<<i),cm[x][i]+len,
            c1.fi+c2.se,c1.fi+cur+(1<<i),c2.se+cur+len});
            ret.fi.fi=max({c1.fi,c2.fi+len,cur+len});
            ret.fi.se=max({c2.se,c1.se+(1<<i),cur+(1<<i)});
        }
        len+=1<<i;
        y=child[x][i];
        x=spa[x][i];
    }
    return ret;
}
void dfs2(int x,int p)
{
    spd[x][0]=cm[x][0]=cut[x][0].fi=cut[x][0].se=0;
    for(int i=0,y=x;i<18;y=spa[y][i++])
    {
        if(spa[x][i]==0)
            break;
        child[x][i]=y;
        {
            int fc1=dp1[y].get()+1;
            int fc2=max(dp2[y].get(),dp1[y].get()+dp1[y].get(dp1[y].get()));
            spd[x][i+1]=max({spd[x][i],spd[spa[x][i]][i],dp2[spa[x][i]].get(fc2),
            dp1[spa[x][i]].get(fc1)+dp1[spa[x][i]].get(dp1[spa[x][i]].get(fc1),fc1)});
        }
        {
            pi c1=cut[x][i];
            pi c2=cut[spa[x][i]][i];
            int cur=dp1[spa[x][i]].get(dp1[y].get()+1);
            cm[x][i+1]=max({cm[x][i]+(1<<i),cm[spa[x][i]][i]+(1<<i),
            c1.fi+c2.se,c1.fi+cur+(1<<i),c2.se+cur+(1<<i)});
            cut[x][i+1].fi=max({c1.fi,c2.fi+(1<<i),cur+(1<<i)});
            cut[x][i+1].se=max({c2.se,c1.se+(1<<i),cur+(1<<i)});
        }
    }
    for(int&t:adj[x])
    {
        if(t!=p)
        {
            int mx=dp3[x].get(dp1[t].get()+1);
            dp3[t].upd(mx+1);
            int mx2=dp3[x].get(mx,dp1[t].get()+1);
            int td2=max(dp2[t].get(),dp1[t].get()+dp1[t].get(dp1[t].get()));
            dp4[t].upd(max(dp4[x].get(td2),mx+mx2));
            dfs2(t,x);
        }
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<pair<pi,int> >ev;
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        u++,v++;
        if(w==1)
            adj[u].eb(v),adj[v].eb(u);
        else if(w*2<n)
            ev.eb(pi(u,v),w);
    }
    sdfs(1,0);
    int ans=inf;
    {
        int d1=max_element(dep+1,dep+n+1)-dep;
        ddfs(d1,0);
        ans=2*n-1-*max_element(depth+1,depth+n+1);
    }
    dfs2(1,0);
    sort(all(ev),[](const pair<pi,int>&x,const pair<pi,int>&y){return x.se<y.se;});
    int c=0;
    for(auto&t:ev)
    {
        if(++c>400000)
            break;
        int u=t.fi.fi;
        int v=t.fi.se;
        int w=t.se;
        int l=lca(u,v);
        int len=dep[u]+dep[v]-dep[l]*2;
        int dmax=0,cmax=0;
        if(v==l)
            swap(u,v);
        if(u==l)
        {
            auto q1=dpth(v,dep[v]-dep[l]);
            auto q2=pth(v,dep[v]-dep[l]);
            int y=kpa(v,dep[v]-dep[l]-1);
            {
                int fc1=dp1[y].get()+1;
                int fc2=max(dp2[y].get(),dp1[y].get()+dp1[y].get(dp1[y].get()));
                dmax=max({q1,dp4[l].get(fc2),
                dp3[l].get(fc1)+dp3[l].get(dp3[l].get(fc1),fc1)});
            }
            {
                int cur=dp3[l].get(dp1[y].get()+1);
                cmax=max(q2.se,q2.fi.fi+cur);
            }
        }
        else
        {
            int qu1=dpth(u,dep[u]-dep[l]);
            int qv1=dpth(v,dep[v]-dep[l]);
            auto qu2=pth(u,dep[u]-dep[l]);
            auto qv2=pth(v,dep[v]-dep[l]);
            int yu=kpa(u,dep[u]-dep[l]-1);
            int yv=kpa(v,dep[v]-dep[l]-1);
            {
                int fcu1=dp1[yu].get()+1;
                int fcv1=dp1[yv].get()+1;
                int fcu2=max(dp2[yu].get(),dp1[yu].get()+dp1[yu].get(dp1[yu].get()));
                int fcv2=max(dp2[yv].get(),dp1[yv].get()+dp1[yv].get(dp1[yv].get()));
                dmax=max({qu1,qv1,dp4[l].get(fcu2,fcv2),
                dp3[l].get(fcu1,fcv1)+dp3[l].get(dp3[l].get(fcu1,fcv1),fcu1,fcv1)});
            }
            {
                int cur=dp3[l].get(dp1[yu].get()+1,dp1[yv].get()+1);
                cmax=max({qu2.se+(dep[v]-dep[l]),qv2.se+(dep[u]-dep[l]),qu2.fi.fi+qv2.fi.fi,
                qu2.fi.fi+cur+(dep[v]-dep[l]),qv2.fi.fi+cur+(dep[u]-dep[l])});
            }
        }
        ans=min(ans,n*2-2-dmax-len+w);
        ans=min(ans,n*2-4-cmax+w);
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 31 ms 43392 KB Output is correct
2 Correct 29 ms 43392 KB Output is correct
3 Correct 29 ms 43384 KB Output is correct
4 Correct 35 ms 43460 KB Output is correct
5 Correct 36 ms 43384 KB Output is correct
6 Correct 39 ms 43384 KB Output is correct
7 Correct 36 ms 43384 KB Output is correct
8 Correct 31 ms 43392 KB Output is correct
9 Correct 33 ms 43392 KB Output is correct
10 Correct 39 ms 43384 KB Output is correct
11 Correct 28 ms 43488 KB Output is correct
12 Correct 36 ms 43392 KB Output is correct
13 Correct 36 ms 43392 KB Output is correct
14 Correct 36 ms 43392 KB Output is correct
15 Correct 34 ms 43392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 43392 KB Output is correct
2 Correct 29 ms 43392 KB Output is correct
3 Correct 29 ms 43384 KB Output is correct
4 Correct 35 ms 43460 KB Output is correct
5 Correct 36 ms 43384 KB Output is correct
6 Correct 39 ms 43384 KB Output is correct
7 Correct 36 ms 43384 KB Output is correct
8 Correct 31 ms 43392 KB Output is correct
9 Correct 33 ms 43392 KB Output is correct
10 Correct 39 ms 43384 KB Output is correct
11 Correct 28 ms 43488 KB Output is correct
12 Correct 36 ms 43392 KB Output is correct
13 Correct 36 ms 43392 KB Output is correct
14 Correct 36 ms 43392 KB Output is correct
15 Correct 34 ms 43392 KB Output is correct
16 Correct 29 ms 43472 KB Output is correct
17 Correct 35 ms 43392 KB Output is correct
18 Correct 35 ms 43392 KB Output is correct
19 Correct 36 ms 43392 KB Output is correct
20 Correct 36 ms 43384 KB Output is correct
21 Correct 36 ms 43456 KB Output is correct
22 Correct 36 ms 43392 KB Output is correct
23 Correct 36 ms 43384 KB Output is correct
24 Correct 29 ms 43384 KB Output is correct
25 Correct 30 ms 43392 KB Output is correct
26 Correct 43 ms 43512 KB Output is correct
27 Correct 30 ms 43392 KB Output is correct
28 Correct 29 ms 43392 KB Output is correct
29 Correct 29 ms 43392 KB Output is correct
30 Correct 29 ms 43392 KB Output is correct
31 Correct 29 ms 43384 KB Output is correct
32 Correct 29 ms 43512 KB Output is correct
33 Correct 30 ms 43392 KB Output is correct
34 Correct 30 ms 43392 KB Output is correct
35 Correct 30 ms 43392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 46348 KB Output is correct
2 Correct 42 ms 46588 KB Output is correct
3 Correct 53 ms 46328 KB Output is correct
4 Correct 37 ms 46208 KB Output is correct
5 Correct 41 ms 46200 KB Output is correct
6 Correct 41 ms 46080 KB Output is correct
7 Correct 49 ms 46476 KB Output is correct
8 Correct 40 ms 46392 KB Output is correct
9 Correct 46 ms 46512 KB Output is correct
10 Correct 40 ms 46200 KB Output is correct
11 Correct 42 ms 46420 KB Output is correct
12 Correct 39 ms 46176 KB Output is correct
13 Correct 47 ms 46328 KB Output is correct
14 Correct 58 ms 46328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 43392 KB Output is correct
2 Correct 29 ms 43392 KB Output is correct
3 Correct 29 ms 43384 KB Output is correct
4 Correct 35 ms 43460 KB Output is correct
5 Correct 36 ms 43384 KB Output is correct
6 Correct 39 ms 43384 KB Output is correct
7 Correct 36 ms 43384 KB Output is correct
8 Correct 31 ms 43392 KB Output is correct
9 Correct 33 ms 43392 KB Output is correct
10 Correct 39 ms 43384 KB Output is correct
11 Correct 28 ms 43488 KB Output is correct
12 Correct 36 ms 43392 KB Output is correct
13 Correct 36 ms 43392 KB Output is correct
14 Correct 36 ms 43392 KB Output is correct
15 Correct 34 ms 43392 KB Output is correct
16 Correct 29 ms 43472 KB Output is correct
17 Correct 35 ms 43392 KB Output is correct
18 Correct 35 ms 43392 KB Output is correct
19 Correct 36 ms 43392 KB Output is correct
20 Correct 36 ms 43384 KB Output is correct
21 Correct 36 ms 43456 KB Output is correct
22 Correct 36 ms 43392 KB Output is correct
23 Correct 36 ms 43384 KB Output is correct
24 Correct 29 ms 43384 KB Output is correct
25 Correct 30 ms 43392 KB Output is correct
26 Correct 43 ms 43512 KB Output is correct
27 Correct 30 ms 43392 KB Output is correct
28 Correct 29 ms 43392 KB Output is correct
29 Correct 29 ms 43392 KB Output is correct
30 Correct 29 ms 43392 KB Output is correct
31 Correct 29 ms 43384 KB Output is correct
32 Correct 29 ms 43512 KB Output is correct
33 Correct 30 ms 43392 KB Output is correct
34 Correct 30 ms 43392 KB Output is correct
35 Correct 30 ms 43392 KB Output is correct
36 Correct 34 ms 43520 KB Output is correct
37 Correct 28 ms 43504 KB Output is correct
38 Correct 34 ms 43520 KB Output is correct
39 Correct 31 ms 43512 KB Output is correct
40 Correct 31 ms 43512 KB Output is correct
41 Correct 31 ms 43512 KB Output is correct
42 Correct 30 ms 43444 KB Output is correct
43 Correct 32 ms 43540 KB Output is correct
44 Correct 30 ms 43520 KB Output is correct
45 Correct 34 ms 43432 KB Output is correct
46 Correct 30 ms 43436 KB Output is correct
47 Correct 36 ms 43520 KB Output is correct
48 Correct 31 ms 43512 KB Output is correct
49 Correct 35 ms 43516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 43392 KB Output is correct
2 Correct 29 ms 43392 KB Output is correct
3 Correct 29 ms 43384 KB Output is correct
4 Correct 35 ms 43460 KB Output is correct
5 Correct 36 ms 43384 KB Output is correct
6 Correct 39 ms 43384 KB Output is correct
7 Correct 36 ms 43384 KB Output is correct
8 Correct 31 ms 43392 KB Output is correct
9 Correct 33 ms 43392 KB Output is correct
10 Correct 39 ms 43384 KB Output is correct
11 Correct 28 ms 43488 KB Output is correct
12 Correct 36 ms 43392 KB Output is correct
13 Correct 36 ms 43392 KB Output is correct
14 Correct 36 ms 43392 KB Output is correct
15 Correct 34 ms 43392 KB Output is correct
16 Correct 29 ms 43472 KB Output is correct
17 Correct 35 ms 43392 KB Output is correct
18 Correct 35 ms 43392 KB Output is correct
19 Correct 36 ms 43392 KB Output is correct
20 Correct 36 ms 43384 KB Output is correct
21 Correct 36 ms 43456 KB Output is correct
22 Correct 36 ms 43392 KB Output is correct
23 Correct 36 ms 43384 KB Output is correct
24 Correct 29 ms 43384 KB Output is correct
25 Correct 30 ms 43392 KB Output is correct
26 Correct 43 ms 43512 KB Output is correct
27 Correct 30 ms 43392 KB Output is correct
28 Correct 29 ms 43392 KB Output is correct
29 Correct 29 ms 43392 KB Output is correct
30 Correct 29 ms 43392 KB Output is correct
31 Correct 29 ms 43384 KB Output is correct
32 Correct 29 ms 43512 KB Output is correct
33 Correct 30 ms 43392 KB Output is correct
34 Correct 30 ms 43392 KB Output is correct
35 Correct 30 ms 43392 KB Output is correct
36 Correct 34 ms 43520 KB Output is correct
37 Correct 28 ms 43504 KB Output is correct
38 Correct 34 ms 43520 KB Output is correct
39 Correct 31 ms 43512 KB Output is correct
40 Correct 31 ms 43512 KB Output is correct
41 Correct 31 ms 43512 KB Output is correct
42 Correct 30 ms 43444 KB Output is correct
43 Correct 32 ms 43540 KB Output is correct
44 Correct 30 ms 43520 KB Output is correct
45 Correct 34 ms 43432 KB Output is correct
46 Correct 30 ms 43436 KB Output is correct
47 Correct 36 ms 43520 KB Output is correct
48 Correct 31 ms 43512 KB Output is correct
49 Correct 35 ms 43516 KB Output is correct
50 Correct 36 ms 43768 KB Output is correct
51 Correct 35 ms 43768 KB Output is correct
52 Correct 34 ms 43768 KB Output is correct
53 Correct 31 ms 43768 KB Output is correct
54 Correct 34 ms 43768 KB Output is correct
55 Correct 39 ms 43648 KB Output is correct
56 Correct 31 ms 43776 KB Output is correct
57 Correct 30 ms 43768 KB Output is correct
58 Correct 34 ms 43768 KB Output is correct
59 Correct 37 ms 43768 KB Output is correct
60 Correct 31 ms 43768 KB Output is correct
61 Correct 32 ms 43768 KB Output is correct
62 Correct 29 ms 43776 KB Output is correct
63 Correct 29 ms 43768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 43392 KB Output is correct
2 Correct 29 ms 43392 KB Output is correct
3 Correct 29 ms 43384 KB Output is correct
4 Correct 35 ms 43460 KB Output is correct
5 Correct 36 ms 43384 KB Output is correct
6 Correct 39 ms 43384 KB Output is correct
7 Correct 36 ms 43384 KB Output is correct
8 Correct 31 ms 43392 KB Output is correct
9 Correct 33 ms 43392 KB Output is correct
10 Correct 39 ms 43384 KB Output is correct
11 Correct 28 ms 43488 KB Output is correct
12 Correct 36 ms 43392 KB Output is correct
13 Correct 36 ms 43392 KB Output is correct
14 Correct 36 ms 43392 KB Output is correct
15 Correct 34 ms 43392 KB Output is correct
16 Correct 29 ms 43472 KB Output is correct
17 Correct 35 ms 43392 KB Output is correct
18 Correct 35 ms 43392 KB Output is correct
19 Correct 36 ms 43392 KB Output is correct
20 Correct 36 ms 43384 KB Output is correct
21 Correct 36 ms 43456 KB Output is correct
22 Correct 36 ms 43392 KB Output is correct
23 Correct 36 ms 43384 KB Output is correct
24 Correct 29 ms 43384 KB Output is correct
25 Correct 30 ms 43392 KB Output is correct
26 Correct 43 ms 43512 KB Output is correct
27 Correct 30 ms 43392 KB Output is correct
28 Correct 29 ms 43392 KB Output is correct
29 Correct 29 ms 43392 KB Output is correct
30 Correct 29 ms 43392 KB Output is correct
31 Correct 29 ms 43384 KB Output is correct
32 Correct 29 ms 43512 KB Output is correct
33 Correct 30 ms 43392 KB Output is correct
34 Correct 30 ms 43392 KB Output is correct
35 Correct 30 ms 43392 KB Output is correct
36 Correct 38 ms 46348 KB Output is correct
37 Correct 42 ms 46588 KB Output is correct
38 Correct 53 ms 46328 KB Output is correct
39 Correct 37 ms 46208 KB Output is correct
40 Correct 41 ms 46200 KB Output is correct
41 Correct 41 ms 46080 KB Output is correct
42 Correct 49 ms 46476 KB Output is correct
43 Correct 40 ms 46392 KB Output is correct
44 Correct 46 ms 46512 KB Output is correct
45 Correct 40 ms 46200 KB Output is correct
46 Correct 42 ms 46420 KB Output is correct
47 Correct 39 ms 46176 KB Output is correct
48 Correct 47 ms 46328 KB Output is correct
49 Correct 58 ms 46328 KB Output is correct
50 Correct 34 ms 43520 KB Output is correct
51 Correct 28 ms 43504 KB Output is correct
52 Correct 34 ms 43520 KB Output is correct
53 Correct 31 ms 43512 KB Output is correct
54 Correct 31 ms 43512 KB Output is correct
55 Correct 31 ms 43512 KB Output is correct
56 Correct 30 ms 43444 KB Output is correct
57 Correct 32 ms 43540 KB Output is correct
58 Correct 30 ms 43520 KB Output is correct
59 Correct 34 ms 43432 KB Output is correct
60 Correct 30 ms 43436 KB Output is correct
61 Correct 36 ms 43520 KB Output is correct
62 Correct 31 ms 43512 KB Output is correct
63 Correct 35 ms 43516 KB Output is correct
64 Correct 36 ms 43768 KB Output is correct
65 Correct 35 ms 43768 KB Output is correct
66 Correct 34 ms 43768 KB Output is correct
67 Correct 31 ms 43768 KB Output is correct
68 Correct 34 ms 43768 KB Output is correct
69 Correct 39 ms 43648 KB Output is correct
70 Correct 31 ms 43776 KB Output is correct
71 Correct 30 ms 43768 KB Output is correct
72 Correct 34 ms 43768 KB Output is correct
73 Correct 37 ms 43768 KB Output is correct
74 Correct 31 ms 43768 KB Output is correct
75 Correct 32 ms 43768 KB Output is correct
76 Correct 29 ms 43776 KB Output is correct
77 Correct 29 ms 43768 KB Output is correct
78 Correct 40 ms 46464 KB Output is correct
79 Correct 39 ms 46456 KB Output is correct
80 Correct 40 ms 46456 KB Output is correct
81 Correct 46 ms 46456 KB Output is correct
82 Correct 39 ms 46336 KB Output is correct
83 Correct 40 ms 46080 KB Output is correct
84 Correct 46 ms 46456 KB Output is correct
85 Correct 39 ms 46464 KB Output is correct
86 Correct 48 ms 46584 KB Output is correct
87 Correct 55 ms 46328 KB Output is correct
88 Correct 42 ms 46328 KB Output is correct
89 Correct 45 ms 46328 KB Output is correct
90 Correct 35 ms 46176 KB Output is correct
91 Correct 48 ms 46200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 43392 KB Output is correct
2 Correct 29 ms 43392 KB Output is correct
3 Correct 29 ms 43384 KB Output is correct
4 Correct 35 ms 43460 KB Output is correct
5 Correct 36 ms 43384 KB Output is correct
6 Correct 39 ms 43384 KB Output is correct
7 Correct 36 ms 43384 KB Output is correct
8 Correct 31 ms 43392 KB Output is correct
9 Correct 33 ms 43392 KB Output is correct
10 Correct 39 ms 43384 KB Output is correct
11 Correct 28 ms 43488 KB Output is correct
12 Correct 36 ms 43392 KB Output is correct
13 Correct 36 ms 43392 KB Output is correct
14 Correct 36 ms 43392 KB Output is correct
15 Correct 34 ms 43392 KB Output is correct
16 Correct 29 ms 43472 KB Output is correct
17 Correct 35 ms 43392 KB Output is correct
18 Correct 35 ms 43392 KB Output is correct
19 Correct 36 ms 43392 KB Output is correct
20 Correct 36 ms 43384 KB Output is correct
21 Correct 36 ms 43456 KB Output is correct
22 Correct 36 ms 43392 KB Output is correct
23 Correct 36 ms 43384 KB Output is correct
24 Correct 29 ms 43384 KB Output is correct
25 Correct 30 ms 43392 KB Output is correct
26 Correct 43 ms 43512 KB Output is correct
27 Correct 30 ms 43392 KB Output is correct
28 Correct 29 ms 43392 KB Output is correct
29 Correct 29 ms 43392 KB Output is correct
30 Correct 29 ms 43392 KB Output is correct
31 Correct 29 ms 43384 KB Output is correct
32 Correct 29 ms 43512 KB Output is correct
33 Correct 30 ms 43392 KB Output is correct
34 Correct 30 ms 43392 KB Output is correct
35 Correct 30 ms 43392 KB Output is correct
36 Correct 38 ms 46348 KB Output is correct
37 Correct 42 ms 46588 KB Output is correct
38 Correct 53 ms 46328 KB Output is correct
39 Correct 37 ms 46208 KB Output is correct
40 Correct 41 ms 46200 KB Output is correct
41 Correct 41 ms 46080 KB Output is correct
42 Correct 49 ms 46476 KB Output is correct
43 Correct 40 ms 46392 KB Output is correct
44 Correct 46 ms 46512 KB Output is correct
45 Correct 40 ms 46200 KB Output is correct
46 Correct 42 ms 46420 KB Output is correct
47 Correct 39 ms 46176 KB Output is correct
48 Correct 47 ms 46328 KB Output is correct
49 Correct 58 ms 46328 KB Output is correct
50 Correct 34 ms 43520 KB Output is correct
51 Correct 28 ms 43504 KB Output is correct
52 Correct 34 ms 43520 KB Output is correct
53 Correct 31 ms 43512 KB Output is correct
54 Correct 31 ms 43512 KB Output is correct
55 Correct 31 ms 43512 KB Output is correct
56 Correct 30 ms 43444 KB Output is correct
57 Correct 32 ms 43540 KB Output is correct
58 Correct 30 ms 43520 KB Output is correct
59 Correct 34 ms 43432 KB Output is correct
60 Correct 30 ms 43436 KB Output is correct
61 Correct 36 ms 43520 KB Output is correct
62 Correct 31 ms 43512 KB Output is correct
63 Correct 35 ms 43516 KB Output is correct
64 Correct 36 ms 43768 KB Output is correct
65 Correct 35 ms 43768 KB Output is correct
66 Correct 34 ms 43768 KB Output is correct
67 Correct 31 ms 43768 KB Output is correct
68 Correct 34 ms 43768 KB Output is correct
69 Correct 39 ms 43648 KB Output is correct
70 Correct 31 ms 43776 KB Output is correct
71 Correct 30 ms 43768 KB Output is correct
72 Correct 34 ms 43768 KB Output is correct
73 Correct 37 ms 43768 KB Output is correct
74 Correct 31 ms 43768 KB Output is correct
75 Correct 32 ms 43768 KB Output is correct
76 Correct 29 ms 43776 KB Output is correct
77 Correct 29 ms 43768 KB Output is correct
78 Correct 40 ms 46464 KB Output is correct
79 Correct 39 ms 46456 KB Output is correct
80 Correct 40 ms 46456 KB Output is correct
81 Correct 46 ms 46456 KB Output is correct
82 Correct 39 ms 46336 KB Output is correct
83 Correct 40 ms 46080 KB Output is correct
84 Correct 46 ms 46456 KB Output is correct
85 Correct 39 ms 46464 KB Output is correct
86 Correct 48 ms 46584 KB Output is correct
87 Correct 55 ms 46328 KB Output is correct
88 Correct 42 ms 46328 KB Output is correct
89 Correct 45 ms 46328 KB Output is correct
90 Correct 35 ms 46176 KB Output is correct
91 Correct 48 ms 46200 KB Output is correct
92 Correct 787 ms 88872 KB Output is correct
93 Correct 789 ms 89008 KB Output is correct
94 Correct 471 ms 87592 KB Output is correct
95 Correct 327 ms 88568 KB Output is correct
96 Correct 399 ms 88696 KB Output is correct
97 Correct 765 ms 92456 KB Output is correct
98 Correct 558 ms 93104 KB Output is correct
99 Correct 662 ms 88688 KB Output is correct
100 Correct 673 ms 89548 KB Output is correct
101 Correct 610 ms 88576 KB Output is correct
102 Correct 169 ms 84648 KB Output is correct
103 Correct 727 ms 91560 KB Output is correct
104 Correct 623 ms 89516 KB Output is correct
105 Correct 606 ms 90284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 43392 KB Output is correct
2 Correct 29 ms 43392 KB Output is correct
3 Correct 29 ms 43384 KB Output is correct
4 Correct 35 ms 43460 KB Output is correct
5 Correct 36 ms 43384 KB Output is correct
6 Correct 39 ms 43384 KB Output is correct
7 Correct 36 ms 43384 KB Output is correct
8 Correct 31 ms 43392 KB Output is correct
9 Correct 33 ms 43392 KB Output is correct
10 Correct 39 ms 43384 KB Output is correct
11 Correct 28 ms 43488 KB Output is correct
12 Correct 36 ms 43392 KB Output is correct
13 Correct 36 ms 43392 KB Output is correct
14 Correct 36 ms 43392 KB Output is correct
15 Correct 34 ms 43392 KB Output is correct
16 Correct 29 ms 43472 KB Output is correct
17 Correct 35 ms 43392 KB Output is correct
18 Correct 35 ms 43392 KB Output is correct
19 Correct 36 ms 43392 KB Output is correct
20 Correct 36 ms 43384 KB Output is correct
21 Correct 36 ms 43456 KB Output is correct
22 Correct 36 ms 43392 KB Output is correct
23 Correct 36 ms 43384 KB Output is correct
24 Correct 29 ms 43384 KB Output is correct
25 Correct 30 ms 43392 KB Output is correct
26 Correct 43 ms 43512 KB Output is correct
27 Correct 30 ms 43392 KB Output is correct
28 Correct 29 ms 43392 KB Output is correct
29 Correct 29 ms 43392 KB Output is correct
30 Correct 29 ms 43392 KB Output is correct
31 Correct 29 ms 43384 KB Output is correct
32 Correct 29 ms 43512 KB Output is correct
33 Correct 30 ms 43392 KB Output is correct
34 Correct 30 ms 43392 KB Output is correct
35 Correct 30 ms 43392 KB Output is correct
36 Correct 38 ms 46348 KB Output is correct
37 Correct 42 ms 46588 KB Output is correct
38 Correct 53 ms 46328 KB Output is correct
39 Correct 37 ms 46208 KB Output is correct
40 Correct 41 ms 46200 KB Output is correct
41 Correct 41 ms 46080 KB Output is correct
42 Correct 49 ms 46476 KB Output is correct
43 Correct 40 ms 46392 KB Output is correct
44 Correct 46 ms 46512 KB Output is correct
45 Correct 40 ms 46200 KB Output is correct
46 Correct 42 ms 46420 KB Output is correct
47 Correct 39 ms 46176 KB Output is correct
48 Correct 47 ms 46328 KB Output is correct
49 Correct 58 ms 46328 KB Output is correct
50 Correct 34 ms 43520 KB Output is correct
51 Correct 28 ms 43504 KB Output is correct
52 Correct 34 ms 43520 KB Output is correct
53 Correct 31 ms 43512 KB Output is correct
54 Correct 31 ms 43512 KB Output is correct
55 Correct 31 ms 43512 KB Output is correct
56 Correct 30 ms 43444 KB Output is correct
57 Correct 32 ms 43540 KB Output is correct
58 Correct 30 ms 43520 KB Output is correct
59 Correct 34 ms 43432 KB Output is correct
60 Correct 30 ms 43436 KB Output is correct
61 Correct 36 ms 43520 KB Output is correct
62 Correct 31 ms 43512 KB Output is correct
63 Correct 35 ms 43516 KB Output is correct
64 Correct 36 ms 43768 KB Output is correct
65 Correct 35 ms 43768 KB Output is correct
66 Correct 34 ms 43768 KB Output is correct
67 Correct 31 ms 43768 KB Output is correct
68 Correct 34 ms 43768 KB Output is correct
69 Correct 39 ms 43648 KB Output is correct
70 Correct 31 ms 43776 KB Output is correct
71 Correct 30 ms 43768 KB Output is correct
72 Correct 34 ms 43768 KB Output is correct
73 Correct 37 ms 43768 KB Output is correct
74 Correct 31 ms 43768 KB Output is correct
75 Correct 32 ms 43768 KB Output is correct
76 Correct 29 ms 43776 KB Output is correct
77 Correct 29 ms 43768 KB Output is correct
78 Correct 40 ms 46464 KB Output is correct
79 Correct 39 ms 46456 KB Output is correct
80 Correct 40 ms 46456 KB Output is correct
81 Correct 46 ms 46456 KB Output is correct
82 Correct 39 ms 46336 KB Output is correct
83 Correct 40 ms 46080 KB Output is correct
84 Correct 46 ms 46456 KB Output is correct
85 Correct 39 ms 46464 KB Output is correct
86 Correct 48 ms 46584 KB Output is correct
87 Correct 55 ms 46328 KB Output is correct
88 Correct 42 ms 46328 KB Output is correct
89 Correct 45 ms 46328 KB Output is correct
90 Correct 35 ms 46176 KB Output is correct
91 Correct 48 ms 46200 KB Output is correct
92 Correct 787 ms 88872 KB Output is correct
93 Correct 789 ms 89008 KB Output is correct
94 Correct 471 ms 87592 KB Output is correct
95 Correct 327 ms 88568 KB Output is correct
96 Correct 399 ms 88696 KB Output is correct
97 Correct 765 ms 92456 KB Output is correct
98 Correct 558 ms 93104 KB Output is correct
99 Correct 662 ms 88688 KB Output is correct
100 Correct 673 ms 89548 KB Output is correct
101 Correct 610 ms 88576 KB Output is correct
102 Correct 169 ms 84648 KB Output is correct
103 Correct 727 ms 91560 KB Output is correct
104 Correct 623 ms 89516 KB Output is correct
105 Correct 606 ms 90284 KB Output is correct
106 Correct 5712 ms 363964 KB Output is correct
107 Correct 5422 ms 361040 KB Output is correct
108 Correct 5890 ms 327220 KB Output is correct
109 Correct 6146 ms 363772 KB Output is correct
110 Correct 5620 ms 364304 KB Output is correct
111 Correct 1594 ms 333652 KB Output is correct
112 Correct 5158 ms 396616 KB Output is correct
113 Correct 5365 ms 376592 KB Output is correct
114 Correct 5599 ms 378916 KB Output is correct
115 Correct 5905 ms 362776 KB Output is correct
116 Correct 5666 ms 369924 KB Output is correct
117 Incorrect 4415 ms 370868 KB Output isn't correct
118 Halted 0 ms 0 KB -