题目描述 https://www.luogu.org/problemnew/show/P2693
暴力暴力暴力,当n<5时,要进行一些特殊判断。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=105;
int n,f1[N],f2[N],f3[N],s1,s2,s3,ans;
void work(int x,int y,int z)
{
for(int i=-2;i<=2;i++)
{
int x1=x+i,y1=y+i,z1=z+i;
if(x1<=0) x1+=n; if(x1>n) x1-=n;
if(y1<=0) y1+=n; if(y1>n) y1-=n;
if(z1<=0) z1+=n; if(z1>n) z1-=n;
f1[x1]++,f2[y1]++,f3[z1]++;
if(f1[x1]==2) s1++;
if(f2[y1]==2) s2++;
if(f3[z1]==2) s3++;
}
}
int main()
{
scanf("%d",&n);
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
work(x,y,z);
scanf("%d%d%d",&x,&y,&z);
work(x,y,z);
if(n>=5) ans=250-s1*s2*s3;
else
{
s1=min(s1,n),s2=min(s2,n),s3=min(s3,n);
ans=2*n*n*n-s1*s2*s3;
}
printf("%d",ans);
return 0;
}