QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673833#7679. Master of Both IVXiaoMo247WA 116ms36740kbC++201.6kb2024-10-25 10:49:302024-10-25 10:49:31

Judging History

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

  • [2024-10-25 10:49:31]
  • 评测
  • 测评结果:WA
  • 用时:116ms
  • 内存:36740kb
  • [2024-10-25 10:49:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 5;
ll Tex, n, a[MAXN], d[35], zero;
vector<ll> b[MAXN];
map<ll, ll> cnt;
void init(){
    for(int i = 0; i <= 32; i ++){
        d[i] = 0;
    }
}
bool insert(ll x){
    for(int i = 32; i >= 0; i --){
        if(!((x >> i) & 1)) continue;
        if(d[i]) x ^= d[i];
        else{
            d[i] = x;
            break;
        }
    }
    if(!x){
        zero ++;
        return 0;
    }
    return 1;
}
ll fastPow(ll a, ll b){
    ll ret = 1;
    while(b){
        if(b & 1) ret *= a;
        a *= a;
        b >>= 1;
    }
    return ret;
}
ll calc(ll x){
    init();
    ll ret = 0;
    for(auto it : b[x]){
        if(cnt[it]){
            if(insert(x)){
                ret += cnt[it] - 1;
            }
            else{
                ret += cnt[it];
            }
        } 
    }
    return fastPow(2, ret);
}
void AC(){
    cin >> n;
    cnt.clear();
    init();
    zero = 0;
    for(int i = 1; i <= n; i ++){
        cin >> a[i];
        insert(a[i]);
    }
    
    ll ans = 0;
    ans += fastPow(2, zero) - 1;
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i ++){
        ans += calc(a[i]);
        cnt[a[i]] ++;
    }
    cout << ans << '\n';
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    for(int i = 1; i <= MAXN - 5; i ++){
        for(int j = i + i; j <= MAXN - 5; j += i){
            b[j].push_back(i);
        }
    }
    cin >> Tex;
    while(Tex --) AC();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 84ms
memory: 36692kb

input:

2
3
1 2 3
5
3 3 5 1 1

output:

4
11

result:

ok 2 number(s): "4 11"

Test #2:

score: -100
Wrong Answer
time: 116ms
memory: 36740kb

input:

40000
5
4 2 5 5 5
5
5 5 5 5 4
5
1 4 4 4 2
5
2 5 2 4 1
5
3 2 4 5 3
5
1 5 5 3 4
5
5 5 5 4 3
5
4 3 3 5 1
5
4 5 5 2 1
5
2 5 4 2 5
5
3 4 3 4 3
5
5 3 5 1 3
5
5 1 2 4 4
5
4 2 5 1 5
5
5 4 2 5 4
5
5 2 5 2 4
5
1 4 5 4 5
5
4 2 3 2 3
5
1 4 1 3 5
5
1 1 2 1 5
5
5 2 5 1 3
5
3 1 2 5 3
5
5 5 1 1 5
5
2 2 2 1 3
5
3 1 ...

output:

8
12
11
11
8
8
8
8
9
9
12
8
10
9
8
9
12
9
11
14
8
8
15
12
9
11
8
8
8
12
15
11
9
9
9
8
11
11
11
12
15
8
15
8
9
9
8
12
11
10
8
11
8
8
11
15
11
10
9
9
9
18
11
9
15
9
15
8
10
10
12
11
8
11
10
17
11
8
18
8
9
8
8
9
8
15
8
11
12
9
11
13
9
18
13
17
18
15
12
14
8
8
8
9
8
8
12
15
15
8
9
15
11
11
8
8
11
11
9
1...

result:

wrong answer 1st numbers differ - expected: '9', found: '8'