QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#55422#1279. Distinct NumberCrysfly#AC ✓70ms21684kbC++111.6kb2022-10-13 18:31:312022-10-13 18:31:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-13 18:31:32]
  • 评测
  • 测评结果:AC
  • 用时:70ms
  • 内存:21684kb
  • [2022-10-13 18:31:31]
  • 提交

answer

// what is matter? never mind. 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long 
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 5005*60*60
#define inf 0x3f3f3f3f

int n,x,l[maxn],r[maxn];

/*
(0,(1<<60)-1)
[0,59]
*/

vi o[66];
int res=0;
void ins(int d,int l,int r,int ql,int qr){
	if(l>=ql&&r<=qr)return o[d].pb(l&x);
	int mid=l+r>>1;
	if(ql<=mid)ins(d-1,l,mid,ql,qr);
	if(qr>mid)ins(d-1,mid+1,r,ql,qr);
}

int ch[maxn][2],tot,bo[maxn];
int newn(){
	int u=++tot;
	bo[u]=ch[u][0]=ch[u][1]=0;
	return u;
}
int dfs(int d,int u){
	if(bo[u])return (1ll<<__builtin_popcountll(x&((1ll<<d)-1)));
	int res=0;
	For(i,0,1)
		if(ch[u][i])res+=dfs(d-1,ch[u][i]);
	return res;
} 

void work()
{
	n=read(),x=read();
	For(i,0,60)o[i].clear();
	For(i,1,n){
		l[i]=read(),r[i]=read();
		ins(60,0,(1ll<<60)-1,l[i],r[i]);
	}//puts("QAQ");
	tot=0;newn();
	Rep(i,59,0){
		for(auto t:o[i]){
			int u=1;
//			cout<<"ins "<<t<<" "<<i<<"\n";
			Rep(j,59,i){
				int c=(t>>j&1);
				if(!ch[u][c])ch[u][c]=newn();
				u=ch[u][c];
			}
			bo[u]=1;
		}
	}
	res=dfs(60,1);
	cout<<res<<"\n";
}

signed main()
{
	int T=read();
	while(T--)work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3624kb

input:

3
2 1
1 2
343 34345
1 3
1 3
1 123242343
1 1000000000000000000

output:

2
3
32768

result:

ok 3 tokens

Test #2:

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

input:

902
5 35
2 17
19 24
32 55
59 63
73 97
5 55
3 17
35 37
38 39
43 82
87 88
1 37
46 88
4 79
1 9
40 56
56 56
57 78
8 61
5 7
19 21
27 33
34 36
36 38
59 73
77 79
94 97
2 86
0 23
72 78
7 43
5 10
12 21
22 34
36 58
65 71
72 88
91 99
9 74
16 24
31 41
44 48
48 49
51 51
57 57
61 65
69 71
85 93
4 85
5 44
46 47
54...

output:

8
25
8
31
21
12
16
8
12
8
4
16
4
14
2
4
8
16
8
11
2
1
2
8
8
2
4
6
2
11
8
6
7
1
15
16
4
12
8
16
8
12
8
7
8
12
2
24
23
2
8
8
4
15
8
8
4
8
8
11
4
31
25
2
2
29
31
16
8
8
4
10
4
8
25
16
9
16
32
11
12
4
13
4
21
4
15
2
26
8
2
6
23
7
7
8
8
4
4
16
16
4
3
2
18
29
23
19
8
8
8
8
16
12
13
12
16
14
16
19
29
15
6
...

result:

ok 902 tokens

Test #3:

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

input:

144
37 3097
273 289
377 483
493 527
881 1209
1210 1333
1521 1552
1554 1768
1967 2194
2218 2279
2567 2606
2614 2619
2976 3115
3388 3436
3684 3685
3885 3894
3963 4635
4793 4815
4979 5242
5292 5380
5495 5515
5569 5723
5815 5862
6114 6162
6253 6334
6394 6428
6638 6978
7063 7201
7416 7541
7703 7805
7884 ...

output:

32
62
248
238
111
256
126
960
128
235
112
64
8
64
256
1635
8
64
128
128
892
128
512
64
32
16
256
256
970
64
128
8
64
128
16
8
16
128
256
16
256
128
920
128
16
128
128
8
112
16
128
16
128
32
256
32
64
488
117
64
512
64
8
457
16
32
128
30
128
64
256
16
128
8
30
32
64
112
64
64
32
128
256
32
128
64
32
...

result:

ok 144 tokens

Test #4:

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

input:

84
10 360403509
48973816 108252157
164366394 380884108
395265805 418262201
485100659 520738020
596118742 615507431
635305129 709062302
751555848 791261801
797493451 834840841
855972732 876160731
899012590 974871121
54 956256021
3167657 7951261
20481210 23841657
24030658 29152491
29609403 30268465
39...

output:

65536
521216
32768
8192
8192
32768
16384
61440
16384
131072
8192
61440
16384
32768
130048
65536
8192
129024
4096
32768
131072
524288
61120
4096
32768
16384
16384
8192
262144
131072
2023230
16384
65536
224776
262144
128
262144
30720
8192
16384
16384
32768
62920
2048
262144
8192
4096
4096
32768
65536
...

result:

ok 84 tokens

Test #5:

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

input:

12
642 656056144552294267
1205077504153600 1477360693520167
1595546284624450 4127356436235572
5414866662365273 5823146368992192
7337259496420109 7972682426389549
9448745794780636 11109842311460514
12887653433953860 13503449087275473
13781829500544374 14564496186927287
16027002617927709 1865702348720...

output:

2147483648
4294967296
513546240
8589934592
268435456
8589934592
33554432
1073741824
8438939648
1073741824
130678784
4294967296

result:

ok 12 tokens

Test #6:

score: 0
Accepted
time: 36ms
memory: 6324kb

input:

5
1000 43911292748429083
84386893000422 337188033563147
572460028333854 1143402890459999
1245596864229694 1859000405347932
2132001737169854 2358580162583486
3006647360833325 4524375608447822
4849371285145764 5304758474303057
5417702504415254 5618888359093370
6163292086365067 7564667400070549
8173544...

output:

268435456
268435456
8589934592
8589934592
1073741824

result:

ok 5 tokens

Test #7:

score: 0
Accepted
time: 53ms
memory: 17136kb

input:

1
5000 655686035371253389
186668087862117 259297183404158
293861518407478 313575947506044
339419635150091 448421610534978
547065051543785 572443782367806
627894785087554 749191001665960
762070924641507 913373097098976
937063749953544 965449952519589
967340189167161 1013515772410700
1072019648503600 ...

output:

34359738368

result:

ok "34359738368"

Test #8:

score: 0
Accepted
time: 47ms
memory: 13220kb

input:

1
5000 91914995239769530
67728785578436 82073656293292
84562086735193 146593621322802
148336367563491 238770850776750
299818275612621 304441716894026
318418283893551 476934081970830
613073427704899 659120924860889
843660282735588 861830438197015
905087020392694 1030736711859764
1077829363776698 1150...

output:

33554432

result:

ok "33554432"

Test #9:

score: 0
Accepted
time: 34ms
memory: 12844kb

input:

1
5000 528143950813318377
163113948481764 188567037147460
278554381492693 368978462984429
511343829378106 529624604741880
692460391436861 714861545431956
779086773688489 826236665757884
1013678690309341 1018796823054183
1188719589429633 1348261782459476
1538129717617398 1636835759911637
167243069286...

output:

134217728

result:

ok "134217728"

Test #10:

score: 0
Accepted
time: 49ms
memory: 17784kb

input:

1
5000 463858441856236890
41633323657150 140385737068372
156260762119769 177910115485804
280075690226048 352803176838650
412629138863263 487942939056837
588887810876438 621902043143645
845171738376850 1000232101342221
1022016198539460 1085040941025761
1137030188065473 1199810338278666
12101916734577...

output:

17167810560

result:

ok "17167810560"

Test #11:

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

input:

1
5000 576460752303423487
5332767185594 10666649298339
81387677327150 130489188547254
146858467017501 159814703831592
231528270523523 249695441693151
292009190334897 348435477515195
358055478120309 402283196482410
452114091436331 471915308563175
518679008296411 550349445681760
611640083961507 629891...

output:

115279780390524297

result:

ok "115279780390524297"

Test #12:

score: 0
Accepted
time: 18ms
memory: 6092kb

input:

1
5000 0
1473650580048 28519770436497
75779144091480 127080905961499
200721484531427 203536016450698
223034614128721 276992355269755
308566830784872 345746450569786
360094713603018 372892227059220
462879906681765 479312421122287
535455268350716 549523402278597
567195794788773 600179256791288
6832841...

output:

1

result:

ok "1"

Test #13:

score: 0
Accepted
time: 50ms
memory: 16388kb

input:

1
5000 655686035371253389
42584905521023 49137557202498
73599187673674 132703732838912
169713668935678 203677549683469
232830835022570 233999762203998
299027394471596 343332679748972
367208120418626 368784411071400
450306544844704 471285226337516
493012044679923 553049042873028
585335447841982 61196...

output:

17179869184

result:

ok "17179869184"

Test #14:

score: 0
Accepted
time: 42ms
memory: 13096kb

input:

1
5000 91914995239769530
40923924909768 48486689867112
115339484123397 130619603163779
177678379757682 189609184407772
246801723503636 266551104863990
293590861960556 296360336009027
370494358482820 420024814761282
487801394075775 488432881896077
517361118735709 557097153616970
573340022663855 62479...

output:

33554432

result:

ok "33554432"

Test #15:

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

input:

886
2 258410637801415850
151490477301876317 265659310486574761
413085279396252795 484741036268183885
2 286969256286298585
118497768807432792 266166959934902451
421706477325683631 481488535121262482
6 610705431669405548
10505610110950201 72027602883587258
83863612504058890 119111838620866979
16561238...

output:

83886080
278134784
4294967296
8589934592
1941962752
132120576
536870912
1073741824
130416640
956301312
7516192768
14763950080
1006632960
2147483648
4294967296
268435456
987758592
4026531840
33554432
4194304
2147483648
536870912
9395240960
65569882112
17179869184
18253611008
33554432
134217728
113413...

result:

ok 886 tokens

Test #16:

score: 0
Accepted
time: 24ms
memory: 3896kb

input:

137
26 928472763242151241
9438843249838607 10676285057131670
18437180475016654 22963165426474413
41285012051208252 46193089577773062
64310012724559487 68099293337073688
85277628800075876 88454346404288201
98552080024529985 105041980301228627
118091959092809741 125164879376367216
131414934485173491 1...

output:

268435456
31138512896
4176478208
536870912
268435456
260046848
16777216
17179869184
99090432
2147483648
536870912
1073741824
120259084288
996147200
1073741824
3087007744
134217728
102910394368
134217728
234881024
1073741824
4160749568
2617245696
67108864
8589934592
33554432
25165824
132120576
167772...

result:

ok 137 tokens

Test #17:

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

input:

97
28 221224637261161210
6048143495584944 17144925407432428
28360395610354390 29141156987251985
38227872769757925 48009941722847958
56359325680123121 69227371648336615
76232066061101607 84812619786868060
93807281560989505 105105308768009410
108363991653783534 123347042319502019
129516847223050996 14...

output:

268435456
207232172032
805306368
13086228480
34359738368
2147483648
1073741824
16777216
134217728
4160749568
134217728
134217728
33554432
402653184
4294967296
120848384
201326592
7205814272
1073741824
61203283968
360710144
14548992
16642998272
12582912
67108864
201326592
234881024
8589934592
2642411...

result:

ok 97 tokens

Test #18:

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

input:

100
99 764401302671431076
6713288067848458 12746712138265673
20953749959155370 28028184512472327
37348115906650040 40948874861493112
43958290311765264 991615075734039348
56271772197478872 614734373591118994
62808573084782230 921438674065518348
70731418989011008 72695148983435228
88669808745689241 92...

output:

17179869184
134217728
33554432
8589934592
134217728
67108864
134217728
67377299456
1099511627776
1073741824
1073741824
274877906944
17179869184
8589934592
536870912
536870912
4294967296
4194304
536870912
134217728
17179869184
17179869184
268435456
4294967296
268435456
4294967296
536870912
67108864
3...

result:

ok 100 tokens

Test #19:

score: 0
Accepted
time: 30ms
memory: 5248kb

input:

17
220 246333038808157653
2082768340336065 3038682313724390
4046124193625818 9936719496811105
15402128193692444 18214021633959112
18251927164113632 22043264815515075
25923423469696099 25955444895035909
32698862379916156 37530280326414170
51908762256830869 52477284751520578
54551240229197440 56829478...

output:

17179869184
67108864
268435456
17179869184
1073741824
8493465600
67108864
274877906944
34359738368
4294967296
4294967296
16777216
33554432
17179869184
4294967296
268435456
67108864

result:

ok 17 tokens

Test #20:

score: 0
Accepted
time: 34ms
memory: 6464kb

input:

5
1000 43911292748429083
84386893000422 337188033563147
572460028333854 1143402890459999
1245596864229694 1859000405347932
2132001737169854 2358580162583486
3006647360833325 4524375608447822
4849371285145764 5304758474303057
5417702504415254 5618888359093370
6163292086365067 7564667400070549
8173544...

output:

268435456
268435456
1073741824
8589934592
1073741824

result:

ok 5 tokens