QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#330307#8077. Alice and BobyhdddWA 496ms47188kbC++141.4kb2024-02-17 14:27:262024-02-17 14:27:27

Judging History

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

  • [2024-02-17 14:27:27]
  • 评测
  • 测评结果:WA
  • 用时:496ms
  • 内存:47188kb
  • [2024-02-17 14:27:26]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=500010;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
	return x*f;
}
bool Mbe;

ll n,a[maxn],ans;
map<ll,int> t;
int tree[maxn*32][4],idx;
int sum[maxn*32];ll mul[maxn*32];
void clr(){
	for(int i=1;i<=idx;i++)tree[i][0]=tree[i][1]=tree[i][2]=tree[i][3]=sum[i]=mul[i]=0;
	idx=1;
}
void work(){
	n=read();ll ans=n*(n-1)*(n-2)/6;
	clr();t.clear();
	for(int i=1;i<=n;i++){
		a[i]=read();int num=++t[a[i]];int val=num-1;
		int nd=1;
		for(int j=0;j<60;j+=2){
			int c=(a[i]>>j)&3ll;
			sum[nd]++;mul[nd]+=val;
			if(!tree[nd][c])tree[nd][c]=++idx;
			nd=tree[nd][c];
		}
		sum[nd]++;mul[nd]+=val;
		nd=1;
		for(int j=0;j<60;j+=2){
			int c=(a[i]>>j)&3ll;
			ans-=1ll*(num-1)*sum[tree[nd][c^1]];
			ans-=1ll*(num-1)*sum[tree[nd][c^3]];
			ans-=mul[tree[nd][c^1]];
			ans-=mul[tree[nd][c^3]];
			nd=tree[nd][c];
		}
		ans-=(num-1)*(num-2)/2;
		// cout<<ressum<<" "<<resmul<<"\n";
	}
	printf("%lld\n",ans);
}

// \
444

bool Med;
int T;
signed main(){
	// freopen("game.in","r",stdin);
	// freopen("game.out","w",stdout);
	
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	
	// cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
	
	T=read();
	while(T--)work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
4
2 0 2 3
3
2 2 3
3
0 2 3

output:

3
0
1

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 496ms
memory: 7948kb

input:

1000000
3
63 98 95
3
61 38 97
3
7 73 98
3
1 10 91
3
94 31 99
3
96 54 97
3
14 44 99
3
81 51 97
3
96 95 92
3
35 90 98
3
7 39 96
3
71 8 96
3
36 35 99
3
82 52 96
3
89 53 99
3
76 85 95
3
80 34 91
3
9 13 99
3
12 17 94
3
40 4 95
3
57 5 93
3
47 69 93
3
23 0 94
3
62 44 97
3
7 4 99
3
21 97 99
3
41 3 99
3
36 9...

output:

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
0
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
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
0
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
0
1
1
1
1
1
1
1
0
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
...

result:

ok 1000000 lines

Test #3:

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

input:

100
100
124984902967623755 124984902967623755 124984902967623755 124984902967623755 124984902967623755 701781449690403068 701781449690403068 701781449690403068 701781449690403068 977908122754831361 977908122754831361 977908122754831361 977908122754831361 977908122754831361 977908122754831361 9779081...

output:

107461
109751
153588
148116
161700
153167
152261
147129
154844
148422
136125
144245
120331
143949
150459
143152
150484
142034
152295
45020
154673
144755
11376
151352
147181
154487
152901
0
126850
152846
154609
87893
153158
136511
137776
145664
148716
143071
154503
152145
137939
148806
147587
150303
...

result:

ok 100 lines

Test #4:

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

input:

1113
500
769204668397077579 769204668397077579 769204668397077579 769204668397077579 995636665671483472 707686578767609936 707686578767609936 707686578767609936 707686578767609936 917930880083760145 917930880083760145 917930880083760145 917930880083760145 226122951868372052 226122951868372052 226122...

output:

19851032
895
20280315
631
574
150
765
1140
798
832
964
922
925
757
885
20486163
934
595
424
819
868
878
892
347
51
842
835
841
666
336
500
904
347
207
832
580
658
1140
688
781
850
730
576
886
20288370
0
892
20379355
859
704
772
779
838
162653189
20459989
0
880
689
934
861
910
19351276
0
436
1140
787...

result:

ok 1113 lines

Test #5:

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

input:

1113
20
226387647481511936 383163331085680645 383163331085680645 383163331085680645 383163331085680645 94933209478071316 94933209478071316 94933209478071316 918231256204066892 148839563663332351 148839563663332351 148839563663332351 148839563663332351 288511938102641684 288511938102641684 2885119381...

output:

823
949
516
940
249
694
859
880
853
676
20020312
576
694
676
584
853
754
180
576
20506117
798
686
811
877
877
757
775
710
781
627
0
20272126
827
884
891
810
1140
0
949
631
919
910
740
940
850
895
852
655
20355240
706
532
595
814
20058143
836
847
496
838
849
819
823
844
884
676
937
580
802
0
907
749
...

result:

ok 1113 lines

Test #6:

score: 0
Accepted
time: 145ms
memory: 43076kb

input:

1113
20
126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 126396674840466495 1263966...

output:

0
1045
886
724
0
910
192
736
859
835
860
892
898
823
799
952
216
634
496
631
925
0
724
853
961
874
916
20310675
19950672
576
937
656
944
0
819
859
835
572
847
631
814
495
853
582
865
871
216
761
256
606
576
922
0
0
520
631
934
20325576
694
0
0
180
416
20498228
895
20364391
718
826
955
778
658
898
76...

result:

ok 1113 lines

Test #7:

score: 0
Accepted
time: 285ms
memory: 7960kb

input:

277777
7
707459322718999568 707459322718999568 707459322718999568 707459322718999568 707459322718999568 707459322718999568 707459322718999568
8
531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624
7
97...

output:

0
0
20
0
4
0
0
0
0
17
25
0
0
0
56
0
9
0
0
56
0
0
0
45
4
0
0
0
0
18
27
34
0
29
20
0
0
0
19
0
24
1
0
0
24
20
0
0
0
4
4
0
4
0
0
0
0
26
0
3
0
30
0
0
56
0
25
0
42
27
0
0
0
0
4
0
0
0
4
0
0
18
19
0
17
0
4
30
0
0
27
0
0
0
0
48
0
0
15
4
0
0
0
0
30
45
0
18
0
0
0
15
0
0
27
20
0
0
15
0
17
0
0
21
0
18
0
0
20
56
...

result:

ok 277777 lines

Test #8:

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

input:

269964
7
707459322718999568 707459322718999568 707459322718999568 707459322718999568 707459322718999568 707459322718999568 707459322718999568
8
531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624 531317697140506624
7
97...

output:

0
0
20
0
4
0
0
0
0
17
25
0
0
0
56
0
9
0
0
56
0
0
0
45
4
0
0
0
0
18
27
34
0
29
20
0
0
0
19
0
24
1
0
0
24
20
0
0
0
4
4
0
4
0
0
0
0
26
0
3
0
30
0
0
56
0
25
0
42
27
0
0
0
0
4
0
0
0
4
0
0
18
19
0
17
0
4
30
0
0
27
0
0
0
0
48
0
0
15
4
0
0
0
0
30
45
0
18
0
0
0
15
0
0
27
20
0
0
15
0
17
0
0
21
0
18
0
0
20
56
...

result:

ok 269964 lines

Test #9:

score: 0
Accepted
time: 271ms
memory: 7920kb

input:

269965
7
230614371974251604 230614371974251604 230614371974251604 230614371974251604 230614371974251604 230614371974251604 230614371974251604
3
536859150713357636 536859150713357636 441156301639193619
7
124970556636004427 124970556636004427 124970556636004427 124970556636004427 124970556636004427 12...

output:

0
0
0
0
0
4
42
0
12
0
0
1
0
45
0
0
42
0
0
0
30
0
0
0
0
0
0
0
56
0
0
0
0
17
0
0
0
0
0
0
12
12
0
3
3
24
0
0
0
42
25
0
1
0
0
0
0
0
18
0
0
0
0
0
15
27
0
4
3
0
17
0
0
0
0
0
0
0
0
0
0
0
0
0
14
1
0
0
0
0
0
18
27
0
0
0
0
0
0
0
21
0
17
0
0
0
26
0
0
0
0
0
0
30
0
4
4
12
1
0
0
21
0
0
0
0
3
1
0
0
0
0
0
4
0
27
0
...

result:

ok 269965 lines

Test #10:

score: 0
Accepted
time: 287ms
memory: 8480kb

input:

19580
98
532442205557641491 532442205557641491 532442205557641491 532442205557641491 532442205557641491 288235054533006661 288235054533006661 288235054533006661 288235054533006661 288235054533006661 288235054533006661 142985775232668922 142985775232668922 142985775232668922 142985775232668922 142985...

output:

136839
149391
154699
20317
97478
2696
3542
6997
18897
141447
13105
146045
115088
18
152160
66764
0
0
127352
63
138594
0
152173
44551
0
153902
1751
150058
81682
1640
0
59151
2060
152836
6994
41273
97624
13506
154541
892
107979
83856
150907
2494
0
89301
149883
0
151981
1422
108103
154349
149896
67730
...

result:

ok 19580 lines

Test #11:

score: 0
Accepted
time: 292ms
memory: 8224kb

input:

19581
100
764976963254243339 611779753208270860 611779753208270860 611779753208270860 616472540793361484 460366951686952020 460366951686952020 460366951686952020 460366951686952020 764613385670099004 764613385670099004 764613385670099004 764613385670099004 247571880840548624 247571880840548624 24757...

output:

152786
154637
150155
154940
126763
4743
153989
66911
120643
126327
196
123249
0
6426
68320
36123
146082
7578
147495
4432
152720
153734
154210
135376
36
154478
6240
6942
153727
147576
24801
142627
148807
153791
0
49431
0
62182
89257
13470
112569
52490
154133
153988
136930
149207
147214
0
117712
29811...

result:

ok 19581 lines

Test #12:

score: -100
Wrong Answer
time: 315ms
memory: 47188kb

input:

113
98
292822280374932800 292822280374932800 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 29393170...

output:

120041
73350
115067
148109
57855
15935
39648
124032
7696
142732
98297
13
109338
49
106241426462
96849
897
60076
70189972778
1427
40930
7700
166112106836
52892
116776
304
119806
115299
3110
58927
38136226084
700
124774
43728
206
70644
54316
39570
0
7441834300
0
80
0
26008
35453
32861
10629
0
6915
385...

result:

wrong answer 91st lines differ - expected: '0', found: '157608119894016'