Submission #734361

# Submission time Handle Problem Language Result Execution time Memory
734361 2023-05-02T10:23:04 Z bin9638 Road Closures (APIO21_roads) C++17
100 / 100
621 ms 41640 KB
#include <bits/stdc++.h>

#ifndef SKY
#include "roads.h"
#endif // SKY

using namespace std;

#define N 100010
#define ll long long
#define fs first
#define sc second
#define ii pair<ll,int>
#define pb push_back

#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

const ll MAX_VAL=2e14;

int cnt,k,n,ktr[N],spec[N];
vector<ii>g[N],edge[N];
ll tong,them,cost[N],dp[N][2];
vector<ll>sum[N];
vector<int>lis,ds[N];

struct nho
{
    void build(int u,int p)
    {
        for(auto v:g[u])
            if(v.sc!=p)
            {
                build(v.sc,u);
                cost[v.sc]=v.fs;
            }
    }

    ll solve(int u,int p,int sl,const vector<ll>&s)
    {

        if(sl<0)
            return MAX_VAL;
        ll res=0;
        for(auto v:g[u])
            if(v.sc!=p)
                if(dp[v.sc][0]<=dp[v.sc][1])
                {
                    res+=dp[v.sc][0];
                }else
                {
                    res+=dp[v.sc][1];
                }
        for(int i=0;i<(int)s.size()-sl;i++)
            res+=s[i];
        return res;
    }

    void DFS(int u,int p)
    {
        for(auto v:g[u])
            if(v.sc!=p)
                DFS(v.sc,u);
        vector<ll>s;
        for(auto v:g[u])
            if(v.sc!=p&&dp[v.sc][0]>dp[v.sc][1])
                s.pb(dp[v.sc][0]-dp[v.sc][1]);
        sort(s.begin(),s.end());
        //0
        dp[u][0]=solve(u,p,k,s)+cost[u];
        //1
        dp[u][1]=solve(u,p,k-(u!=0),s);
    }
}nho;

ll get(int u,int sl)
{
    if(sl>=sum[u].size())
        return 0;
    if(sl==0)
        return sum[u].back();
    return sum[u].back()-sum[u][sl-1];
}

ll solve(int u,int p,int sl,const vector<ll>&s)
{
    if(sl<0)
        return MAX_VAL;
    ll cong=0,res=MAX_VAL;
    for(auto v:edge[u])
        if(v.sc!=p)
        {
             if(dp[v.sc][0]<=dp[v.sc][1])
                {
                    cong+=dp[v.sc][0];
                }else
                {
                    cong+=dp[v.sc][1];
                }
        }
    if((int)s.size()<=sl)
        res=min(res,cong+get(u,sl-(int)s.size()));
    for(int i=0;i<s.size();i++)
    {
        cong+=s[i];
        if((int)s.size()-i-1<=sl)
            res=min(res,cong+get(u,sl-((int)s.size()-i-1)));
    }
    return res;
}

void DFS(int u,int p)
{
    ktr[u]=k;
    for(auto v:edge[u])
        if(v.sc!=p)
        {
            cost[v.sc]=v.fs;
            DFS(v.sc,u);
        }
    vector<ll>s;
    for(auto v:edge[u])
        if(v.sc!=p&&dp[v.sc][0]>dp[v.sc][1])
            s.pb(dp[v.sc][0]-dp[v.sc][1]);
     if((int)s.size()+(int)sum[u].size()>k-(p!=-1))
        sort(s.begin(),s.end());
    //0
    dp[u][0]=solve(u,p,k,s)+cost[u];
    //1
    dp[u][1]=solve(u,p,k-(p!=-1),s);
}

vector<long long> minimum_closure_costs(int NNN, vector<int> UUU, vector<int> VVV, vector<int> WWW)
{
    n=NNN;
    for(int i=0;i<n-1;i++)
    {
        int u=UUU[i],v=VVV[i],w=WWW[i];
        g[u].pb({w,v});
        g[v].pb({w,u});
    }
    cost[0]=1e18;
    nho.build(0,-1);
    vector<ll>kq;
    for(k=0;k<=0;k++)
    {
        nho.DFS(0,-1);
        kq.pb(dp[0][1]);
    }
    for(int i=0;i<n;i++)
        ds[(int)g[i].size()].pb(i);
    for(int i=0;i<n;i++)
        spec[i]=1;
    vector<int>luu;
    for(k=1;k<n;k++)
    {
        for(auto u:ds[k])
            luu.pb(u);
        if(k==1||luu.size()>=100)
        {
            for(auto u:luu)
                spec[u]=0;
            luu.clear();
            for(int i=0;i<n;i++)
                sum[i].clear(),edge[i].clear();
            them=tong=0;
             for(int i=0;i<n-1;i++)
                {
                    int u=UUU[i],v=VVV[i],w=WWW[i];
                    tong+=1ll*w;
                    if((int)g[u].size()<(int)g[v].size())
                        swap(u,v);
                    if(spec[u]&&spec[v])
                    {
                        edge[u].pb({w,v});
                        edge[v].pb({w,u});
                        continue;
                    }
                    if(spec[u])
                    {
                        sum[u].pb(w);
                        continue;
                    }
                    them+=1ll*w;
                }
             for(int i=0;i<n;i++)
            {
                sort(sum[i].begin(),sum[i].end(),greater<ll>());
                for(int j=1;j<sum[i].size();j++)
                    sum[i][j]+=sum[i][j-1];
            }
            lis.clear();
            for(int i=0;i<n;i++)
                if(spec[i]==1)
                    lis.pb(i);
             memset(cost,0x3f3f,sizeof(cost));
        }
         ll res=0;
        for(auto u:lis)
            if(ktr[u]!=k)
                DFS(u,-1),res+=dp[u][1];
        kq.pb(res);
    }
    return kq;
}

#ifdef SKY
int main()
{
    freopen("A.inp","r",stdin);
    freopen("A.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int>U(n-1),V(n-1),W(n-1);
    for(int i=0;i<n-1;i++)
        cin>>U[i]>>V[i]>>W[i];
    vector<ll>kq=minimum_closure_costs(n,U,V,W);
    for(auto u:kq)cout<<u<<" ";
    return 0;
}
#endif

Compilation message

roads.cpp: In member function 'long long int nho::solve(int, int, int, const std::vector<long long int>&)':
roads.cpp:48:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   48 |             if(v.sc!=p)
      |               ^
roads.cpp: In function 'long long int get(int, int)':
roads.cpp:80:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     if(sl>=sum[u].size())
      |        ~~^~~~~~~~~~~~~~~
roads.cpp: In function 'long long int solve(int, int, int, const std::vector<long long int>&)':
roads.cpp:105:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |     for(int i=0;i<s.size();i++)
      |                 ~^~~~~~~~~
roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:191:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  191 |                 for(int j=1;j<sum[i].size();j++)
      |                             ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 7 ms 10708 KB Output is correct
3 Correct 9 ms 10736 KB Output is correct
4 Correct 7 ms 10760 KB Output is correct
5 Correct 6 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 7 ms 10452 KB Output is correct
8 Correct 7 ms 10708 KB Output is correct
9 Correct 7 ms 10708 KB Output is correct
10 Correct 5 ms 10452 KB Output is correct
11 Correct 5 ms 10452 KB Output is correct
12 Correct 40 ms 17880 KB Output is correct
13 Correct 68 ms 22772 KB Output is correct
14 Correct 67 ms 21860 KB Output is correct
15 Correct 75 ms 22884 KB Output is correct
16 Correct 74 ms 23176 KB Output is correct
17 Correct 72 ms 23140 KB Output is correct
18 Correct 6 ms 10452 KB Output is correct
19 Correct 72 ms 21772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 72 ms 34632 KB Output is correct
3 Correct 99 ms 37612 KB Output is correct
4 Correct 94 ms 39308 KB Output is correct
5 Correct 87 ms 39420 KB Output is correct
6 Correct 6 ms 10964 KB Output is correct
7 Correct 7 ms 10964 KB Output is correct
8 Correct 6 ms 10992 KB Output is correct
9 Correct 6 ms 10452 KB Output is correct
10 Correct 5 ms 10452 KB Output is correct
11 Correct 6 ms 10452 KB Output is correct
12 Correct 53 ms 27892 KB Output is correct
13 Correct 91 ms 39436 KB Output is correct
14 Correct 6 ms 10452 KB Output is correct
15 Correct 70 ms 36616 KB Output is correct
16 Correct 81 ms 39436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10452 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 6 ms 10452 KB Output is correct
4 Correct 7 ms 10452 KB Output is correct
5 Correct 6 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 7 ms 10524 KB Output is correct
8 Correct 6 ms 10452 KB Output is correct
9 Correct 6 ms 10452 KB Output is correct
10 Correct 6 ms 10452 KB Output is correct
11 Correct 5 ms 10452 KB Output is correct
12 Correct 5 ms 10452 KB Output is correct
13 Correct 6 ms 10452 KB Output is correct
14 Correct 5 ms 10452 KB Output is correct
15 Correct 6 ms 10452 KB Output is correct
16 Correct 6 ms 10516 KB Output is correct
17 Correct 7 ms 10452 KB Output is correct
18 Correct 8 ms 10452 KB Output is correct
19 Correct 5 ms 10452 KB Output is correct
20 Correct 6 ms 10492 KB Output is correct
21 Correct 6 ms 10452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10452 KB Output is correct
2 Correct 6 ms 10452 KB Output is correct
3 Correct 6 ms 10452 KB Output is correct
4 Correct 7 ms 10452 KB Output is correct
5 Correct 6 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 7 ms 10524 KB Output is correct
8 Correct 6 ms 10452 KB Output is correct
9 Correct 6 ms 10452 KB Output is correct
10 Correct 6 ms 10452 KB Output is correct
11 Correct 5 ms 10452 KB Output is correct
12 Correct 5 ms 10452 KB Output is correct
13 Correct 6 ms 10452 KB Output is correct
14 Correct 5 ms 10452 KB Output is correct
15 Correct 6 ms 10452 KB Output is correct
16 Correct 6 ms 10516 KB Output is correct
17 Correct 7 ms 10452 KB Output is correct
18 Correct 8 ms 10452 KB Output is correct
19 Correct 5 ms 10452 KB Output is correct
20 Correct 6 ms 10492 KB Output is correct
21 Correct 6 ms 10452 KB Output is correct
22 Correct 5 ms 10452 KB Output is correct
23 Correct 7 ms 10708 KB Output is correct
24 Correct 9 ms 10836 KB Output is correct
25 Correct 9 ms 10708 KB Output is correct
26 Correct 16 ms 10836 KB Output is correct
27 Correct 8 ms 10708 KB Output is correct
28 Correct 8 ms 10708 KB Output is correct
29 Correct 10 ms 10804 KB Output is correct
30 Correct 15 ms 10712 KB Output is correct
31 Correct 19 ms 10708 KB Output is correct
32 Correct 8 ms 10708 KB Output is correct
33 Correct 7 ms 10964 KB Output is correct
34 Correct 8 ms 10964 KB Output is correct
35 Correct 7 ms 10964 KB Output is correct
36 Correct 8 ms 10708 KB Output is correct
37 Correct 7 ms 10724 KB Output is correct
38 Correct 7 ms 10708 KB Output is correct
39 Correct 6 ms 10452 KB Output is correct
40 Correct 6 ms 10480 KB Output is correct
41 Correct 7 ms 10452 KB Output is correct
42 Correct 6 ms 10452 KB Output is correct
43 Correct 7 ms 10452 KB Output is correct
44 Correct 7 ms 10452 KB Output is correct
45 Correct 7 ms 10532 KB Output is correct
46 Correct 9 ms 10452 KB Output is correct
47 Correct 6 ms 10452 KB Output is correct
48 Correct 6 ms 10436 KB Output is correct
49 Correct 8 ms 10452 KB Output is correct
50 Correct 5 ms 10452 KB Output is correct
51 Correct 6 ms 10452 KB Output is correct
52 Correct 8 ms 10452 KB Output is correct
53 Correct 8 ms 10708 KB Output is correct
54 Correct 9 ms 10836 KB Output is correct
55 Correct 8 ms 10708 KB Output is correct
56 Correct 7 ms 10716 KB Output is correct
57 Correct 9 ms 10700 KB Output is correct
58 Correct 7 ms 10452 KB Output is correct
59 Correct 9 ms 10452 KB Output is correct
60 Correct 7 ms 10452 KB Output is correct
61 Correct 6 ms 10516 KB Output is correct
62 Correct 6 ms 10452 KB Output is correct
63 Correct 5 ms 10452 KB Output is correct
64 Correct 11 ms 10836 KB Output is correct
65 Correct 9 ms 10836 KB Output is correct
66 Correct 15 ms 10708 KB Output is correct
67 Correct 8 ms 10724 KB Output is correct
68 Correct 13 ms 10748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 26844 KB Output is correct
2 Correct 254 ms 26528 KB Output is correct
3 Correct 321 ms 24212 KB Output is correct
4 Correct 293 ms 27252 KB Output is correct
5 Correct 95 ms 24200 KB Output is correct
6 Correct 279 ms 22468 KB Output is correct
7 Correct 265 ms 26296 KB Output is correct
8 Correct 69 ms 22240 KB Output is correct
9 Correct 157 ms 30876 KB Output is correct
10 Correct 381 ms 26464 KB Output is correct
11 Correct 218 ms 23820 KB Output is correct
12 Correct 198 ms 23216 KB Output is correct
13 Correct 6 ms 10452 KB Output is correct
14 Correct 80 ms 36632 KB Output is correct
15 Correct 82 ms 39424 KB Output is correct
16 Correct 10 ms 10836 KB Output is correct
17 Correct 9 ms 10964 KB Output is correct
18 Correct 15 ms 10708 KB Output is correct
19 Correct 9 ms 10708 KB Output is correct
20 Correct 19 ms 10708 KB Output is correct
21 Correct 68 ms 21764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 277 ms 26844 KB Output is correct
2 Correct 254 ms 26528 KB Output is correct
3 Correct 321 ms 24212 KB Output is correct
4 Correct 293 ms 27252 KB Output is correct
5 Correct 95 ms 24200 KB Output is correct
6 Correct 279 ms 22468 KB Output is correct
7 Correct 265 ms 26296 KB Output is correct
8 Correct 69 ms 22240 KB Output is correct
9 Correct 157 ms 30876 KB Output is correct
10 Correct 381 ms 26464 KB Output is correct
11 Correct 218 ms 23820 KB Output is correct
12 Correct 198 ms 23216 KB Output is correct
13 Correct 6 ms 10452 KB Output is correct
14 Correct 80 ms 36632 KB Output is correct
15 Correct 82 ms 39424 KB Output is correct
16 Correct 10 ms 10836 KB Output is correct
17 Correct 9 ms 10964 KB Output is correct
18 Correct 15 ms 10708 KB Output is correct
19 Correct 9 ms 10708 KB Output is correct
20 Correct 19 ms 10708 KB Output is correct
21 Correct 68 ms 21764 KB Output is correct
22 Correct 6 ms 10452 KB Output is correct
23 Correct 6 ms 10452 KB Output is correct
24 Correct 5 ms 10452 KB Output is correct
25 Correct 221 ms 24892 KB Output is correct
26 Correct 199 ms 23636 KB Output is correct
27 Correct 351 ms 27324 KB Output is correct
28 Correct 500 ms 24264 KB Output is correct
29 Correct 81 ms 23252 KB Output is correct
30 Correct 293 ms 22096 KB Output is correct
31 Correct 127 ms 22292 KB Output is correct
32 Correct 510 ms 25576 KB Output is correct
33 Correct 65 ms 22456 KB Output is correct
34 Correct 260 ms 26340 KB Output is correct
35 Correct 180 ms 31396 KB Output is correct
36 Correct 211 ms 23728 KB Output is correct
37 Correct 240 ms 24672 KB Output is correct
38 Correct 55 ms 28620 KB Output is correct
39 Correct 83 ms 40756 KB Output is correct
40 Correct 8 ms 10776 KB Output is correct
41 Correct 9 ms 10836 KB Output is correct
42 Correct 8 ms 10748 KB Output is correct
43 Correct 7 ms 10624 KB Output is correct
44 Correct 7 ms 10752 KB Output is correct
45 Correct 7 ms 10452 KB Output is correct
46 Correct 6 ms 10484 KB Output is correct
47 Correct 7 ms 10464 KB Output is correct
48 Correct 7 ms 10516 KB Output is correct
49 Correct 7 ms 10484 KB Output is correct
50 Correct 58 ms 18368 KB Output is correct
51 Correct 66 ms 23748 KB Output is correct
52 Correct 255 ms 28124 KB Output is correct
53 Correct 306 ms 27696 KB Output is correct
54 Correct 305 ms 25640 KB Output is correct
55 Correct 289 ms 28504 KB Output is correct
56 Correct 81 ms 25588 KB Output is correct
57 Correct 300 ms 23796 KB Output is correct
58 Correct 253 ms 27720 KB Output is correct
59 Correct 61 ms 23424 KB Output is correct
60 Correct 169 ms 32024 KB Output is correct
61 Correct 374 ms 27916 KB Output is correct
62 Correct 211 ms 25128 KB Output is correct
63 Correct 198 ms 24684 KB Output is correct
64 Correct 6 ms 10452 KB Output is correct
65 Correct 71 ms 37876 KB Output is correct
66 Correct 97 ms 40696 KB Output is correct
67 Correct 10 ms 10752 KB Output is correct
68 Correct 14 ms 10788 KB Output is correct
69 Correct 15 ms 10708 KB Output is correct
70 Correct 8 ms 10708 KB Output is correct
71 Correct 12 ms 10796 KB Output is correct
72 Correct 58 ms 22616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 10452 KB Output is correct
2 Correct 7 ms 10708 KB Output is correct
3 Correct 9 ms 10736 KB Output is correct
4 Correct 7 ms 10760 KB Output is correct
5 Correct 6 ms 10452 KB Output is correct
6 Correct 6 ms 10452 KB Output is correct
7 Correct 7 ms 10452 KB Output is correct
8 Correct 7 ms 10708 KB Output is correct
9 Correct 7 ms 10708 KB Output is correct
10 Correct 5 ms 10452 KB Output is correct
11 Correct 5 ms 10452 KB Output is correct
12 Correct 40 ms 17880 KB Output is correct
13 Correct 68 ms 22772 KB Output is correct
14 Correct 67 ms 21860 KB Output is correct
15 Correct 75 ms 22884 KB Output is correct
16 Correct 74 ms 23176 KB Output is correct
17 Correct 72 ms 23140 KB Output is correct
18 Correct 6 ms 10452 KB Output is correct
19 Correct 72 ms 21772 KB Output is correct
20 Correct 5 ms 10452 KB Output is correct
21 Correct 72 ms 34632 KB Output is correct
22 Correct 99 ms 37612 KB Output is correct
23 Correct 94 ms 39308 KB Output is correct
24 Correct 87 ms 39420 KB Output is correct
25 Correct 6 ms 10964 KB Output is correct
26 Correct 7 ms 10964 KB Output is correct
27 Correct 6 ms 10992 KB Output is correct
28 Correct 6 ms 10452 KB Output is correct
29 Correct 5 ms 10452 KB Output is correct
30 Correct 6 ms 10452 KB Output is correct
31 Correct 53 ms 27892 KB Output is correct
32 Correct 91 ms 39436 KB Output is correct
33 Correct 6 ms 10452 KB Output is correct
34 Correct 70 ms 36616 KB Output is correct
35 Correct 81 ms 39436 KB Output is correct
36 Correct 6 ms 10452 KB Output is correct
37 Correct 6 ms 10452 KB Output is correct
38 Correct 6 ms 10452 KB Output is correct
39 Correct 7 ms 10452 KB Output is correct
40 Correct 6 ms 10452 KB Output is correct
41 Correct 6 ms 10452 KB Output is correct
42 Correct 7 ms 10524 KB Output is correct
43 Correct 6 ms 10452 KB Output is correct
44 Correct 6 ms 10452 KB Output is correct
45 Correct 6 ms 10452 KB Output is correct
46 Correct 5 ms 10452 KB Output is correct
47 Correct 5 ms 10452 KB Output is correct
48 Correct 6 ms 10452 KB Output is correct
49 Correct 5 ms 10452 KB Output is correct
50 Correct 6 ms 10452 KB Output is correct
51 Correct 6 ms 10516 KB Output is correct
52 Correct 7 ms 10452 KB Output is correct
53 Correct 8 ms 10452 KB Output is correct
54 Correct 5 ms 10452 KB Output is correct
55 Correct 6 ms 10492 KB Output is correct
56 Correct 6 ms 10452 KB Output is correct
57 Correct 5 ms 10452 KB Output is correct
58 Correct 7 ms 10708 KB Output is correct
59 Correct 9 ms 10836 KB Output is correct
60 Correct 9 ms 10708 KB Output is correct
61 Correct 16 ms 10836 KB Output is correct
62 Correct 8 ms 10708 KB Output is correct
63 Correct 8 ms 10708 KB Output is correct
64 Correct 10 ms 10804 KB Output is correct
65 Correct 15 ms 10712 KB Output is correct
66 Correct 19 ms 10708 KB Output is correct
67 Correct 8 ms 10708 KB Output is correct
68 Correct 7 ms 10964 KB Output is correct
69 Correct 8 ms 10964 KB Output is correct
70 Correct 7 ms 10964 KB Output is correct
71 Correct 8 ms 10708 KB Output is correct
72 Correct 7 ms 10724 KB Output is correct
73 Correct 7 ms 10708 KB Output is correct
74 Correct 6 ms 10452 KB Output is correct
75 Correct 6 ms 10480 KB Output is correct
76 Correct 7 ms 10452 KB Output is correct
77 Correct 6 ms 10452 KB Output is correct
78 Correct 7 ms 10452 KB Output is correct
79 Correct 7 ms 10452 KB Output is correct
80 Correct 7 ms 10532 KB Output is correct
81 Correct 9 ms 10452 KB Output is correct
82 Correct 6 ms 10452 KB Output is correct
83 Correct 6 ms 10436 KB Output is correct
84 Correct 8 ms 10452 KB Output is correct
85 Correct 5 ms 10452 KB Output is correct
86 Correct 6 ms 10452 KB Output is correct
87 Correct 8 ms 10452 KB Output is correct
88 Correct 8 ms 10708 KB Output is correct
89 Correct 9 ms 10836 KB Output is correct
90 Correct 8 ms 10708 KB Output is correct
91 Correct 7 ms 10716 KB Output is correct
92 Correct 9 ms 10700 KB Output is correct
93 Correct 7 ms 10452 KB Output is correct
94 Correct 9 ms 10452 KB Output is correct
95 Correct 7 ms 10452 KB Output is correct
96 Correct 6 ms 10516 KB Output is correct
97 Correct 6 ms 10452 KB Output is correct
98 Correct 5 ms 10452 KB Output is correct
99 Correct 11 ms 10836 KB Output is correct
100 Correct 9 ms 10836 KB Output is correct
101 Correct 15 ms 10708 KB Output is correct
102 Correct 8 ms 10724 KB Output is correct
103 Correct 13 ms 10748 KB Output is correct
104 Correct 277 ms 26844 KB Output is correct
105 Correct 254 ms 26528 KB Output is correct
106 Correct 321 ms 24212 KB Output is correct
107 Correct 293 ms 27252 KB Output is correct
108 Correct 95 ms 24200 KB Output is correct
109 Correct 279 ms 22468 KB Output is correct
110 Correct 265 ms 26296 KB Output is correct
111 Correct 69 ms 22240 KB Output is correct
112 Correct 157 ms 30876 KB Output is correct
113 Correct 381 ms 26464 KB Output is correct
114 Correct 218 ms 23820 KB Output is correct
115 Correct 198 ms 23216 KB Output is correct
116 Correct 6 ms 10452 KB Output is correct
117 Correct 80 ms 36632 KB Output is correct
118 Correct 82 ms 39424 KB Output is correct
119 Correct 10 ms 10836 KB Output is correct
120 Correct 9 ms 10964 KB Output is correct
121 Correct 15 ms 10708 KB Output is correct
122 Correct 9 ms 10708 KB Output is correct
123 Correct 19 ms 10708 KB Output is correct
124 Correct 68 ms 21764 KB Output is correct
125 Correct 6 ms 10452 KB Output is correct
126 Correct 6 ms 10452 KB Output is correct
127 Correct 5 ms 10452 KB Output is correct
128 Correct 221 ms 24892 KB Output is correct
129 Correct 199 ms 23636 KB Output is correct
130 Correct 351 ms 27324 KB Output is correct
131 Correct 500 ms 24264 KB Output is correct
132 Correct 81 ms 23252 KB Output is correct
133 Correct 293 ms 22096 KB Output is correct
134 Correct 127 ms 22292 KB Output is correct
135 Correct 510 ms 25576 KB Output is correct
136 Correct 65 ms 22456 KB Output is correct
137 Correct 260 ms 26340 KB Output is correct
138 Correct 180 ms 31396 KB Output is correct
139 Correct 211 ms 23728 KB Output is correct
140 Correct 240 ms 24672 KB Output is correct
141 Correct 55 ms 28620 KB Output is correct
142 Correct 83 ms 40756 KB Output is correct
143 Correct 8 ms 10776 KB Output is correct
144 Correct 9 ms 10836 KB Output is correct
145 Correct 8 ms 10748 KB Output is correct
146 Correct 7 ms 10624 KB Output is correct
147 Correct 7 ms 10752 KB Output is correct
148 Correct 7 ms 10452 KB Output is correct
149 Correct 6 ms 10484 KB Output is correct
150 Correct 7 ms 10464 KB Output is correct
151 Correct 7 ms 10516 KB Output is correct
152 Correct 7 ms 10484 KB Output is correct
153 Correct 58 ms 18368 KB Output is correct
154 Correct 66 ms 23748 KB Output is correct
155 Correct 255 ms 28124 KB Output is correct
156 Correct 306 ms 27696 KB Output is correct
157 Correct 305 ms 25640 KB Output is correct
158 Correct 289 ms 28504 KB Output is correct
159 Correct 81 ms 25588 KB Output is correct
160 Correct 300 ms 23796 KB Output is correct
161 Correct 253 ms 27720 KB Output is correct
162 Correct 61 ms 23424 KB Output is correct
163 Correct 169 ms 32024 KB Output is correct
164 Correct 374 ms 27916 KB Output is correct
165 Correct 211 ms 25128 KB Output is correct
166 Correct 198 ms 24684 KB Output is correct
167 Correct 6 ms 10452 KB Output is correct
168 Correct 71 ms 37876 KB Output is correct
169 Correct 97 ms 40696 KB Output is correct
170 Correct 10 ms 10752 KB Output is correct
171 Correct 14 ms 10788 KB Output is correct
172 Correct 15 ms 10708 KB Output is correct
173 Correct 8 ms 10708 KB Output is correct
174 Correct 12 ms 10796 KB Output is correct
175 Correct 58 ms 22616 KB Output is correct
176 Correct 5 ms 10452 KB Output is correct
177 Correct 312 ms 29280 KB Output is correct
178 Correct 167 ms 25292 KB Output is correct
179 Correct 621 ms 25524 KB Output is correct
180 Correct 86 ms 25432 KB Output is correct
181 Correct 95 ms 26620 KB Output is correct
182 Correct 105 ms 26156 KB Output is correct
183 Correct 268 ms 27856 KB Output is correct
184 Correct 246 ms 24776 KB Output is correct
185 Correct 132 ms 24056 KB Output is correct
186 Correct 115 ms 23932 KB Output is correct
187 Correct 89 ms 25424 KB Output is correct
188 Correct 267 ms 27912 KB Output is correct
189 Correct 361 ms 27588 KB Output is correct
190 Correct 239 ms 25968 KB Output is correct
191 Correct 258 ms 25180 KB Output is correct
192 Correct 218 ms 25448 KB Output is correct
193 Correct 223 ms 25372 KB Output is correct
194 Correct 224 ms 25984 KB Output is correct
195 Correct 77 ms 36396 KB Output is correct
196 Correct 85 ms 39584 KB Output is correct
197 Correct 93 ms 41640 KB Output is correct
198 Correct 88 ms 41596 KB Output is correct
199 Correct 7 ms 10708 KB Output is correct
200 Correct 8 ms 10876 KB Output is correct
201 Correct 7 ms 10836 KB Output is correct
202 Correct 16 ms 10752 KB Output is correct
203 Correct 8 ms 10708 KB Output is correct
204 Correct 8 ms 10708 KB Output is correct
205 Correct 8 ms 10836 KB Output is correct
206 Correct 18 ms 10708 KB Output is correct
207 Correct 17 ms 10708 KB Output is correct
208 Correct 9 ms 10708 KB Output is correct
209 Correct 7 ms 10964 KB Output is correct
210 Correct 7 ms 11092 KB Output is correct
211 Correct 7 ms 10964 KB Output is correct
212 Correct 8 ms 10744 KB Output is correct
213 Correct 7 ms 10752 KB Output is correct
214 Correct 7 ms 10708 KB Output is correct
215 Correct 7 ms 10452 KB Output is correct
216 Correct 6 ms 10452 KB Output is correct
217 Correct 7 ms 10452 KB Output is correct
218 Correct 7 ms 10488 KB Output is correct
219 Correct 6 ms 10480 KB Output is correct
220 Correct 8 ms 10480 KB Output is correct
221 Correct 6 ms 10452 KB Output is correct
222 Correct 8 ms 10452 KB Output is correct
223 Correct 6 ms 10488 KB Output is correct
224 Correct 6 ms 10480 KB Output is correct
225 Correct 6 ms 10452 KB Output is correct
226 Correct 8 ms 10484 KB Output is correct
227 Correct 6 ms 10484 KB Output is correct
228 Correct 6 ms 10452 KB Output is correct
229 Correct 220 ms 26228 KB Output is correct
230 Correct 253 ms 24700 KB Output is correct
231 Correct 268 ms 28648 KB Output is correct
232 Correct 482 ms 25556 KB Output is correct
233 Correct 69 ms 24524 KB Output is correct
234 Correct 248 ms 23428 KB Output is correct
235 Correct 123 ms 23724 KB Output is correct
236 Correct 483 ms 26740 KB Output is correct
237 Correct 84 ms 23736 KB Output is correct
238 Correct 280 ms 27708 KB Output is correct
239 Correct 153 ms 32684 KB Output is correct
240 Correct 229 ms 25300 KB Output is correct
241 Correct 202 ms 24616 KB Output is correct
242 Correct 53 ms 28744 KB Output is correct
243 Correct 77 ms 40700 KB Output is correct
244 Correct 7 ms 10708 KB Output is correct
245 Correct 8 ms 10836 KB Output is correct
246 Correct 7 ms 10708 KB Output is correct
247 Correct 8 ms 10708 KB Output is correct
248 Correct 7 ms 10708 KB Output is correct
249 Correct 7 ms 10452 KB Output is correct
250 Correct 6 ms 10452 KB Output is correct
251 Correct 9 ms 10484 KB Output is correct
252 Correct 6 ms 10452 KB Output is correct
253 Correct 5 ms 10452 KB Output is correct
254 Correct 43 ms 18348 KB Output is correct
255 Correct 64 ms 23800 KB Output is correct
256 Correct 68 ms 23400 KB Output is correct
257 Correct 90 ms 24652 KB Output is correct
258 Correct 81 ms 24912 KB Output is correct
259 Correct 76 ms 25036 KB Output is correct
260 Correct 283 ms 28124 KB Output is correct
261 Correct 263 ms 27784 KB Output is correct
262 Correct 297 ms 25784 KB Output is correct
263 Correct 275 ms 28608 KB Output is correct
264 Correct 85 ms 25592 KB Output is correct
265 Correct 294 ms 24004 KB Output is correct
266 Correct 261 ms 27660 KB Output is correct
267 Correct 60 ms 23452 KB Output is correct
268 Correct 152 ms 32092 KB Output is correct
269 Correct 379 ms 27868 KB Output is correct
270 Correct 265 ms 25184 KB Output is correct
271 Correct 192 ms 24636 KB Output is correct
272 Correct 5 ms 10452 KB Output is correct
273 Correct 75 ms 37884 KB Output is correct
274 Correct 87 ms 40696 KB Output is correct
275 Correct 9 ms 10748 KB Output is correct
276 Correct 11 ms 10756 KB Output is correct
277 Correct 17 ms 10708 KB Output is correct
278 Correct 9 ms 10724 KB Output is correct
279 Correct 13 ms 10708 KB Output is correct
280 Correct 60 ms 22660 KB Output is correct