QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#715285#8077. Alice and Bobqzez#RE 0ms3952kbC++141.1kb2024-11-06 11:20:082024-11-06 11:20:09

Judging History

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

  • [2024-11-06 11:20:09]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3952kb
  • [2024-11-06 11:20:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=5e5+10;
int T,n;
ll a[N];
ll C2(int x){
    return x*(x-1ll)/2;
}
ll C3(int n){
    return n*(n-1ll)*(n-2)/6;
}
void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        ll x;
        scanf("%lld",&x);
        a[i]=0;
        for(int j=0;j<60;j++)if(x>>j&1){
            a[i]|=1ll<<60-1-j;
        }
    }
    sort(a+1,a+1+n);
    ll ans=0;
    for(int l=1,r;l<=n;l=r){
        for(r=l+1;r<=n&&a[l]==a[r];r++);
        ans+=(r-l)*(l-1ll)*(n-r+1);
        // cerr<<ans<<endl;
    }
    for(int k=0;2*k+1<=60;k++){
        int t=60-(2*k+1);
        for(int l=1,r;l<=n;l=r){
            for(r=l+1;(a[l]>>t)==(a[r]>>t);r++);
            ll w[2]={0,0};
            for(int i=l,j;i<r;i=j){
                for(j=i+1;j<r&&a[j]==a[i];j++);
                w[a[i]>>t-1&1]+=C2(j-i);
            }
            for(int i=l;i<r;i++){
                ans+=w[~a[i]>>t-1&1];
            }
        }
    }
    printf("%lld\n",ans);
}
int main(){
    for(scanf("%d",&T);T--;)work();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3952kb

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: -100
Runtime Error

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:


result: