QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#712529#9588. 可重集合icpc_zhzx034#AC ✓540ms343236kbC++141.7kb2024-11-05 16:02:492024-11-05 16:02:50

Judging History

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

  • [2024-11-05 16:02:50]
  • 评测
  • 测评结果:AC
  • 用时:540ms
  • 内存:343236kb
  • [2024-11-05 16:02:49]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll,ll> P;
#define _for(x,y,z) for (int x(y),_(z); x<=_; ++x)
#define _rep(x,y,z) for (int x(y),_(z); x>=_; --x)
inline ll read(){ ll x; cin>>x; return x; }
inline void _init(){
	#ifdef LOCAL
		assert(freopen("test.in", "r", stdin));
		assert(freopen("test.out", "w", stdout));
	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
}

const int N = 5005;
const int M = 5e5 + 5;

vector <int> tree[N << 2];

int n, l[N], r[N], k[N], ans[N];

stack <int> st[M];

inline void update(int i, int l, int r, int ql, int qr, int k) {
	if (ql <= l && r <= qr) {
		tree[i].emplace_back(k);
		return;
	}
	int mid = (l + r) >> 1;
	if (ql <= mid) {
		update(i << 1, l, mid, ql, qr, k);
	}
	if (qr > mid) {
		update(i << 1 | 1, mid + 1, r, ql, qr, k);
	}
}

inline void dfs(int i, int l, int r, bitset <M> b) {
	for (auto u: tree[i]) {
		b |= (b << u);
	}
	if (l == r) {
		ans[l] = b.count() - 1;
		return;
	}
	int mid = (l + r) >> 1;
	dfs(i << 1, l, mid, b);
	dfs(i << 1 | 1, mid + 1, r, b);
}

bitset <M> b;

void init() {}
void procedure() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int op, val;
		cin >> op >> val;
		if (op == 1) {
			st[val].push(i);
			l[i] = i;
			r[i] = n;
			k[i] = val;
		} else {
			int u = st[val].top();
			st[val].pop();
			r[u] = i - 1;
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (!k[i]) {
			continue;
		}
		update(1, 1, n, l[i], r[i], k[i]);
	}
	b[0] = 1;
	dfs(1, 1, n, b);
	for (int i = 1; i <= n; ++i) {
		cout << ans[i] << "\n";
	}
}

int main() {
	_init(), init();
	int T=1;
	while(T--) procedure();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 53ms
memory: 340576kb

input:

4
1 100
1 999
1 10
2 100

output:

1
3
7
3

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 60ms
memory: 340716kb

input:

7
1 1
1 2
1 1
1 4
1 5
2 1
2 4

output:

1
3
4
8
13
12
7

result:

ok 7 lines

Test #3:

score: 0
Accepted
time: 431ms
memory: 342940kb

input:

5000
1 132200
2 132200
1 304115
1 119865
1 7246
1 23773
1 6583
2 6583
2 119865
1 13380
1 38501
2 7246
1 115933
2 115933
1 52649
1 48334
1 2824
1 9919
2 2824
1 9007
1 309
2 304115
1 41830
2 9919
1 153380
1 100177
1 2775
2 13380
1 2913
1 16644
1 1437
2 9007
2 309
1 10921
1 1853
1 170
2 23773
1 561
1 2...

output:

1
0
1
3
7
15
31
15
7
15
31
15
31
15
31
63
127
255
127
255
511
255
507
255
511
1023
2015
1007
2015
4031
8055
4031
2015
4031
7759
15515
7775
15387
30382
58433
108009
190146
111225
185051
285581
368440
423581
454204
396073
336717
213883
159845
245001
322194
254226
170951
93547
170423
268968
353531
4067...

result:

ok 5000 lines

Test #4:

score: 0
Accepted
time: 438ms
memory: 342888kb

input:

5000
1 85125
1 398908
1 13524
1 1813
1 18
1 572
1 26
1 1
1 2
1 2
1 5
2 398908
1 310976
1 21533
1 53704
2 53704
2 2
1 14599
1 25403
1 4012
2 13524
1 5360
1 722
2 5
1 8852
1 11241
1 2118
1 3775
2 85125
1 2643
1 71319
1 1491
2 21533
1 34087
1 341
1 501
1 16
2 16
1 118
1 6
1 1
2 26
1 5
2 501
1 73
1 130
...

output:

1
3
7
15
31
63
127
255
511
767
1311
655
1311
2623
5247
2623
1983
3967
7935
15799
7935
15871
31231
16255
31687
62439
111475
188379
94439
131739
252971
303753
236975
327525
351411
362165
367697
362165
367961
372481
373587
370299
373257
369507
373441
375625
307451
327507
325445
322089
316803
305169
152...

result:

ok 5000 lines

Test #5:

score: 0
Accepted
time: 420ms
memory: 342824kb

input:

5000
1 371880
2 371880
1 376281
1 47394
1 54450
2 54450
1 32244
1 17874
1 331
2 17874
1 25072
1 10958
2 47394
1 21019
1 4788
2 25072
2 21019
2 32244
1 6041
2 331
1 28287
1 44056
2 4788
1 27846
1 4917
1 764
1 475
1 269
2 10958
1 10989
1 70
1 1
1 1
1 1
1 1
1 1
2 1
1 1
2 10989
1 4809
2 4809
1 744
1 395...

output:

1
0
1
3
7
3
7
15
31
15
31
63
31
63
127
63
31
15
31
15
31
63
31
63
111
223
447
895
511
1023
2047
4079
6111
8111
10111
12095
10111
12095
6143
11967
6143
10751
20927
39343
71835
61351
102547
146551
190225
146187
190487
208281
216595
222805
217709
221279
184729
179007
165579
131663
194357
214145
220687
...

result:

ok 5000 lines

Test #6:

score: 0
Accepted
time: 424ms
memory: 343180kb

input:

5000
1 231200
1 52288
2 52288
1 125132
2 231200
1 35966
2 125132
2 35966
1 278730
1 203562
1 9463
1 6273
2 203562
2 6273
2 278730
1 351089
2 351089
1 32982
1 227550
2 9463
2 227550
2 32982
1 133184
2 133184
1 483637
1 12107
1 1779
2 1779
1 1939
1 1358
1 202
1 562
2 1358
2 1939
1 1143
2 483637
1 3232...

output:

1
3
1
3
1
3
1
0
1
3
7
15
7
3
1
3
1
3
7
3
1
0
1
0
1
3
7
3
7
15
31
63
31
15
31
15
31
63
127
63
127
255
511
1023
2047
4095
2047
4095
2047
1023
2031
1023
2047
4087
2047
1023
2047
4095
8175
15999
30503
58495
108403
148507
83819
143095
82895
140783
220059
156537
222927
151759
224685
279633
307241
321675
3...

result:

ok 5000 lines

Test #7:

score: 0
Accepted
time: 420ms
memory: 343112kb

input:

5000
1 19461
2 19461
1 460737
2 460737
1 107147
1 362854
1 14327
2 362854
1 122948
1 70710
1 151455
2 151455
1 115023
1 13519
1 30643
1 8024
2 115023
1 128069
1 4431
2 70710
2 13519
1 66134
2 107147
2 66134
2 30643
1 79716
1 105017
1 30306
1 3854
1 716
2 122948
1 80666
2 79716
1 111381
1 6242
1 4141...

output:

1
0
1
0
1
3
7
3
7
15
31
15
31
63
127
255
127
255
511
255
127
255
127
63
31
63
127
255
511
1023
511
1023
511
1023
2047
4031
2015
4031
8055
15943
30771
16071
29819
56445
92513
164089
258313
171952
100107
52600
93583
163055
257885
359692
275914
179233
113509
193033
287812
373599
422727
345988
422978
36...

result:

ok 5000 lines

Test #8:

score: 0
Accepted
time: 472ms
memory: 343236kb

input:

5000
1 102
1 771
1 301
1 901
1 477
1 373
1 755
2 771
1 370
1 487
2 477
1 156
1 742
1 54
2 54
2 373
2 742
1 932
2 901
1 294
1 362
1 416
1 459
1 642
2 370
2 301
1 485
1 251
1 32
1 383
1 391
1 56
2 416
2 459
1 263
1 901
2 932
1 203
1 462
1 266
1 62
2 294
1 216
1 591
2 62
2 383
1 140
2 251
1 553
2 591
2...

output:

1
3
7
15
31
63
127
63
127
239
119
239
451
769
451
239
119
239
119
231
463
845
1525
2460
1561
891
1591
2371
3213
3852
4409
4857
4355
3732
4275
5180
4244
4639
5139
5513
5783
5421
5743
6334
6076
5673
5939
5644
6199
5604
5101
5371
5876
5121
4839
5165
6083
5705
6125
6718
7351
8186
8568
8300
9188
10139
94...

result:

ok 5000 lines

Test #9:

score: 0
Accepted
time: 470ms
memory: 343188kb

input:

5000
1 34
2 34
1 81
1 730
2 730
2 81
1 21
1 169
1 571
1 290
1 387
1 107
1 396
1 15
1 848
2 290
1 404
1 149
1 134
2 149
1 395
1 700
2 404
1 161
1 604
1 671
1 332
1 345
2 671
2 161
2 848
1 397
2 332
1 137
2 700
1 414
2 137
2 396
1 534
1 350
1 575
1 110
1 449
1 944
2 110
2 571
2 575
1 874
1 652
1 893
1...

output:

1
0
1
3
1
0
1
3
7
15
31
63
127
231
463
231
463
817
1163
796
1311
2089
1311
1999
2916
3715
4271
4680
3995
3608
2748
3313
2809
3298
2588
3044
2631
1839
2709
3241
3852
4206
4687
5631
5293
4710
4111
4985
5649
6542
6934
7272
7524
7107
7574
7157
7793
7141
7717
8662
8268
7974
8665
7720
7128
6570
6888
7185
...

result:

ok 5000 lines

Test #10:

score: 0
Accepted
time: 461ms
memory: 342960kb

input:

5000
1 780
1 949
2 949
1 294
2 780
1 421
1 717
2 421
1 621
1 973
2 621
1 674
2 717
2 674
2 973
1 638
2 294
2 638
1 637
1 23
1 757
2 23
1 387
1 799
2 387
1 291
1 186
1 998
2 637
1 343
1 684
2 757
1 323
1 896
1 656
2 291
1 648
1 690
1 508
1 152
2 656
1 916
1 16
2 648
2 799
1 770
1 856
1 589
1 865
1 86...

output:

1
3
1
3
1
3
7
3
7
15
7
15
7
3
1
3
1
0
1
3
7
3
7
15
7
15
31
63
31
63
127
63
127
255
499
255
511
943
1709
2735
1713
2745
3971
2753
1630
2711
3775
4803
5876
6953
7708
6944
7836
7092
6112
5094
3946
2700
3810
4852
5975
7016
7894
8529
9121
9748
9264
9721
8783
9793
10380
10822
11192
10816
11158
11538
11841...

result:

ok 5000 lines

Test #11:

score: 0
Accepted
time: 477ms
memory: 342952kb

input:

5000
1 83
2 83
1 94
1 11
1 42
1 40
1 50
2 42
1 32
2 50
1 20
1 28
1 54
1 39
1 81
1 55
1 55
2 32
1 57
2 94
1 45
1 2
1 59
2 55
1 14
1 26
1 37
1 15
1 67
1 28
1 31
2 28
2 37
1 12
1 36
1 71
1 65
1 96
2 11
1 47
1 89
1 94
1 25
1 74
1 7
1 48
1 70
1 97
1 58
1 24
1 52
1 30
1 44
1 33
1 30
2 15
1 25
1 10
1 12
1 ...

output:

1
0
1
3
7
15
31
15
31
15
31
59
101
166
263
340
395
337
414
320
379
415
474
419
451
483
522
549
616
644
675
647
610
630
666
737
802
898
879
926
1015
1109
1136
1210
1229
1277
1347
1444
1502
1526
1578
1608
1652
1685
1715
1696
1721
1735
1747
1758
1824
1838
1885
1934
1986
1947
2032
2074
2089
2125
2192
21...

result:

ok 5000 lines

Test #12:

score: 0
Accepted
time: 480ms
memory: 342984kb

input:

5000
1 46
2 46
1 3
1 73
1 3
1 89
1 31
1 21
2 3
1 92
1 81
1 33
1 56
2 92
1 33
1 57
1 53
1 63
1 85
1 71
2 3
2 85
1 88
1 63
1 85
1 4
1 71
1 23
1 80
1 49
1 7
2 89
1 65
2 63
1 56
1 38
2 65
1 40
1 71
2 7
2 71
2 63
1 48
2 48
1 83
1 78
2 81
1 61
1 52
1 96
1 23
1 3
1 81
1 87
1 16
1 97
2 21
1 79
1 49
1 79
1 9...

output:

1
0
1
3
5
11
23
46
31
55
111
213
309
199
248
339
402
473
558
633
596
511
599
662
747
787
858
897
979
1032
1069
980
1047
984
1040
1080
1015
1057
1128
1101
1030
967
1015
967
1050
1128
1047
1108
1160
1256
1283
1316
1397
1484
1508
1605
1574
1653
1702
1781
1875
1956
2005
2027
2058
1987
2057
2024
2059
213...

result:

ok 5000 lines

Test #13:

score: 0
Accepted
time: 529ms
memory: 342912kb

input:

5000
1 259
1 262
1 144
1 164
1 36
1 299
1 138
1 18
1 206
2 164
1 14
2 138
1 136
1 272
1 106
1 268
1 103
1 41
1 81
2 36
1 296
2 206
2 259
1 116
1 78
1 161
1 134
1 149
1 88
1 225
1 117
1 69
1 284
1 79
1 14
1 192
1 51
1 292
1 31
2 161
1 125
1 236
1 52
1 139
1 71
1 25
1 243
1 142
1 136
1 154
1 177
1 68
...

output:

1
3
7
15
31
63
123
247
448
249
443
241
423
761
1060
1354
1617
1766
1925
1773
2077
1843
1564
1776
1930
2101
2245
2410
2518
2743
2864
2955
3239
3336
3368
3560
3625
3917
3984
3823
3948
4184
4248
4387
4464
4513
4756
4898
5034
5188
5365
5435
5671
5892
5921
6157
6279
6555
6626
6900
6980
7127
7210
7299
758...

result:

ok 5000 lines

Test #14:

score: 0
Accepted
time: 540ms
memory: 343124kb

input:

5000
1 263
1 92
1 134
1 182
1 79
1 78
1 168
1 200
1 162
1 76
1 173
1 135
1 149
1 68
1 1
1 199
1 96
1 182
1 117
1 149
1 218
1 216
1 278
1 174
1 197
1 114
1 199
1 215
1 110
2 92
1 182
1 78
1 79
1 219
1 155
1 217
1 8
1 26
1 235
1 229
1 33
1 219
1 43
2 173
1 137
1 47
1 229
1 119
1 31
1 252
1 126
1 136
1...

output:

1
3
7
15
31
63
117
235
445
648
903
1140
1335
1493
1594
1797
1921
2103
2250
2399
2619
2837
3115
3289
3488
3616
3815
4030
4150
4044
4226
4306
4387
4608
4763
4980
5048
5112
5347
5576
5639
5858
5911
5738
5875
5958
6187
6306
6365
6617
6743
6879
7019
7057
7278
7322
7437
7712
7850
7963
8241
8456
8529
8453
...

result:

ok 5000 lines

Test #15:

score: 0
Accepted
time: 385ms
memory: 343164kb

input:

5000
1 57
1 70097
1 88
1 38
2 38
1 19
1 51
1 20
1 70
2 57
2 88
2 70
1 25
2 20
1 47
1 96
1 429665
2 47
2 19
1 54
2 96
1 15
2 429665
1 63
1 429695
2 63
1 63
2 429695
1 42062
1 58
1 10
1 387565
2 51
2 70097
2 63
2 58
2 54
1 13
1 70310
2 15
2 10
2 70310
1 3
1 70332
2 387565
1 49
2 25
1 79
1 357552
1 64
...

output:

1
3
7
15
7
15
31
59
103
55
27
15
31
15
31
63
127
63
31
63
31
63
31
63
127
63
127
63
127
255
415
831
415
207
111
55
27
55
111
63
31
15
31
63
31
63
31
63
127
255
511
951
495
735
383
639
447
255
447
719
943
1383
1615
1391
2783
1903
3199
4127
3039
4255
3567
4255
3103
1551
3103
2287
3103
1551
775
951
759...

result:

ok 5000 lines

Test #16:

score: 0
Accepted
time: 378ms
memory: 342812kb

input:

5000
1 68
2 68
1 71
1 61
1 69
1 39
2 61
2 69
1 320009
1 56
1 96
1 35
2 35
1 151682
2 71
2 96
1 28214
2 320009
1 36
1 41
1 39
2 56
2 39
2 36
2 41
2 28214
2 151682
1 25
1 455049
2 39
2 25
2 455049
1 61
1 4
2 4
1 33
1 42
1 49
2 33
2 42
1 3
1 17
1 56
2 3
1 75
1 13
1 20
1 64
1 3
1 1
1 15
1 88
1 89463
1 7...

output:

1
0
1
3
7
15
7
3
7
15
31
63
31
63
31
15
31
15
31
63
95
47
31
15
7
3
1
3
7
3
1
0
1
3
1
3
7
15
7
3
7
15
31
15
31
61
113
195
252
299
338
426
853
995
893
1055
2111
2203
1951
3903
4407
4711
5335
10671
11535
13087
14431
14095
12895
25791
24671
25407
24671
26879
29823
27007
29023
30463
33631
35103
33887
36...

result:

ok 5000 lines

Test #17:

score: 0
Accepted
time: 375ms
memory: 342868kb

input:

5000
1 407167
1 23
1 24
1 55271
2 23
1 52
1 37486
2 407167
1 157148
2 52
2 24
1 95
1 93
2 95
2 93
1 82954
1 93
1 75
1 30
2 157148
2 55271
1 73
2 75
1 59
1 11
1 46
1 379248
2 73
1 21
2 379248
1 23
1 68
1 139833
1 38
1 66
2 68
1 94
1 97
1 7
1 66
1 44
1 79
2 44
2 139833
1 63
1 66
1 2
1 100
1 27
1 64
1 ...

output:

1
3
7
15
7
15
31
15
31
15
7
15
31
15
7
15
31
63
127
63
31
63
31
63
127
255
511
255
511
255
447
719
1439
2031
2687
2063
2911
3687
4079
4607
5007
5639
5255
2627
2887
3151
3255
3655
3787
4043
4419
4759
4651
4275
4115
4391
4783
5119
4731
4359
4571
4723
4623
4359
4095
4483
4711
4839
5163
5035
4695
4467
4...

result:

ok 5000 lines

Test #18:

score: 0
Accepted
time: 360ms
memory: 343156kb

input:

5000
1 98
1 100
1 5
1 94
2 100
1 83
2 98
1 64
1 91
1 79452
1 88
1 5
2 64
1 94
2 91
2 94
2 79452
1 310646
2 310646
2 83
2 5
1 346313
1 153500
2 88
1 54
1 7
1 27
2 153500
1 31
1 92
1 99
1 153278
2 153278
1 52
1 51
1 67
1 17
1 72
1 1
2 1
1 18
1 96
1 152905
2 54
1 54
2 51
1 47
1 4
2 5
2 54
1 26
2 31
1 3...

output:

1
3
7
15
7
15
7
15
31
63
111
159
79
119
59
39
19
39
19
11
7
15
31
15
31
63
127
63
127
217
343
687
343
527
757
919
1057
1205
1271
1205
1285
1477
2955
2739
2955
2743
2931
3027
2895
2671
2839
2715
2843
2667
2875
2479
2211
2515
2859
2991
3075
2955
3075
1537
1677
838
791
769
1539
1641
1735
3471
3347
3471...

result:

ok 5000 lines

Test #19:

score: 0
Accepted
time: 377ms
memory: 342812kb

input:

5000
1 40
1 1
1 11
1 29
1 26
1 65
2 1
2 11
2 40
1 104856
1 72
1 44
2 26
2 72
1 41
1 54935
1 28
1 40
2 104856
1 19
1 80
1 67
1 283910
2 65
1 29
2 29
1 41
2 28
1 13
1 68
2 283910
1 68
2 68
1 4
1 260364
1 80
1 184175
2 13
2 29
1 42
2 40
1 40
2 184175
1 37
1 37
2 80
2 41
1 47
1 184175
2 54935
1 33
1 58
...

output:

1
3
7
13
27
51
27
15
7
15
31
63
31
15
31
63
127
231
115
213
365
563
1127
775
951
775
967
679
987
1283
641
777
641
725
1451
1771
3543
3103
2359
3031
2535
3031
1515
1791
1955
1635
1471
1707
3415
1707
1879
2127
1895
2111
1055
2111
1899
1607
1287
1671
3343
3047
2511
2095
2639
3135
2615
2919
3063
3375
30...

result:

ok 5000 lines

Test #20:

score: 0
Accepted
time: 261ms
memory: 342764kb

input:

5000
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 12709
1 107790
1 1
1 1
1 1
1 1
2 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
1 1
1 1
2 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
1 1
2 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
1 1
1 162967
2 1
1 1
2 1
1 1
1 154881
1 1
1 1
1 1
1 61610
2 1
1 1
...

output:

1
2
3
4
5
6
7
8
9
10
11
12
25
51
55
59
63
67
63
67
71
67
71
75
79
83
87
91
95
99
103
99
103
107
111
115
119
123
119
123
127
123
127
131
135
139
143
139
143
147
143
147
151
155
159
163
327
319
327
319
327
655
671
687
703
1407
1375
1407
1375
1343
1311
1279
1311
1343
1375
1343
1375
1407
1375
1343
1375
...

result:

ok 5000 lines

Test #21:

score: 0
Accepted
time: 279ms
memory: 342768kb

input:

5000
1 1
1 1
1 1
1 1
1 1
1 1
1 160302
1 339692
2 1
2 160302
1 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
2 1
1 1
2 1
2 1
1 1
1 1
1 1
2 1
1 1
1 1
2 1
1 1
1 1
1 160291
2 1
1 1
2 1
1 1
2 1
2 1
2 160291
1 1
2 1
1 1
1 1
1 1
2 1
2 1
1 1
1 1
1 1
1 1
1 106418
1 1
1 1
1 1
1 1
1 1
2 1
1 1
1 1
1 1
1 1
2 1
1 1
1...

output:

1
2
3
4
5
6
13
27
23
11
13
15
17
15
17
19
21
23
25
27
29
27
29
27
25
27
29
31
29
31
33
31
33
35
71
67
71
67
71
67
63
31
33
31
33
35
37
35
33
35
37
39
41
83
87
91
95
99
103
99
103
107
111
115
111
115
119
123
127
131
135
139
143
287
279
287
143
287
279
287
279
139
143
287
143
147
151
155
159
163
167
1...

result:

ok 5000 lines

Test #22:

score: 0
Accepted
time: 268ms
memory: 342804kb

input:

5000
1 237109
2 237109
1 159170
1 38235
1 302595
2 38235
1 38235
2 38235
1 38235
2 38235
1 38235
2 38235
1 38235
2 38235
1 38235
2 302595
1 52831
1 249764
2 249764
1 249764
2 249764
1 46590
2 46590
2 38235
1 274365
1 13634
2 159170
2 274365
1 283180
2 283180
1 433535
2 52831
1 52831
2 13634
1 13634
...

output:

1
0
1
3
7
3
7
3
7
3
7
3
7
3
7
3
7
15
7
15
7
15
7
3
7
15
7
3
7
3
7
3
7
3
7
3
7
3
7
15
7
15
7
3
7
3
7
3
7
3
7
3
7
3
1
3
1
3
1
0
1
3
7
3
7
3
7
15
7
15
7
3
7
3
7
3
1
0
1
3
7
3
7
3
7
3
7
3
1
0
1
0
1
3
1
0
1
0
1
3
1
3
7
15
31
15
7
3
7
3
7
15
7
15
7
15
7
15
7
15
7
15
7
15
7
15
31
15
31
15
31
15
31
15
31
15...

result:

ok 5000 lines

Test #23:

score: 0
Accepted
time: 253ms
memory: 342840kb

input:

5000
1 214779
1 109955
1 138804
1 36462
2 109955
1 109955
2 138804
1 138804
2 214779
1 65105
1 19962
1 129712
2 109955
2 129712
1 239667
2 36462
1 36462
2 239667
2 19962
1 259629
2 65105
1 65105
2 65105
2 259629
1 324734
2 324734
1 98691
1 173529
1 52514
2 36462
1 36462
2 52514
2 138804
1 191318
2 3...

output:

1
3
7
15
7
15
7
15
7
15
31
63
31
15
31
15
31
15
7
15
7
15
7
3
7
3
7
15
31
15
31
15
7
15
7
15
7
15
7
15
7
15
7
15
31
15
31
15
7
15
7
15
7
15
7
15
7
15
7
15
7
15
31
15
31
15
31
15
31
15
31
15
7
15
31
15
7
3
7
15
7
15
7
15
7
3
7
3
7
3
7
3
1
3
7
3
1
3
1
3
1
3
1
0
1
3
1
3
1
3
1
0
1
3
7
3
1
3
1
3
1
3
1
3
...

result:

ok 5000 lines

Test #24:

score: 0
Accepted
time: 251ms
memory: 342804kb

input:

5000
1 221811
2 221811
1 500000
2 500000
1 268297
2 268297
1 260774
1 239226
2 260774
1 260774
2 260774
1 108896
2 239226
1 127209
1 151199
1 112696
2 127209
1 48
1 24821
2 48
2 151199
1 253587
2 108896
1 108896
2 112696
1 112696
2 24821
2 108896
1 42788
2 42788
1 133717
2 133717
2 112696
1 246413
2...

output:

1
0
1
0
1
0
1
3
1
3
1
3
1
3
7
15
7
15
31
15
7
15
7
15
7
15
7
3
7
3
7
3
1
3
1
3
1
3
1
0
1
3
7
3
1
0
1
3
1
3
7
3
7
3
7
3
7
3
7
3
7
15
7
15
7
15
7
15
7
15
7
15
31
63
31
63
31
63
31
63
31
63
127
63
31
63
31
63
31
63
31
63
127
63
127
63
127
63
31
63
31
15
31
15
31
15
7
3
1
3
7
3
7
3
1
3
7
3
7
3
7
3
1
3
1...

result:

ok 5000 lines

Test #25:

score: 0
Accepted
time: 277ms
memory: 342800kb

input:

5000
1 412
2 412
1 782
1 132
2 782
2 132
1 81099
1 666
1 60332
1 158
2 158
2 666
1 664
2 664
2 60332
1 48108
2 81099
2 48108
1 96862
2 96862
1 68270
2 68270
1 506
2 506
1 826
2 826
1 109
1 27840
2 27840
1 243
1 5544
2 109
1 92001
2 5544
2 243
1 326911
1 894
2 92001
2 894
1 76755
2 76755
2 326911
1 6...

output:

1
0
1
3
1
0
1
3
7
15
7
3
7
3
1
3
1
0
1
0
1
0
1
0
1
0
1
3
1
3
7
3
7
3
1
3
7
3
1
3
1
0
1
0
1
3
1
3
7
15
31
63
31
63
31
63
31
15
7
3
7
3
7
3
1
0
1
3
1
0
1
0
1
3
7
15
7
3
1
0
1
3
1
0
1
0
1
0
1
0
1
0
1
3
1
3
7
3
7
3
7
3
1
3
1
0
1
0
1
3
7
15
31
63
31
63
127
255
127
255
511
255
127
63
31
15
7
3
7
15
7
3
7
...

result:

ok 5000 lines

Test #26:

score: 0
Accepted
time: 284ms
memory: 342804kb

input:

5000
1 264
2 264
1 69860
1 790
2 790
1 679
2 69860
1 661
1 192
2 192
1 50
1 250472
1 113
1 4383
2 113
2 679
2 250472
2 661
2 50
2 4383
1 52990
2 52990
1 168
2 168
1 263
2 263
1 29240
2 29240
1 64248
1 16
1 981
2 981
2 16
2 64248
1 378
2 378
1 69
2 69
1 447
2 447
1 93715
2 93715
1 692
1 365
2 692
1 3...

output:

1
0
1
3
1
3
1
3
7
3
7
15
31
63
31
15
7
3
1
0
1
0
1
0
1
0
1
0
1
3
7
3
1
0
1
0
1
0
1
0
1
0
1
3
1
3
1
3
1
3
1
3
1
3
1
3
1
3
7
15
7
15
31
63
127
63
31
63
127
255
127
63
127
255
511
1023
2047
4095
8159
4079
2047
1023
511
255
127
63
127
63
31
15
7
3
1
3
7
15
31
15
7
3
7
3
7
15
7
3
7
15
7
3
1
3
1
0
1
3
7
3...

result:

ok 5000 lines

Test #27:

score: 0
Accepted
time: 352ms
memory: 342860kb

input:

5000
1 199
1 477
1 41148
1 886
1 72346
1 87312
1 56
1 57572
2 72346
2 41148
1 27252
2 57572
1 30675
2 56
1 35019
1 4874
1 85967
1 60062
2 87312
1 446
2 85967
1 914
1 11510
1 47437
1 51556
2 27252
2 914
2 886
2 446
1 548
1 105
1 28
1 475
2 11510
1 442
2 35019
2 60062
1 333
1 322
2 28
1 96583
2 333
1 ...

output:

1
3
7
15
31
63
127
255
127
63
127
63
127
63
127
255
511
1023
511
1023
511
1023
2047
4093
8131
4079
2047
1023
511
1023
2047
4095
8159
4079
8109
4095
2047
3951
7683
4023
8047
4095
7903
13675
7135
14099
25455
50017
79753
50017
82967
46937
76565
40659
70727
126293
206467
160245
271919
186765
271919
1763...

result:

ok 5000 lines

Test #28:

score: 0
Accepted
time: 424ms
memory: 342948kb

input:

5000
1 416655
1 18920
1 19900
2 19900
2 18920
1 44385
2 416655
1 358205
1 14685
2 44385
1 125170
1 1860
1 5
1 20
1 55
2 14685
1 2175
2 55
1 8110
2 20
1 705
1 85
2 2175
1 4525
2 705
1 230
2 85
1 1765
1 15
1 50
1 45
1 5
2 1860
1 845
1 85
1 430
2 358205
1 77480
2 230
1 55665
1 161715
2 85
2 5
1 61295
1...

output:

1
3
7
3
1
3
1
3
7
3
7
15
31
63
127
63
127
63
127
63
127
255
127
255
127
255
127
255
511
1015
1615
2159
1215
2431
4351
8415
4207
8415
4351
8511
16976
9713
7162
14129
25925
15655
7901
4003
7819
14711
26859
43249
26353
44414
63383
76971
85570
75150
59111
79895
88801
77270
61567
41283
63472
79639
89752
...

result:

ok 5000 lines

Test #29:

score: 0
Accepted
time: 318ms
memory: 342860kb

input:

5000
1 234185
1 67627
2 234185
2 67627
1 279538
1 115283
2 279538
2 115283
1 285705
1 97328
2 97328
1 38745
2 285705
2 38745
1 95074
2 95074
1 80255
1 412699
2 412699
2 80255
1 45514
2 45514
1 55846
1 159586
1 104461
2 104461
2 159586
2 55846
1 482734
1 7805
1 1505
1 3178
2 1505
1 4319
1 91
1 441
1 ...

output:

1
3
1
0
1
3
1
0
1
3
1
3
1
0
1
0
1
3
1
0
1
0
1
3
7
3
1
0
1
3
7
15
7
15
31
63
127
255
503
943
479
239
479
255
505
255
127
255
511
255
511
255
511
255
127
255
511
255
511
1023
511
1015
511
255
127
63
31
63
127
255
127
255
127
63
127
63
127
255
127
63
31
15
7
15
31
63
127
63
31
63
31
15
7
15
7
15
31
63
...

result:

ok 5000 lines

Test #30:

score: 0
Accepted
time: 314ms
memory: 342768kb

input:

5000
1 6033
1 4205
1 10859
1 5069
2 5069
1 3308
1 6841
1 9111
1 9508
2 6841
2 10859
1 47
2 9111
2 4205
1 1578
2 1578
1 68
1 10813
1 5418
2 3308
2 68
2 10813
2 47
2 5418
2 9508
1 3695
2 6033
1 3248
2 3248
1 9127
2 3695
2 9127
1 5351
1 33
1 5274
1 6076
1 8004
2 5351
2 33
1 75
2 6076
2 8004
2 75
2 5274...

output:

1
3
7
15
7
15
31
63
127
63
31
63
31
15
31
15
31
63
127
63
31
15
7
3
1
3
1
3
1
3
1
0
1
3
7
15
31
15
7
15
7
3
1
0
1
0
1
0
1
0
1
0
1
0
1
3
7
15
31
63
127
255
127
63
127
255
511
255
511
1023
511
1023
2015
1007
1987
1007
503
1005
510
255
127
63
31
15
31
63
31
63
125
237
475
237
475
237
123
63
127
255
127...

result:

ok 5000 lines

Test #31:

score: 0
Accepted
time: 325ms
memory: 342828kb

input:

5000
1 40
1 3767
2 40
1 2023
2 2023
2 3767
1 6918
2 6918
1 69
2 69
1 6543
1 72
1 6736
2 6543
2 6736
1 8712
2 8712
1 9335
1 31
2 31
2 72
1 5535
1 9461
1 3118
2 9335
2 5535
2 3118
2 9461
1 1674
1 3879
1 22
1 10425
1 3179
1 9464
1 3147
2 3879
2 3179
2 9464
1 7685
2 3147
1 29
1 52
2 22
1 2399
2 52
2 239...

output:

1
3
1
3
1
0
1
0
1
0
1
3
7
3
1
3
1
3
7
3
1
3
7
15
7
3
1
0
1
3
7
15
31
63
127
63
31
15
31
15
31
63
31
63
31
15
7
3
7
15
31
15
31
15
31
63
127
255
491
983
507
255
495
991
1979
3935
1979
1023
2045
1022
2045
3827
7399
13879
24200
33402
21979
12775
6725
3407
6759
3488
6753
3913
1983
3915
7513
3923
7645
40...

result:

ok 5000 lines

Test #32:

score: 0
Accepted
time: 472ms
memory: 343164kb

input:

5000
1 39
1 35
1 16
1 57
1 83
1 33
1 67
1 77
1 79
1 72
1 55
1 69
1 54
1 94
1 67
1 64
1 16
1 23
1 49
1 100
1 20
1 65
1 31
1 63
1 94
1 82
1 67
1 96
1 81
1 92
1 32
1 70
1 28
1 76
1 32
1 30
1 79
1 65
1 62
1 90
1 29
1 11
1 85
1 55
1 99
1 45
1 16
1 88
1 15
1 75
1 55
1 96
1 22
1 71
1 16
1 100
1 76
1 95
1 4...

output:

1
3
7
15
31
61
103
175
280
374
441
520
592
686
753
829
853
890
945
1045
1081
1146
1185
1248
1342
1424
1491
1587
1668
1760
1794
1864
1900
1976
2008
2044
2123
2188
2250
2340
2373
2396
2481
2536
2635
2680
2696
2784
2805
2880
2935
3031
3057
3128
3144
3244
3320
3415
3460
3496
3546
3633
3665
3763
3801
386...

result:

ok 5000 lines

Test #33:

score: 0
Accepted
time: 464ms
memory: 342824kb

input:

5000
1 77
1 48
1 77
1 44
1 89
1 40
1 89
1 2
1 66
1 3
1 53
1 17
1 60
1 92
1 56
1 68
1 20
1 33
1 97
1 77
1 79
1 15
1 79
1 52
1 89
1 33
1 76
1 71
1 76
1 26
1 53
1 46
1 89
1 82
1 49
1 58
1 87
1 46
1 94
1 40
1 34
1 35
1 93
1 91
1 3
1 33
1 14
1 2
1 46
1 47
1 27
1 31
1 95
1 19
1 17
1 76
1 27
1 86
1 43
1 44...

output:

1
3
5
11
23
47
71
143
258
379
462
527
587
679
739
807
837
880
977
1054
1133
1160
1239
1291
1380
1413
1489
1560
1636
1672
1725
1771
1860
1942
1991
2049
2136
2182
2276
2316
2350
2385
2478
2569
2578
2611
2629
2643
2689
2736
2763
2794
2889
2908
2925
3001
3028
3114
3157
3201
3238
3290
3328
3403
3417
3473...

result:

ok 5000 lines

Test #34:

score: 0
Accepted
time: 528ms
memory: 343192kb

input:

4975
1 100000
1 100000
1 100000
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
...

output:

1
2
3
7
11
15
19
23
27
31
35
39
43
47
51
55
59
63
67
71
75
79
83
87
91
95
99
103
107
111
115
119
123
127
131
135
139
143
147
151
155
159
163
167
171
175
179
183
187
191
195
199
203
207
211
215
219
223
227
231
235
239
243
247
251
255
259
263
267
271
275
279
283
287
291
295
299
303
307
311
315
319
323...

result:

ok 4975 lines

Extra Test:

score: 0
Extra Test Passed