Make complaints:Data seems a little waterDirect enumeration to 200 can get 80 points.
Another: I was too weak, and when the game only 90 points, # 7 dead card is not in the past, and finally found no judge \ (z_1 \) and \ (z_2 \) range ......
Subtask 1:
Method:
Direct output 4
, finished.
Subtask 2:
Method:
Direct violence enumeration \ (X \) , \ (Y \) , \ (Z \) , determines whether or not to look at the relationship satisfies:
\ [\ FORALL I \ in \ left [. 1, n-\ right], ST \ left | a_i-x \ right | \
bigoplus \ left | b_i-y \ right | \ bigoplus \ left | c_i -z \ right | = 9 \] time complexity: \ (O (nM ^. 3) \) ( \ ( the n-\ Leq 5 \) , can be ignored)
By \ (60 \% \) data.
Code:
#include<bits/stdc++.h>
#define int long long
#define Maxn 10
using namespace std;
inline void read(int &x)
{
int f=1;x=0;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
x*=f;
}
int n,M;
int ans=0;
int a[Maxn],b[Maxn],c[Maxn];
void solve1()
{
int flag=1;
for(int x=1;x<=M;x++)
{
for(int y=1;y<=M;y++)
{
for(int z=1;z<=M;z++)
{
for(int i=1;i<=n;i++)
{
if((((abs(a[i]-x))^(abs(b[i]-y)))^(abs(c[i]-z)))!=9)
{
flag=0;
break;
}
}
if(flag==1)
{
ans++;
}else
{
flag=1;
}
}
}
}
printf("%lld\n",ans);
return ;
}
signed main()
{
read(n),read(M);
for(int i=1;i<=n;i++)
{
read(a[i]);
read(b[i]);
read(c[i]);
}
ans=0;
if(M<=200)
{
solve1();
return 0;
}
}
Subtask 3:
Method :
Consider optimizing enumeration. If yes what properties:
\ [A \ B bigoplus \ bigoplus C = D \]
it will be apparent to give:
\ [\ the begin Equation} {\ the aligned the begin {A} & \ bigoplus B \ \\ & bigoplus D = A \ bigoplus B \ bigoplus \ left (A \ bigoplus B \ bigoplus C \ right) \\ & = \ left [\ left (A \ bigoplus B \ right) \ bigoplus \ left (A \ bigoplus B \ right) \ right] \ bigoplus C \\ & \ because x \
bigoplus x = 0,0 \ bigoplus x = x \\ & \ therefore A \ bigoplus B \ bigoplus D = C \ end {aligned} \ end {equation} \] requires only pieces For \ (X \) , \ (Y \) , then:
\ [\ the begin {Equation} \ the begin {the aligned} & \ left | c_1 and-Z \ right | = \ left | A_1-X \ right | \ bigoplus \ left | b_1-y \ right |
\ bigoplus 9 \ end {aligned} \ end {equation} \] we set
\ [C = \ left | a_1 -x \ right | \ bigoplus \ left | b_1-y \ right | \ bigoplus 9 \]
is:
\ [Z_1 = c_1 and-C, C + c_1 and Z_2 = \]
Finally, only we need to determine what \ (z_1 \) and \ (z_2 \) satisfies the following properties can be:
\ [\ FORALL i \ in \ left [2, the n-\ right], ST \ left | a_i-the X-\ right | \ bigoplus \ left | b_i-y \ right | \ bigoplus \ left | c_i -z_j \ right | = 9 \ text { and} z_j \ in [1, M ] \\ (j \ in \ {1,2 \} ) \]
time complexity: \ (O (nM 2 ^) \) ( \ (n-\ Leq. 5 \) , can be ignored)
Code:
#include<bits/stdc++.h>
#define int long long
#define Maxn 10
using namespace std;
inline void read(int &x)
{
int f=1;x=0;char s=getchar();
while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
x*=f;
}
int n,M;
int ans=0;
int a[Maxn],b[Maxn],c[Maxn];
map<int,int>mp;
void solve1()
{
int flag=1;
for(int x=1;x<=M;x++)
{
for(int y=1;y<=M;y++)
{
for(int z=1;z<=M;z++)
{
for(int i=1;i<=n;i++)
{
if((((abs(a[i]-x))^(abs(b[i]-y)))^(abs(c[i]-z)))!=9)
{
flag=0;
break;
}
}
if(flag==1)
{
ans++;
}else
{
flag=1;
}
}
}
}
printf("%lld\n",ans);
return ;
}
void solve2()
{
int flag1=1,flag2=1;
for(int x=1;x<=M;x++)
{
for(int y=1;y<=M;y++)
{
mp.clear();
int tmp=(((abs(a[1]-x))^(abs(b[1]-y)))^9);
int zkkk=c[1]-tmp;
int zwww=c[1]+tmp;
if(zkkk>=1&&zkkk<=M)
{
for(int i=2;i<=n;i++)
{
if((((abs(a[i]-x))^(abs(b[i]-y)))^(abs(c[i]-zkkk)))!=9)
{
flag1=0;
break;
}
}
if(flag1==1&&mp.find(zkkk)==mp.end())
{
ans++;
mp[zkkk]=1;
}else
{
flag1=1;
}
}else
{
flag1=1;
}
if(zwww>=1&&zwww<=M)
{
for(int i=2;i<=n;i++)
{
if((((abs(a[i]-x))^(abs(b[i]-y)))^(abs(c[i]-zwww)))!=9)
{
flag2=0;
break;
}
}
if(flag2==1&&mp.find(zwww)==mp.end())
{
ans++;
}else
{
flag2=1;
}
}else
{
flag2=1;
}
}
}
printf("%lld\n",ans);
return ;
}
signed main()
{
read(n),read(M);
for(int i=1;i<=n;i++)
{
read(a[i]);
read(b[i]);
read(c[i]);
}
ans=0;
if(M<=200)
{
solve1();
return 0;
}
else
{
solve2();
return 0;
}
}