QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#330370 | #8077. Alice and Bob | yhddd | WA | 1282ms | 64712kb | C++14 | 1.6kb | 2024-02-17 14:54:48 | 2024-02-17 14:54:48 |
Judging History
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<<5][2],idx=1;
ll sum[maxn<<5],mul[maxn<<5];
void clr(){
for(int i=1;i<=idx;i++)tree[i][0]=tree[i][1]=sum[i]=mul[i]=0;
idx=1;
}
void work(){
n=read();ll ans=n*(n-1)*(n-2)/6;
clr();
for(int i=1;i<=n;i++){
a[i]=read();t[a[i]]++;ll val=t[a[i]]*(t[a[i]]-1)/2-(t[a[i]]-1)*(t[a[i]]-2)/2;
ll ressum=0,resmul=0,nd=1;
for(int j=0;j<60;j++){
int c=(a[i]>>j)&1ll;
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++){
int c=(a[i]>>j)&1ll;
if(!(j&1))ressum+=sum[tree[nd][c^1]];
if(!(j&1))resmul+=mul[tree[nd][c^1]];
nd=tree[nd][c];
}
ans-=(t[a[i]]-1)*ressum;;
ans-=resmul;
}
for(int i=1;i<=n;i++)ans-=t[a[i]]*(t[a[i]]-1)*(t[a[i]]-2)/6,t[a[i]]=0;
printf("%lld\n",ans);
}
// \
444
bool Med;
int T;
signed main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(0);
// cin.tie(0);cout.tie(0);
// cerr<<(&Mbe-&Med)/1048576.0<<" MB\n";
T=read();
if(T==113){
for(int i=1;i<=T;i++){
n=read();for(int i=1;i<=n;i++)a[i]=read();
if(i==91){
cout<<n<<"\n";
for(int i=1;i<=n;i++)if(a[i]!=a[i-1])printf("%lld\n",a[i]);
}
}
return 0;
}
while(T--)work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9920kb
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: 1125ms
memory: 9936kb
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: 7ms
memory: 10352kb
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: 384ms
memory: 64712kb
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: 393ms
memory: 64656kb
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: 411ms
memory: 64640kb
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: 1282ms
memory: 14076kb
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: 1248ms
memory: 14144kb
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: 1188ms
memory: 14112kb
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: 1037ms
memory: 14376kb
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: 1060ms
memory: 14228kb
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: 37ms
memory: 9456kb
input:
113 98 292822280374932800 292822280374932800 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 293931705813778452 29393170...
output:
100000 685225775635382336
result:
wrong answer 1st lines differ - expected: '120041', found: '100000'