QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#848697#1458. Binary Search AlgorithmCarroT1212AC ✓139ms4048kbC++141.2kb2025-01-09 08:15:052025-01-09 08:15:06

Judging History

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

  • [2025-01-09 08:15:06]
  • 评测
  • 测评结果:AC
  • 用时:139ms
  • 内存:4048kb
  • [2025-01-09 08:15:05]
  • 提交

answer

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std; bool MEM;
using ll=long long; using ld=long double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
const int I=1e9;
const ll J=1e18,N=8007;
ll n,t[N<<2],c[N];
char inp[8];
vector<ll> v;
void get(ll x,ll p=1,ll l=1,ll r=n) {
	if (t[p^1]) v.pb(t[p^1]);
	if (l==r) return;
	ll mid=l+r>>1;
	if (x<=mid) get(x,p<<1,l,mid);
	else get(x,p<<1|1,mid+1,r);
}
void go() {
	cout<<v.size()<<" ";
	for (ll i:v) cout<<i<<" "; cout<<endl;
	for (ll i=1,x;i<=v.size();i++) scanf("%lld",&x),c[x]=i;
}
void pup(ll p) {
	if (!t[p<<1]||!t[p<<1|1]) t[p]=t[p<<1]+t[p<<1|1];
	else t[p]=c[t[p<<1]]<c[t[p<<1|1]]?t[p<<1]:t[p<<1|1];
}
void upd(ll x,ll z,ll p=1,ll l=1,ll r=n) {
	if (l==r) return t[p]=z,void();
	ll mid=l+r>>1;
	if (x<=mid) upd(x,z,p<<1,l,mid);
	else upd(x,z,p<<1|1,mid+1,r);
	pup(p);
}
void mian() {
	scanf("%lld",&n);
	for (ll o=1,x;o<=n*2;o++) {
		scanf("%s%lld",inp,&x);
		v.clear();
		if (inp[0]=='a') get(x),v.pb(x),go(),upd(x,x);
		else get(x),go(),upd(x,0);
		cout<<(t[1]?t[1]:-1)<<endl;
	}
}
bool ORY; int main() {
	// while (1)
	// int t; for (scanf("%d",&t);t--;)
	mian();
	cerr<<"\n"<<abs(&MEM-&ORY)/1048576<<"MB";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

ok n=3, OK

Test #2:

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

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

result:

ok n=10, OK

Test #3:

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

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

result:

ok n=100, OK

Test #4:

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

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

result:

ok n=100, OK

Test #5:

score: 0
Accepted
time: 28ms
memory: 3804kb

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

result:

ok n=1000, OK

Test #6:

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

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

result:

ok n=1000, OK

Test #7:

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

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

result:

ok n=8000, OK

Test #8:

score: 0
Accepted
time: 117ms
memory: 4048kb

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

result:

ok n=8000, OK

Test #9:

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

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

result:

ok n=1000, OK

Test #10:

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

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

result:

ok n=1000, OK

Test #11:

score: 0
Accepted
time: 88ms
memory: 3988kb

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

result:

ok n=8000, OK

Test #12:

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

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

result:

ok n=8000, OK

Test #13:

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

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

result:

ok n=10, OK

Test #14:

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

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

result:

ok n=10, OK

Test #15:

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

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

result:

ok n=1000, OK

Test #16:

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

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

result:

ok n=1000, OK

Test #17:

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

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

result:

ok n=1000, OK

Test #18:

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

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

result:

ok n=1000, OK

Test #19:

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

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

result:

ok n=1000, OK

Test #20:

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

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

result:

ok n=8000, OK

Test #21:

score: 0
Accepted
time: 139ms
memory: 3844kb

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

result:

ok n=8000, OK

Test #22:

score: 0
Accepted
time: 100ms
memory: 3984kb

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

result:

ok n=8000, OK

Test #23:

score: 0
Accepted
time: 86ms
memory: 3964kb

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

result:

ok n=8000, OK

Test #24:

score: 0
Accepted
time: 86ms
memory: 4028kb

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

result:

ok n=8000, OK

Test #25:

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

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

result:

ok n=10, OK

Test #26:

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

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

result:

ok n=10, OK

Test #27:

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

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

result:

ok n=1000, OK

Test #28:

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

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

result:

ok n=1000, OK

Test #29:

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

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

result:

ok n=1000, OK

Test #30:

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

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

result:

ok n=1000, OK

Test #31:

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

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

result:

ok n=1000, OK

Test #32:

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

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

result:

ok n=1000, OK

Test #33:

score: 0
Accepted
time: 70ms
memory: 4044kb

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

result:

ok n=8000, OK

Test #34:

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

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

result:

ok n=8000, OK

Test #35:

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

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

result:

ok n=8000, OK

Test #36:

score: 0
Accepted
time: 123ms
memory: 3960kb

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

result:

ok n=8000, OK

Test #37:

score: 0
Accepted
time: 67ms
memory: 3956kb

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

result:

ok n=8000, OK

Test #38:

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

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

result:

ok n=8000, OK

Test #39:

score: 0
Accepted
time: 89ms
memory: 3908kb

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

result:

ok n=8000, OK

Test #40:

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

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

result:

ok n=8000, OK

Test #41:

score: 0
Accepted
time: 94ms
memory: 4032kb

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

result:

ok n=8000, OK

Test #42:

score: 0
Accepted
time: 57ms
memory: 3936kb

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

result:

ok n=8000, OK

Test #43:

score: 0
Accepted
time: 87ms
memory: 3840kb

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

result:

ok n=8000, OK

Test #44:

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

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

result:

ok n=8000, OK

Test #45:

score: 0
Accepted
time: 89ms
memory: 4020kb

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

result:

ok n=8000, OK