QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#806563#1458. Binary Search Algorithm_lhy_AC ✓199ms19868kbC++141.6kb2024-12-09 11:43:332024-12-09 11:43:33

Judging History

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

  • [2024-12-09 11:43:33]
  • 评测
  • 测评结果:AC
  • 用时:199ms
  • 内存:19868kb
  • [2024-12-09 11:43:33]
  • 提交

answer

#include<bits/stdc++.h>
#define N 8005
#define ls ((p)<<1)
#define rs (((p)<<1)|1)
using namespace std;
int n,mi[N<<2],in[N],ans[N],pos[N],nw;
char ch[N];
set<int> S;
bitset<N> q[N],xiao[N];
void ins(int p)
{
    if(!p) return ;
    if(mi[ls]&&in[mi[ls]]) S.insert(mi[ls]);
    if(mi[rs]&&in[mi[rs]]) S.insert(mi[rs]);
    ins(p>>1);
}
void pushup(int p)
{
    if(!p) return ;
    // printf("%d:%d->%d\n",p,mi[ls],mi[rs]);
    if(xiao[mi[ls]][mi[rs]]) mi[p]=mi[ls];
    else mi[p]=mi[rs];
    pushup(p>>1);
}
void update(int p,int L,int R,int pos,int c)
{
    if(L==R)
    {
        mi[p]=c;
        nw=p;
        ins(p>>1);
        return ;
    }
    int mid=(L+R)>>1;
    if(mid>=pos) update(ls,L,mid,pos,c);
    else update(rs,mid+1,R,pos,c);
}
void query()
{
    printf("%d ",S.size());
    for(auto to:S)
        printf("%d ",to);
    printf("\n");
    fflush(stdout);
    for(int i=1;i<=S.size();i++)
        scanf("%d",&ans[i]),pos[ans[i]]=i;
}
void work()
{
    int x;
    scanf("%s%d",ch+1,&x);
    S.clear();
    if(ch[1]=='a') in[x]=1,update(1,1,n,x,x);
    else in[x]=0,update(1,1,n,x,0);
    query();
    for(auto i:S)
        for(auto j:S)
        {
            if(pos[i]<pos[j]) xiao[i][j]=1,xiao[j][i]=0;
            else xiao[i][j]=0,xiao[j][i]=1;
        }
    pushup(nw>>1);
    if(mi[1]==0) puts("-1");
    else printf("%d\n",mi[1]);
    fflush(stdout);
}
int main()
{
    scanf("%d",&n);
    q[0][0]=1;
    for(int i=1;i<=n;i++)
        q[i][0]=q[0][i]=1,xiao[i][0]=1,xiao[0][i]=0,q[i][i]=1;
    for(int i=1;i<=2*n;i++)
        work();
    return 0;
}

詳細信息

Test #1:

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

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 1 3 
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: 3892kb

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 4 6 9 
9
2 4 6 
4
3 4 6 7 
7
1 7 
7
2 5 7 
7
3 5 7 8 
7
3 5 7 10 
7
3 5 7 10 
7
3 3 5 7 
3
4 2 3 5 7 
3
3 3 7 10 
3
2 3 7 
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: 3ms
memory: 4192kb

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 81 96 
81
3 81 94 96 
81
2 32 81 
81
3 32 35 81 
81
3 32 59 81 
81
3 32 50 81 
81
4 50 57 59 81 
81
4 32 39 50 81 
39
5 39 55 57 59 81 
39
3 23 39 81 
39
6 23 32 39 40 50 81 
39
4 5 23 39 81 
39
5 2 5 23 39 81 
39
4 39 57 59 81 
39
5 5 12 23 39 81 
39
5 12 32 39 50 81 
39
5 39 51 57 59 81...

result:

ok n=100, OK

Test #4:

score: 0
Accepted
time: 3ms
memory: 4192kb

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 71 75 
71
2 43 71 
43
3 43 69 71 
43
3 43 55 71 
43
3 43 71 89 
43
3 31 43 71 
43
5 43 52 55 71 89 
43
3 24 43 71 
24
4 6 24 43 71 
24
5 6 9 24 43 71 
24
5 24 55 62 71 89 
24
5 6 19 24 43 71 
24
5 24 31 35 43 71 
24
6 24 31 35 38 43 71 
24
5 24 35 39 43 71 
39
6 39 55 62 63 71 89 
39
6 39...

result:

ok n=100, OK

Test #5:

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

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 93 917 
93
3 93 917 921 
93
3 70 93 917 
93
3 93 917 949 
93
3 93 777 949 
93
3 93 237 949 
93
3 93 581 949 
581
3 93 461 581 
581
4 93 319 461 581 
581
5 42 93 237 319 581 
581
4 93 581 690 949 
581
5 93 581 631 690 949 
581
5 93 135 237 319 581 
581
5 93 319 424 461 581 
581
6 93 581 63...

result:

ok n=1000, OK

Test #6:

score: 0
Accepted
time: 15ms
memory: 7288kb

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 589 844 
589
2 341 589 
589
3 341 362 589 
589
4 341 589 844 955 
955
4 341 565 589 955 
955
3 341 467 955 
955
4 341 589 664 955 
955
3 167 341 955 
167
5 167 589 844 879 955 
167
6 167 589 844 879 934 955 
167
5 167 589 757 844 934 
167
6 167 589 757 934 941 955 
167
4 56 167 341 934 ...

result:

ok n=1000, OK

Test #7:

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

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 827 4801 
827
4 827 2497 2709 4801 
827
3 827 4516 4801 
827
4 656 827 2709 4801 
827
4 827 4516 4773 4801 
4773
4 827 1444 2709 4773 
4773
5 827 2338 2497 2709 4773 
4773
5 827 1254 1444 2709 4773 
4773
3 827 4773 5749 
4773
4 827 2709 3926 4773 
4773
3 827 4773 7537 ...

result:

ok n=8000, OK

Test #8:

score: 0
Accepted
time: 96ms
memory: 19832kb

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 1866 5228 
5228
3 1866 4496 5228 
5228
3 1866 2574 5228 
5228
4 1492 1866 2574 5228 
5228
4 1866 4496 5228 5427 
5228
4 1866 2574 3355 5228 
3355
5 3355 4496 5228 5427 5495 
3355
3 3355 5228 6421 
3355
4 3355 5228 6421 7543 
3355
5 3355 4400 4496 5228 7543 
3355
5 3355 4311 4400 5228 ...

result:

ok n=8000, OK

Test #9:

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

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 650 964 967 
964
2 129 964 
964
3 129 345 964 
964
4 129 345 454 964 
964
4 129 614 650 964 
964
4 11 129 345 964 
964
5 129 650 963 964 967 
964
5 129 345 357 454 964 
964
5 129 300 345 454 964 
964
4 129 650 785 964 
964
5 129 614 650 700 964 
964
5 129 345 442 454 964 ...

result:

ok n=1000, OK

Test #10:

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

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 651 792 
792
3 651 792 816 
792
2 325 792 
792
4 325 651 792 876 
792
3 325 408 792 
792
4 289 325 408 792 
792
4 289 651 746 792 
792
4 289 408 492 792 
792
3 2 289 792 
792
6 2 289 408 462 492 792 
792
4 2 98 462 792 
792
5 2 68 98 462 792 
792
6 2 68 69 98 462 792 
792
6 462 746 792 ...

result:

ok n=1000, OK

Test #11:

score: 0
Accepted
time: 137ms
memory: 19736kb

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 650 4964 6871 
4964
3 129 650 4964 
4964
3 650 3768 4964 
4964
4 650 1551 3768 4964 
4964
4 650 4964 6223 6871 
4964
4 650 3768 3875 4964 
4964
5 650 4964 6223 6536 6871 
4964
5 650 4964 6223 6438 6871 
4964
4 650 4964 5015 6871 
4964
4 650 2528 3768 4964 
4964
5 650 ...

result:

ok n=8000, OK

Test #12:

score: 0
Accepted
time: 151ms
memory: 19816kb

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 3562 6508 
6508
3 1830 3562 6508 
6508
3 3562 6508 6995 
6508
5 1830 2628 2741 3562 6508 
6508
5 1830 2741 3523 3562 6508 
6508
3 2741 4497 6508 
6508
4 1175 1830 2741 6508 
6508
4 2741 4497 5626 6508 
6508
5 1175 2252 2741 3562 6508 
6508
6 1175 2252 2606 2741 3562 ...

result:

ok n=8000, OK

Test #13:

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

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 3 7 
3
3 3 7 10 
3
3 1 3 7 
3
4 3 7 9 10 
3
3 3 5 7 
3
4 3 4 5 7 
3
4 3 7 8 10 
3
5 3 6 7 8 10 
3
5 1 2 3 5 7 
3
3 1 5 7 
7
4 1 6 8 10 
10
3 1 8 9 
1
3 2 5 9 
9
3 2 4 9 
9
2 4 8 
4
2 4 6 
4
2 2 6 
6
1 2 
2
0 
-1

result:

ok n=10, OK

Test #14:

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

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 5 7 9 
7
4 2 4 5 7 
7
4 2 3 5 7 
3
5 1 2 3 5 7 
3
4 3 6 7 9 
3
4 3 7 9 10 
3
4 3 7 8 10 
3
4 3 6 8 10 
3
3 1 5 10 
10
3 1 4 10 
10
3 1 8 10 
10
2 1 8 
1
3 2 4 8 
4
2 4 6 
4
2 4 6 
4
1 6 
6
0 
-1

result:

ok n=10, OK

Test #15:

score: 0
Accepted
time: 40ms
memory: 7996kb

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 650 964 967 
964
2 129 964 
964
3 129 345 964 
964
4 129 345 454 964 
964
4 129 614 650 964 
964
4 11 129 345 964 
964
5 129 650 963 964 967 
964
5 129 345 357 454 964 
964
5 129 300 345 454 964 
964
4 129 650 785 964 
964
5 129 614 650 700 964 
964
5 129 345 442 454 964 ...

result:

ok n=1000, OK

Test #16:

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

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 449 644 871 
644
3 97 449 644 
97
4 97 644 853 871 
853
4 97 449 496 853 
496
4 97 418 496 853 
418
4 97 207 418 853 
207
5 207 401 418 496 853 
401
4 401 519 644 853 
519
4 207 276 401 519 
276
5 276 519 576 644 853 
576
5 74 97 207 276 576 
74
5 74 194 207 276 576 
194
...

result:

ok n=1000, OK

Test #17:

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

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 35 747 
35
3 35 391 747 
35
3 35 747 770 
35
4 35 707 747 770 
35
4 35 344 391 770 
35
4 35 747 770 881 
35
5 35 747 753 770 881 
35
5 35 266 344 391 770 
35
4 35 126 391 770 
126
5 11 35 126 391 770 
11
5 11 705 707 747 770 
11
4 11 672 747 770 
11
5 11 107 126 391 770 
11
5 11 266 391 4...

result:

ok n=1000, OK

Test #18:

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

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 326 650 914 
650
4 326 629 650 914 
650
5 326 626 629 650 914 
650
3 326 416 650 
650
4 416 650 785 914 
650
5 416 650 785 837 914 
650
4 300 326 416 650 
650
4 300 650 700 785 
650
3 164 300 650 
650
6 300 650 785 786 837 914 
650
6 164 300 304 326 416 650 
650
5 164 300...

result:

ok n=1000, OK

Test #19:

score: 0
Accepted
time: 23ms
memory: 5944kb

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 129 786 
129
3 129 614 786 
129
4 129 614 786 967 
967
3 129 454 967 
967
4 34 129 454 967 
967
4 129 614 700 967 
967
4 129 300 454 967 
967
5 129 300 454 488 967 
967
5 129 614 786 963 967 
967
5 34 79 129 454 967 
967
5 129 614 700 743 967 
967
6 11 34 79 129 454 967 
967
5 129 300 3...

result:

ok n=1000, OK

Test #20:

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

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 650 4964 6871 
4964
3 129 650 4964 
4964
3 650 3768 4964 
4964
4 650 1551 3768 4964 
4964
4 650 4964 6223 6871 
4964
4 650 3768 3875 4964 
4964
5 650 4964 6223 6536 6871 
4964
5 650 4964 6223 6438 6871 
4964
4 650 4964 5015 6871 
4964
4 650 2528 3768 4964 
4964
5 650 ...

result:

ok n=8000, OK

Test #21:

score: 0
Accepted
time: 141ms
memory: 19824kb

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 3493 5110 
5110
3 533 3493 5110 
533
4 533 1700 3493 5110 
1700
3 1700 4277 5110 
4277
4 1700 2368 3493 4277 
2368
4 2368 4277 4495 5110 
4495
5 2368 4277 4305 4495 5110 
4305
3 2368 4305 6965 
6965
5 1700 2368 2503 3493 6965 
2503
6 2503 4305 4339 4495 5110 6965 
4339
5 2503 4339 511...

result:

ok n=8000, OK

Test #22:

score: 0
Accepted
time: 129ms
memory: 19816kb

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 612 2743 
612
2 612 7916 
612
4 612 1433 2743 7916 
1433
4 1433 2140 2743 7916 
1433
5 612 840 1433 2140 7916 
1433
3 1433 4289 7916 
1433
4 1433 2140 3912 4289 
1433
4 1433 4289 6323 7916 
1433
5 1433 2140 3859 3912 4289 
1433
4 1433 4289 4368 6323 
1433
5 1433 4289 6046 6323 7916 
143...

result:

ok n=8000, OK

Test #23:

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

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 3393 5029 
5029
3 650 3393 5029 
650
4 650 3393 3599 5029 
650
3 650 5029 5102 
650
4 650 5029 5102 5122 
650
3 650 5102 6641 
650
4 475 650 3393 5102 
650
4 650 1323 3393 5102 
650
5 650 1323 1821 3393 5102 
650
5 650 3393 3447 3599 5102 
650
6 475 578 650 1821 3393 5102 
650
4 650 5...

result:

ok n=8000, OK

Test #24:

score: 0
Accepted
time: 199ms
memory: 19740kb

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 3768 5029 
3768
4 878 1821 3768 5029 
3768
3 3768 5001 5029 
3768
5 878 1608 1821 3768 5029 
3768
4 1821 2691 3768 5029 
3768
3 3768 5029 7293 
3768
4 3768 5029 7275 7293 
3768
4 3768 5029 6223 7275 
3768
5 227 878 1821 3768 6223 
3768
5 1821 2691 3768 3809 6223 
3768...

result:

ok n=8000, OK

Test #25:

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

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 3 7 
3
3 3 7 10 
3
3 1 3 7 
3
4 3 7 9 10 
3
3 3 5 7 
3
4 3 4 5 7 
3
4 3 7 8 10 
3
5 3 6 7 8 10 
3
5 1 2 3 5 7 
3
3 1 5 7 
7
4 1 6 8 10 
10
3 1 8 9 
1
3 2 5 9 
9
3 2 4 9 
9
2 4 8 
4
2 4 6 
4
2 2 6 
6
1 2 
2
0 
-1

result:

ok n=10, OK

Test #26:

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

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 3 6 8 10 
3
4 1 3 4 10 
3
5 3 6 7 8 10 
3
5 1 2 3 4 7 
3
4 3 7 9 10 
3
4 3 4 5 7 
3
3 1 5 7 
7
4 1 6 8 10 
10
3 1 8 9 
1
3 2 5 9 
9
3 5 6 9 
9
3 2 4 9 
9
2 4 6 
4
2 2 6 
6
1 2 
2
0 
-1

result:

ok n=10, OK

Test #27:

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

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 650 964 967 
964
2 129 964 
964
3 129 345 964 
964
4 129 345 454 964 
964
4 129 614 650 964 
964
4 11 129 345 964 
964
5 129 650 963 964 967 
964
5 129 345 357 454 964 
964
5 129 300 345 454 964 
964
4 129 650 785 964 
964
5 129 614 650 700 964 
964
5 129 345 442 454 964 ...

result:

ok n=1000, OK

Test #28:

score: 0
Accepted
time: 4ms
memory: 5948kb

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 449 644 871 
644
3 97 449 644 
97
4 97 644 853 871 
853
4 97 449 496 853 
496
4 97 418 496 853 
418
4 97 207 418 853 
207
5 207 401 418 496 853 
401
4 401 519 644 853 
519
4 207 276 401 519 
276
5 276 519 576 644 853 
576
5 74 97 207 276 576 
74
5 74 194 207 276 576 
194
...

result:

ok n=1000, OK

Test #29:

score: 0
Accepted
time: 20ms
memory: 7828kb

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 800 897 986 
986
2 601 986 
601
4 601 800 858 986 
858
3 601 627 858 
858
2 398 858 
858
3 124 398 858 
858
6 124 601 858 885 897 986 
858
5 124 554 601 627 858 
858
4 124 234 398 858 
858
4 124 398 482 858 
858
5 124 398 482 489 858 
858
6 124 554 771 800 858 885 
858
6 ...

result:

ok n=1000, OK

Test #30:

score: 0
Accepted
time: 13ms
memory: 9304kb

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 101 442 
442
3 101 183 442 
442
3 101 373 442 
442
2 442 837 
442
5 101 326 373 442 837 
442
3 442 585 837 
442
5 101 373 442 450 585 
442
5 15 101 183 442 585 
442
4 442 585 626 837 
442
4 442 585 837 914 
442
5 442 585 786 837 914 
442
5 101 373 442 494 585 
442
6 442 585 786 828 837 ...

result:

ok n=1000, OK

Test #31:

score: 0
Accepted
time: 3ms
memory: 8928kb

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 79 442 
442
3 79 442 454 
454
2 454 520 
454
4 79 101 454 520 
454
4 79 343 454 520 
454
3 454 520 585 
454
3 454 585 700 
454
4 454 585 632 700 
454
5 79 300 343 454 700 
454
3 454 700 878 
454
5 64 79 101 454 700 
454
4 79 227 454 700 
454
4 454 700 878 964 
964
4 454 700 828 964 
964
5...

result:

ok n=1000, OK

Test #32:

score: 0
Accepted
time: 17ms
memory: 7244kb

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 449 644 964 
964
3 97 449 964 
964
5 97 644 853 871 964 
964
4 97 449 496 964 
964
4 97 418 496 964 
964
4 97 207 418 964 
964
5 207 401 418 496 964 
964
4 401 519 644 964 
964
4 207 276 401 964 
964
5 276 519 576 644 964 
964
5 74 97 207 276 964 
964
5 74 ...

result:

ok n=1000, OK

Test #33:

score: 0
Accepted
time: 110ms
memory: 19824kb

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 650 4964 6871 
4964
3 129 650 4964 
4964
3 650 3768 4964 
4964
4 650 1551 3768 4964 
4964
4 650 4964 6223 6871 
4964
4 650 3768 3875 4964 
4964
5 650 4964 6223 6536 6871 
4964
5 650 4964 6223 6438 6871 
4964
4 650 4964 5015 6871 
4964
4 650 2528 3768 4964 
4964
5 650 ...

result:

ok n=8000, OK

Test #34:

score: 0
Accepted
time: 131ms
memory: 19808kb

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 3493 5110 
5110
3 533 3493 5110 
533
4 533 1700 3493 5110 
1700
3 1700 4277 5110 
4277
4 1700 2368 3493 4277 
2368
4 2368 4277 4495 5110 
4495
5 2368 4277 4305 4495 5110 
4305
3 2368 4305 6965 
6965
5 1700 2368 2503 3493 6965 
2503
6 2503 4305 4339 4495 5110 6965 
4339
5 2503 4339 511...

result:

ok n=8000, OK

Test #35:

score: 0
Accepted
time: 130ms
memory: 19852kb

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 1338 2046 
1338
2 1338 5158 
5158
5 1220 1338 1439 2046 5158 
5158
4 412 1338 2046 5158 
5158
3 1338 5158 5737 
5737
4 1338 2046 3968 5737 
5737
5 412 703 1338 2046 5737 
5737
5 1338 2046 2858 3968 5737 
5737
6 1338 2046 2783 2858 3968 5737 
5737
5 1338 2858 3798 396...

result:

ok n=8000, OK

Test #36:

score: 0
Accepted
time: 111ms
memory: 19684kb

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 4520 6131 6799 
6131
2 1676 6131 
6131
3 1676 1844 6131 
6131
5 1676 4520 6131 6799 6912 
6131
3 1676 3621 6131 
6131
4 3621 4018 4520 6131 
4018
4 1178 1676 3621 4018 
4018
4 1178 2082 3621 4018 
4018
5 1178 4018 6131 6172 6912 
6172
6 1178 1568 1676 1844 3621 6172 ...

result:

ok n=8000, OK

Test #37:

score: 0
Accepted
time: 141ms
memory: 19820kb

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 893 2960 
2960
2 2960 7459 
7459
4 111 893 2960 7459 
111
4 111 1185 2960 7459 
111
4 111 2960 3327 7459 
111
3 111 5397 7459 
5397
5 111 2960 3327 3963 5397 
5397
4 111 4988 5397 7459 
5397
4 111 5397 6640 7459 
5397
6 111 2960 3327 3584 3963 5397 
5397
5 111 4988 5397 5536 7459 
5397
...

result:

ok n=8000, OK

Test #38:

score: 0
Accepted
time: 136ms
memory: 19804kb

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 3768 5755 
3768
3 3768 5029 5755 
3768
4 3768 5029 5530 5755 
3768
3 3768 5029 7826 
3768
4 3768 5029 6194 7826 
3768
4 355 1821 3768 5029 
3768
5 355 1113 1821 3768 5029 
3768
5 3768 5015 5029 5755 6194 
3768
5 343 355 1821 3768 5015 
3768
5 343 650 1821 3768 5015 
6...

result:

ok n=8000, OK

Test #39:

score: 0
Accepted
time: 107ms
memory: 19868kb

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 3325 5911 
3325
3 664 3325 5911 
3325
4 664 708 3325 5911 
3325
4 708 3325 3589 5911 
3325
5 708 3325 3589 3869 5911 
3325
3 3325 5911 6353 
3325
4 3325 5408 5911 6353 
3325
4 708 2396 3325 6353 
3325
4 708 1926 3325 6353 
3325
7 1926 2396 3325 3589 3822 3869 6353 
3325
5 1926 2396 24...

result:

ok n=8000, OK

Test #40:

score: 0
Accepted
time: 119ms
memory: 19760kb

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 520 4857 
4857
3 520 3380 4857 
4857
3 520 4857 5397 
4857
4 520 1551 3380 4857 
1551
4 1551 4675 4857 5397 
1551
4 1551 4857 5397 5755 
1551
4 1551 2691 3380 4857 
1551
5 1551 2691 3380 3809 4857 
1551
5 520 1551 1608 3809 4857 
1551
5 1551 4675 4679 4857 5755 
1551
3 1551 4857 6194 
1...

result:

ok n=8000, OK

Test #41:

score: 0
Accepted
time: 113ms
memory: 19704kb

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 3540 6114 
6114
3 3540 6114 7095 
6114
4 3540 6114 7095 7142 
6114
3 3540 4694 6114 
6114
3 1040 3540 6114 
6114
4 1040 2503 3540 6114 
6114
4 3540 4694 5498 6114 
6114
5 3540 4061 4694 5498 6114 
6114
4 213 1040 3540 6114 
6114
5 213 300 1040 3540 6114 
6114
6 20 213 300 1040 3540 61...

result:

ok n=8000, OK

Test #42:

score: 0
Accepted
time: 122ms
memory: 19736kb

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 6663 7408 
7408
2 2088 7408 
2088
3 1213 2088 7408 
2088
4 1213 2088 3752 7408 
3752
3 3752 4898 7408 
3752
5 3752 4898 6663 6916 7408 
3752
5 1213 2088 3470 3752 7408 
3470
6 3470 4898 6588 6663 6916 7408 
3470
5 3470 4898 6136 6588 7408 
3470
6 1213 2088 3470 3508 3752 6588 
3508
6 ...

result:

ok n=8000, OK

Test #43:

score: 0
Accepted
time: 126ms
memory: 19772kb

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 2364 6663 7626 
6663
3 131 2364 6663 
131
4 131 6567 6663 7626 
131
4 131 6567 6812 7626 
131
3 131 4718 6567 
131
4 131 1312 2364 6567 
1312
4 1312 4718 5091 6567 
1312
5 1312 4718 4819 5091 6567 
4819
5 131 1312 1421 2364 4819 
4819
4 1312 2361 2364 4819 
4819
4 13...

result:

ok n=8000, OK

Test #44:

score: 0
Accepted
time: 118ms
memory: 19820kb

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 615 4339 7105 
615
4 615 4339 4718 7105 
615
3 615 2503 7105 
615
5 615 4339 4718 4810 7105 
615
4 615 4810 6965 7105 
615
4 615 1700 2503 7105 
615
5 533 615 1700 2503 7105 
615
4 615 2503 3145 7105 
615
5 615 4810 6288 6965 7105 
6288
5 615 2496 2503 3145 6288 
6288
...

result:

ok n=8000, OK

Test #45:

score: 0
Accepted
time: 112ms
memory: 19820kb

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 3493 4964 5110 
4964
3 533 3493 4964 
4964
4 533 1700 3493 4964 
4964
4 1700 4277 4964 5110 
4964
4 1700 2368 3493 4964 
4964
5 2368 4277 4495 4964 5110 
4964
6 2368 4277 4305 4495 4964 5110 
4964
3 2368 4964 6965 
4964
5 1700 2368 2503 3493 4964 
4964
7 2503 4305 43...

result:

ok n=8000, OK