QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#38306 | #1176. Binomial | wyhao | WA | 35ms | 6380kb | C++ | 629b | 2022-07-05 09:56:32 | 2022-07-05 09:56:33 |
Judging History
answer
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1000005;
typedef long long ll;
int T,n,a[N],s[N];
int main(){
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
s[a[i]]++;
}
ll ans=0;
for(int i=1;i<=n;i++){
if(a[i]!=a[i-1]){
ll k=0;
// printf("%d:",a[i]);
for(int x=a[i];x;x=a[i]&(x-1)){
// printf("%d ",x);
k+=s[x];
}
// printf(":%d %d\n",k);
// puts("");
ans+=1ll*k*s[a[i]];
// printf("%d\n",ans);
}
}
printf("%lld\n",ans);
for(int i=1;i<=n;i++) s[a[i]]--;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3672kb
input:
2 3 1 5 6 3 1 1 1
output:
4 9
result:
ok 2 number(s): "4 9"
Test #2:
score: -100
Wrong Answer
time: 35ms
memory: 6380kb
input:
10 1 1 3321 108907 496886 513637 107549 602502 235745 583320 401703 649106 841450 806050 127630 250786 780434 780387 256680 723365 604626 255396 251497 992405 594166 951810 524404 585892 85571 821715 581042 711296 187617 367585 862536 856196 312147 121285 967957 495031 855565 619680 318939 618420 91...
output:
1 39045 1158 22259 2006 3213 15059 426 88 1191
result:
wrong answer 2nd numbers differ - expected: '38911', found: '39045'