link :
Method: Quasi- matrix
parsing:
we are the upper-tempo operation.
so we just need to leave a situation where the situation does not differ or equals zero.
each pile of matches is considered a binary number.
then we just need to come up with a maximal linearly independent group to achieve the situation we want.
so now set m=s,l m={s,l},s is a matrix of all the numbers, L is the maximal linearly independent group we take out.
so now if we can testify that this thing is hereditary and also has an exchange, then he is a quasi-array of spicy. In fact, the main is the establishment of the exchange of evidence.
then WYF has such a piece of evidence.
Set A,b∈i, and | a|<| B|, we have to prove the existence of x∈b, so that a∪{x}∈i. Using the method of absurdity, it is assumed that for any x∈b-a, a∪{x} does not belong to I, then the elements in the b-a are in the different or space of a, and can be different or represented by a subset of a.
So the elements in B are in the XOR or space of a. Then there must be B's different or space contained in A's different or space. by | a|<| b| and a,b linearly unrelated, obviously contradictory. So the commutative existence is equivalent to any two maximal linearly independent groups of the proof vector group. This is the linear algebra tutorial, go to see the proof. So we have proved the greedy optimality by the pseudo matrix, and then we just need to get greedy to solve a maximal linearly independent group. and then it's like the Gauss elimination. Code:
#include <cstdio> #include <cstring> #include <iostream> #include <
Algorithm> #define N-using namespace std;
typedef long Long LL;
int a[n];
int b[n];
int n;
ll sum;
ll ans;
int cmp (int x,int y) {return x>y;} int main () {scanf ("%d", &n);
for (int i=1;i<=n;i++) scanf ("%d", &a[i]), sum+=a[i];
Sort (a+1,a+n+1,cmp);
for (int i=1;i<=n;i++) {int tmp=a[i];
for (int j=30;j>=0;j--) {if (a[i]& (1<<J)) if (!b[j]) {b[j]=i;break;}
else A[i]^=a[b[j]];
} if (a[i]!=0) ans+=tmp;
} if (ans==0) printf (" -1\n");
else printf ("%lld\n", Sum-ans); }