-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMaximumXorSubmatrix.cpp
94 lines (87 loc) · 1.24 KB
/
MaximumXorSubmatrix.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define LD long double
#define gc getchar_unlocked
#define pc putchar_unlocked
#define MOD 1000000007
#define MAXN 1000005
#define bitcount __builtin_popcount
#define INF 2000000000
#define EPS 1e-9
template<typename T>T absll(T X)
{
if(X<0)
return -1*X;
else
return X;
}
LL maxi,temp;
LL dp[105][105];
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int N;
temp=0,maxi=0;
cin>>N;
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
cin>>dp[i][j];
}
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
if(i>0)
{
dp[i][j]^=dp[i-1][j];
}
if(j>0)
{
dp[i][j]^=dp[i][j-1];
}
if(i>0&&j>0)
{
dp[i][j]^=dp[i-1][j-1];
}
}
}
for(int i=0;i<N;i++)
{
for(int j=0;j<N;j++)
{
for(int k=i;k<N;k++)
{
for(int l=j;l<N;l++)
{
temp=dp[k][l];
if(i>0)
{
temp^=dp[i-1][l];
}
if(j>0)
{
temp^=dp[k][j-1];
}
if(i>0&&j>0)
{
temp^=dp[i-1][j-1];
}
maxi=max(maxi,temp);
}
}
}
}
cout<<maxi<<endl;
}
return 0;
}