QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#806773#1458. Binary Search AlgorithmcyxAC ✓164ms3924kbC++142.0kb2024-12-09 15:00:422024-12-09 15:00:43

Judging History

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

  • [2024-12-09 15:00:43]
  • 评测
  • 测评结果:AC
  • 用时:164ms
  • 内存:3924kb
  • [2024-12-09 15:00:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n;
int ord[8020];
vector<int> qr;
struct SegTree
{
    int t[8020 << 2];
#define ls id << 1
#define rs id << 1 | 1
    void build(int id = 1, int l = 1, int r = n)
    {
        t[id] = -1;
        if (l == r)
            return t[id] = -1, void();
        int mid = l + r >> 1;
        build(ls, l, mid);
        build(rs, mid + 1, r);
    }
    void push_up(int id)
    {
        if (~t[ls] && ~t[rs])
            t[id] = ord[t[ls]] < ord[t[rs]] ? t[ls] : t[rs];
        else if (~t[ls])
            t[id] = t[ls];
        else
            t[id] = t[rs];
    }
    void getquery(int p, bool add, int id = 1, int l = 1, int r = n)
    {
        if (p <= l && r <= p)
        {
            if (add)
                qr.push_back(p);
            return;
        }
        int mid = l + r >> 1;
        if (p <= mid)
        {
            getquery(p, add, ls, l, mid);
            if (~t[rs])
                qr.push_back(t[rs]);
        }
        else
        {
            getquery(p, add, rs, mid + 1, r);
            if (~t[ls])
                qr.push_back(t[ls]);
        }
    }
    void update(int p, int k, int id = 1, int l = 1, int r = n)
    {
        if (r < p || l > p)
            return;
        if (p <= l && r <= p)
            return t[id] = k, void();
        int mid = l + r >> 1;
        update(p, k, ls, l, mid);
        update(p, k, rs, mid + 1, r);
        push_up(id);
    }

} T;
int main()
{
    cin >> n;
    T.build();
    for (int i = 1; i <= 2 * n; i++)
    {
        qr.clear();
        string op;
        int x;
        cin >> op >> x;
        T.getquery(x, op == "add");
        cout << qr.size() << ' ';
        for (int j : qr)
            cout << j << ' ';
        cout << endl;
        for (int j = 1; j <= qr.size(); j++)
        {
            int y;
            cin >> y;
            ord[y] = j;
        }
        T.update(x, op == "add" ? x : -1);
        cout << T.t[1] << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3668kb

input:

3
add 1
1
add 3
3 1
delete 1
3
add 2
3 2
delete 3
2
delete 2


output:

1 1 
1
2 3 1 
3
1 3 
3
2 2 3 
3
1 2 
2
0 
-1

result:

ok n=3, OK

Test #2:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

10
add 9
9
add 4
9 4
add 6
9 4 6
delete 9
4 6
add 7
7 4 6
delete 4
7
add 5
7 5
add 8
7 5 8
add 10
7 10 5
delete 8
7 10 5
add 3
3 7 5
add 2
3 7 5 2
delete 6
3 7 10
delete 10
3 7
delete 7
3
add 1
3 1 5 2
delete 1
3 5 2
delete 3
5 2
delete 5
2
delete 2


output:

1 9 
9
2 4 9 
9
3 6 9 4 
9
2 6 4 
4
3 7 6 4 
7
1 7 
7
2 5 7 
7
3 8 7 5 
7
3 10 7 5 
7
3 7 10 5 
7
3 3 5 7 
3
4 2 3 5 7 
3
3 7 10 3 
3
2 7 3 
3
1 3 
3
4 1 2 3 5 
3
3 2 3 5 
3
2 2 5 
5
1 2 
2
0 
-1

result:

ok n=10, OK

Test #3:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

100
add 81
81
add 96
81 96
add 94
81 94 96
add 32
81 32
add 35
81 32 35
add 59
81 32 59
add 50
81 50 32
add 57
81 50 57 59
add 39
39 81 50 32
add 55
39 81 57 59 55
add 23
39 81 23
add 40
39 81 50 40 23 32
add 5
39 81 23 5
add 2
39 81 23 5 2
delete 55
39 81 57 59
add 12
39 81 12 23 5
delete 40
39 81 ...

output:

1 81 
81
2 96 81 
81
3 94 96 81 
81
2 32 81 
81
3 35 32 81 
81
3 59 81 32 
81
3 50 32 81 
81
4 57 59 81 50 
81
4 39 50 32 81 
39
5 55 57 59 81 39 
39
3 23 39 81 
39
6 40 39 50 32 23 81 
39
4 5 23 39 81 
39
5 2 5 23 39 81 
39
4 57 59 81 39 
39
5 12 5 23 39 81 
39
5 39 50 32 12 81 
39
5 51 57 59 81 39...

result:

ok n=100, OK

Test #4:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

100
add 71
71
add 75
71 75
add 43
43 71
add 69
43 71 69
add 55
43 71 55
add 89
43 71 89
add 31
43 71 31
add 52
43 71 89 55 52
add 24
24 43 71
add 6
24 43 71 6
add 9
24 43 71 6 9
add 62
24 71 89 62 55
add 19
24 43 71 6 19
add 35
24 43 71 35 31
add 38
24 43 71 35 31 38
add 39
39 24 43 71 35
add 63
39 ...

output:

1 71 
71
2 75 71 
71
2 43 71 
43
3 69 71 43 
43
3 55 71 43 
43
3 89 71 43 
43
3 31 43 71 
43
5 52 55 71 89 43 
43
3 24 43 71 
24
4 6 24 43 71 
24
5 9 6 24 43 71 
24
5 62 55 71 89 24 
24
5 19 24 6 43 71 
24
5 35 31 43 24 71 
24
6 38 35 31 43 24 71 
24
5 39 43 35 24 71 
39
6 63 62 55 71 89 39 
39
6 68...

result:

ok n=100, OK

Test #5:

score: 0
Accepted
time: 8ms
memory: 3644kb

input:

1000
add 93
93
add 917
93 917
add 921
93 917 921
add 70
93 917 70
add 949
93 949 917
add 777
93 949 777
add 237
93 949 237
add 581
581 93 949
add 461
581 93 461
add 319
581 93 319 461
add 42
581 93 42 319 237
add 690
581 93 690 949
add 631
581 93 631 690 949
add 135
581 93 319 237 135
add 424
581 93...

output:

1 93 
93
2 917 93 
93
3 921 917 93 
93
3 70 93 917 
93
3 949 917 93 
93
3 777 949 93 
93
3 237 93 949 
93
3 581 949 93 
581
3 461 93 581 
581
4 319 461 93 581 
581
5 42 93 237 319 581 
581
4 690 581 949 93 
581
5 631 690 581 949 93 
581
5 135 237 93 319 581 
581
5 424 461 319 93 581 
581
6 647 631 6...

result:

ok n=1000, OK

Test #6:

score: 0
Accepted
time: 29ms
memory: 3648kb

input:

1000
add 589
589
add 844
589 844
add 341
589 341
add 362
589 341 362
add 955
955 589 341 844
add 565
955 589 565 341
add 467
955 341 467
add 664
955 589 341 664
add 167
167 955 341
add 879
167 955 589 844 879
add 934
167 934 955 589 844 879
add 757
167 934 757 589 844
add 941
167 934 757 955 589 941...

output:

1 589 
589
2 844 589 
589
2 341 589 
589
3 362 341 589 
589
4 955 844 589 341 
955
4 565 589 955 341 
955
3 467 341 955 
955
4 664 589 955 341 
955
3 167 341 955 
167
5 879 955 844 589 167 
167
6 934 879 955 844 589 167 
167
5 757 844 934 589 167 
167
6 941 955 934 757 589 167 
167
4 56 167 341 934 ...

result:

ok n=1000, OK

Test #7:

score: 0
Accepted
time: 81ms
memory: 3676kb

input:

8000
add 2497
2497
add 827
827 2497
add 4801
827 4801
add 2709
827 4801 2709 2497
add 4516
827 4801 4516
add 656
827 656 4801 2709
add 4773
4773 827 4801 4516
add 1444
4773 827 1444 2709
add 2338
4773 827 2709 2338 2497
add 1254
4773 827 1444 2709 1254
add 5749
4773 827 5749
add 3926
4773 827 3926 2...

output:

1 2497 
2497
2 827 2497 
827
2 4801 827 
827
4 2709 2497 827 4801 
827
3 4516 4801 827 
827
4 656 827 2709 4801 
827
4 4773 4801 4516 827 
4773
4 1444 827 2709 4773 
4773
5 2338 2497 2709 827 4773 
4773
5 1254 1444 827 2709 4773 
4773
3 5749 4773 827 
4773
4 3926 2709 827 4773 
4773
3 7537 4773 827 ...

result:

ok n=8000, OK

Test #8:

score: 0
Accepted
time: 114ms
memory: 3672kb

input:

8000
add 1866
1866
add 5228
5228 1866
add 4496
5228 4496 1866
add 2574
5228 1866 2574
add 1492
5228 1866 2574 1492
add 5427
5228 4496 1866 5427
add 3355
3355 5228 1866 2574
add 5495
3355 5228 4496 5495 5427
add 6421
3355 5228 6421
add 7543
3355 7543 5228 6421
add 4400
3355 4400 7543 5228 4496
add 43...

output:

1 1866 
1866
2 5228 1866 
5228
3 4496 5228 1866 
5228
3 2574 1866 5228 
5228
4 1492 1866 2574 5228 
5228
4 5427 5228 4496 1866 
5228
4 3355 2574 1866 5228 
3355
5 5495 5427 5228 4496 3355 
3355
3 6421 5228 3355 
3355
4 7543 6421 5228 3355 
3355
5 4400 4496 5228 7543 3355 
3355
5 4311 4400 5228 7543 ...

result:

ok n=8000, OK

Test #9:

score: 0
Accepted
time: 12ms
memory: 3588kb

input:

1000
add 964
964
add 650
964 650
add 967
964 650 967
add 129
964 129
add 345
964 129 345
add 454
964 129 345 454
add 614
964 650 129 614
add 11
964 129 345 11
add 963
964 650 967 129 963
add 357
964 129 345 454 357
add 300
964 129 345 454 300
add 785
964 650 129 785
add 700
964 650 129 614 700
add 4...

output:

1 964 
964
2 650 964 
964
3 967 964 650 
964
2 129 964 
964
3 345 129 964 
964
4 454 345 129 964 
964
4 614 650 964 129 
964
4 11 129 345 964 
964
5 963 964 967 650 129 
964
5 357 345 454 129 964 
964
5 300 345 454 129 964 
964
4 785 964 650 129 
964
5 700 650 614 964 129 
964
5 442 454 345 129 964 ...

result:

ok n=1000, OK

Test #10:

score: 0
Accepted
time: 29ms
memory: 3640kb

input:

1000
add 651
651
add 792
792 651
add 816
792 816 651
add 325
792 325
add 876
792 651 325 876
add 408
792 408 325
add 289
792 289 408 325
add 746
792 746 289 651
add 492
792 289 408 492
add 2
792 289 2
add 462
792 462 289 408 2 492
add 98
792 462 98 2
add 68
792 462 68 98 2
add 69
792 462 68 69 98 2
...

output:

1 651 
651
2 792 651 
792
3 816 792 651 
792
2 325 792 
792
4 876 792 651 325 
792
3 408 325 792 
792
4 289 325 408 792 
792
4 746 651 792 289 
792
4 492 408 289 792 
792
3 2 289 792 
792
6 462 492 408 289 2 792 
792
4 98 2 462 792 
792
5 68 98 2 462 792 
792
6 69 68 98 2 462 792 
792
6 834 816 792 ...

result:

ok n=1000, OK

Test #11:

score: 0
Accepted
time: 81ms
memory: 3728kb

input:

8000
add 4964
4964
add 650
4964 650
add 6871
4964 650 6871
add 129
4964 650 129
add 3768
4964 650 3768
add 1551
4964 650 3768 1551
add 6223
4964 650 6871 6223
add 3875
4964 650 3768 3875
add 6536
4964 650 6871 6223 6536
add 6438
4964 650 6871 6223 6438
add 5015
4964 650 6871 5015
add 2528
4964 650 3...

output:

1 4964 
4964
2 650 4964 
4964
3 6871 4964 650 
4964
3 129 650 4964 
4964
3 3768 650 4964 
4964
4 1551 650 3768 4964 
4964
4 6223 6871 4964 650 
4964
4 3875 3768 650 4964 
4964
5 6536 6871 6223 4964 650 
4964
5 6438 6223 6871 4964 650 
4964
4 5015 4964 6871 650 
4964
4 2528 3768 650 4964 
4964
5 1952...

result:

ok n=8000, OK

Test #12:

score: 0
Accepted
time: 55ms
memory: 3632kb

input:

8000
add 3562
3562
add 2628
3562 2628
add 6508
6508 3562
add 1830
6508 3562 1830
add 6995
6508 6995 3562
add 2741
6508 2741 3562 2628 1830
add 3523
6508 2741 3562 3523 1830
add 4497
6508 4497 2741
add 1175
6508 2741 1175 1830
add 5626
6508 4497 2741 5626
add 2252
6508 2741 3562 1175 2252
add 2606
65...

output:

1 3562 
3562
2 2628 3562 
3562
2 6508 3562 
6508
3 1830 3562 6508 
6508
3 6995 6508 3562 
6508
5 2741 2628 3562 1830 6508 
6508
5 3523 3562 2741 1830 6508 
6508
3 4497 6508 2741 
6508
4 1175 1830 2741 6508 
6508
4 5626 4497 6508 2741 
6508
5 2252 2741 3562 1175 6508 
6508
6 2606 2741 2252 3562 1175 ...

result:

ok n=8000, OK

Test #13:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

10
add 3
3
add 7
3 7
add 10
3 7 10
add 1
3 7 1
add 9
3 7 10 9
add 5
3 7 5
add 4
3 7 5 4
add 8
3 7 10 8
add 6
3 7 10 8 6
add 2
3 7 1 5 2
delete 3
7 1 5
delete 7
10 1 8 6
delete 10
1 9 8
delete 1
9 5 2
delete 5
9 4 2
delete 9
4 8
delete 8
4 6
delete 4
6 2
delete 6
2
delete 2


output:

1 3 
3
2 7 3 
3
3 10 7 3 
3
3 1 3 7 
3
4 9 10 7 3 
3
3 5 3 7 
3
4 4 5 3 7 
3
4 8 7 10 3 
3
5 6 7 8 10 3 
3
5 2 1 3 5 7 
3
3 1 5 7 
7
4 6 8 10 1 
10
3 9 8 1 
1
3 2 5 9 
9
3 4 2 9 
9
2 8 4 
4
2 6 4 
4
2 2 6 
6
1 2 
2
0 
-1

result:

ok n=10, OK

Test #14:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

10
add 9
9
add 5
9 5
add 2
9 5 2
add 7
7 9 5
add 4
7 5 4 2
add 3
3 7 5 2
add 1
3 7 1 5 2
add 6
3 7 9 6
add 10
3 7 10 9
add 8
3 7 10 8
delete 7
3 10 8 6
delete 3
10 1 5
delete 5
10 1 4
delete 9
10 1 8
delete 10
1 8
delete 1
4 8 2
delete 8
4 6
delete 2
4 6
delete 4
6
delete 6


output:

1 9 
9
2 5 9 
9
3 2 5 9 
9
3 7 9 5 
7
4 4 5 2 7 
7
4 3 2 5 7 
3
5 1 2 3 5 7 
3
4 6 7 9 3 
3
4 10 9 7 3 
3
4 8 7 10 3 
3
4 6 8 10 3 
3
3 1 5 10 
10
3 4 1 10 
10
3 10 8 1 
10
2 8 1 
1
3 2 4 8 
4
2 6 4 
4
2 4 6 
4
1 6 
6
0 
-1

result:

ok n=10, OK

Test #15:

score: 0
Accepted
time: 22ms
memory: 3868kb

input:

1000
add 964
964
add 650
964 650
add 967
964 650 967
add 129
964 129
add 345
964 129 345
add 454
964 129 345 454
add 614
964 650 129 614
add 11
964 129 345 11
add 963
964 650 967 129 963
add 357
964 129 345 454 357
add 300
964 129 345 454 300
add 785
964 650 129 785
add 700
964 650 129 614 700
add 4...

output:

1 964 
964
2 650 964 
964
3 967 964 650 
964
2 129 964 
964
3 345 129 964 
964
4 454 345 129 964 
964
4 614 650 964 129 
964
4 11 129 345 964 
964
5 963 964 967 650 129 
964
5 357 345 454 129 964 
964
5 300 345 454 129 964 
964
4 785 964 650 129 
964
5 700 650 614 964 129 
964
5 442 454 345 129 964 ...

result:

ok n=1000, OK

Test #16:

score: 0
Accepted
time: 12ms
memory: 3808kb

input:

1000
add 871
871
add 449
449 871
add 644
644 449 871
add 97
97 644 449
add 853
853 97 644 871
add 496
496 853 97 449
add 418
418 496 853 97
add 207
207 418 853 97
add 401
401 207 418 496 853
add 519
519 401 853 644
add 276
276 519 401 207
add 576
576 276 519 853 644
add 74
74 576 276 207 97
add 194
...

output:

1 871 
871
2 449 871 
449
3 644 871 449 
644
3 97 449 644 
97
4 853 871 644 97 
853
4 496 449 97 853 
496
4 418 496 97 853 
418
4 207 97 418 853 
207
5 401 418 496 207 853 
401
4 519 644 853 401 
519
4 276 401 207 519 
276
5 576 519 644 853 276 
576
5 74 97 207 276 576 
74
5 194 207 74 276 576 
194
...

result:

ok n=1000, OK

Test #17:

score: 0
Accepted
time: 7ms
memory: 3612kb

input:

1000
add 35
35
add 747
35 747
add 391
35 391 747
add 770
35 770 747
add 707
35 770 747 707
add 344
35 391 770 344
add 881
35 770 747 881
add 753
35 770 747 881 753
add 266
35 391 770 266 344
add 126
126 35 391 770
add 11
11 126 35 391 770
add 705
11 770 747 707 705
add 672
11 770 747 672
add 107
11 ...

output:

1 35 
35
2 747 35 
35
3 391 35 747 
35
3 770 747 35 
35
4 707 747 770 35 
35
4 344 391 35 770 
35
4 881 770 747 35 
35
5 753 770 881 747 35 
35
5 266 344 391 35 770 
35
4 126 35 391 770 
126
5 11 35 126 391 770 
11
5 705 707 747 770 11 
11
4 672 747 770 11 
11
5 107 11 126 391 770 
11
5 439 391 266 ...

result:

ok n=1000, OK

Test #18:

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

input:

1000
add 914
914
add 326
326 914
add 650
650 326 914
add 629
650 629 326 914
add 626
650 626 629 326 914
add 416
650 416 326
add 785
650 785 416 914
add 837
650 785 837 416 914
add 300
650 300 416 326
add 700
650 300 785 700
add 164
650 300 164
add 786
650 300 785 786 837 914
add 304
650 300 164 416...

output:

1 914 
914
2 326 914 
326
3 650 914 326 
650
4 629 650 914 326 
650
5 626 629 650 914 326 
650
3 416 326 650 
650
4 785 914 650 416 
650
5 837 785 914 650 416 
650
4 300 326 416 650 
650
4 700 650 785 300 
650
3 164 300 650 
650
6 786 785 837 914 650 300 
650
6 304 300 326 416 164 650 
650
5 450 416...

result:

ok n=1000, OK

Test #19:

score: 0
Accepted
time: 0ms
memory: 3872kb

input:

1000
add 129
129
add 786
129 786
add 614
129 614 786
add 967
967 129 614 786
add 454
967 129 454
add 34
967 129 454 34
add 700
967 129 614 700
add 300
967 129 454 300
add 488
967 129 454 300 488
add 963
967 129 614 963 786
add 79
967 129 454 79 34
add 743
967 129 614 700 743
add 11
967 129 454 11 79...

output:

1 129 
129
2 786 129 
129
3 614 786 129 
129
4 967 786 614 129 
967
3 454 129 967 
967
4 34 129 454 967 
967
4 700 614 967 129 
967
4 300 454 129 967 
967
5 488 454 300 129 967 
967
5 963 967 786 614 129 
967
5 79 34 129 454 967 
967
5 743 700 614 967 129 
967
6 11 34 79 129 454 967 
967
5 384 454 3...

result:

ok n=1000, OK

Test #20:

score: 0
Accepted
time: 101ms
memory: 3924kb

input:

8000
add 4964
4964
add 650
4964 650
add 6871
4964 650 6871
add 129
4964 650 129
add 3768
4964 650 3768
add 1551
4964 650 3768 1551
add 6223
4964 650 6871 6223
add 3875
4964 650 3768 3875
add 6536
4964 650 6871 6223 6536
add 6438
4964 650 6871 6223 6438
add 5015
4964 650 6871 5015
add 2528
4964 650 3...

output:

1 4964 
4964
2 650 4964 
4964
3 6871 4964 650 
4964
3 129 650 4964 
4964
3 3768 650 4964 
4964
4 1551 650 3768 4964 
4964
4 6223 6871 4964 650 
4964
4 3875 3768 650 4964 
4964
5 6536 6871 6223 4964 650 
4964
5 6438 6223 6871 4964 650 
4964
4 5015 4964 6871 650 
4964
4 2528 3768 650 4964 
4964
5 1952...

result:

ok n=8000, OK

Test #21:

score: 0
Accepted
time: 85ms
memory: 3608kb

input:

8000
add 3493
3493
add 5110
5110 3493
add 533
533 5110 3493
add 1700
1700 533 5110 3493
add 4277
4277 1700 5110
add 2368
2368 4277 1700 3493
add 4495
4495 2368 4277 5110
add 4305
4305 4495 2368 4277 5110
add 6965
6965 4305 2368
add 2503
2503 6965 2368 1700 3493
add 4339
4339 2503 6965 4305 4495 5110...

output:

1 3493 
3493
2 5110 3493 
5110
3 533 3493 5110 
533
4 1700 533 3493 5110 
1700
3 4277 5110 1700 
4277
4 2368 3493 1700 4277 
2368
4 4495 4277 5110 2368 
4495
5 4305 4277 4495 5110 2368 
4305
3 6965 4305 2368 
6965
5 2503 2368 3493 1700 6965 
2503
6 4339 4305 4495 5110 6965 2503 
4339
5 5195 5110 433...

result:

ok n=8000, OK

Test #22:

score: 0
Accepted
time: 125ms
memory: 3792kb

input:

8000
add 612
612
add 2743
612 2743
add 7916
612 7916
add 1433
1433 612 2743 7916
add 2140
1433 2140 2743 7916
add 840
1433 612 2140 7916 840
add 4289
1433 4289 7916
add 3912
1433 4289 2140 3912
add 6323
1433 4289 6323 7916
add 3859
1433 4289 3859 2140 3912
add 4368
1433 4289 6323 4368
add 6046
1433 ...

output:

1 612 
612
2 2743 612 
612
2 7916 612 
612
4 1433 612 2743 7916 
1433
4 2140 2743 1433 7916 
1433
5 840 612 1433 2140 7916 
1433
3 4289 7916 1433 
1433
4 3912 2140 1433 4289 
1433
4 6323 7916 4289 1433 
1433
5 3859 3912 2140 1433 4289 
1433
4 4368 4289 6323 1433 
1433
5 6046 6323 7916 4289 1433 
143...

result:

ok n=8000, OK

Test #23:

score: 0
Accepted
time: 66ms
memory: 3744kb

input:

8000
add 3393
3393
add 5029
5029 3393
add 650
650 5029 3393
add 3599
650 5029 3393 3599
add 5102
650 5102 5029
add 5122
650 5102 5029 5122
add 6641
650 5102 6641
add 475
650 5102 3393 475
add 1323
650 5102 3393 1323
add 1821
650 5102 1821 3393 1323
add 3447
650 5102 3393 3447 3599
add 578
650 5102 1...

output:

1 3393 
3393
2 5029 3393 
5029
3 650 3393 5029 
650
4 3599 3393 650 5029 
650
3 5102 5029 650 
650
4 5122 5102 5029 650 
650
3 6641 5102 650 
650
4 475 650 3393 5102 
650
4 1323 650 3393 5102 
650
5 1821 1323 650 3393 5102 
650
5 3447 3393 3599 650 5102 
650
6 578 650 475 1821 3393 5102 
650
4 7293 ...

result:

ok n=8000, OK

Test #24:

score: 0
Accepted
time: 144ms
memory: 3584kb

input:

8000
add 3768
3768
add 878
3768 878
add 5029
3768 5029
add 1821
3768 1821 5029 878
add 5001
3768 5029 5001
add 1608
3768 1821 5029 1608 878
add 2691
3768 1821 5029 2691
add 7293
3768 5029 7293
add 7275
3768 5029 7275 7293
add 6223
3768 6223 5029 7275
add 227
3768 6223 1821 878 227
add 3809
3768 6223...

output:

1 3768 
3768
2 878 3768 
3768
2 5029 3768 
3768
4 1821 878 3768 5029 
3768
3 5001 5029 3768 
3768
5 1608 1821 878 3768 5029 
3768
4 2691 3768 1821 5029 
3768
3 7293 5029 3768 
3768
4 7275 7293 5029 3768 
3768
4 6223 7275 5029 3768 
3768
5 227 878 1821 3768 6223 
3768
5 3809 3768 2691 1821 6223 
3768...

result:

ok n=8000, OK

Test #25:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

10
add 3
3
add 7
3 7
add 10
3 7 10
add 1
3 7 1
add 9
3 7 10 9
add 5
3 7 5
add 4
3 7 5 4
add 8
3 7 10 8
add 6
3 7 10 8 6
add 2
3 7 1 5 2
delete 3
7 1 5
delete 7
10 1 8 6
delete 10
1 9 8
delete 1
9 5 2
delete 5
9 4 2
delete 9
4 8
delete 8
4 6
delete 4
6 2
delete 6
2
delete 2


output:

1 3 
3
2 7 3 
3
3 10 7 3 
3
3 1 3 7 
3
4 9 10 7 3 
3
3 5 3 7 
3
4 4 5 3 7 
3
4 8 7 10 3 
3
5 6 7 8 10 3 
3
5 2 1 3 5 7 
3
3 1 5 7 
7
4 6 8 10 1 
10
3 9 8 1 
1
3 2 5 9 
9
3 4 2 9 
9
2 8 4 
4
2 6 4 
4
2 2 6 
6
1 2 
2
0 
-1

result:

ok n=10, OK

Test #26:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

10
add 10
10
add 8
10 8
add 4
10 4
add 3
3 10 4
add 6
3 10 8 6
add 1
3 10 1 4
add 7
3 7 10 8 6
add 2
3 7 1 4 2
add 9
3 7 10 9
add 5
3 7 5 4
delete 3
7 1 5
delete 7
10 1 8 6
delete 10
1 9 8
delete 1
9 5 2
delete 8
9 5 6
delete 5
9 4 2
delete 9
4 6
delete 4
6 2
delete 6
2
delete 2


output:

1 10 
10
2 8 10 
10
2 4 10 
10
3 3 4 10 
3
4 6 8 10 3 
3
4 1 3 4 10 
3
5 7 6 8 10 3 
3
5 2 1 3 4 7 
3
4 9 10 7 3 
3
4 5 4 3 7 
3
3 1 5 7 
7
4 6 8 10 1 
10
3 9 8 1 
1
3 2 5 9 
9
3 6 9 5 
9
3 4 2 9 
9
2 6 4 
4
2 2 6 
6
1 2 
2
0 
-1

result:

ok n=10, OK

Test #27:

score: 0
Accepted
time: 9ms
memory: 3872kb

input:

1000
add 964
964
add 650
964 650
add 967
964 650 967
add 129
964 129
add 345
964 129 345
add 454
964 129 345 454
add 614
964 650 129 614
add 11
964 129 345 11
add 963
964 650 967 129 963
add 357
964 129 345 454 357
add 300
964 129 345 454 300
add 785
964 650 129 785
add 700
964 650 129 614 700
add 4...

output:

1 964 
964
2 650 964 
964
3 967 964 650 
964
2 129 964 
964
3 345 129 964 
964
4 454 345 129 964 
964
4 614 650 964 129 
964
4 11 129 345 964 
964
5 963 964 967 650 129 
964
5 357 345 454 129 964 
964
5 300 345 454 129 964 
964
4 785 964 650 129 
964
5 700 650 614 964 129 
964
5 442 454 345 129 964 ...

result:

ok n=1000, OK

Test #28:

score: 0
Accepted
time: 31ms
memory: 3660kb

input:

1000
add 871
871
add 449
449 871
add 644
644 449 871
add 97
97 644 449
add 853
853 97 644 871
add 496
496 853 97 449
add 418
418 496 853 97
add 207
207 418 853 97
add 401
401 207 418 496 853
add 519
519 401 853 644
add 276
276 519 401 207
add 576
576 276 519 853 644
add 74
74 576 276 207 97
add 194
...

output:

1 871 
871
2 449 871 
449
3 644 871 449 
644
3 97 449 644 
97
4 853 871 644 97 
853
4 496 449 97 853 
496
4 418 496 97 853 
418
4 207 97 418 853 
207
5 401 418 496 207 853 
401
4 519 644 853 401 
519
4 276 401 207 519 
276
5 576 519 644 853 276 
576
5 74 97 207 276 576 
74
5 194 207 74 276 576 
194
...

result:

ok n=1000, OK

Test #29:

score: 0
Accepted
time: 14ms
memory: 3620kb

input:

1000
add 986
986
add 800
986 800
add 897
986 800 897
add 601
601 986
add 858
858 601 986 800
add 627
858 601 627
add 398
858 398
add 124
858 124 398
add 885
858 124 885 601 986 897
add 554
858 124 554 601 627
add 234
858 124 234 398
add 482
858 124 482 398
add 489
858 124 482 489 398
add 771
858 124...

output:

1 986 
986
2 800 986 
986
3 897 986 800 
986
2 601 986 
601
4 858 800 986 601 
858
3 627 601 858 
858
2 398 858 
858
3 124 398 858 
858
6 885 897 986 858 601 124 
858
5 554 601 627 858 124 
858
4 234 124 398 858 
858
4 482 398 124 858 
858
5 489 482 398 124 858 
858
6 771 800 858 885 554 124 
858
6 ...

result:

ok n=1000, OK

Test #30:

score: 0
Accepted
time: 32ms
memory: 3472kb

input:

1000
add 101
101
add 442
442 101
add 183
442 101 183
add 373
442 101 373
add 837
442 837
add 326
442 101 837 373 326
add 585
442 585 837
add 450
442 101 585 450 373
add 15
442 101 585 15 183
add 626
442 585 837 626
add 914
442 585 837 914
add 786
442 585 786 837 914
add 494
442 101 585 373 494
add 8...

output:

1 101 
101
2 442 101 
442
3 183 101 442 
442
3 373 442 101 
442
2 837 442 
442
5 326 373 442 101 837 
442
3 585 837 442 
442
5 450 442 373 101 585 
442
5 15 101 183 442 585 
442
4 626 585 837 442 
442
4 914 837 585 442 
442
5 786 837 914 585 442 
442
5 494 442 373 101 585 
442
6 828 837 786 914 585 ...

result:

ok n=1000, OK

Test #31:

score: 0
Accepted
time: 7ms
memory: 3676kb

input:

1000
add 79
79
add 442
442 79
add 454
454 442 79
add 520
454 520
add 101
454 79 101 520
add 343
454 79 343 520
add 585
454 585 520
add 700
454 700 585
add 632
454 700 585 632
add 300
454 300 700 79 343
add 878
454 700 878
add 64
454 700 79 64 101
add 227
454 700 79 227
add 964
964 454 700 878
add 82...

output:

1 79 
79
2 442 79 
442
3 454 442 79 
454
2 520 454 
454
4 101 79 454 520 
454
4 343 454 79 520 
454
3 585 520 454 
454
3 700 585 454 
454
4 632 700 585 454 
454
5 300 343 454 79 700 
454
3 878 700 454 
454
5 64 79 101 454 700 
454
4 227 79 454 700 
454
4 964 878 700 454 
964
4 828 964 700 454 
964
5...

result:

ok n=1000, OK

Test #32:

score: 0
Accepted
time: 11ms
memory: 3636kb

input:

1000
add 964
964
add 871
964 871
add 449
964 449
add 644
964 644 449
add 97
964 97 449
add 853
964 853 97 644 871
add 496
964 496 97 449
add 418
964 418 496 97
add 207
964 207 418 97
add 401
964 401 207 418 496
add 519
964 519 401 644
add 276
964 276 401 207
add 576
964 576 276 519 644
add 74
964 74...

output:

1 964 
964
2 871 964 
964
2 449 964 
964
3 644 964 449 
964
3 97 449 964 
964
5 853 871 964 644 97 
964
4 496 449 97 964 
964
4 418 496 97 964 
964
4 207 97 418 964 
964
5 401 418 496 207 964 
964
4 519 644 964 401 
964
4 276 401 207 964 
964
5 576 519 644 964 276 
964
5 74 97 207 276 964 
964
5 194...

result:

ok n=1000, OK

Test #33:

score: 0
Accepted
time: 84ms
memory: 3880kb

input:

8000
add 4964
4964
add 650
4964 650
add 6871
4964 650 6871
add 129
4964 650 129
add 3768
4964 650 3768
add 1551
4964 650 3768 1551
add 6223
4964 650 6871 6223
add 3875
4964 650 3768 3875
add 6536
4964 650 6871 6223 6536
add 6438
4964 650 6871 6223 6438
add 5015
4964 650 6871 5015
add 2528
4964 650 3...

output:

1 4964 
4964
2 650 4964 
4964
3 6871 4964 650 
4964
3 129 650 4964 
4964
3 3768 650 4964 
4964
4 1551 650 3768 4964 
4964
4 6223 6871 4964 650 
4964
4 3875 3768 650 4964 
4964
5 6536 6871 6223 4964 650 
4964
5 6438 6223 6871 4964 650 
4964
4 5015 4964 6871 650 
4964
4 2528 3768 650 4964 
4964
5 1952...

result:

ok n=8000, OK

Test #34:

score: 0
Accepted
time: 132ms
memory: 3676kb

input:

8000
add 3493
3493
add 5110
5110 3493
add 533
533 5110 3493
add 1700
1700 533 5110 3493
add 4277
4277 1700 5110
add 2368
2368 4277 1700 3493
add 4495
4495 2368 4277 5110
add 4305
4305 4495 2368 4277 5110
add 6965
6965 4305 2368
add 2503
2503 6965 2368 1700 3493
add 4339
4339 2503 6965 4305 4495 5110...

output:

1 3493 
3493
2 5110 3493 
5110
3 533 3493 5110 
533
4 1700 533 3493 5110 
1700
3 4277 5110 1700 
4277
4 2368 3493 1700 4277 
2368
4 4495 4277 5110 2368 
4495
5 4305 4277 4495 5110 2368 
4305
3 6965 4305 2368 
6965
5 2503 2368 3493 1700 6965 
2503
6 4339 4305 4495 5110 6965 2503 
4339
5 5195 5110 433...

result:

ok n=8000, OK

Test #35:

score: 0
Accepted
time: 115ms
memory: 3724kb

input:

8000
add 1338
1338
add 1220
1338 1220
add 2046
1338 2046
add 5158
5158 1338
add 1439
5158 1338 2046 1439 1220
add 412
5158 1338 2046 412
add 5737
5737 5158 1338
add 3968
5737 1338 2046 3968
add 703
5737 1338 703 2046 412
add 2858
5737 2858 1338 2046 3968
add 2783
5737 2858 1338 2046 3968 2783
add 37...

output:

1 1338 
1338
2 1220 1338 
1338
2 2046 1338 
1338
2 5158 1338 
5158
5 1439 1338 1220 2046 5158 
5158
4 412 1338 2046 5158 
5158
3 5737 5158 1338 
5737
4 3968 2046 1338 5737 
5737
5 703 412 1338 2046 5737 
5737
5 2858 2046 3968 1338 5737 
5737
6 2783 2858 2046 3968 1338 5737 
5737
5 3798 3968 2858 133...

result:

ok n=8000, OK

Test #36:

score: 0
Accepted
time: 108ms
memory: 3596kb

input:

8000
add 6131
6131
add 4520
6131 4520
add 6799
6131 4520 6799
add 1676
6131 1676
add 1844
6131 1676 1844
add 6912
6131 4520 6912 1676 6799
add 3621
6131 3621 1676
add 4018
4018 6131 4520 3621
add 1178
4018 1178 3621 1676
add 2082
4018 1178 3621 2082
add 6172
6172 4018 1178 6131 6912
add 1568
6172 11...

output:

1 6131 
6131
2 4520 6131 
6131
3 6799 6131 4520 
6131
2 1676 6131 
6131
3 1844 1676 6131 
6131
5 6912 6799 6131 4520 1676 
6131
3 3621 1676 6131 
6131
4 4018 4520 6131 3621 
4018
4 1178 1676 3621 4018 
4018
4 2082 3621 1178 4018 
4018
5 6172 6131 6912 4018 1178 
6172
6 1568 1676 1844 1178 3621 6172 ...

result:

ok n=8000, OK

Test #37:

score: 0
Accepted
time: 147ms
memory: 3620kb

input:

8000
add 893
893
add 2960
2960 893
add 7459
7459 2960
add 111
111 7459 2960 893
add 1185
111 7459 1185 2960
add 3327
111 7459 3327 2960
add 5397
5397 111 7459
add 3963
5397 111 3327 2960 3963
add 4988
5397 111 7459 4988
add 6640
5397 111 7459 6640
add 3584
5397 111 3327 2960 3584 3963
add 5536
5397 ...

output:

1 893 
893
2 2960 893 
2960
2 7459 2960 
7459
4 111 893 2960 7459 
111
4 1185 111 2960 7459 
111
4 3327 2960 111 7459 
111
3 5397 7459 111 
5397
5 3963 3327 2960 111 5397 
5397
4 4988 5397 7459 111 
5397
4 6640 7459 5397 111 
5397
6 3584 3963 3327 2960 111 5397 
5397
5 5536 5397 4988 7459 111 
5397
...

result:

ok n=8000, OK

Test #38:

score: 0
Accepted
time: 150ms
memory: 3660kb

input:

8000
add 3768
3768
add 355
3768 355
add 5755
3768 5755
add 5029
3768 5029 5755
add 5530
3768 5029 5755 5530
add 7826
3768 5029 7826
add 6194
3768 5029 6194 7826
add 1821
3768 1821 5029 355
add 1113
3768 1821 5029 355 1113
add 5015
3768 5015 5029 5755 6194
add 343
3768 5015 1821 343 355
add 650
650 3...

output:

1 3768 
3768
2 355 3768 
3768
2 5755 3768 
3768
3 5029 5755 3768 
3768
4 5530 5755 5029 3768 
3768
3 7826 5029 3768 
3768
4 6194 7826 5029 3768 
3768
4 1821 355 3768 5029 
3768
5 1113 1821 355 3768 5029 
3768
5 5015 5029 5755 6194 3768 
3768
5 343 355 1821 3768 5015 
3768
5 650 343 1821 3768 5015 
6...

result:

ok n=8000, OK

Test #39:

score: 0
Accepted
time: 163ms
memory: 3696kb

input:

8000
add 3325
3325
add 5911
3325 5911
add 664
3325 5911 664
add 708
3325 5911 708 664
add 3589
3325 5911 3589 708
add 3869
3325 3869 5911 3589 708
add 6353
3325 6353 5911
add 5408
3325 6353 5408 5911
add 2396
3325 6353 708 2396
add 1926
3325 6353 1926 708
add 3822
3325 6353 3869 1926 3589 2396 3822
...

output:

1 3325 
3325
2 5911 3325 
3325
3 664 3325 5911 
3325
4 708 664 3325 5911 
3325
4 3589 3325 708 5911 
3325
5 3869 3589 3325 708 5911 
3325
3 6353 5911 3325 
3325
4 5408 5911 6353 3325 
3325
4 2396 3325 708 6353 
3325
4 1926 708 3325 6353 
3325
7 3822 3869 3589 3325 2396 1926 6353 
3325
5 2476 2396 33...

result:

ok n=8000, OK

Test #40:

score: 0
Accepted
time: 164ms
memory: 3880kb

input:

8000
add 520
520
add 4857
4857 520
add 3380
4857 520 3380
add 5397
4857 520 5397
add 1551
1551 4857 520 3380
add 4675
1551 4857 4675 5397
add 5755
1551 4857 5755 5397
add 2691
1551 4857 3380 2691
add 3809
1551 3809 4857 3380 2691
add 1608
1551 3809 4857 1608 520
add 4679
1551 4857 4675 5755 4679
add...

output:

1 520 
520
2 4857 520 
4857
3 3380 520 4857 
4857
3 5397 4857 520 
4857
4 1551 520 3380 4857 
1551
4 4675 4857 5397 1551 
1551
4 5755 5397 4857 1551 
1551
4 2691 3380 1551 4857 
1551
5 3809 3380 2691 1551 4857 
1551
5 1608 1551 520 3809 4857 
1551
5 4679 4675 4857 5755 1551 
1551
3 6194 4857 1551 
1...

result:

ok n=8000, OK

Test #41:

score: 0
Accepted
time: 140ms
memory: 3724kb

input:

8000
add 3540
3540
add 6114
6114 3540
add 7095
6114 3540 7095
add 7142
6114 3540 7095 7142
add 4694
6114 3540 4694
add 1040
6114 3540 1040
add 2503
6114 3540 1040 2503
add 5498
6114 3540 4694 5498
add 4061
6114 3540 4061 4694 5498
add 213
6114 3540 1040 213
add 300
6114 300 3540 1040 213
add 20
6114...

output:

1 3540 
3540
2 6114 3540 
6114
3 7095 6114 3540 
6114
4 7142 7095 6114 3540 
6114
3 4694 6114 3540 
6114
3 1040 3540 6114 
6114
4 2503 3540 1040 6114 
6114
4 5498 4694 6114 3540 
6114
5 4061 4694 5498 6114 3540 
6114
4 213 1040 3540 6114 
6114
5 300 213 1040 3540 6114 
6114
6 20 213 300 1040 3540 61...

result:

ok n=8000, OK

Test #42:

score: 0
Accepted
time: 148ms
memory: 3904kb

input:

8000
add 6663
6663
add 7408
7408 6663
add 2088
2088 7408
add 1213
2088 7408 1213
add 3752
3752 2088 7408 1213
add 4898
3752 7408 4898
add 6916
3752 7408 6916 4898 6663
add 3470
3470 3752 2088 7408 1213
add 6588
3470 6588 7408 6916 4898 6663
add 6136
3470 6588 7408 6136 4898
add 3508
3508 3470 3752 6...

output:

1 6663 
6663
2 7408 6663 
7408
2 2088 7408 
2088
3 1213 2088 7408 
2088
4 3752 2088 1213 7408 
3752
3 4898 7408 3752 
3752
5 6916 6663 7408 4898 3752 
3752
5 3470 3752 2088 1213 7408 
3470
6 6588 6663 6916 7408 4898 3470 
3470
5 6136 6588 7408 4898 3470 
3470
6 3508 3752 3470 2088 1213 6588 
3508
6 ...

result:

ok n=8000, OK

Test #43:

score: 0
Accepted
time: 109ms
memory: 3680kb

input:

8000
add 6663
6663
add 2364
6663 2364
add 7626
6663 7626 2364
add 131
131 6663 2364
add 6567
131 6567 6663 7626
add 6812
131 6567 7626 6812
add 4718
131 6567 4718
add 1312
1312 131 6567 2364
add 5091
1312 5091 6567 4718
add 4819
4819 1312 5091 6567 4718
add 1421
4819 1312 131 1421 2364
add 2361
4819...

output:

1 6663 
6663
2 2364 6663 
6663
3 7626 6663 2364 
6663
3 131 2364 6663 
131
4 6567 6663 7626 131 
131
4 6812 6567 7626 131 
131
3 4718 6567 131 
131
4 1312 131 2364 6567 
1312
4 5091 4718 6567 1312 
1312
5 4819 4718 5091 6567 1312 
4819
5 1421 1312 131 2364 4819 
4819
4 2361 2364 1312 4819 
4819
4 35...

result:

ok n=8000, OK

Test #44:

score: 0
Accepted
time: 148ms
memory: 3728kb

input:

8000
add 4339
4339
add 615
615 4339
add 7105
615 7105 4339
add 4718
615 7105 4718 4339
add 2503
615 7105 2503
add 4810
615 7105 4810 4718 4339
add 6965
615 7105 4810 6965
add 1700
615 7105 2503 1700
add 533
615 7105 2503 1700 533
add 3145
615 7105 3145 2503
add 6288
6288 615 7105 4810 6965
add 2496
...

output:

1 4339 
4339
2 615 4339 
615
3 7105 4339 615 
615
4 4718 4339 7105 615 
615
3 2503 615 7105 
615
5 4810 4718 4339 7105 615 
615
4 6965 7105 4810 615 
615
4 1700 615 2503 7105 
615
5 533 615 1700 2503 7105 
615
4 3145 2503 615 7105 
615
5 6288 6965 7105 4810 615 
6288
5 2496 2503 3145 615 6288 
6288
...

result:

ok n=8000, OK

Test #45:

score: 0
Accepted
time: 108ms
memory: 3664kb

input:

8000
add 4964
4964
add 3493
4964 3493
add 5110
4964 5110 3493
add 533
4964 533 3493
add 1700
4964 1700 533 3493
add 4277
4964 4277 1700 5110
add 2368
4964 2368 1700 3493
add 4495
4964 4495 2368 4277 5110
add 4305
4964 4305 4495 2368 4277 5110
add 6965
4964 6965 2368
add 2503
4964 2503 2368 1700 3493...

output:

1 4964 
4964
2 3493 4964 
4964
3 5110 4964 3493 
4964
3 533 3493 4964 
4964
4 1700 533 3493 4964 
4964
4 4277 4964 5110 1700 
4964
4 2368 3493 1700 4964 
4964
5 4495 4277 4964 5110 2368 
4964
6 4305 4277 4495 4964 5110 2368 
4964
3 6965 4964 2368 
4964
5 2503 2368 3493 1700 4964 
4964
7 4339 4305 44...

result:

ok n=8000, OK