QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#390759#4810. Add OneBeaterWA 1ms3708kbC++201.1kb2024-04-15 21:14:512024-04-15 21:14:51

Judging History

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

  • [2024-04-15 21:14:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-04-15 21:14:51]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std ;
const int MAXN=1e5+7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
#define endl "\n"

typedef unsigned long long ull;

vector<ull> B;
void insert(ull x) {
    for (auto b : B)
        x = min(x, b ^ x);
    for (auto &b : B)
        b = min(b, b ^ x);
    if (x)
        B.push_back(x);
}

int check(ll x,int lim){
    for(auto b:B){
        ll t=x;
        for(int i=0;i<=lim;i++){
            if((b>>i)&1){
                t^=1ll<<i;
            }
        }
        x=min(x,t);
    }
    if(x==0){
        return 1;
    }else{
        return 0;
    }
}

void solve(){
	int n;
    cin>>n;
    ll a[n+1];
    ll cnt=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        insert(a[i]);
        cnt^=a[i];
    }
    sort(B.begin(),B.end());
    ll ans=0;
    for(int i=0;i<=60;i++){
        if(check((1ll<<i)-1,i)){
            ans=max(ans,cnt^((1ll<<(i+1))-1));
        }
    }
    cout<<ans<<endl;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int t=1;
	
//	cin>>t;
	while(t--){
		solve();
	}
	
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3656kb

input:

4
1 2 1 2

output:

7

result:

ok 1 number(s): "7"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

5
1 2 3 4 5

output:

14

result:

ok 1 number(s): "14"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

6
1 2 4 7 15 31

output:

47

result:

ok 1 number(s): "47"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

5
41 40 50 11 36

output:

99

result:

ok 1 number(s): "99"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

6
10 40 60 2 44 47

output:

96

result:

ok 1 number(s): "96"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

6
46 25 39 47 23 60

output:

107

result:

ok 1 number(s): "107"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

6
56 90 61 63 56 23

output:

112

result:

ok 1 number(s): "112"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

7
8 83 78 19 36 6 22

output:

205

result:

ok 1 number(s): "205"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

7
23 23 22 78 2 29 88

output:

32

result:

ok 1 number(s): "32"

Test #10:

score: 0
Accepted
time: 1ms
memory: 3588kb

input:

7
109 80 14 27 9 45 24

output:

235

result:

ok 1 number(s): "235"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

7
144 152 137 143 145 139 183

output:

220

result:

ok 1 number(s): "220"

Test #12:

score: -100
Wrong Answer
time: 0ms
memory: 3592kb

input:

7
189 270 119 372 240 144 153

output:

74

result:

wrong answer 1st numbers differ - expected: '78', found: '74'