n*n*n的图形,m条线,每条线上的方格被删除。问一共删除了多少个方格
ans=m*n 。然后推断一下直线相交的交点。去重就可以
#include "stdio.h"#include "string.h"int xy[1010][1010],xz[1010][1010],yz[1010][1010],hash[1010];struct node{ int x,y,z;} mark[1010];int main(){ int Case,n,m,i,j,cnt,a,b,ans,sum; char ch1,ch2; scanf("%d",&Case); while (Case--) { scanf("%d%d",&n,&m); if (m==0) { printf("0\n"); continue; } memset(xy,0,sizeof(xy)); memset(xz,0,sizeof(xz)); memset(yz,0,sizeof(yz)); cnt=0; while (m--) // 去重边 { getchar(); scanf("%c=%d,%c=%d",&ch1,&a,&ch2,&b); if (ch1=='X' && ch2=='Y' && xy[a][b]==0) { mark[cnt].x=a; mark[cnt].y=b; mark[cnt++].z=-1; xy[a][b]=1; } if (ch1=='Y' && ch2=='X' && xy[b][a]==0) { mark[cnt].x=b; mark[cnt].y=a; mark[cnt++].z=-1; xy[b][a]=1; } if (ch1=='X' && ch2=='Z' && xz[a][b]==0) { mark[cnt].x=a; mark[cnt].z=b; mark[cnt++].y=-1; xz[a][b]=1; } if (ch1=='Z' && ch2=='X' && xz[b][a]==0) { mark[cnt].x=b; mark[cnt].z=a; mark[cnt++].y=-1; xz[b][a]=1; } if (ch1=='Y' && ch2=='Z' && yz[a][b]==0) { mark[cnt].y=a; mark[cnt].z=b; mark[cnt++].x=-1; yz[a][b]=1; } if (ch1=='Z' && ch2=='Y' && yz[b][a]==0) { mark[cnt].y=b; mark[cnt].z=a; mark[cnt++].x=-1; yz[b][a]=1; } } ans=n; for (i=1; i