QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#798310#8647. JOI TourMath4Life202048 2137ms803216kbC++1412.3kb2024-12-04 11:34:552024-12-04 11:34:56

Judging History

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

  • [2024-12-04 11:34:56]
  • 评测
  • 测评结果:48
  • 用时:2137ms
  • 内存:803216kb
  • [2024-12-04 11:34:55]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include "joitour.h"
#include <bits/stdc++.h>
using namespace std;
using ll = int; using pii = pair<ll,ll>;
const ll Nm = 2e5+5;

ll N;
long long ans = 0;
vector<int> F,U,V;
vector<pii> locs[Nm]; //{index of subtree, index in subtree}
ll rlbl[Nm];
//vector<ll> hld;

const ll Sm = 4194304; const ll E = 22;

//long long sts0[2*Sm]; //already pushed sum s0
int na0[2*Sm];  //number active in 0
int pd0[2*Sm]; //number to push down
//long long sts2[2*Sm];
int na2[2*Sm];
int pd2[2*Sm];
ll allc = 0; //allocator for memory

inline ll v2(ll x) {
    return __builtin_ctz(x);
}

inline void pdn0(ll p) { //push down at position p
    //return;
    //sts0[p]+=stna0[p]*pd0[p];
    pd0[2*p]+=pd0[p];
    pd0[2*p+1]+=pd0[p];
    pd0[p]=0;
}

inline void pdn2(ll p) { //push down at position p
    //return;
    //sts2[p]+=stna2[p]*pd2[p];
    pd2[2*p]+=pd2[p];
    pd2[2*p+1]+=pd2[p];
    pd2[p]=0;
}

ll wrt0(ll x, ll v) { //v is the DELTA
    //return 0;
    for (ll e=15;e>0;e--) {
        pdn0((x>>e)+(1LL<<(E-e)));
    }
    //sts0[x+Sm] += v*pd0[x+Sm];
    na0[x+Sm] += v;
    for (ll e=1;e<=15;e++) {
        ll p = ((x>>e)+(1LL<<(E-e)));
        //sts0[p] += v*pd0[x+Sm];
        na0[p] += v;
    }
    return v*pd0[x+Sm];
}

ll wrt2(ll x, ll v) {
    //return 0;
    for (ll e=15;e>0;e--) {
        pdn2((x>>e)+(1LL<<(E-e)));
    }
   // sts2[x+Sm] += v*pd2[x+Sm];
    na2[x+Sm] += v;
    for (ll e=1;e<=15;e++) {
        ll p = ((x>>e)+(1<<(E-e)));
        //sts2[p] += v*pd2[x+Sm];
        na2[p] += v;
    }
    return v*pd2[x+Sm];
}

pii wrtI(ll x, ll y, ll v) { //return {n21, n01} updates
    //cout << "write 1 to range "<<x<<","<<y<<"\n";
    //return {0,0};
    if (x>y) {
        return {0,0};
    }
    ll vx = v2(x); ll vy = v2(y+1);
    if (vx<vy) {
        ll p = (x>>vx)+(1<<(E-vx));
        pii p1 = {v*na0[p],v*na2[p]};
        pd0[p]+=v; pd2[p]+=v;
        pii p2 = wrtI(x+(1<<vx),y,v);
        return {p1.first+p2.first,p1.second+p2.second};
    } else {
        ll p = (y>>vy)+(1<<(E-vy));
        pii p1 = {v*na0[p],v*na2[p]};
        pd0[p]+=v; pd2[p]+=v;
        pii p2 = wrtI(x,y-(1<<vy),v);
        return {p1.first+p2.first,p1.second+p2.second};
    }
}

struct cst { //cdt subtree
    ll M;
    long long n0,n2,n21,n01;
    vector<ll> Fn;
    ll r;
    vector<vector<ll>> fadj;
    vector<ll> radj;
    vector<int> tsz; //subtree size
    vector<int> sti; //segtree index
   // vector<long long> v0,v2,v21,v01;
    /*void lft(ll x) {
        v0[x]=(Fn[x]==0);
        v2[x]=(Fn[x]==2);
        v21[x]=0;
        v01[x]=0;
        for (ll y: fadj[x]) {
            lft(y);
            v0[x]+=v0[y];
            v2[x]+=v2[y];
            v01[x]+=v01[y];
            v21[x]+=v21[y];
        }
        if (Fn[x]==1) {
            v01[x]+=v0[x];
            v21[x]+=v2[x];
        }
    }
    void calc() {
        vector<long long> emp(M,0);
        v0=emp; v2=emp; v21=emp; v01=emp;
        lft(r);
        n0=v0[r]; n2=v2[r]; n21=v21[r]; n01=v01[r];
        v0.clear(); v2.clear(); v21.clear(); v01.clear();
    }*/
    cst(ll r0, ll M0, vector<vector<ll>> adj,vector<ll> f0) {
        n0=0; n2=0; n21=0; n01=0;
        r=r0; M=M0;
        Fn=f0;
        vector<bool> found;
        for (ll m=0;m<M;m++) {
            tsz.push_back(0);
            sti.push_back(0);
            radj.push_back(-1);
            found.push_back(0);
            fadj.push_back((vector<ll>){});
        }
        // queue<ll> q;
        // q.push(r);
        // while (!q.empty()) {
        //     ll x = q.front(); q.pop();
        //     found[x]=1;
        //     for (ll y: adj[x]) {
        //         if (!found[y]) {
        //             radj[y]=x;
        //             q.push(y);
        //             fadj[x].push_back(y);
        //         }
        //     }
        // }
        stack<pii> q0;
        q0.push({r,0});
        while (!q0.empty()) {
            pii p0 = q0.top(); q0.pop();
            ll x = p0.first; ll t = p0.second;
            if (t==0) {
                found[x]=1;
                q0.push({x,1});
                for (ll y: adj[x]) {
                    if (!found[y]) {
                        radj[y]=x;
                        q0.push({y,0});
                        fadj[x].push_back(y);
                    }
                }
            } else {
                tsz[x]=1;
               // cout << "x="<<x<<", Fn[x]="<<Fn[x]<<"\n";
                for (ll y: adj[x]) {
                   // cout << "y in fadj="<<y<<"\n";
                    if (radj[y]==x) {
                        //cout << "f1\n";
                        tsz[x]+=tsz[y];
                    }
                }
                //cout << "tsz[x]="<<tsz[x]<<"\n";
                sti[x]=allc;
                if (f0[x]==0) {
                    n0++;
                    n01 += wrt0(allc,1); //v is the DELTA
                } else if (f0[x]==2) {
                    n2++;
                    n21 += wrt2(allc,1);
                } else {
                    pii p1mod = wrtI(allc-tsz[x]+1,allc,1);
                    n01 = p1mod.first+n01;
                    n21 = p1mod.second+n21;
                }
                allc++;
            }
        }
        //cout << "n0,n2,n01,n21="<<n0<<","<<n2<<","<<n01<<","<<n21<<"\n";
        //calc();
    }
    /*void upd(ll x, ll v) {
        Fn[x]=v;
        calc();
    }*/
    void upd(ll x, ll v) {
        if (Fn[x]==0) {
            n0--;
            n01 += wrt0(sti[x],-1);
        } else if (Fn[x]==2) {
            n2--;
            n21 += wrt2(sti[x],-1);
        } else {
            pii p1mod = wrtI(sti[x]-tsz[x]+1,sti[x],-1);
            n01 = p1mod.first+n01;
            n21 = p1mod.second+n21;
        }
        Fn[x]=v;
        if (Fn[x]==0) {
            n0++;
            n01 += wrt0(sti[x],1);
        } else if (Fn[x]==2) {
            n2++;
            n21 += wrt2(sti[x],1);
        } else {
            pii p1mod = wrtI(sti[x]-tsz[x]+1,sti[x],1);
            n01 = p1mod.first+n01;
            n21 = p1mod.second+n21;
        }
       // cout << "n0,n2,n01,n21="<<n0<<","<<n2<<","<<n01<<","<<n21<<"\n";
    }
}; 

struct cdt { //centroid decomp tree
    ll M; //size
    vector<vector<ll>> fadj;
    vector<ll> Fn; //new F
    vector<pii> strl; //subtree locations: {index of st, index in st}
    vector<cst*> v1;
    long long s21=0, s01=0, s0=0, s2=0, s210=0, s012=0, s02=0;
    cdt(ll M1, vector<vector<ll>> fadj1, vector<ll> Fn1) { //fadj is really just adj oops
        M=M1; fadj=fadj1; Fn=Fn1;
        for (ll m=0;m<M;m++) {
            strl.push_back((pii){0,0});
        }
        ll rcnt = 0;
        for (ll x: fadj[0]) {
            //unordered_map<ll,ll> rlbl; //relabel
            vector<vector<ll>> nadj;
            vector<ll> fnew;
            ll Mn = 0;
            queue<pii> q0;
            q0.push({x,-1});
            //cout << "x="<<x<<"\n";
            while (!q0.empty()) {
                pii p0 = q0.front(); q0.pop();
                ll z = p0.first; ll pz = p0.second;
                if (z==0) {
                    continue;
                }
                //if (rlbl.find(z)==rlbl.end()) {
                    rlbl[z]=Mn++;
                    //cout << "defining z="<<z<<" as "<<rlbl[z]<<"\n";
                    nadj.push_back((vector<ll>){});
                    fnew.push_back(Fn[z]);
                    strl[z]={rcnt,rlbl[z]};
                    //cout << "relabel: z="<<z<<"->"<<rlbl[z]<<"\n";
                    //locs[z].push_back({dind,rlbl[z]});
               // }
                if (pz != -1) {
                    //cout << "z,pz="<<z<<","<<pz<<"\n";
                    nadj[rlbl[z]].push_back(rlbl[pz]);
                    nadj[rlbl[pz]].push_back(rlbl[z]);
                }
                for (ll nz: fadj[z]) {
                    if (nz != pz && nz != 0) {
                        q0.push({nz,z});
                    }
                }
            }
            v1.push_back(new cst(0LL,Mn,nadj,fnew));
            rcnt++;
        }
        for (ll r=0;r<rcnt;r++) {
            s21 += (v1[r]->n21);
            s01 += (v1[r]->n01);
            s0 += (v1[r]->n0);
            s2 += v1[r]->n2;
            s210 += (v1[r]->n21)*(v1[r]->n0);
            s012 += (v1[r]->n01)*(v1[r]->n2);
            s02 += (v1[r]->n0)*(v1[r]->n2);
        }
        ans += (s21*s0-s210+s01*s2-s012);
        if (Fn[0]==0) {
            ans += s21;
        } else if (Fn[0]==1) {
            ans += (s0*s2-s02);
        } else {
            ans += s01;
        }
    }
    void upd(ll x, ll vf) {
        if (x==0) {
            ll v0 = Fn[0];
            if (v0==0) {
                ans -= s21;
            } else if (v0==1) {
                ans -= (s0*s2-s02);
            } else {
                assert(v0==2);
                ans -= s01;
            }
            if (vf==0) {
                ans += s21;
            } else if (vf==1) {
                ans += (s0*s2-s02);
            } else {
                assert(vf==2);
                ans += s01;
            }
        } else {
            ll v0 = Fn[0];
            if (v0==0) {
                ans -= s21;
            } else if (v0==1) {
                ans -= (s0*s2-s02);
            } else {
                assert(v0==2);
                ans -= s01;
            }
            ans -= (s21*s0-s210+s01*s2-s012);

            ll i = strl[x].first;
            s21 -= (v1[i]->n21);
            s01 -= (v1[i]->n01);
            s2 -= (v1[i]->n2);
            s0 -= (v1[i]->n0);
            s210 -= (v1[i]->n21)*(v1[i]->n0);
            s012 -= (v1[i]->n01)*(v1[i]->n2);
            s02 -= (v1[i]->n0)*(v1[i]->n2);

            (*v1[i]).upd(strl[x].second,vf);

            i = strl[x].first;
            s21 += (v1[i]->n21);
            s01 += (v1[i]->n01);
            s2 += (v1[i]->n2);
            s0 += (v1[i]->n0);
            s210 += (v1[i]->n21)*(v1[i]->n0);
            s012 += (v1[i]->n01)*(v1[i]->n2);
            s02 += (v1[i]->n0)*(v1[i]->n2);

            v0 = Fn[0];
            if (v0==0) {
                ans += s21;
            } else if (v0==1) {
                ans += (s0*s2-s02);
            } else {
                assert(v0==2);
                ans += s01;
            }
            ans += (s21*s0-s210+s01*s2-s012);
        }
        Fn[x]=vf;
    }
};

vector<ll> adj[Nm];
bool found[Nm];
ll sz[Nm]; 
ll rev[Nm];
vector<cdt*> cdtr;

ll getsz(ll x, ll pr = -1) {
    sz[x]=1;
    for (ll y: adj[x]) {
        if (y != pr && !found[y]) {
            sz[x]+=getsz(y,x);
        }
    }
    return sz[x];
}

ll getctr(ll x, ll sz0, ll pr=-1) {
    for (ll y: adj[x]) {
        if (y != pr && !found[y]) {
            if (2*sz[y]>=sz0) {
                return getctr(y,sz0,x);
            }
        }
    }
    return x;
}

ll dind = 0; //index in cdtr

void bldDcmp(ll x=0) { //start, previous
    ll sz0 = getsz(x);
    ll y = getctr(x,sz0);
    vector<vector<ll>> nadj; //new adjacency
    vector<ll> fnew;
    ll M = 0;
    queue<pii> q0;
    q0.push({y,-1});
    while (!q0.empty()) {
        pii p0 = q0.front(); q0.pop();
        ll z = p0.first; ll pz = p0.second;
        rlbl[z]=M++;
        nadj.push_back((vector<ll>){});
        fnew.push_back(F[z]);
        locs[z].push_back({dind,rlbl[z]});
        if (pz != -1) {
            nadj[rlbl[z]].push_back(rlbl[pz]);
            nadj[rlbl[pz]].push_back(rlbl[z]);
        }
        for (ll zn: adj[z]) {
            if (!found[zn] && zn != pz) {
                q0.push({zn,z});
            }
        }
    }
    cdtr.push_back(new cdt(M,nadj,fnew));
    found[y]=1;
    dind++;
    for (ll z: adj[y]) {
        if (!found[z]) {
            bldDcmp(z);
        }
    }
}

void init(int N1, vector<int> F1, vector<int> U1, vector<int> V1, int Q) {
    N=N1;
    F=F1;
    U=U1;
    V=V1;
    for (ll i=0;i<(N-1);i++) {
        adj[U[i]].push_back(V[i]);
        adj[V[i]].push_back(U[i]);
    }
    bldDcmp(); //build centroid decomposition
}

void change(int x, int y) {
    for (pii p0: locs[x]) {
        (*cdtr[p0.first]).upd(p0.second,y);
    }
}

long long num_tours() {
    return ans;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 0ms
memory: 49664kb

input:

400
1 1 0 2 2 0 2 1 1 1 1 0 1 2 2 2 2 0 0 2 0 2 0 2 1 1 2 2 1 2 1 0 1 2 2 2 0 0 0 2 1 2 2 0 0 0 1 2 1 1 0 1 1 2 1 2 2 2 1 1 0 1 1 1 2 2 1 1 0 0 1 1 0 0 1 1 1 2 2 2 1 1 2 1 1 1 0 2 0 2 1 0 1 1 2 0 0 2 1 0 2 2 1 0 0 0 0 1 1 1 0 1 2 1 1 1 2 0 2 2 0 2 0 1 0 1 1 1 1 0 1 1 0 0 0 2 2 0 2 2 2 1 1 0 1 2 0 1 ...

output:

597892
604453
604236
600488
598028
594449
593671
586072
582432
581797
586919
588018
591441
592178
589303
587825
591777
595845
591906
591733
593937
592286
587593
583280
582383
580941
576582
577908
579779
578590
578141
577238
577854
584168
591759
594698
591476
590496
583825
582797
581264
586076
587779...

result:

ok 

Test #2:

score: 6
Accepted
time: 3ms
memory: 53004kb

input:

3
1 2 2
0 2
0 1
100
1 0
2 0
0 2
0 0
0 1
2 1
0 2
0 1
0 2
0 1
0 2
1 2
2 2
0 1
2 0
1 0
1 2
1 0
1 1
0 2
1 2
1 0
2 2
2 0
1 1
0 1
1 2
2 1
2 2
2 0
2 2
2 0
2 1
2 0
2 1
1 1
1 0
1 1
0 0
2 0
0 1
1 0
1 2
0 0
0 1
1 1
0 0
2 2
0 1
2 0
0 2
2 2
2 1
1 2
0 1
1 1
1 2
1 0
0 2
2 0
2 1
0 0
0 1
1 2
1 1
2 2
1 2
0 2
1 1
0 1
...

output:

0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0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0
0
0
0
0
3
4
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
0
0
0
0
0
0
2
0
0
0
0
0
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 

Test #5:

score: 6
Accepted
time: 6ms
memory: 53240kb

input:

6
0 0 0 0 0 2
2 4
4 5
0 4
2 3
1 5
100
5 1
3 1
4 1
0 2
2 2
2 0
5 2
4 0
2 2
1 2
4 2
0 1
3 0
4 0
0 2
3 1
4 1
4 0
4 1
0 0
3 2
2 1
2 2
3 1
3 0
1 0
4 2
0 1
5 0
3 1
2 0
2 1
0 2
5 2
1 2
5 1
1 0
2 0
3 0
4 0
1 2
3 2
2 1
5 0
0 1
4 2
4 1
0 0
2 0
3 0
3 2
3 0
5 2
3 2
0 1
0 0
5 0
1 1
4 2
5 1
3 1
2 2
0 2
2 1
1 0
1 ...

output:

0
0
0
0
3
4
3
3
0
0
0
0
0
0
0
0
0
0
0
0
3
4
4
4
3
5
4
0
0
0
0
0
0
0
0
0
0
2
2
2
1
3
2
2
2
2
1
2
5
4
3
4
3
6
5
2
5
4
2
0
0
0
0
0
0
2
0
1
2
2
1
2
4
2
1
2
4
2
1
2
2
3
5
2
4
0
2
2
0
0
0
1
2
1
0
0
0
0
0
3
2

result:

ok 

Test #6:

score: 6
Accepted
time: 3ms
memory: 53596kb

input:

400
1 1 1 0 0 0 1 1 2 1 1 1 1 1 1 0 2 2 1 0 1 0 2 0 1 2 2 1 1 2 2 1 2 0 2 0 2 0 0 0 0 2 1 2 1 0 2 0 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 1 1 1 2 1 2 0 0 2 1 1 1 2 2 0 0 0 2 2 1 1 1 2 1 1 0 1 0 0 2 1 2 1 2 0 0 2 0 2 1 2 1 1 0 2 2 2 1 1 0 2 0 0 0 1 2 2 1 2 1 0 2 0 0 1 0 0 0 1 2 0 2 1 0 0 0 0 1 1 2 1 1 0 1 0 ...

output:

89736
92089
97184
97881
97958
97957
98575
98780
98194
98636
98571
98118
98137
96880
97697
97751
97126
95885
95846
95881
95780
96554
97541
97088
97147
97124
97229
97271
97761
98723
98751
99213
99575
99558
99541
100018
99689
100639
100160
101057
98928
99588
98995
99010
98196
103072
103702
103678
10365...

result:

ok 

Test #7:

score: 6
Accepted
time: 3ms
memory: 52660kb

input:

400
1 1 0 2 2 0 2 1 1 1 1 0 1 2 2 2 2 0 0 2 0 2 0 2 1 1 2 2 1 2 1 0 1 2 2 2 0 0 0 2 1 2 2 0 0 0 1 2 1 1 0 1 1 2 1 2 2 2 1 1 0 1 1 1 2 2 1 1 0 0 1 1 0 0 1 1 1 2 2 2 1 1 2 1 1 1 0 2 0 2 1 0 1 1 2 0 0 2 1 0 2 2 1 0 0 0 0 1 1 1 0 1 2 1 1 1 2 0 2 2 0 2 0 1 0 1 1 1 1 0 1 1 0 0 0 2 2 0 2 2 2 1 1 0 1 2 0 1 ...

output:

17280
17415
17280
17408
17272
17145
17272
17136
17000
16988
17112
16988
16851
16974
17097
17080
17202
17324
17202
17324
17466
17324
17182
17061
16940
16920
16800
16660
16541
16520
16380
16356
16497
16638
16779
16660
16520
16497
16356
16497
16638
16520
16541
16560
16577
16714
16592
16605
16728
16740
...

result:

ok 

Subtask #2:

score: 8
Accepted

Dependency #1:

100%
Accepted

Test #8:

score: 8
Accepted
time: 28ms
memory: 59132kb

input:

4000
2 0 2 1 2 1 0 2 0 2 2 1 0 2 2 2 2 1 1 2 2 1 1 0 2 0 0 2 1 0 0 1 1 1 0 2 0 2 2 1 0 2 2 1 0 2 2 1 2 2 0 2 0 1 1 2 2 0 2 0 0 1 0 0 0 1 2 1 0 2 2 1 0 0 0 0 1 2 0 0 1 2 1 0 0 1 2 2 1 2 0 2 0 2 1 2 1 0 0 1 1 2 2 2 1 2 2 0 2 0 1 2 0 1 2 1 2 2 1 1 1 2 0 0 0 0 1 2 2 2 0 1 1 2 2 2 0 1 0 0 2 1 1 0 2 0 1 0...

output:

620474975
620091276
620213053
620215716
620182492
619967950
620433875
620378867
619791163
620294584
620042350
620254670
619599499
619635328
619632073
619845490
620198042
620214770
620452856
620637250
620099913
620537344
620561024
620602104
620531392
620536225
620559149
621081398
621137321
621348648
...

result:

ok 

Test #9:

score: 8
Accepted
time: 31ms
memory: 52788kb

input:

4000
0 1 1 2 1 2 1 2 2 2 0 0 2 1 2 1 1 0 0 2 0 0 2 0 2 1 2 1 0 2 2 1 2 0 2 1 0 1 2 1 1 0 0 0 0 1 2 0 1 2 0 1 2 2 1 2 1 2 1 1 0 0 0 0 1 0 0 0 2 2 1 2 2 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 0 0 0 2 0 0 0 2 1 1 2 0 0 0 0 0 0 0 2 0 1 1 1 2 2 2 1 2 0 1 0 2 0 0 1 2 0 2 1 0 0 1 0 2 2 0 0 0 1 0 1 0 0 2 2 1 2 0 0 0...

output:

42768942
42797072
42797223
42840318
42832995
42797246
42797380
42817147
42816920
42815937
42778805
42753526
42752585
42787135
42764416
42796136
42796797
42766303
42765309
42764279
42740223
42739766
42767580
43539681
43587532
43564273
43590474
43562674
43561503
43524119
43524798
43524001
43525085
435...

result:

ok 

Test #10:

score: 8
Accepted
time: 3ms
memory: 55360kb

input:

4000
2 0 2 1 2 1 0 2 0 2 2 1 0 2 2 2 2 1 1 2 2 1 1 0 2 0 0 2 1 0 0 1 1 1 0 2 0 2 2 1 0 2 2 1 0 2 2 1 2 2 0 2 0 1 1 2 2 0 2 0 0 1 0 0 0 1 2 1 0 2 2 1 0 0 0 0 1 2 0 0 1 2 1 0 0 1 2 2 1 2 0 2 0 2 1 2 1 0 0 1 1 2 2 2 1 2 2 0 2 0 1 2 0 1 2 1 2 2 1 1 1 2 0 0 0 0 1 2 2 2 0 1 1 2 2 2 0 1 0 0 2 1 1 0 2 0 1 0...

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 

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 2137ms
memory: 780824kb

input:

200000
0 2 2 0 2 2 0 1 1 0 2 2 0 1 2 2 0 1 0 2 1 1 0 1 0 2 0 2 0 0 0 1 0 0 2 0 2 1 0 0 1 1 1 0 0 2 1 2 2 1 0 2 2 2 0 2 2 1 2 0 1 0 0 1 2 0 0 2 1 1 1 0 1 1 1 2 1 0 1 1 0 1 2 2 2 0 1 0 1 1 0 2 0 1 0 2 0 0 2 2 2 2 2 0 0 2 1 2 2 1 2 0 1 1 1 1 1 0 2 0 2 0 1 1 1 0 1 0 2 1 2 0 1 1 0 2 1 2 2 2 0 0 2 2 2 0 1...

output:

76526232464924

result:

wrong answer 

Subtask #4:

score: 0
Wrong Answer

Test #38:

score: 16
Accepted
time: 4ms
memory: 50508kb

input:

3
1 1 1
0 1
1 2
100
2 0
0 0
0 2
2 1
0 1
0 0
0 1
0 0
1 0
2 2
0 1
0 0
0 1
1 1
0 0
2 0
2 1
2 2
0 2
2 1
2 2
2 0
0 1
2 1
0 2
0 1
2 0
2 1
0 0
2 0
2 1
2 2
0 2
2 0
0 0
2 1
2 0
2 2
1 2
0 1
1 1
2 1
0 0
0 2
0 1
0 0
1 2
1 0
1 2
1 0
0 1
2 2
2 1
2 2
0 2
1 2
2 1
0 0
0 2
0 1
1 1
2 0
0 0
1 2
0 2
0 0
1 0
0 1
0 2
2 1
...

output:

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

output:

748492
751280
745592
746546
748685
749066
748286
746439
742602
741927
739801
738044
740003
732801
732137
732791
741037
740750
744502
744511
744015
746300
749460
745730
745106
751192
750538
754769
756253
757792
760457
756172
757024
761186
760814
761345
762058
764833
769148
767330
764502
764339
767930...

result:

ok 

Test #43:

score: 16
Accepted
time: 19ms
memory: 56064kb

input:

4000
1 1 1 2 0 2 2 1 1 2 0 1 0 1 2 0 1 1 1 1 1 0 0 0 2 2 1 2 2 0 1 2 0 0 2 0 1 0 2 1 2 0 0 0 0 2 0 2 2 1 0 2 2 2 2 1 0 2 1 0 1 1 2 1 0 0 0 2 1 1 0 1 0 1 2 2 2 1 0 1 2 0 2 2 1 2 1 0 1 1 0 1 0 0 2 0 2 2 1 0 1 2 0 2 1 1 0 2 1 2 2 0 0 0 1 2 0 2 1 2 0 0 2 1 1 2 1 1 0 2 1 0 2 0 1 1 0 0 0 0 2 0 2 1 2 0 0 2...

output:

791220194
791202818
791448703
790793734
790538710
790399232
790680228
790274544
789587326
789569532
789589951
789568904
789520169
789458372
789475557
788952064
788936826
788957112
788606079
788625706
788314564
788853784
788476658
788033878
787760817
787604725
787949498
787930696
787950912
787946164
...

result:

ok 

Test #44:

score: 0
Wrong Answer
time: 1519ms
memory: 803216kb

input:

200000
1 2 0 2 1 2 1 1 0 1 1 1 0 1 2 0 2 1 2 1 1 0 0 0 0 2 2 2 0 0 1 1 1 2 1 0 0 2 2 0 2 1 0 2 0 0 1 1 2 2 0 2 0 0 1 1 2 2 0 2 1 1 1 1 0 2 0 1 1 0 2 0 0 2 1 0 2 2 2 0 0 2 0 2 0 2 2 1 2 1 1 2 0 1 0 0 2 0 2 2 1 0 0 2 1 0 2 0 2 1 0 2 1 0 2 0 0 0 0 0 2 0 0 2 2 1 0 2 0 2 1 2 1 2 2 2 0 2 0 0 0 0 2 1 0 0 1...

output:

80368931226833

result:

wrong answer 

Subtask #5:

score: 0
Wrong Answer

Test #60:

score: 16
Accepted
time: 3ms
memory: 53644kb

input:

3
2 0 0
0 1
0 2
100
0 1
2 2
2 1
1 1
0 0
2 2
1 2
0 2
0 1
0 0
0 1
0 2
2 1
1 0
2 2
2 0
0 0
0 2
1 1
1 2
2 2
2 1
0 0
2 2
0 1
1 0
0 0
2 0
1 1
1 0
2 1
2 0
0 2
0 1
2 2
1 1
0 0
0 1
2 1
0 0
2 0
0 1
2 1
2 0
0 2
2 2
0 1
2 0
0 0
0 1
2 1
0 2
0 1
0 2
2 2
1 0
1 1
1 2
1 0
1 2
1 0
0 0
1 1
0 1
1 0
2 0
1 2
1 0
0 2
0 0
...

output:

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

result:

ok 

Test #61:

score: 16
Accepted
time: 0ms
memory: 45612kb

input:

4
1 0 1 0
0 1
0 2
1 3
100
0 2
3 2
1 1
0 1
3 1
3 2
3 1
2 2
1 2
2 1
1 0
2 2
3 2
3 1
1 1
3 2
2 0
3 1
0 2
1 2
2 1
2 2
0 1
1 0
3 0
3 2
3 1
3 0
0 0
2 0
1 1
1 2
0 1
1 0
2 2
2 1
1 1
3 2
0 0
2 2
0 1
3 1
1 0
2 1
2 0
1 2
0 2
3 0
3 1
0 1
0 2
3 2
3 1
1 1
1 0
2 2
0 0
0 1
0 0
0 1
0 0
2 0
0 1
3 2
0 2
3 0
2 2
2 1
3 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
0
2
0
0
0
0
0
0
1
2
1
1
2
0
0
0
0
1
0
2
0
0
0
1
1
0
0
1
0
0
1
0
0
0
1
0
0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0
2
1
0
0
0
0
0
0
0
0
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2
1
2
3
2
3
3
3
0
4
4
3
2
2
2
1
0
0
0
2
2
2
4
2
4
2
2
0
0
0
0
0
0
3
3
3
3
2
2
2
0
0
3
0
0
0
0
0

result:

ok 

Test #64:

score: 16
Accepted
time: 0ms
memory: 48576kb

input:

400
1 1 1 0 1 0 2 2 0 0 2 1 2 2 1 2 2 1 1 1 2 1 0 1 2 0 0 1 0 0 1 0 1 2 1 2 1 2 0 0 1 1 0 2 1 1 1 1 0 2 2 1 2 0 0 1 1 2 1 2 1 1 0 0 0 2 0 2 2 0 1 2 0 2 0 1 0 0 2 2 1 0 2 2 2 2 1 2 1 1 2 1 2 2 2 2 0 0 2 1 2 0 1 1 1 1 0 1 1 0 2 0 0 1 1 1 1 0 1 2 0 2 1 2 1 1 1 0 0 0 2 2 1 0 1 0 0 1 2 1 1 2 0 2 0 1 1 2 ...

output:

81027
81548
82381
82262
82052
81837
81658
81443
82127
81941
82560
80316
79750
80735
80890
73382
73536
73359
73138
72918
72653
71997
72478
72672
72911
72261
72853
73213
72954
73769
74787
74121
73931
71563
71778
70747
70281
70114
67043
66640
66415
65849
66006
66629
66799
66844
71682
71874
72971
72416
...

result:

ok 

Test #65:

score: 16
Accepted
time: 12ms
memory: 57856kb

input:

4000
1 1 1 0 1 1 0 2 1 1 2 1 2 2 1 0 1 2 2 0 1 1 1 1 2 0 1 1 0 0 2 0 1 1 2 2 2 2 1 1 1 1 0 0 1 2 0 1 0 2 1 2 2 1 2 0 1 2 0 0 0 1 1 0 1 2 1 1 1 1 0 1 0 1 1 2 1 1 0 1 1 0 0 2 2 0 1 0 0 1 1 2 0 0 1 0 0 1 0 0 2 0 2 2 1 1 2 0 2 1 2 2 0 1 1 1 1 1 1 1 0 2 0 2 0 1 1 1 1 1 1 0 0 0 1 2 1 2 0 0 0 0 1 1 2 0 0 0...

output:

14132542
14132780
14127197
14127091
14141758
14141687
14141782
14142021
14142204
14134941
14142824
14142974
14140574
14140667
14180192
14184660
14184584
14184417
14184136
14167667
14167744
14167912
14167710
14167788
14174353
14182082
14181898
14186831
14198546
14205957
14196800
14206231
14206053
141...

result:

ok 

Test #66:

score: 0
Wrong Answer
time: 1359ms
memory: 678656kb

input:

200000
0 1 1 2 2 0 2 2 0 2 0 2 1 1 2 1 1 0 1 1 1 2 1 1 0 1 1 0 2 2 1 0 1 0 1 0 0 1 2 1 1 0 0 1 1 1 1 0 2 0 2 1 0 2 2 0 2 0 0 1 1 1 2 1 0 0 1 0 2 2 2 1 1 2 1 0 0 1 0 2 1 0 1 1 1 2 1 0 1 1 2 2 2 1 2 2 0 1 1 1 2 0 0 2 0 1 0 1 0 2 0 2 1 2 2 1 0 0 0 2 1 2 0 0 1 2 2 1 1 1 0 0 1 2 2 2 2 0 0 1 1 0 1 0 1 2 2...

output:

42799913280

result:

wrong answer 

Subtask #6:

score: 34
Accepted

Dependency #2:

100%
Accepted

Test #82:

score: 34
Accepted
time: 1031ms
memory: 404492kb

input:

100000
2 1 0 2 1 2 2 2 0 1 2 1 1 2 1 2 1 1 1 1 1 0 1 0 0 1 0 1 1 2 0 1 2 1 0 1 2 2 2 1 0 1 0 2 1 1 2 0 1 0 0 2 0 2 2 2 2 1 0 2 0 1 1 2 2 2 0 2 1 0 1 1 0 1 1 0 1 1 1 2 2 0 2 1 1 2 0 0 0 2 0 2 2 1 1 2 2 1 2 2 1 0 2 0 1 2 2 1 1 1 2 2 1 1 1 2 0 0 0 0 1 0 0 0 2 0 2 0 0 2 1 0 0 2 2 2 0 1 1 1 1 1 0 1 0 0 1...

output:

9559281849549
9558726709272
9558729881442
9559281849549
9558726709272
9559281849549
9558729881442
9559281849549
9558729881442
9559281849549
9558726709272
9559281849549
9559183715845
9558884413811
9558329259230
9558343181485
9558898362995
9558346366933
9558349676690
9558901679573
9558349676690
955890...

result:

ok 

Test #83:

score: 34
Accepted
time: 1037ms
memory: 378616kb

input:

100000
0 0 1 1 1 2 1 0 1 1 0 2 1 1 1 1 0 0 0 2 1 0 1 2 0 2 0 0 0 2 2 0 2 0 1 1 1 0 2 0 2 1 1 2 1 1 0 0 2 1 0 2 2 1 0 1 1 0 0 2 1 2 0 2 2 1 2 0 2 1 0 2 2 1 0 1 0 1 2 0 0 1 1 2 0 0 0 2 1 2 1 2 0 0 1 2 0 1 2 1 1 1 0 0 1 0 1 2 1 0 2 0 2 2 0 2 0 1 1 1 2 1 1 0 1 0 1 0 0 1 1 1 1 0 2 1 0 0 2 2 2 2 1 1 1 2 1...

output:

9596047596512
9595616104943
9596053532037
9595619499659
9595182072565
9594755235780
9595189245987
9595616104943
9595622020637
9595188010430
9595625415285
9595192640635
9595619499659
9595613541827
9595619499659
9595192640635
9595625415285
9595619499659
9595182072565
9594755235780
9595192640635
959562...

result:

ok 

Test #84:

score: 34
Accepted
time: 1350ms
memory: 396240kb

input:

100000
2 1 2 2 0 0 1 1 1 0 0 2 0 0 2 0 0 2 1 2 2 2 0 0 2 0 2 0 0 1 2 0 1 1 0 0 1 0 0 2 0 0 2 0 1 2 0 1 1 1 2 1 0 1 0 0 2 0 2 1 2 1 1 0 1 2 0 0 2 2 1 2 1 2 1 1 2 2 2 0 1 1 0 1 1 1 0 1 1 0 0 0 0 1 2 0 2 1 2 0 1 1 2 1 2 1 1 2 0 2 2 2 1 0 0 2 1 1 2 2 0 1 2 1 0 0 2 1 0 2 2 0 2 1 1 0 0 1 1 2 0 2 0 0 2 0 1...

output:

9622694298497
9622741686310
9622812806952
9622385374356
9622418884136
9622421503780
9622420867340
9622420434599
9622420218943
9622422748226
9622422450342
9622422397283
9622169880867
9621998244485
9622205951428
9622011532374
9621602858583
9621832212874
9621831997132
9621807638552
9621958911257
962181...

result:

ok 

Test #85:

score: 34
Accepted
time: 1282ms
memory: 394416kb

input:

100000
2 2 1 1 2 1 1 1 1 2 1 1 1 2 1 2 1 2 1 2 2 1 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 1 1 2 1 1 2 1 1 2 2 1 2 1 2 2 2 1 1 2 1 2 1 2 2 1 2 1 2 1 1 1 1 2 1 1 1 2 1 2 2 1 1 2 2 1 1 1 1 1 2 2 2 1 2 2 1 2 2 2 2 1 1 2 2 1 0 2 2 1 2 2 2 1 2 1 1 2 2 2 1 2 2 1 1 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 1 1 0 1 1 2 1 1 1 1 1...

output:

1772658133910
1772639782734
1772648903878
1772618082106
1772649217472
1772697652664
1772731157534
1772763191996
1772788201196
1772800273408
1772798905708
1772762384054
1772809290010
1772773292125
1773433797235
1773430197860
1773394126747
1773373709629
1773409559971
1773427138827
1773429214543
177341...

result:

ok 

Test #86:

score: 34
Accepted
time: 1194ms
memory: 382748kb

input:

100000
2 2 0 0 0 0 0 0 2 0 2 2 2 0 0 0 0 2 0 0 0 2 0 2 0 0 2 2 2 0 2 2 0 1 2 2 2 2 0 0 2 2 2 2 0 2 0 2 0 2 2 0 0 0 2 2 0 0 2 0 2 2 2 2 2 2 0 0 0 2 2 0 0 0 0 0 0 2 2 2 0 0 0 0 0 0 2 0 2 0 0 2 0 2 0 0 0 0 2 2 2 2 2 0 2 2 2 1 2 2 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 0 0 2 2 2 2 0 0 0 2 2 0 2 2 2 2 2...

output:

1843753459322
1843753087792
1843752887582
1843753149703
1843753376437
1842907711904
1843928418693
1843928692910
1843928333235
1843928094156
1843927777974
1844670077790
1844669722756
1844670011062
1844670215928
1844670513830
1844670852422
1844670613096
1844670372198
1844670703956
1845582952910
184558...

result:

ok 

Test #87:

score: 34
Accepted
time: 1320ms
memory: 389336kb

input:

100000
0 1 1 1 1 1 1 1 1 1 0 0 2 1 0 0 1 1 0 1 1 0 1 1 1 1 0 1 1 1 0 0 1 0 1 1 0 0 1 0 1 0 0 0 0 1 1 1 0 0 1 1 1 1 1 0 1 2 2 1 1 0 0 1 1 1 0 0 0 1 1 1 0 1 0 0 1 0 0 1 1 1 1 1 0 2 0 1 0 2 0 0 1 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 1 0 0 2 1 1 0 0 0 0 0 1 1 0 2 0 1 0 0 1 1 1 1 1 0 1 1 0 1 0 1 0 1 0 0 0 0 0 0...

output:

1819509716742
1819523711225
1819540834260
1819553383315
1819563838563
1819562574646
1819526028449
1819557687502
1819582585402
1818769577336
1819313617009
1819342800218
1819342227082
1818768476934
1818743031680
1818772634362
1818804432744
1818844001778
1818826931304
1818865298394
1818825092164
181878...

result:

ok 

Test #88:

score: 34
Accepted
time: 997ms
memory: 353164kb

input:

100000
0 0 0 2 1 1 2 1 0 1 2 2 2 0 1 1 0 2 0 1 2 1 1 0 1 0 1 2 2 2 1 0 2 1 2 0 2 1 2 0 0 2 0 1 1 2 2 0 1 2 0 2 2 1 1 1 2 1 2 0 0 2 1 1 1 2 1 1 0 2 1 1 1 0 1 2 1 0 2 1 1 2 1 1 2 0 2 2 0 1 0 0 2 0 0 0 2 2 0 2 0 0 0 0 0 2 0 0 0 2 2 1 2 0 1 2 2 2 2 2 2 0 0 1 2 1 1 1 1 0 2 1 2 0 0 1 0 2 1 0 2 2 1 2 2 2 0...

output:

85533161552
85530394278
85527900114
85525331224
85522844128
85525611360
85528304613
85530708556
85530692903
85527908072
85530565223
85533241447
85535788637
85533232941
85533217460
85535938670
85533159843
85530417127
85527677728
85530322861
85533020406
85535709872
85538183615
85536297229
85538975445
...

result:

ok 

Test #89:

score: 34
Accepted
time: 937ms
memory: 343044kb

input:

100000
1 0 1 0 0 1 0 2 1 2 0 2 1 2 2 2 0 1 2 1 0 2 1 1 2 0 0 0 2 1 2 0 1 2 2 0 0 2 1 2 1 2 2 1 0 1 1 1 0 1 2 1 1 0 0 0 2 2 1 2 2 1 0 2 2 0 2 0 2 2 0 2 1 1 2 1 1 1 0 2 2 0 0 1 2 0 2 1 1 1 0 2 1 0 1 2 2 1 0 2 0 0 1 0 2 0 1 1 2 0 2 0 2 1 0 0 2 0 0 0 0 0 0 2 0 0 0 2 1 0 0 1 0 0 0 1 2 2 0 2 0 2 2 0 2 2 0...

output:

88163490600
88160808346
88160823013
88160806597
88163278177
88160659295
88160650228
88160632339
88158778956
88158767343
88158788337
88156045885
88158477899
88161276306
88163944130
88161470349
88161489759
88158923131
88158900690
88158880553
88156266829
88156277772
88158744340
88156157169
88153483056
...

result:

ok 

Test #90:

score: 34
Accepted
time: 1149ms
memory: 364044kb

input:

100000
1 1 2 1 0 2 1 1 2 2 0 2 1 1 2 0 0 1 2 2 0 1 0 0 0 1 2 2 1 2 0 0 2 2 0 1 2 0 0 1 2 1 0 2 0 2 0 0 1 1 2 0 2 1 0 1 0 1 2 0 2 1 1 2 0 1 1 2 1 0 0 2 2 1 1 2 0 1 1 1 0 2 0 2 2 2 2 0 0 2 2 2 0 0 0 2 0 1 1 1 0 2 0 0 0 1 2 0 1 2 0 0 2 1 1 1 0 2 2 1 1 2 2 0 2 2 0 0 0 0 2 1 0 0 2 1 1 0 1 2 2 2 1 0 2 1 1...

output:

29984838387
29985755560
29985756841
29984806281
29985878178
29986890992
29986890294
29985914110
29985913709
29986824656
29985753613
29986630132
29987705519
29986903166
29987877242
29987878744
29987038858
29986095385
29986094477
29985114036
29985115301
29985918815
29985918476
29985047769
29985952726
...

result:

ok 

Test #91:

score: 34
Accepted
time: 1156ms
memory: 362584kb

input:

100000
0 0 2 1 1 2 2 0 1 1 0 2 0 0 2 2 1 1 1 2 2 1 2 0 1 1 1 0 2 1 0 1 0 1 0 1 1 1 0 2 0 1 0 2 2 2 2 0 2 0 2 1 2 1 1 0 0 0 2 0 0 2 1 2 2 0 2 2 2 2 0 0 0 1 0 1 1 0 2 1 0 0 2 2 0 1 1 1 2 0 0 2 0 0 1 2 1 2 2 2 1 2 0 2 0 2 0 1 1 0 2 1 0 0 1 0 1 2 2 2 0 0 1 1 1 0 0 0 0 2 0 2 1 1 2 0 1 0 0 2 1 1 0 0 2 1 2...

output:

93294755255
93291946437
93291905849
93291930160
93291970148
93288955619
93288998449
93289042651
93289002479
93291744929
93294689769
93294650692
93291768144
93294445662
93291579404
93291617784
93294316936
93291496921
93288670156
93285734973
93283089413
93280296518
93277353657
93277315526
93280162676
...

result:

ok 

Test #92:

score: 34
Accepted
time: 1060ms
memory: 346144kb

input:

100000
1 2 2 0 1 1 0 0 0 0 0 0 2 2 1 2 0 0 0 0 0 1 2 0 1 0 2 0 0 2 0 1 0 1 0 1 2 2 0 2 1 2 0 2 2 0 0 1 2 1 1 2 1 0 0 1 2 1 0 2 1 0 1 0 0 2 0 2 2 0 1 1 0 1 2 0 0 2 2 0 1 2 0 1 1 2 2 1 2 0 2 1 0 0 0 1 2 2 1 0 1 1 0 2 1 0 0 2 1 1 1 2 0 1 0 1 0 1 2 0 0 2 1 2 1 1 2 0 2 1 1 1 0 0 0 1 2 1 2 2 1 1 1 2 2 2 2...

output:

316136684336
316136626565
316136536103
316127639502
316118013463
316107977992
316107913417
316117391225
316107301123
316097347283
316087783495
316087737078
316078110459
316087866540
316077980382
316087308618
316097274857
316088143581
316097797283
316107750466
316107683345
316117437095
316117370809
3...

result:

ok 

Test #93:

score: 34
Accepted
time: 1044ms
memory: 328268kb

input:

100000
0 0 2 0 0 0 0 1 0 1 1 0 2 0 2 2 2 1 2 1 2 0 1 2 1 0 0 1 2 2 0 2 2 0 2 1 2 2 2 1 1 0 1 2 1 1 2 1 2 0 2 1 0 1 2 1 2 1 0 1 0 2 0 1 2 2 1 2 1 2 0 2 1 1 1 1 0 0 0 0 0 0 1 0 0 2 0 0 0 1 1 1 0 2 0 2 1 0 1 1 0 1 1 0 1 2 0 2 0 1 0 0 0 0 1 1 1 1 2 1 2 1 1 2 2 2 1 0 2 1 0 0 0 2 0 1 2 2 1 1 1 0 2 2 1 0 2...

output:

1095656831871
1095619257668
1095618839928
1095588795545
1095554618379
1095554736432
1095589461566
1095589737943
1095624279061
1095623976424
1095624284716
1095598229229
1095568067817
1095567763685
1095568137834
1095568080998
1095602558471
1095568532073
1095534383970
1095567808145
1095567574094
109553...

result:

ok 

Test #94:

score: 34
Accepted
time: 1076ms
memory: 372360kb

input:

100000
2 1 0 0 0 2 1 0 1 1 2 1 0 0 1 1 2 2 2 2 1 0 1 2 1 0 0 1 2 1 0 2 2 0 0 0 1 1 1 1 0 2 1 1 2 2 0 1 1 1 0 2 0 1 0 2 1 0 2 1 1 2 2 0 0 0 1 0 1 1 1 1 2 2 1 1 1 0 0 2 0 2 0 1 0 2 1 2 2 0 2 0 0 1 1 0 2 0 1 0 2 2 1 0 0 1 2 0 0 1 0 1 2 2 1 0 1 0 2 1 1 2 2 0 2 0 0 2 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 2 2...

output:

4097865354006
4098331326178
4098516651380
4098050662313
4098049761584
4098050662313
4098516651380
4098050662313
4098516651380
4098050662313
4098516651380
4098050662313
4098516651380
4098049761584
4098050662313
4098142136514
4098141235639
4098608141919
4098142136514
4098238707855
4098237808229
409870...

result:

ok 

Test #95:

score: 34
Accepted
time: 1276ms
memory: 347616kb

input:

100000
1 1 2 1 2 1 2 1 1 2 1 1 2 0 0 0 0 2 2 2 0 1 0 0 1 2 0 0 0 1 0 1 1 1 1 2 1 0 1 1 0 0 1 2 1 0 1 0 1 2 0 1 2 1 0 2 2 2 1 1 2 0 2 1 1 0 1 1 1 2 1 0 0 2 2 0 0 0 1 1 2 2 0 2 0 0 0 0 0 0 1 1 0 0 0 1 2 1 1 0 1 0 0 0 2 0 1 0 0 1 2 2 0 0 2 1 2 2 2 0 0 2 1 0 2 2 0 0 1 2 1 2 1 2 2 1 0 2 2 1 0 2 0 0 1 0 1...

output:

4130152291057
4130056852820
4130179707803
4130180563664
4130181455962
4130294178778
4130174597295
4130298144138
4130393454351
4130394596969
4130393850725
4130488422291
4130372094581
4130372982891
4130512333976
4130606032139
4130484424711
4130485171130
4130485895897
4130611887465
4130730104101
413073...

result:

ok 

Test #96:

score: 34
Accepted
time: 1261ms
memory: 348596kb

input:

100000
0 2 0 0 1 1 1 2 1 2 1 1 0 2 0 1 2 0 1 0 0 0 0 0 1 0 0 2 1 1 0 0 1 2 0 1 2 0 0 2 0 0 0 1 0 2 0 0 1 1 0 2 1 1 2 2 2 0 1 2 2 0 1 0 2 2 2 2 2 0 2 2 1 2 0 2 0 0 2 1 0 1 1 0 2 2 2 2 0 0 1 0 1 1 1 0 2 1 1 0 2 0 0 0 1 0 2 0 0 2 0 1 2 1 1 1 0 0 0 0 1 0 2 0 1 2 0 1 0 0 1 1 2 0 2 1 2 0 0 0 0 2 0 2 1 0 1...

output:

4100962908565
4100510865543
4100607662611
4100487528621
4100488262981
4100865918189
4100866614488
4100865516353
4100866242610
4100728509312
4101187810873
4101062881775
4100692329824
4101011802771
4100762608651
4100761526715
4100630386031
4100765060727
4101084455940
4101085404592
4100706314594
410058...

result:

ok 

Test #97:

score: 34
Accepted
time: 1246ms
memory: 361868kb

input:

100000
1 1 1 1 2 1 2 2 1 1 2 1 2 1 2 2 1 1 2 2 2 1 2 1 1 1 1 2 2 2 2 2 1 2 2 1 2 1 1 2 1 2 1 1 1 1 0 1 2 2 1 2 1 1 1 2 1 2 2 1 2 2 1 2 2 1 1 2 1 2 2 2 2 1 1 0 2 1 2 1 2 2 1 2 2 1 1 2 1 1 2 2 2 1 1 1 2 1 2 2 2 2 2 2 1 2 2 1 1 1 1 2 1 1 1 2 2 1 2 2 2 2 1 1 2 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 1 2 2 1 1 1 2...

output:

760293049692
760306100439
760263999028
760480245694
760492615292
760480829183
760493497722
760535256365
760557814477
760545556296
760586281642
760572056367
760550639584
760536606475
760715883136
760715172930
760727499627
760745780459
760758584604
760778253175
760830109490
760842444211
760860329576
7...

result:

ok 

Test #98:

score: 34
Accepted
time: 1281ms
memory: 351832kb

input:

100000
2 0 0 2 2 0 0 0 2 1 0 0 0 2 2 2 2 2 0 2 0 0 0 2 2 2 0 2 2 0 2 0 2 0 0 2 0 0 2 2 2 0 2 1 0 2 2 2 0 0 2 0 2 0 0 0 0 2 0 1 2 0 0 2 2 0 0 0 1 2 0 0 0 0 2 2 0 0 2 2 2 2 0 2 0 2 0 1 2 0 0 2 2 1 2 2 0 0 1 0 2 0 2 2 0 2 2 2 0 0 2 0 1 2 2 2 0 2 0 0 2 0 2 0 0 0 0 2 0 2 2 0 0 2 0 2 0 0 2 2 0 0 2 2 0 2 0...

output:

826654004799
826654194674
826654133463
826654181312
826654023514
826653920266
826653733788
826653945959
826654117797
826653908276
826653782514
826653654511
826653600933
826653703960
826653569046
826653403956
826653364326
826653257770
826653422914
826637448595
826637279229
826637350616
826637456619
8...

result:

ok 

Test #99:

score: 34
Accepted
time: 1315ms
memory: 348028kb

input:

100000
0 0 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 1 2 1 0 1 0 0 1 1 0 0 0 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 0 0 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 0 0 0 0 1 1 1 0 1 1 1 0 0 0 1 0 0 1 0 0 2 1 0 1 1 1 0 0 1 0 0 0 1 1 1 1 0 1 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 1 0 0 2...

output:

805664825072
805710705933
805723700257
805746319258
805945918968
805738618967
805724576457
806002959191
805989799837
805977031104
806165842730
806385976425
806408592276
806377174159
806363910989
806347226901
806360612288
806338305997
806276355069
806502601984
806516973760
806533700682
806519137461
8...

result:

ok 

Test #100:

score: 34
Accepted
time: 1099ms
memory: 388384kb

input:

100000
0 1 1 2 1 2 1 0 0 2 0 2 1 1 0 1 0 1 0 2 1 2 0 2 0 2 0 0 1 1 2 1 0 1 1 0 1 0 0 0 2 1 2 1 2 2 0 1 2 0 0 0 0 1 1 2 2 1 1 2 1 2 1 1 0 0 1 1 0 1 2 1 1 1 1 1 1 2 0 2 1 1 0 0 0 0 2 2 1 0 2 2 0 2 1 2 2 0 0 1 1 2 0 0 1 0 2 0 0 2 2 0 0 0 1 0 1 2 2 2 0 1 1 1 0 1 0 1 2 1 2 0 0 1 1 1 2 0 1 0 1 2 0 0 0 2 0...

output:

12378861465034
12378861549997
12379137199914
12378861549997
12378861465034
12379137199914
12378861549997
12379137199914
12378861549997
12379137199914
12378861549997
12378861465034
12379137199914
12378861549997
12378861465034
12379137199914
12379139464690
12378863821511
12378861607010
12378861521021
...

result:

ok 

Test #101:

score: 34
Accepted
time: 1048ms
memory: 406380kb

input:

100000
2 1 0 2 1 1 0 2 1 0 1 0 1 2 0 2 0 0 0 1 0 2 2 1 1 1 1 1 1 2 2 1 2 0 2 2 0 2 1 2 1 0 2 2 0 2 2 2 1 2 0 2 1 0 2 0 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 2 0 0 2 0 2 2 1 1 2 2 1 0 1 1 2 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 2 0 1 0 0 2 0 0 2 0 1 0 2 0 0 1 1 0 2 1 2 0 0 1 0 2 2 0 1 1 0 0 0 0 0 0 2 2 0 2 0 1...

output:

12356317730902
12355757413015
12355206931832
12355757413015
12356309564939
12355759083756
12356309564939
12355757413015
12356309564939
12356317730902
12355757413015
12355764355718
12356316540921
12355759083756
12356316540921
12355764355718
12355757413015
12355206931832
12355764355718
12356324640326
...

result:

ok 

Test #102:

score: 34
Accepted
time: 1336ms
memory: 391824kb

input:

100000
0 0 2 0 2 1 0 2 0 0 1 2 1 2 2 2 2 2 0 2 1 1 0 1 0 0 0 2 1 1 0 2 2 2 1 1 2 0 0 1 1 1 0 1 1 1 0 1 2 0 0 0 1 0 0 2 0 0 1 0 2 2 2 0 0 0 1 1 2 0 0 1 0 2 1 2 1 1 2 1 0 0 2 0 0 1 2 1 0 2 0 1 0 0 1 1 0 0 0 1 0 2 2 2 1 0 2 0 0 0 0 2 2 2 1 2 2 0 0 1 1 0 1 1 0 1 1 0 1 2 2 0 2 1 0 1 0 2 2 2 1 1 0 1 1 0 2...

output:

12361639333356
12361912035054
12361609273559
12361770767102
12361412299625
12361269172442
12361537499341
12361367443063
12361634309892
12362109703751
12362114355666
12362375712286
12362234785038
12362428752181
12362669907842
12362625781780
12362630221089
12362634525130
12362620483084
12362319321363
...

result:

ok 

Test #103:

score: 34
Accepted
time: 895ms
memory: 309876kb

input:

100000
2 0 2 2 0 2 1 1 1 2 1 2 1 2 0 1 0 0 1 0 1 1 1 1 2 1 2 0 0 0 2 0 2 0 0 2 1 2 0 0 0 2 2 1 0 2 0 1 1 2 2 1 1 1 2 0 2 0 0 0 1 2 2 1 0 2 2 0 0 1 0 0 1 1 1 1 0 2 0 0 2 1 2 0 1 2 2 1 2 1 0 1 2 0 2 0 2 0 1 2 0 2 0 2 1 0 0 2 0 2 1 0 1 0 1 0 2 0 2 1 1 2 2 0 1 0 1 1 2 2 1 2 1 0 1 1 2 0 1 0 0 2 1 1 1 2 2...

output:

145953829313
146504500096
145953786136
146504500096
145953829313
146504500096
145953786136
146504500096
146498364765
146494865483
145944184844
145944228277
145940137065
146490757708
146487565932
145936961863
145866474549
145866437173
145862282860
146412887959
145862282860
146412887959
145862239383
1...

result:

ok 

Test #104:

score: 34
Accepted
time: 1026ms
memory: 312388kb

input:

100000
2 2 0 0 2 1 0 1 1 0 0 2 0 1 1 0 2 1 1 1 0 2 1 2 1 1 1 0 0 2 1 0 0 1 1 0 1 0 1 0 0 0 2 2 2 1 0 0 2 1 2 1 0 2 2 2 1 2 1 0 1 2 2 1 2 2 0 2 0 1 2 1 0 2 1 2 0 1 0 2 2 2 2 0 0 1 1 0 2 1 1 0 1 2 1 1 2 0 2 2 1 0 1 1 2 0 0 2 0 1 0 1 0 0 0 0 2 2 1 0 0 0 1 1 1 0 0 2 1 2 1 0 1 0 0 1 0 2 0 1 2 0 1 2 2 1 2...

output:

151045518233
151048940412
151048989721
151053526119
151050138354
151050193203
151055666168
151055685648
151051538661
151051501359
151051437434
151055614564
151055562909
151050782917
151045903094
151045858691
151045902613
151050281551
151054706281
151054659497
151051011982
151051038544
151050997994
1...

result:

ok 

Test #105:

score: 34
Accepted
time: 1035ms
memory: 307656kb

input:

100000
2 1 1 2 1 2 1 1 2 2 1 2 2 2 2 1 2 2 2 1 2 2 1 1 2 2 1 2 2 2 2 1 2 1 2 2 1 2 2 2 2 2 1 1 0 2 1 2 2 1 1 2 1 2 2 1 2 2 1 1 1 2 1 2 2 1 1 0 1 1 1 2 2 2 1 1 2 1 2 2 1 1 2 0 1 1 2 1 2 2 2 1 2 1 1 1 1 2 1 1 1 1 1 1 2 1 2 1 1 0 1 2 2 2 2 1 2 2 1 1 2 1 2 1 1 1 2 1 1 1 2 1 2 2 2 2 1 2 2 2 1 1 2 1 2 1 1...

output:

32424642834
32424016637
32423181413
32422521607
32422011030
32421420718
32421975315
32422021723
32421445691
32422124570
32421644969
32437042481
32437981275
32437188280
32437694289
32437234630
32436460553
32435914229
32435762179
32436340401
32437235210
32436735319
32436674155
32436085921
32435406450
...

result:

ok 

Test #106:

score: 34
Accepted
time: 1026ms
memory: 313416kb

input:

100000
2 2 0 2 2 0 0 0 2 2 0 2 2 0 2 2 0 2 0 2 2 0 0 0 2 0 0 2 0 2 2 0 2 0 0 0 0 0 0 0 2 0 2 2 2 2 2 2 0 2 0 0 2 2 0 0 2 2 0 2 0 0 0 2 2 0 0 2 0 2 0 2 2 0 2 0 2 0 2 2 2 0 0 2 2 0 2 0 0 0 2 0 0 0 0 0 2 2 2 2 2 0 0 2 2 2 0 2 2 0 0 2 0 2 2 1 2 0 0 2 2 2 2 2 0 0 2 0 0 0 2 0 2 0 2 0 0 0 2 1 2 2 0 0 0 2 0...

output:

30359891732
30359464977
30359456207
30359468177
30359458176
30359469622
30359249191
30359234680
30359226951
30359218756
30297949108
30297963056
30297968904
30297347234
30297356949
30297345763
30297355160
30297345296
30297358418
30297351515
30297358970
30297347945
30297338878
30297327219
30297318098
...

result:

ok 

Test #107:

score: 34
Accepted
time: 1044ms
memory: 320388kb

input:

100000
0 0 1 0 0 1 1 1 0 0 1 1 1 1 0 2 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 0 0 0 0 1 1 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 0 0 1 0 1 2 0 0 0 1 1 1 0 1 1 1 1 0 1 0 2 0 1 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 1 0 0 0 1 1 1 1 0 2 1...

output:

30136609798
30136083207
30136736964
30135867822
30136355770
30136818513
30137497353
30137018626
30137619738
30138121767
30138581832
30138076345
30147341758
30147950560
30147393815
30147136333
30157889347
30161770164
30162347130
30161851147
30154669620
30163331241
30162783461
30162151016
30161255000
...

result:

ok 

Test #108:

score: 34
Accepted
time: 1059ms
memory: 318664kb

input:

100000
2 0 1 2 1 0 0 1 1 2 2 0 0 0 2 1 1 0 1 1 0 1 1 0 0 0 0 0 1 1 2 2 2 2 1 2 0 2 2 1 2 1 2 0 0 2 2 0 1 0 0 1 0 1 1 0 2 1 2 2 0 1 1 1 2 1 2 2 1 2 1 0 2 2 2 1 0 1 2 0 1 1 0 0 1 0 1 2 0 0 2 1 2 0 1 0 0 1 0 0 0 0 1 0 2 1 1 2 2 2 2 2 2 0 0 0 1 2 0 2 0 0 0 0 0 0 0 0 2 2 1 1 0 1 1 1 2 1 1 1 1 1 2 0 2 2 1...

output:

135628486664
135625574730
135621919068
135617830047
135622386052
135623351927
135623329877
135618955253
135614745390
135618471579
135622037033
135625519834
135625536177
135621562312
135617599779
135621889275
135621856312
135626209041
135629696172
135632966938
135629614690
135633710238
135637450477
1...

result:

ok 

Test #109:

score: 34
Accepted
time: 170ms
memory: 137752kb

input:

100000
2 1 0 2 1 2 2 2 0 1 2 1 1 2 1 2 1 1 1 1 1 0 1 0 0 1 0 1 1 2 0 1 2 1 0 1 2 2 2 1 0 1 0 2 1 1 2 0 1 0 0 2 0 2 2 2 2 1 0 2 0 1 1 2 2 2 0 2 1 0 1 1 0 1 1 0 1 1 1 2 2 0 2 1 1 2 0 0 0 2 0 2 2 1 1 2 2 1 2 2 1 0 2 0 1 2 2 1 1 1 2 2 1 1 1 2 0 0 0 0 1 0 0 0 2 0 2 0 0 2 1 0 0 2 2 2 0 1 1 1 1 1 0 1 0 0 1...

output:

1107046824
0
0
1107046824
0
1107046824
0
1107046824
0
1107046824
0
1107046824
1107013440
1107046824
0
0
1107079985
0
0
1107080208
0
1107080208
0
1107080208
0
0
0
0
0
1107080429
0
0
1107080429
0
0
0
0
0
0
0
1107113592
0
0
0
0
0
0
0
0
0
1107113370
0
0
0
1107113370
1107146532
0
1107146532
0
1107146532
...

result:

ok 

Test #110:

score: 34
Accepted
time: 229ms
memory: 134552kb

input:

100000
2 2 2 1 2 0 2 2 0 1 0 1 0 2 0 0 0 1 0 0 1 1 1 2 0 2 2 0 1 0 2 2 1 0 0 0 2 1 2 1 0 0 2 0 2 2 2 0 2 2 2 0 0 0 1 1 2 0 2 0 2 2 1 1 0 0 0 0 0 1 0 0 0 0 2 2 0 0 2 1 0 0 2 0 2 1 1 1 2 1 0 0 2 0 1 1 2 1 0 1 2 1 2 2 0 2 0 0 2 0 0 2 0 1 2 0 2 2 1 0 2 2 0 0 2 0 0 1 2 1 1 0 0 1 2 1 2 2 1 1 1 2 1 0 2 0 0...

output:

1110249440
1110282960
1110249837
1110283356
1110250232
1110249837
1110250232
1110217108
1110217500
1110251016
1110217500
1110251016
1110251405
1110251792
1110284920
1110251405
1110217890
1110251016
1110284532
1110318048
1110351176
1110384304
1110383913
1110417432
1110383913
1110384304
1110351176
111...

result:

ok 

Test #111:

score: 34
Accepted
time: 205ms
memory: 155372kb

input:

100000
1 1 1 1 2 1 2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 1 2 1 2 1 1 2 1 1 2 1 2 1 2 2 2 2 2 2 2 1 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 2 2 2 2 2 1 1 2 2 1 1 1 2 2 2 1 1 2 2 1 2 1 2 2 2 2 1 1 1 1 2 1 0 2 1 2 2 1 2 2 1 2 1 1 1 1 2 2 0 2 2 1 2 0 1 2 1 1 2 2 2 2 1 2 1 1 1 2 1 2 2 2 1 2 1 2 2 0 2 1 1 2 1 1 2 1 1 2 1...

output:

146452258
146455281
146452258
146455281
146458304
146503728
146500704
146497680
146500704
146503728
146500704
146497680
146494656
146497680
146543100
146546125
146549150
146552175
146549150
146552175
146549150
146546125
146543100
146540075
146585492
146588518
146591544
146588518
146585492
146582466
...

result:

ok 

Test #112:

score: 34
Accepted
time: 234ms
memory: 138404kb

input:

100000
2 0 0 2 2 1 0 0 2 2 2 2 2 2 0 0 2 2 2 0 2 0 2 0 0 2 0 0 0 0 2 0 0 0 2 0 1 0 1 0 2 0 0 0 0 2 2 2 0 2 2 2 0 0 0 0 2 2 0 2 1 2 2 0 2 2 0 2 2 0 0 0 2 0 0 2 0 0 2 2 2 2 0 1 2 0 2 2 0 0 0 2 0 0 2 0 0 1 2 2 0 0 0 0 2 0 0 2 2 0 0 0 2 2 0 0 2 2 2 0 0 1 2 2 2 0 0 0 2 2 0 2 2 2 2 0 2 0 0 2 2 2 2 0 0 0 2...

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 

Test #113:

score: 34
Accepted
time: 196ms
memory: 138668kb

input:

100000
1 0 0 1 0 2 1 2 1 1 1 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 1 1 0 0 2 1 0 1 0 0 0 1 2 0 1 0 1 1 1 0 1 0 1 2 0 1 2 1 1 1 0 2 0 1 1 0 0 2 1 1 2 0 1 0 0 1 1 1 0 0 0 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 1 1 0 0 0 1 0 1 1 1 1 2 0 0 0 1 1 1 0 0 1 0 1 1 1 0 0 1 1 0 1 0 1 1 0 0 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 

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%