QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534315#5494. 软件包管理器ancienta100 ✓260ms26420kbC++204.9kb2024-08-27 01:47:522024-08-27 01:47:52

Judging History

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

  • [2024-08-27 01:47:52]
  • 评测
  • 测评结果:100
  • 用时:260ms
  • 内存:26420kb
  • [2024-08-27 01:47:52]
  • 提交

answer

#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;
#define LL long long
LL father[100000];
LL son[100000];
LL sizes[100000];
LL ancestor[100000];
LL no[100000];
LL en[100000];
LL inde;
vector<LL> child[100000];
class segment_tree
{
public:
    segment_tree* left_tree;
    segment_tree* right_tree;
    LL left;
    LL right;
    LL middle;
    LL total;
    LL tag; //-1 for empty, 0 for default, and 1 for full
    segment_tree(LL left, LL right)
    {
        this->tag = -1;
        this->total = 0;
        this->left = left;
        this->right = right;
        this->middle = (left + right) / 2;
        if (left >= right) return;
        this->left_tree = new segment_tree(left, middle);
        this->right_tree = new segment_tree(middle + 1, right);
    }
    LL query(LL left, LL right)
    {
        //cout << "querying " << left << " " << right << endl;
        if (left > right) return 0;
        if (-1 == this->tag)
        {
            //cout << "tag -1 " << endl;
            return 0;
        }
        if (1 == this->tag)
        {
            //cout << "tag 1 " << endl;
            return right - left + 1;
        }
        if (left == right && this->left == left && this->right == right && 0 == this->tag) return 0;
        LL s = 0;
        if (left <= this->middle) s+= this->left_tree->query(left, min(right, this->middle));
        if (right > this->middle) s+= this->right_tree->query(max(left, this->middle + 1), right);
        //cout << "just return " << s << endl;
        return s;
    }
    void update(LL left, LL right, LL tag)
    {
        //cout << "updating " << left << " " << right << endl;
        if (left > right) return;
        if (this->left == left && this->right == right)
        {
            this->tag = tag;
            return;
        }
        if (0 != this->tag) this->left_tree->tag = this->tag;
        if (left <= this->middle)
        {

            this->left_tree->update(left, min(right, this->middle), tag);
        }
        if (0 != this->tag) this->right_tree->tag = this->tag;
        if (this->middle < right)
        {
            this->right_tree->update(max(left, this->middle + 1), right, tag);
        }
        this->tag = 0;
    }
};

void depth_first_search(LL node)
{
    LL s = 0;
    for (auto it = child[node].begin(); it != child[node].end(); ++it)
    {
        LL a = *it;
        depth_first_search(a);
        s += sizes[a];
    }
    sizes[node] = s + 1;
}
void depth_first_search2(LL node, LL node2)
{
    no[node] = inde;
    inde ++;
    ancestor[node] = node2;
    if (0 == child[node].size())
    {
        en[node] = inde - 1;
        return;
    }
    LL max_size = 0;
    for (auto it = child[node].begin(); it != child[node].end(); ++it)
    {
        LL a = *it;
        if (max_size < sizes[a])
        {
            max_size = sizes[a];
            son[node] = a;
        }
    }
    depth_first_search2(son[node], node2);
    for (auto it = child[node].begin(); it != child[node].end(); ++it)
    {
        LL a = *it;
        if (a == son[node]) continue;
        depth_first_search2(a, a);
    }
    en[node] = inde - 1;
}
int main()
{
    memset(father,-1,sizeof(father));
    memset(son,-1,sizeof(son));
    LL n;
    cin >> n;
    for (LL i = 1; i < n; ++i)
    {
        cin >> father[i];
        child[father[i]].push_back(i);
    }
    depth_first_search(0);
    /*for (LL i = 0; i < n; ++i)
    {
        cout << sizes[i] << endl;
    }*/
    inde = 0;
    depth_first_search2(0, 0);
    for (LL i = 0; i < n; ++i)
    {
        //cout << "node: " << i << endl;
        //cout << "no " << no[i] << endl;
        //cout << "father " << father[i] << endl;
        //cout << "ancestor " << ancestor[i] << endl;
    }
    segment_tree* tree = new segment_tree(0, n - 1);
    LL q;
    cin >> q;
    for (LL i = 0; i < q; ++i)
    {
        string s; LL x;
        cin >> s >> x;
        if ('i' == s[0])
        {
            LL answer = 0;
            while (-1 != x)
            {
                //cout << "test" << x << endl;
                if (x == ancestor[x])
                {
                    answer += (1 - tree->query(no[x], no[x]));
                    tree->update(no[x], no[x], 1);
                    x = father[x];
                }
                else
                {
                    //cout << no[x] << no[ancestor[x]] << endl;
                    answer += (no[x] - no[ancestor[x]] + 1 - tree->query(no[ancestor[x]], no[x]));
                    tree->update(no[ancestor[x]], no[x], 1);
                    x = father[ancestor[x]];
                }
            }
            cout << answer << endl;
        }
        else
        {
            LL answer = tree->query(no[x], en[x]);
            tree->update(no[x], en[x], -1);
            cout << answer << endl;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 4ms
memory: 11180kb

input:

5000
1197 1612 491 3490 3733 0 0 3931 3369 4435 321 1353 2697 938 3328 4392 3119 4473 0 2503 1082 3880 4507 2372 4977 3341 4390 3183 1719 3241 3443 3832 2394 0 1666 609 2625 4805 4406 4721 89 3020 0 706 74 2003 729 3221 0 0 2882 1522 4880 1794 4672 3137 2963 0 1299 3535 2022 2284 199 0 1056 0 0 420 ...

output:

457
160
245
458
431
515
436
407
401
237
180
348
309
69
341
428
368
355
191
203
157
237
278
347
391
135
140
390
420
226
259
447
312
81
166
372
469
378
190
41
258
334
395
349
97
200
241
354
561
617
330
77
266
219
288
589
427
169
242
208
176
472
444
444
431
330
355
262
207
401
387
331
298
68
291
438
29...

result:

ok 5000 lines

Test #2:

score: 5
Accepted
time: 0ms
memory: 10108kb

input:

5000
1197 1612 491 3490 3733 0 0 3931 3369 4435 321 1353 2697 938 3328 4392 3119 4473 0 2503 1082 3880 4507 2372 4977 3341 4390 3183 1719 3241 3443 3832 2394 0 1666 609 2625 4805 4406 4721 89 3020 0 706 74 2003 729 3221 0 0 2882 1522 4880 1794 4672 3137 2963 0 1299 3535 2022 2284 199 0 1056 0 0 420 ...

output:

457
160
245
458
431
515
436
407
401
237
180
348
309
69
341
428
368
355
191
203
157
237
278
347
391
135
140
390
420
226
259
447
312
81
166
372
469
378
190
41
258
334
395
349
97
200
241
354
561
617
330
77
266
219
288
589
427
169
242
208
176
472
444
444
431
330
355
262
207
401
387
331
298
68
291
438
29...

result:

ok 5000 lines

Test #3:

score: 5
Accepted
time: 236ms
memory: 24992kb

input:

100000
0 0 0 1 2 4 1 7 3 5 9 4 7 9 6 12 2 7 15 15 1 7 18 18 2 18 11 25 13 10 13 21 23 9 16 0 3 25 38 15 31 30 14 34 41 45 35 7 39 5 12 21 45 22 35 14 26 27 52 29 20 50 33 24 0 51 31 6 68 57 39 12 54 21 58 21 71 46 37 27 28 6 39 30 34 16 67 45 76 87 37 25 84 35 46 62 85 13 52 76 53 98 45 50 35 8 64 1...

output:

8
12
12
4
17
8
9
9
10
8
6
6
7
4
11
8
5
11
6
8
10
6
6
4
11
11
5
6
5
4
10
6
7
6
9
5
5
11
8
7
10
7
6
3
5
2
2
2
7
4
6
6
5
2
9
8
12
5
5
8
8
9
5
5
3
4
7
8
12
2
7
7
6
7
8
13
6
8
11
2
6
7
5
7
8
8
12
6
5
5
12
1
4
3
6
9
2
7
0
6
9
6
5
4
8
5
7
12
5
3
4
5
14
4
9
8
3
2
5
6
10
7
3
5
8
6
8
5
5
11
3
8
9
6
7
5
3
10
6...

result:

ok 100000 lines

Test #4:

score: 5
Accepted
time: 226ms
memory: 24992kb

input:

100000
0 0 0 1 2 4 1 7 3 5 9 4 7 9 6 12 2 7 15 15 1 7 18 18 2 18 11 25 13 10 13 21 23 9 16 0 3 25 38 15 31 30 14 34 41 45 35 7 39 5 12 21 45 22 35 14 26 27 52 29 20 50 33 24 0 51 31 6 68 57 39 12 54 21 58 21 71 46 37 27 28 6 39 30 34 16 67 45 76 87 37 25 84 35 46 62 85 13 52 76 53 98 45 50 35 8 64 1...

output:

8
12
12
4
17
8
9
9
10
8
6
6
7
4
11
8
5
11
6
8
10
6
6
4
11
11
5
6
5
4
10
6
7
6
9
5
5
11
8
7
10
7
6
3
5
2
2
2
7
4
6
6
5
2
9
8
12
5
5
8
8
9
5
5
3
4
7
8
12
2
7
7
6
7
8
13
6
8
11
2
6
7
5
7
8
8
12
6
5
5
12
1
4
3
6
9
2
7
0
6
9
6
5
4
8
5
7
12
5
3
4
5
14
4
9
8
3
2
5
6
10
7
3
5
8
6
8
5
5
11
3
8
9
6
7
5
3
10
6...

result:

ok 100000 lines

Test #5:

score: 5
Accepted
time: 258ms
memory: 24920kb

input:

100000
0 1 0 0 4 0 5 7 6 3 1 8 10 8 14 8 16 12 17 14 9 8 21 4 12 22 2 5 24 27 7 25 14 8 10 26 3 35 21 23 23 7 29 22 15 20 45 21 11 49 12 6 50 5 40 33 35 54 2 27 1 48 59 15 45 33 57 61 33 6 69 14 65 37 14 21 13 20 46 12 16 12 61 26 68 55 69 45 49 55 61 71 31 12 30 74 12 23 95 37 51 93 5 103 44 73 101...

output:

13
11
9
9
9
8
5
5
2
9
12
6
10
12
10
8
3
17
9
9
6
7
5
5
9
7
0
8
2
6
4
11
7
0
6
9
8
4
4
9
2
7
0
5
9
8
5
12
5
6
7
5
8
8
8
4
5
11
3
6
5
6
4
8
6
11
4
9
0
2
4
7
10
1
10
6
9
5
7
8
8
6
7
6
9
5
6
3
7
8
3
5
2
3
9
4
4
5
8
5
3
6
3
5
2
7
4
3
4
6
7
7
7
11
7
9
10
6
3
0
4
11
4
7
9
2
2
6
7
6
7
8
7
9
4
13
9
0
8
5
4
7...

result:

ok 100000 lines

Test #6:

score: 5
Accepted
time: 204ms
memory: 25036kb

input:

100000
0 1 2 1 2 3 2 4 3 4 2 11 12 6 8 7 3 8 12 18 2 20 7 0 13 23 14 22 26 3 17 31 2 16 18 25 23 30 16 25 7 33 21 0 18 2 27 45 36 16 23 29 31 7 39 53 19 12 50 53 58 17 40 32 18 46 54 10 4 25 64 64 20 25 22 66 4 68 30 56 17 74 19 81 5 58 25 79 75 47 55 38 35 69 92 71 30 31 98 78 76 80 10 96 63 42 31 ...

output:

18
7
7
9
11
0
8
4
15
5
7
8
1
13
7
10
8
6
3
10
8
7
7
12
1
7
12
9
8
6
0
5
0
3
6
5
4
9
3
6
6
8
3
6
6
7
6
11
9
12
12
8
0
3
8
6
7
5
4
12
16
1
7
4
4
3
11
8
7
10
8
7
5
4
11
7
7
7
3
8
8
3
7
3
7
5
5
5
3
2
8
5
10
7
3
7
6
6
4
6
3
5
6
4
10
8
6
5
6
0
3
3
6
5
9
7
4
7
7
9
5
7
5
8
7
0
6
1
13
7
9
0
3
4
0
5
7
3
6
8
5...

result:

ok 100000 lines

Test #7:

score: 5
Accepted
time: 224ms
memory: 25240kb

input:

100000
0 0 0 1 2 4 1 7 3 5 9 4 7 9 6 12 2 7 15 15 1 7 18 18 2 18 11 25 13 10 13 21 23 9 16 0 3 25 38 15 31 30 14 34 41 45 35 7 39 5 12 21 45 22 35 14 26 27 52 29 20 50 33 24 0 51 31 6 68 57 39 12 54 21 58 21 71 46 37 27 28 6 39 30 34 16 67 45 76 87 37 25 84 35 46 62 85 13 52 76 53 98 45 50 35 8 64 1...

output:

8
12
12
4
17
8
9
9
10
8
6
6
7
4
11
8
5
11
6
8
10
6
6
4
11
11
5
6
5
4
10
6
7
6
9
5
5
11
8
7
10
7
6
3
0
2
2
2
7
4
6
6
5
0
9
8
12
5
5
8
8
0
0
5
3
4
7
8
0
2
7
7
6
7
8
13
6
8
11
2
0
7
5
7
8
8
12
6
5
5
13
1
4
5
6
9
2
7
0
6
9
6
5
4
8
5
7
12
5
3
4
5
14
4
9
8
3
2
5
6
10
7
3
5
8
6
8
5
5
11
3
8
9
0
7
0
3
10
6
...

result:

ok 100000 lines

Test #8:

score: 5
Accepted
time: 260ms
memory: 24992kb

input:

100000
0 0 0 1 2 4 1 7 3 5 9 4 7 9 6 12 2 7 15 15 1 7 18 18 2 18 11 25 13 10 13 21 23 9 16 0 3 25 38 15 31 30 14 34 41 45 35 7 39 5 12 21 45 22 35 14 26 27 52 29 20 50 33 24 0 51 31 6 68 57 39 12 54 21 58 21 71 46 37 27 28 6 39 30 34 16 67 45 76 87 37 25 84 35 46 62 85 13 52 76 53 98 45 50 35 8 64 1...

output:

8
12
12
4
17
8
9
9
10
8
6
6
7
4
11
8
5
11
6
8
10
6
6
4
11
11
5
6
5
4
10
6
7
6
9
5
5
11
8
7
10
7
6
3
0
2
2
2
7
4
6
6
5
0
9
8
12
5
5
8
8
0
0
5
3
4
7
8
0
2
7
7
6
7
8
13
6
8
11
2
0
7
5
7
8
8
12
6
5
5
13
1
4
5
6
9
2
7
0
6
9
6
5
4
8
5
7
12
5
3
4
5
14
4
9
8
3
2
5
6
10
7
3
5
8
6
8
5
5
11
3
8
9
0
7
0
3
10
6
...

result:

ok 100000 lines

Test #9:

score: 5
Accepted
time: 156ms
memory: 26144kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

7694
1906
2712
6313
8840
10375
9552
10204
8947
4943
6832
9983
11518
7197
4422
7671
10075
8287
5128
7401
9242
10682
11147
4908
368
887
5225
10945
10118
6788
8008
11102
8214
8251
11339
9314
4789
6722
10275
4433
1147
7258
8446
5752
8734
9051
9825
7213
1842
1007
6655
9431
3945
6746
8207
4736
3375
4968
7...

result:

ok 100000 lines

Test #10:

score: 5
Accepted
time: 171ms
memory: 26420kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

8581
4479
8289
8994
6975
8487
6498
5606
7743
4737
4349
10132
9598
4314
6512
11399
11016
7758
7739
8489
8870
7195
4032
4333
5675
9954
10040
8132
6473
7664
9685
10093
9738
4062
3185
4166
2185
6100
5826
2590
6906
6274
6076
10512
8028
8158
10576
10934
12336
11448
10355
10410
7482
5350
6305
5643
5074
557...

result:

ok 100000 lines

Test #11:

score: 5
Accepted
time: 202ms
memory: 26088kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

6863
6729
12040
11297
6043
3220
4736
2642
4611
6314
6768
10859
9174
3107
4902
8211
7399
5803
4229
3747
3397
8233
11927
5970
3327
4457
1636
4342
4680
1436
5026
10391
10437
5162
4386
7216
9342
7869
7244
5132
6077
8059
6976
6086
6919
7645
7160
11372
8977
8166
11488
6267
1757
7217
6329
5914
8361
8876
70...

result:

ok 100000 lines

Test #12:

score: 5
Accepted
time: 180ms
memory: 26092kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

11395
8979
7615
7821
7507
4202
2974
8325
8200
5965
9187
10442
6440
2200
2475
2563
4368
9664
7698
3328
6571
5321
970
4991
6376
4606
5967
5147
3500
5685
8016
7047
9089
8478
6896
6620
8081
7504
3129
6209
7590
6921
5781
7807
7526
6187
9069
9147
10259
9675
5416
3202
4993
7504
10817
9167
9221
10166
4038
2...

result:

ok 100000 lines

Test #13:

score: 5
Accepted
time: 188ms
memory: 26136kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10480
4922
5712
11243
10068
5860
3371
5477
4138
840
1421
710
5308
10668
11676
10704
6431
7935
6639
5765
9926
10690
8365
7487
8504
8897
7207
6236
7568
7957
5325
4124
7351
7186
4419
2896
2370
4387
8780
10937
6423
4428
8148
5387
4389
5196
3908
5217
6094
8053
10485
11304
8671
8671
9379
7129
7723
7898
83...

result:

ok 100000 lines

Test #14:

score: 5
Accepted
time: 156ms
memory: 26140kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10480
4922
5712
11243
10068
5860
3371
5477
4138
840
1421
710
5308
10668
11676
10704
6431
7935
6639
5765
9926
10690
8365
7487
8504
8897
7207
6236
7568
7957
5325
4124
7351
7186
4419
2896
2370
4387
8780
10937
6423
4428
8148
5387
4389
5196
3908
5217
6094
8053
10485
11304
8671
8671
9379
7129
7723
7898
83...

result:

ok 100000 lines

Test #15:

score: 5
Accepted
time: 207ms
memory: 26148kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10820
10371
8551
7108
7440
9241
10667
5194
6896
7879
5756
8946
7450
6963
8063
5124
6048
5254
1215
2998
5846
7204
6627
7889
7735
6147
9394
8573
3800
3701
8172
9217
5949
6679
8945
4771
3713
9828
9674
5658
7692
11554
6708
3505
8297
8936
6057
5710
8343
10104
9082
8297
7267
6859
7372
8996
9356
9206
10447...

result:

ok 100000 lines

Test #16:

score: 5
Accepted
time: 188ms
memory: 26152kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10820
10371
8551
7108
7440
9241
10667
5194
6896
7879
5756
8946
7450
6963
8063
5124
6048
5254
1215
2998
5846
7204
6627
7889
7735
6147
9394
8573
3800
3701
8172
9217
5949
6679
8945
4771
3713
9828
9674
5658
7692
11554
6708
3505
8297
8936
6057
5710
8343
10104
9082
8297
7267
6859
7372
8996
9356
9206
10447...

result:

ok 100000 lines

Test #17:

score: 5
Accepted
time: 180ms
memory: 26220kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10820
10371
8551
7108
7440
9241
10667
5194
6896
7879
5756
8946
7450
6963
8063
5124
6048
5254
1215
2998
5846
7204
6627
7889
7735
6147
9394
8573
3800
3701
8172
9217
5949
6679
8945
4771
3713
9828
9674
5658
7692
11554
6708
3505
8297
8936
6057
5710
8343
10104
9082
8297
7267
6859
7372
8996
9356
9206
10447...

result:

ok 100000 lines

Test #18:

score: 5
Accepted
time: 191ms
memory: 26152kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10820
10371
8551
7108
7440
9241
10667
5194
6896
7879
5756
8946
7450
6963
8063
5124
6048
5254
1215
2998
5846
7204
6627
7889
7735
6147
9394
8573
3800
3701
8172
9217
5949
6679
8945
4771
3713
9828
9674
5658
7692
11554
6708
3505
8297
8936
6057
5710
8343
10104
9082
8297
7267
6859
7372
8996
9356
9206
10447...

result:

ok 100000 lines

Test #19:

score: 5
Accepted
time: 197ms
memory: 26388kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10820
10371
8551
7108
7440
9241
10667
5194
6896
7879
5756
8946
7450
6963
8063
5124
6048
5254
1215
2998
5846
7204
6627
7889
7735
6147
9394
8573
3800
3701
8172
9217
5949
6679
8945
4771
3713
9828
9674
5658
7692
11554
6708
3505
8297
8936
6057
5710
8343
10104
9082
8297
7267
6859
7372
8996
9356
9206
10447...

result:

ok 100000 lines

Test #20:

score: 5
Accepted
time: 181ms
memory: 26220kb

input:

100000
67900 38650 71400 4599 90457 91976 56382 60188 88280 94727 0 91149 39722 79239 53412 19144 44540 58803 43574 28515 66477 15585 98202 31397 48655 81036 69170 59687 69954 99538 3170 14923 53437 96022 84960 71972 24205 46764 47685 50572 84521 54475 63602 50837 24017 0 84383 67721 82796 21296 975...

output:

10820
10371
8551
7108
7440
9241
10667
5194
6896
7879
5756
8946
7450
6963
8063
5124
6048
5254
1215
2998
5846
7204
6627
7889
7735
6147
9394
8573
3800
3701
8172
9217
5949
6679
8945
4771
3713
9828
9674
5658
7692
11554
6708
3505
8297
8936
6057
5710
8343
10104
9082
8297
7267
6859
7372
8996
9356
9206
10447...

result:

ok 100000 lines

Extra Test:

score: 0
Extra Test Passed