QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#810542#8647. JOI Tourtopfloorboss48 2281ms910504kbC++2011.2kb2024-12-12 00:42:552024-12-12 00:42:56

Judging History

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

  • [2024-12-12 00:42:56]
  • 评测
  • 测评结果:48
  • 用时:2281ms
  • 内存:910504kb
  • [2024-12-12 00:42:55]
  • 提交

answer

#include "joitour.h"
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <random>
#include <cassert>

using namespace std;

struct Fenwick {
    int n;
    vector<long long> tree;

    Fenwick() {}

    void build(int x) {
        n = x;
        tree.resize(n + 1);
    }

    long long get_sum(int ind){
        long long ans = 0;
        for (int i = ind; i >= 0; i = (i & (i + 1)) - 1){
            ans += tree[i];
        }
        return ans;
    }

    void upd(int ind, long long x){
        for (int i = ind; i < n; i = (i | (i + 1))){
            tree[i] += x;
        }
    }

    long long su(int l, int r){
        return get_sum(r) - get_sum(l-1);
    }
};

struct Fenwick2 {
    int n;
    vector<long long> tree;

    Fenwick2() {}

    void build(int x) {
        n = x;
        tree.resize(n + 3);
    }

    long long get(int ind) {
        long long ans = 0;
        for (int i = ind; i >= 0; i = (i & (i + 1)) - 1){
            ans += tree[i];
        }
        return ans;
    }

    void upd(int ind, long long x) {
        for (int i = ind; i < n; i = (i | (i + 1))){
            tree[i] += x;
        }
    }

    void upd(int l, int r, long long x) {
        upd(l, x);
        upd(r + 1, -x);
    }
};
vector<vector<int>> g;
vector<int> col;

long long anss = 0;

struct HLD {
    vector<vector<int>> gr;
    map<int, int> gt;
    vector<int> ord, tin, tout, backord, up, sz, pr, uppest, c;
    vector<long long> ct01, ct21, ct0, ct2;
    vector<Fenwick> lol;
    Fenwick2 lol1;
    int timer = 1;
    long long ans = 0, tans = 0;

    void dfssz(int v, int p) {
        if (p != -1) {
            pr[v] = p;
            for (int i = 0; i < (int)gr[v].size() - 1; ++i) {
                if (gr[v][i] == p) {
                    swap(gr[v][i], gr[v][i + 1]);
                }
            }
            if (gr[v].size()) gr[v].pop_back();
        }
        if (p == -1) {
            for (auto e : gr[v]) {
                uppest[e] = e;
            }
        } else {
            for (auto e : gr[v]) {
                uppest[e] = uppest[v];
            }
        }
        sz[v] = 1;
        tin[v] = timer++;
        for (auto e : gr[v]) {
            dfssz(e, v);
            ct0[v] += ct0[e];
            ct2[v] += ct2[e];
            ct01[v] += ct01[e];
            ct21[v] += ct21[e];
            sz[v] += sz[e];
        }
        tout[v] = timer++;
        if (c[v] == 0) {
            ct0[v]++;
        }
        if (c[v] == 2) {
            ct2[v]++;
        }
        if (c[v] == 1) {
            ct01[v] += ct0[v];
            ct21[v] += ct2[v];
        }
    }

    void dfs(int v) {
        backord[v] = ord.size();
        ord.push_back(v);
        if (gr[v].size() == 0) return;
        for (auto &e : gr[v]) {
            up[e] = e;
            if (sz[e] > sz[gr[v][0]]) {
                swap(e, gr[v][0]);
            }
        }
        up[gr[v][0]] = up[v];
        for (auto e : gr[v]) {
            dfs(e);
        }
    }

    HLD(){}

    void upd(int v, int x) {
        lol1.upd(backord[v], backord[v] + sz[v] - 1, x);
    }

    long long get1s(int v) {
        return lol1.get(backord[v]);
    }

    long long get0s(int v) {
        return lol[0].su(backord[v], backord[v] + sz[v] - 1);
    }

    long long get2s(int v) {
        return lol[2].su(backord[v], backord[v] + sz[v] - 1);
    }

    void build(vector<int> kek) {
        int n = (int)kek.size();
        gr.resize(n);
        for (int i = 0; i < n; ++i) gt[kek[i]] = i;
        c.resize(n);
        for (int i = 0; i < n; ++i) {
            c[i] = col[kek[i]];
            for (auto e : g[kek[i]]) {
                if (gt.find(e) != gt.end()) {
                    gr[i].push_back(gt[e]);
                }
            }
        }
        uppest.resize(n);
        tin.resize(n);
        tout.resize(n);
        backord.resize(n);
        up.resize(n);
        sz.resize(n);
        pr.resize(n);
        ct0.resize(n);
        ct2.resize(n);
        ct01.resize(n);
        ct21.resize(n);
        dfssz(0, -1);
        dfs(0);
        lol.resize(3);
        lol1.build(n);
        for (int i = 0; i < 3; ++i) {
            if (i == 1) continue;
            lol[i].build(n);
        }
        for (int i = 0; i < n; ++i) {
            if (c[ord[i]] == 1) continue;
            lol[c[ord[i]]].upd(i, 1);
        }
        for (int i = 0; i < n; ++i) {
            if (c[ord[i]] == 1) {
                upd(ord[i], 1);
            }
        }
        for (auto e : gr[0]) {
            ans += ct01[e] * (ct2[0] - ct2[e]);
            ans += ct21[e] * (ct0[0] - ct0[e]);
            int T = ct2[0] - ct2[e];
            if (c[0] == 2) T--;
            // if (c[0] == 1) {
            //     ans += ct0[e] * (ct2[0] - ct2[e]);
            // }
            tans += ct0[e] * T;
        }
    }

    long long get01(int v) {
        if (c[0] == 1) return ct01[0] - ct01[v] - ct0[0];
        return ct01[0] - ct01[v];
    }

    long long get21(int v) {
        if (c[0] == 1) return ct21[0] - ct21[v] - ct2[0];
        return ct21[0] - ct21[v];
    }

    void kek1(int v, int col) {
        v = gt[v];
        if (v == 0) {
            if (c[v] == 2) {
                ans -= ct01[0];
                ct2[v]--;
                lol[2].upd(backord[v], -1);
            }
            if (c[v] == 0) {
                ans -= ct21[0];
                ct0[v]--;
                lol[0].upd(backord[v], -1);
            }
            if (c[v] == 1) {
                ct01[v] -= ct0[v];
                ct21[v] -= ct2[v];
                upd(0, -1);
            }
            c[v] = col;
            if (c[v] == 2) {
                ans += ct01[0];
                ct2[v]++;
                lol[2].upd(backord[v], 1);
            }
            if (c[v] == 0) {
                ans += ct21[0];
                ct0[v]++;
                lol[0].upd(backord[v], 1);
            }
            if (c[v] == 1) {
                ct01[v] += ct0[v];
                ct21[v] += ct2[v];
                upd(0, 1);
            }
            return;
        }
        int t = uppest[v];
        int e = t;
        if (c[v] == 0) {
            int TT = get1s(v);
            if (c[0] == 1) TT--;
            ans -= TT * (ct2[0] - ct2[t]);
            ans -= get21(t);
            ct0[t]--;
            ct01[t] -= get1s(v);
            if (c[0] == 1) ct01[t]++;
            ct0[0]--;
            ct01[0] -= get1s(v);
            lol[0].upd(backord[v], -1);
            int T = ct2[0] - ct2[t];
            if (c[0] == 2) T--;
            tans -= T;
        }
        if (c[v] == 1) {
            ans -= get0s(v) * (ct2[0] - ct2[t]);
            ans -= get2s(v) * (ct0[0] - ct0[t]);
            ct01[0] -= get0s(v);
            ct21[0] -= get2s(v);
            ct01[t] -= get0s(v);
            ct21[t] -= get2s(v);
            upd(v, -1);
        }
        if (c[v] == 2) {
            int TT = get1s(v);
            if (c[0] == 1) TT--;
            ans -= TT * (ct0[0] - ct0[t]);
            ans -= get01(t);
            // cout << c[0] << ' ';
            // cout << get01(t) << ' ' << get1s(v) * (ct0[0] - ct0[t]) << ' ' << ans << ' ';
            ct2[t]--;
            ct21[t] -= get1s(v);
            if (c[0] == 1) ct21[t]++;
            ct2[0]--;
            ct21[0] -= get1s(v);
            lol[2].upd(backord[v], -1);
            int T = ct0[0] - ct0[t];
            if (c[0] == 0) T--;
            tans -= T;
        }
        c[v] = col;
        if (c[v] == 0) {
            int TT = get1s(v);
            if (c[0] == 1) TT--;
            ans += TT * (ct2[0] - ct2[t]);
            ans += get21(t);
            ct0[t]++;
            ct01[t] += get1s(v);
            if (c[0] == 1) ct01[t]--;
            ct0[0]++;
            ct01[0] += get1s(v);
            lol[0].upd(backord[v], 1);
            int T = ct2[0] - ct2[t];
            if (c[0] == 2) T--;
            tans += T;
        }
        if (c[v] == 1) {
            ans += get0s(v) * (ct2[0] - ct2[t]);
            ans += get2s(v) * (ct0[0] - ct0[t]);
            ct01[0] += get0s(v);
            ct21[0] += get2s(v);
            ct01[t] += get0s(v);
            ct21[t] += get2s(v);
            upd(v, 1);
        }
        if (c[v] == 2) {
            int TT = get1s(v);
            if (c[0] == 1) TT--;
            ans += TT * (ct0[0] - ct0[t]);
            ans += get01(t);
            ct2[t]++;
            ct21[t] += get1s(v);
            if (c[0] == 1) ct21[t]--;
            ct2[0]++;
            ct21[0] += get1s(v);
            lol[2].upd(backord[v], 1);
            int T = ct0[0] - ct0[t];
            if (c[0] == 0) T--;
            tans += T;
        }
        e = t;
    }

    long long getans() {
        if (c[0] == 1) return ans + tans;
        return ans;
    }
};

vector<HLD> lol;
vector<int> sz, cc, ord;
vector<vector<int>> p;

void dfssz(int v, int pr) {
    sz[v] = 1;
    for (auto e : g[v]) {
        if (e == pr) continue;
        if (cc[e] != -1) continue;
        dfssz(e, v);
        sz[v] += sz[e];
    }
    ord.push_back(v);
}

void find_centroid(int v, int d) {
    ord.clear();
    dfssz(v, -1);
    int N = sz[v];
    int cntr = -1;
    for (auto &e : ord) {
        if (sz[e] > N / 2) {
            cntr = e;
            swap(e, ord[0]);
            break;
        }
    }
    lol[cntr].build(ord);
    cc[cntr] = d;
    for (auto e : ord) {
        p[d][e] = cntr;
    }
    for (auto e : g[cntr]) {
        if (cc[e] == -1) {
            find_centroid(e, d + 1);
        }
    }
}

void init(int N, std::vector<int> F, std::vector<int> U, std::vector<int> V, int Q) {
    g.resize(N);
    sz.resize(N);
    p.resize(20, vector<int>(N));
    cc.resize(N, -1);
    col = F;
    for (int i = 0; i < N - 1; ++i) {
        g[U[i]].push_back(V[i]);
        g[V[i]].push_back(U[i]);
    }
    lol.resize(N);
    find_centroid(0, 0);
    for (auto e : lol) anss += e.getans();
}

void change(int X, int Y) {
    for (int i = 0; i <= cc[X]; ++i) {
        anss -= lol[p[i][X]].getans();
        lol[p[i][X]].kek1(X, Y);
        anss += lol[p[i][X]].getans();
    }
}

long long num_tours() {
    return anss;
}

#ifdef LOCAL 

int main() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  int N;
  assert(scanf("%d", &N) == 1);

  std::vector<int> F(N);
  for (int i = 0; i < N; i++) {
    assert(scanf("%d", &F[i]) == 1);
  }

  std::vector<int> U(N - 1), V(N - 1);
  for (int j = 0; j < N - 1; j++) {
    assert(scanf("%d %d", &U[j], &V[j]) == 2);
  }

  int Q;
  assert(scanf("%d", &Q) == 1);

  init(N, F, U, V, Q);
  printf("%lld\n", num_tours());
  fflush(stdout);

  for (int k = 0; k < Q; k++) {
    int X, Y;
    assert(scanf("%d %d", &X, &Y) == 2);

    change(X, Y);
    printf("%lld\n", num_tours());
    fflush(stdout);
  }
}


#endif

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 4ms
memory: 4656kb

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: 1ms
memory: 4104kb

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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 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: 2ms
memory: 4300kb

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: 42ms
memory: 16676kb

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: 27ms
memory: 15340kb

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: 17ms
memory: 10332kb

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
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

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:

77241161705660

result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #38:

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

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 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0 2 1 2 2 1 0 1 1 2 0 1 2 0 2 1 2 1 1 2 1 1 0 1 0 2 2 2 2 1 0 1 0 0 0 2 2 0 2 1 1 0 0 0 1 1 1 0 0 2 0 0 2 0 1 2 1 1 0 1 2 1 0 1 0 1 1 0 1 2 0 1 0 2 2 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: 33ms
memory: 17104kb

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: 16
Accepted
time: 1828ms
memory: 910492kb

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:

98878415111108

result:

ok 

Test #45:

score: 16
Accepted
time: 1842ms
memory: 910504kb

input:

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

output:

18725807625786

result:

ok 

Test #46:

score: 16
Accepted
time: 1753ms
memory: 910420kb

input:

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

output:

19001142419904

result:

ok 

Test #47:

score: 16
Accepted
time: 1861ms
memory: 910356kb

input:

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

output:

19038058071323

result:

ok 

Test #48:

score: 16
Accepted
time: 1033ms
memory: 437900kb

input:

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

output:

12305851592762
12305852134900
12306133507778
12305866995960
12305585087263
12305866995960
12305585642746
12305866995960
12305585642746
12305866995960
12305585642746
12305583154618
12305582570257
12305583154618
12305864493268
12305582570257
12305583154618
12305864493268
12305863525808
12305581608077
...

result:

ok 

Test #49:

score: 16
Accepted
time: 953ms
memory: 437948kb

input:

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

output:

12301813256756
12302373157130
12301813256756
12302373157130
12302924262596
12302925522835
12302374383909
12302373157130
12301813256756
12302373157130
12302374383909
12301813256756
12302367485243
12302364362222
12302924262596
12302364362222
12302367485243
12301813256756
12302364362222
12302925522835
...

result:

ok 

Test #50:

score: 16
Accepted
time: 1399ms
memory: 437624kb

input:

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

output:

12418513167989
12418318171086
12418165193041
12418160409001
12418126763330
12418040055626
12418267377528
12418272506223
12417820448436
12417972199669
12417773522932
12417576059620
12417757013704
12417825430253
12418053743032
12418508820771
12418503688442
12418439828326
12418689699116
12418838558201
...

result:

ok 

Test #51:

score: 16
Accepted
time: 1402ms
memory: 437620kb

input:

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

output:

2346723587578
2346797006215
2346772375460
2346809727919
2347690734887
2347721226196
2347677034956
2347711403087
2347703419765
2347769503612
2347741902138
2348263987234
2348275750601
2348310490766
2348282698683
2348245269554
2348276304355
2348288123222
2348310435745
2348929711544
2348877359493
234885...

result:

ok 

Test #52:

score: 16
Accepted
time: 1359ms
memory: 437828kb

input:

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

output:

2400462386571
2400462158148
2400461544795
2400461889958
2400461185189
2400461548434
2400461920357
2400461234560
2400460695567
2400460511380
2400459879735
2400460424304
2400460567413
2400460041056
2400459736037
2400459512574
2400459660195
2400459345806
2400575350120
2400575946924
2400575378804
240057...

result:

ok 

Test #53:

score: 16
Accepted
time: 1396ms
memory: 437744kb

input:

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

output:

2323745275743
2323777633776
2323806469161
2323833154157
2323840493310
2323808770580
2324765240403
2324758452482
2323776601856
2323753628594
2323785579860
2323750302594
2323802364215
2323774143294
2323758276966
2323764116183
2323699833384
2324252351662
2324767071839
2324755050915
2324753777905
232472...

result:

ok 

Test #54:

score: 16
Accepted
time: 2281ms
memory: 910328kb

input:

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

output:

98436910774628
98435790492478
98436353021634
98437473264408
98435641752233
98434521544912
98435641752233
98435650540959
98434527058080
98432660574726
98432663853112
98432964316426
98432961059499
98432964316426
98432961059499
98432964316426
98434084562142
98432964316426
98434084562142
98432873827394
...

result:

ok 

Test #55:

score: 16
Accepted
time: 1986ms
memory: 910388kb

input:

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

output:

98656322568720
98654089382763
98656300074379
98654089382763
98656300074379
98654089382763
98656322568720
98656332308779
98654099189422
98656309947638
98656300074379
98654084729795
98656309947638
98656300074379
98654089382763
98651874038179
98654099189422
98654089382763
98654099189422
98656332308779
...

result:

ok 

Test #56:

score: 0
Time Limit Exceeded

input:

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

output:

98966103892595
98967140571022
98967143550915
98967142609596
98966185678400
98966421102932
98965911821926
98965913407716
98965918104910
98965913417511
98965122079850
98965524762266
98965522367911
98966328834972
98966123179251
98966127823396
98967012540625
98969031950525
98969028633876
98967004001828
...

result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #60:

score: 16
Accepted
time: 1ms
memory: 4108kb

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: 1ms
memory: 3816kb

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

output:

1
1
3
1
2
1
0
1
0
3
5
2
0
0
0
0
0
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: 4608kb

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: 26ms
memory: 16004kb

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: 16
Accepted
time: 1859ms
memory: 859020kb

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:

44705759734

result:

ok 

Test #67:

score: 16
Accepted
time: 1810ms
memory: 859232kb

input:

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

output:

8081399556

result:

ok 

Test #68:

score: 16
Accepted
time: 1796ms
memory: 859036kb

input:

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

output:

7578518269

result:

ok 

Test #69:

score: 16
Accepted
time: 1845ms
memory: 859000kb

input:

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

output:

7842611505

result:

ok 

Test #70:

score: 16
Accepted
time: 1035ms
memory: 411924kb

input:

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

output:

8821295872
8821296147
9564139052
8821295872
8821295681
9564138785
9564557503
9564371980
8821528877
8821295963
8821273000
8821273290
8821273000
9564071254
8821273290
9564071254
8821273000
8821273290
9564071254
8821273290
8820974722
9563750804
8820974722
8820974425
9563750804
8820974722
8821039686
882...

result:

ok 

Test #71:

score: 16
Accepted
time: 1356ms
memory: 412012kb

input:

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

output:

9900828574
9901123105
9901558117
9901559863
9901561538
9901241053
9901243302
9900841539
9901073511
9900841551
9901224707
9900891827
9901193513
9901191456
9900859127
9900508225
9900868272
9900869818
9901103676
9901101160
9901405928
9901403850
9901736004
9902118965
9902402250
9902404114
9902169373
990...

result:

ok 

Test #72:

score: 16
Accepted
time: 1394ms
memory: 412144kb

input:

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

output:

8866532903
8866266025
8866265404
8866264491
8865969722
8865968574
8865970233
8866204005
8865029098
8865196570
8865368030
8865370923
8865369538
8865168328
8865135093
8865385470
8865384250
8865383594
8865076149
8865313844
8865546375
8865244496
8864975343
8864974133
8864739724
8864740482
8864739477
886...

result:

ok 

Test #73:

score: 16
Accepted
time: 1409ms
memory: 411944kb

input:

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

output:

1923134841
1923098761
1923068781
1923100856
1923136813
1923178461
1923151422
1923190446
1923139511
1923107348
1923142475
1923193068
1922471761
1922501746
1922531560
1922483959
1923074561
1923029924
1922988637
1923039300
1923012232
1923055404
1923709851
1924332573
1924291452
1924336408
1923841979
192...

result:

ok 

Test #74:

score: 16
Accepted
time: 1373ms
memory: 411768kb

input:

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

output:

1525082875
1525082664
1525098402
1525098613
1525098402
1525098613
1525098666
1525098457
1530990775
1530990974
1530991108
1530990905
1530990702
1530990737
1530990721
1530990924
1530990945
1530990921
1531653395
1531653190
1531653395
1531653190
1531653147
1531653354
1531653381
1531653176
1531687363
153...

result:

ok 

Test #75:

score: 16
Accepted
time: 1392ms
memory: 412024kb

input:

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

output:

2063072176
2063026328
2063571586
2064283826
2064244031
2064284088
2064324207
2063683556
2063638505
2063590631
2063627298
2063648635
2063605542
2063913146
2063956384
2063999436
2063960585
2063923816
2063883884
2063860177
2063893092
2063929914
2064077069
2064034617
2063988435
2064000191
2063960758
206...

result:

ok 

Test #76:

score: 16
Accepted
time: 2180ms
memory: 858924kb

input:

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

output:

35803105614
38762344942
38761437962
35802153839
38761437962
38762063367
35802734800
35802734454
38762063367
35802734800
38762063367
38762064512
35802735377
38762064512
38762643916
35803270356
35803270016
38762643916
35803270016
35803268938
38762642614
35803268938
38762642614
35803269286
35803463662
...

result:

ok 

Test #77:

score: 0
Time Limit Exceeded

input:

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

output:

43444761896
43445433771
43445977597
43445201981
43445746105
43445006762
43445006666
43445724756
43445723551
43445121919
43445841023
43445839953
43445839539
43445839231
43446516618
43447290990
43448075191
43448075302
43447423180
43447834695
43447163589
43447706753
43447705667
43447704670
43446988668
...

result:


Subtask #6:

score: 34
Accepted

Dependency #2:

100%
Accepted

Test #82:

score: 34
Accepted
time: 1537ms
memory: 423048kb

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: 1459ms
memory: 423532kb

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: 1885ms
memory: 423832kb

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: 1913ms
memory: 424420kb

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: 1863ms
memory: 424580kb

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: 1932ms
memory: 423636kb

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: 1326ms
memory: 402692kb

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: 1313ms
memory: 402624kb

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: 1944ms
memory: 411988kb

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: 1873ms
memory: 402572kb

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: 1836ms
memory: 388036kb

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: 1760ms
memory: 376148kb

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: 1619ms
memory: 416008kb

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: 1978ms
memory: 415660kb

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: 1971ms
memory: 415572kb

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: 2040ms
memory: 416108kb

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: 1906ms
memory: 415444kb

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: 1969ms
memory: 416192kb

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: 1717ms
memory: 435368kb

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: 1549ms
memory: 436232kb

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: 2093ms
memory: 435192kb

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: 1379ms
memory: 359196kb

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: 1652ms
memory: 360296kb

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: 1628ms
memory: 358512kb

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: 1589ms
memory: 357928kb

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: 1749ms
memory: 362424kb

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: 1681ms
memory: 361332kb

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: 481ms
memory: 172612kb

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: 491ms
memory: 172496kb

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: 504ms
memory: 172400kb

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: 493ms
memory: 172644kb

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: 471ms
memory: 172392kb

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%