QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#331754 | #8077. Alice and Bob | zhouhuanyi | AC ✓ | 1014ms | 12524kb | C++14 | 1.5kb | 2024-02-18 18:36:33 | 2024-02-18 18:36:33 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#define N 1000000
using namespace std;
long long read()
{
char c=0;
long long sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
struct reads
{
long long num;
int data;
};
reads tong[N+1],tong2[N+1];
int T,n,length,length2;
long long a[N+1],ans;
int main()
{
int pv,res;
long long res2;
T=read();
while (T--)
{
n=read(),ans=1ll*n*(n-1)*(n-2)/6,pv=1,length=res=res2=0;
for (int i=1;i<=n;++i) a[i]=read();
sort(a+1,a+n+1);
for (int i=1;i<=n;++i)
if (i==n||a[i]!=a[i+1])
tong[++length]=(reads){a[i],i-pv+1},pv=i+1;
for (int i=1;i<=length;++i) ans-=1ll*tong[i].data*(tong[i].data-1)*(tong[i].data-2)/6;
for (int i=0;i<=59;++i)
{
if (i)
{
length2=0;
for (int j=1;j<=length;++j)
if (!(tong[j].num&(1ll<<(i-1))))
tong2[++length2]=tong[j];
for (int j=1;j<=length;++j)
if (tong[j].num&(1ll<<(i-1)))
tong2[++length2]=tong[j];
length=length2;
for (int j=1;j<=length;++j) tong[j]=tong2[j];
}
res=res2=0;
for (int j=1;j<=length;++j)
{
if (!(i&1)) ans-=res*((1ll*tong[j].data*(tong[j].data-1))>>1)+res2*tong[j].data;
else ans+=res*((1ll*tong[j].data*(tong[j].data-1))>>1)+res2*tong[j].data;
if (j==length||(tong[j].num&((1ll<<i)-1))!=(tong[j+1].num&((1ll<<i)-1))) res=res2=0;
else res+=tong[j].data,res2+=((1ll*tong[j].data*(tong[j].data-1))>>1);
}
}
printf("%lld\n",ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7908kb
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: 1014ms
memory: 7908kb
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: 5776kb
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: 91ms
memory: 7604kb
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: 86ms
memory: 8320kb
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: 89ms
memory: 7672kb
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: 428ms
memory: 5848kb
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: 402ms
memory: 5860kb
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: 405ms
memory: 5776kb
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: 339ms
memory: 5888kb
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: 359ms
memory: 5848kb
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: 0
Accepted
time: 117ms
memory: 12236kb
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:
ok 113 lines
Test #13:
score: 0
Accepted
time: 112ms
memory: 10536kb
input:
90 3406 532424562553209088 158855933934257476 158855933934257476 158855933934257476 158855933934257476 782715729020470283 707669346552398929 288319712831477061 247514693620221263 247514693620221263 130530491746762814 842387340990879055 842387340990879055 153296734442554448 837791090267406655 8377910...
output:
6571367942 11726 166292869644 27 26954 28868 28736 2372 53734 165417925984 9146 166632009448480 0 60 27531 0 142222 51335 100925369590 76346 29109712247 6238 10275818834 10998 335 0 5764 51996271007 0 103460 13125 25615 0 41824 4281 27350 10814 29329734597 166330673153 8247657371 3849858883 18826157...
result:
ok 90 lines
Test #14:
score: 0
Accepted
time: 156ms
memory: 10672kb
input:
63 3370 922457482464597072 464039388170490879 464039388170490879 225349977749853507 463671340262293524 900274011071579216 900274011071579216 307744856415159361 307744856415159361 703236115670565964 613182476301435148 613182476301435148 613182476301435148 688248329052635212 842668473126573120 8426684...
output:
6367224179 9582 69594082093 0 166186252899 0 26950773803 114768 59941009202 99503564 2043 5199059656 3356 33573899 23283 9979 20831626068740078 166288445933 20711 5271382473 24449 20830452120748755 166316383674 166329198847 1363080174 78722583 166632349906996 5826 41348735293 0 526157446 88900470842...
result:
ok 63 lines
Test #15:
score: 0
Accepted
time: 107ms
memory: 10560kb
input:
56 10 630074613009813580 630074613009813580 630074613009813580 630074613009813580 630070128879621453 224983586954039571 172436823461351759 854966784809058315 244138107286409556 244138107286409556 77 311104896306774017 311104896306774017 379446981849842689 707669058572587073 707669058572587073 154329...
output:
88 67545 2688540916 19672614065 6751 55 3772 131024 14155 28237 78039 68737 88965 72819 122147545917 3676 4283 98824 26376 2353 8187 126004 0 40456955007 37726694236 6186 0 101455838361 7002 166330037724 146115823547 1667 85320 4285 18 20831632903226707 0 122543 21571524911 0 31994 5401 11240134209 ...
result:
ok 56 lines
Test #16:
score: 0
Accepted
time: 143ms
memory: 10712kb
input:
57 37 535749739189960979 514406861548373252 842576109031736383 842576109031736383 842576109031736383 842576109031736383 842576109031736383 842576109031736383 842576109031736383 707761693432807741 707761693432807741 707761693432807741 707761693432807741 707761693432807741 19211788235314256 1921178823...
output:
6025 0 20831638130249234 20831631512426859 15 199 78656 152181 98678 15603512283 96409189 0 64970 75646 166327921171 87272 82133 1467 90187 80888 26866545690 141842 0 145665484 106040 145896 319 166632091953803 0 23476 166329981715 161299353463 165993021685 0 110699 287 78027 75269 123526 0 52540 79...
result:
ok 57 lines
Test #17:
score: 0
Accepted
time: 213ms
memory: 11072kb
input:
44 48 129680861313193295 53119448608413003 53119448608413003 53119448608413003 531229392692641808 537135964781036560 537135964781036560 537135964781036560 537135964781036560 537135964781036560 537135964781036560 537135964781036560 537135964781036560 537135964781036560 537135964781036560 537135964781...
output:
10558 60437 18989792160 103517 48 122852 0 30410 4336 22480 71773 20831632673297518 436 144467 166331158889 52587 31 3164 89026 165835468247 10569247187 162524786965 48496202430 20832558062262740 0 6916292574 89845 191003661 4222 22360 20831634138885646 85260483 23778 70662 128456 162230429 22121 12...
result:
ok 44 lines
Test #18:
score: 0
Accepted
time: 69ms
memory: 11272kb
input:
45 500000 124913378541507854 124913378541507854 124913378541507854 124913378541507854 154119238920781903 153226070486422788 153226070486422788 153226070486422788 153226070486422788 153226070486422788 153226070486422788 153226070486422788 153226070486422788 153226070486422788 153226070486422788 15322...
output:
20831632792066685 41121 47451 1507 2872570499 86 27025 1820615906 40652 14472 4494 81902 18957 0 166152234114 2304 13241352661 2512161557 2853 30813 74164 20054 14444 27 27639 24 8556 111472863425 3335038965 78779573669 48505683890 67859190149 24757 106181 56242 16047 8433886324 15411 78792 16892904...
result:
ok 45 lines
Test #19:
score: 0
Accepted
time: 215ms
memory: 10860kb
input:
31 26 73188992934219844 923864119700181056 311897363957761360 311897363957761360 23665889703445525 784030688001152272 918284098177421376 990077814066643264 990077814066643264 990077814066643264 990077814066643264 990077814066643264 153273697379095552 855880527022657600 855880527022657600 85588052702...
output:
2130 17448 35325 10689037581 590 166273093978 70958640548 143706269312 166027340204 0 7891 115444873997 52540 58317 41910991283 1491 46908 20831628381932131 153260 8585 7496 54712708344 142716152590 123313199953 115436 5058734812 20832558101516158 20831626942253027 149789421147 0 87745
result:
ok 31 lines
Test #20:
score: 0
Accepted
time: 13ms
memory: 6764kb
input:
32 50 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396527276356 379503396...
output:
0 1971 484 42812 9964 56 90901 64527 8397 5380 0 110397 55641 20 5508 43504 57399 95027 19364942289 143608645067 17219 6607990598 128534 0 166329067259 26249 3020 39083 0 1250 73987 70731
result:
ok 32 lines
Test #21:
score: 0
Accepted
time: 145ms
memory: 10592kb
input:
49 69 158569700491592720 230609698835730451 918024612355314705 918024612355314705 918024612355314705 382823583065392389 157496577120539732 764978128581644540 764978128581644540 919062281894036812 919062281894036812 919062281894036812 312248178298863941 312248178298863941 312248178298863941 312248178...
output:
48469 127530056 262 178 17669 20831631650968240 32633 29453943615 2362 166314675889 38627 13152 164520613597 11480 58610 0 27670 1540 55419 0 4058 81877043522 60443898546 61 52 97086 14667397744 2056606 9628 132355 63960 139240 16 115238 4877 19586 584063219 15787 0 71232 166214817242 76746 125355 7...
result:
ok 49 lines
Test #22:
score: 0
Accepted
time: 96ms
memory: 10788kb
input:
50 17 859539636439811408 859539636439811408 859539636439811408 72362456256675921 379780388568973584 312156025124044816 860591951459733567 247589547299132735 172419148668818703 172419148668818703 172419148668818703 859188631294772236 513513031342249295 513513031342249295 994866168667067472 7657522049...
output:
569 166070665858 3241029553 1196857431 53563 39282032591 33602 46232 15016 7980 391 44552 0 26896 42789556572 36625975431 139288 33444 83751 1978 151692 88405681102 79337 102843 5101 20832558070045494 36207559212 148425 121795 5267495114 276 9 112317 59470 0 6250 4960 5488 0 84 1858 63140478413 4273...
result:
ok 50 lines
Test #23:
score: 0
Accepted
time: 149ms
memory: 12524kb
input:
98 82 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 75361692648554570 753616...
output:
0 30962 135 31361 512 160383565763 107803 2329 372 28251 39290 70502938269 869 72962358 107836703 93986 6046740498 539116207 90481 1498 107156 37527 14487 3276 67161 1847942655 5151 25921 20254 525 42921865173 61209 166122343573 66210 5517 20831636130004066 0 64032309783 102342 166325991568 11886 60...
result:
ok 98 lines
Extra Test:
score: 0
Extra Test Passed