QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#407993#4810. Add Onechenxinyang2006WA 1ms3916kbC++201.6kb2024-05-09 15:46:242024-05-09 15:46:26

Judging History

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

  • [2024-05-09 15:46:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3916kb
  • [2024-05-09 15:46:24]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;

template <class T>
void chkmax(T &x,T y){
	if(x < y) x = y;
}

template <class T>
void chkmin(T &x,T y){
	if(x > y) x = y;
}

inline int popcnt(int x){
	return __builtin_popcount(x);
}

inline int ctz(int x){
	return __builtin_ctz(x);
}


/*ll power(ll p,int k = mod - 2){
	ll ans = 1;
	while(k){
		if(k % 2 == 1) ans = ans * p % mod;
		p = p * p % mod;
		k /= 2;	
	}
	return ans;
}*/
int n;
ll a[1000005];
ll w[65];
int rnk;
void insert(ll val){
	rep(k,0,59){
		if(((val >> k) & 1) == 0) continue;
		if(!w[k]){
			w[k] = val;
			rnk++;
			return;
		}
		val ^= w[k];
	}
}

int main(){
//	freopen("test.in","r",stdin);
	scanf("%d",&n);
	ll sum = 0,answer = 0;
	rep(i,1,n){
		scanf("%lld",&a[i]);
		insert(a[i]);
		sum ^= a[i];
	}

	ll cur = 0,qwq = 0;
	rep(k,0,59){
		qwq += 1ll << k;
		if(k){
			if(((cur >> k) & 1) == 0) chkmax(answer,sum ^ qwq);
			else if(w[k]) chkmax(answer,sum ^ qwq);
		}
		if(((cur >> k) & 1) == 0){
			if(!w[k]) break;
			cur ^= w[k];
		}
	}
	if(rnk < n) chkmax(answer,sum ^ 1);
	printf("%lld\n",answer);
	return 0;
}

详细

Test #1:

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

input:

4
1 2 1 2

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

input:

5
1 2 3 4 5

output:

14

result:

ok 1 number(s): "14"

Test #3:

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

input:

6
1 2 4 7 15 31

output:

47

result:

ok 1 number(s): "47"

Test #4:

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

input:

5
41 40 50 11 36

output:

99

result:

ok 1 number(s): "99"

Test #5:

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

input:

6
10 40 60 2 44 47

output:

96

result:

ok 1 number(s): "96"

Test #6:

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

input:

6
46 25 39 47 23 60

output:

107

result:

ok 1 number(s): "107"

Test #7:

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

input:

6
56 90 61 63 56 23

output:

112

result:

ok 1 number(s): "112"

Test #8:

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

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: 3848kb

input:

7
23 23 22 78 2 29 88

output:

32

result:

ok 1 number(s): "32"

Test #10:

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

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: 3812kb

input:

7
144 152 137 143 145 139 183

output:

220

result:

ok 1 number(s): "220"

Test #12:

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

input:

7
189 270 119 372 240 144 153

output:

78

result:

ok 1 number(s): "78"

Test #13:

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

input:

7
4819 2494 1822 4759 2622 4111 2460

output:

7510

result:

ok 1 number(s): "7510"

Test #14:

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

input:

8
83 20 17 43 52 78 68 45

output:

145

result:

ok 1 number(s): "145"

Test #15:

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

input:

8
289 205 96 274 304 476 230 246

output:

925

result:

ok 1 number(s): "925"

Test #16:

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

input:

8
6866 7210 3474 9147 7676 7287 7339 7605

output:

14267

result:

ok 1 number(s): "14267"

Test #17:

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

input:

100
9080 7595 3488 1872 5813 1238 8798 2114 2047 6437 1719 5095 9036 2318 3453 8455 9441 7752 388 4695 1433 8253 1558 9068 8432 6751 5897 6993 7763 983 6741 9852 9812 5679 7980 8956 5905 7738 3091 3364 9630 5345 1574 255 5215 6863 9002 7324 6216 6471 2574 6026 5611 7998 1449 2191 4306 525 6534 1692 ...

output:

17374

result:

ok 1 number(s): "17374"

Test #18:

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

input:

200
5427 2263 8443 3141 4775 842 1756 8604 3074 4508 9608 3344 9356 6102 710 7484 6543 7718 7441 7920 9928 8282 3941 1347 6908 4386 4269 4723 5797 1447 2381 305 7275 2568 9250 3113 8438 9273 1280 6609 5225 9253 3732 7991 2975 8690 9299 9009 63 2852 4309 2316 2948 9798 3731 790 9770 5527 1775 8388 44...

output:

27971

result:

ok 1 number(s): "27971"

Test #19:

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

input:

200
11526 12520 983 17606 861 12619 10319 11496 18084 8341 10236 7895 19999 5599 416 12109 16336 9173 15715 1418 8492 13373 8142 6881 13158 16435 9429 593 15751 8793 1476 19166 6627 10965 7368 1295 15449 8063 14489 9651 13570 944 11544 10602 10342 6543 6385 1108 19358 4365 4990 18004 11530 4237 1253...

output:

45265

result:

ok 1 number(s): "45265"

Test #20:

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

input:

500
4445 583 3305 855 5165 3564 1977 1573 903 3999 3272 8905 8160 4359 5982 8912 7850 5050 6441 5436 4598 3644 685 2529 4467 2012 1541 8348 4624 1495 4558 5195 3169 6737 5622 3837 4693 7760 1530 8909 6326 7449 612 6472 2347 9855 8008 4469 9859 5498 6014 2939 4554 3016 1947 1863 8316 532 1407 6723 78...

output:

28641

result:

ok 1 number(s): "28641"

Test #21:

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

input:

500
1661 12688 355 1454 9870 13986 4189 5369 7983 10827 10213 10113 17158 700 1226 2428 2974 7119 11534 8559 7798 3004 19051 16749 95 13485 7097 2421 7105 9719 8741 7554 684 9179 13579 17207 3845 1575 5918 9955 14241 15879 16925 8748 13847 6872 7546 10956 17584 11939 10438 17481 18105 6203 12057 527...

output:

56453

result:

ok 1 number(s): "56453"

Test #22:

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

input:

500
29952 7185 11740 19601 20588 28851 26372 18354 28858 10524 11297 1355 21526 22865 5405 14315 270 6167 22276 21386 14797 19800 12528 2687 9931 4142 11217 9345 25152 8322 7151 29748 29999 16449 18987 12412 24097 27398 3492 25222 12725 593 19682 3523 19984 12618 8215 977 20339 16993 8123 14039 4389...

output:

34673

result:

ok 1 number(s): "34673"

Test #23:

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

input:

1000
6878 9388 5539 9330 1321 5637 6801 9707 549 8458 4985 5073 5585 7617 53 2051 6298 1307 7096 1797 4152 6514 9894 710 4623 5610 7432 5861 4882 898 2886 967 1921 9934 8181 6986 7696 893 5483 8623 1166 3391 9760 443 5539 9729 9886 5174 4608 8823 9504 9059 2618 924 6559 7806 1413 1958 9432 908 9484 ...

output:

23640

result:

ok 1 number(s): "23640"

Test #24:

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

input:

1000
1841 2537 5882 16739 15299 12706 65 12364 14174 18767 11672 3116 12582 7584 5498 9806 70 9855 738 17027 12840 10343 2208 14647 18021 6379 12184 6647 17976 12215 6447 8279 1701 5870 15780 6479 3195 1165 7338 7879 13609 5035 18593 3029 15933 13654 18639 18887 4722 15026 17282 13833 10869 16503 28...

output:

38186

result:

ok 1 number(s): "38186"

Test #25:

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

input:

1000
24478 26881 36979 16229 23705 13295 4494 7434 31698 27401 39676 13484 21250 30204 31220 25448 39653 30287 23238 31463 29096 7341 38577 25912 15171 22175 30609 36996 24646 22322 32899 21804 38419 35415 24331 35045 5996 31671 32285 37555 19838 20380 1510 1742 18089 1652 15842 15282 23039 25261 37...

output:

120138

result:

ok 1 number(s): "120138"

Test #26:

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

input:

2000
1 0 0 0 1 1 1 1 1 0 0 0 1 0 1 1 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 1 0 0 0 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 1 0 0 0 1 1 0 1 1 0 1 1 0 1 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 0 0 0 0 0...

output:

2

result:

ok 1 number(s): "2"

Test #27:

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

input:

2000
9335 8938 9465 1282 4326 2363 290 9711 446 7258 9783 8421 172 7241 1736 211 1622 2138 9260 8686 3616 669 1588 4763 1746 4735 4091 1926 3895 7134 442 8185 3356 4135 1970 7322 8713 2544 33 1356 1623 9852 604 3639 6767 7278 2518 1877 9942 3709 8241 4124 7358 5395 951 7447 5246 9616 378 3366 2585 1...

output:

32570

result:

ok 1 number(s): "32570"

Test #28:

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

input:

2000
3654 10024 7054 19973 7369 11154 3337 3790 7189 10098 7716 22747 15661 5684 2899 37191 32809 30246 18335 12171 10202 10487 9259 5872 26880 18142 25853 3814 29934 39639 2622 24871 26293 25652 27398 9172 6082 6338 32909 5105 36824 4885 15034 5532 8672 3053 33858 35339 33823 15064 14154 3852 6849 ...

output:

79016

result:

ok 1 number(s): "79016"

Test #29:

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

input:

3000
2199 237 5140 3235 5581 3405 1621 1466 8186 6465 8514 1361 4760 773 5576 2281 3037 4719 1424 1665 3080 4418 1126 7065 2804 3860 8592 8399 3315 5527 5842 7154 4792 2652 3601 8066 135 4603 2426 4091 3830 4560 3201 6835 8402 894 9060 6422 2711 9002 5227 1347 9939 9866 7502 7495 828 1180 3483 5824 ...

output:

26556

result:

ok 1 number(s): "26556"

Test #30:

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

input:

5000
7114 7180 2990 7141 3749 9017 4285 2819 4072 6631 2042 3741 7845 3931 8940 4670 7620 8132 4001 1940 6324 1916 2358 3419 3142 8203 7186 3095 3499 156 549 3339 5099 3213 3337 8739 6892 8313 7619 1717 6495 3978 8394 8911 3015 2060 2141 7264 2971 7023 8386 3637 9418 964 5880 6778 2401 808 5377 8988...

output:

18004

result:

ok 1 number(s): "18004"

Test #31:

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

input:

5000
1110 32658 19743 18676 38020 15940 44942 47521 33916 42962 23873 11211 14880 47046 10202 3359 43610 22064 1756 22609 25858 11836 43502 28895 8597 3292 40418 1655 35687 37757 4859 5935 13415 6029 23112 7965 10528 35373 7229 35235 5856 10388 35031 35708 45755 26348 48731 5606 6006 8650 45836 3465...

output:

126707

result:

ok 1 number(s): "126707"

Test #32:

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

input:

1
9400310136562468

output:

0

result:

wrong answer 1st numbers differ - expected: '9400310136562469', found: '0'