#include<iostream>#include<queue>usingnamespace std;struct point {
int x, y, z;}node;bool inq[1290][130][61]={
false};int X[6]={
1,-1,0,0,0,0};int Y[6]={
0,0,1,-1,0,0};int Z[6]={
0,0,0,0,1,-1};int n, m, l, t, max1 =0, v[1290][130][61];booljudge(int x,int y,int z){
if(x >= n || y >= m || z >= l || y <0|| x <0|| z <0)returnfalse;//忘了xyz要大于0,段错误,虽然在vs中能对if(inq[x][y][z]==true|| v[x][y][z]==0)returnfalse;returntrue;}intbfs(int x,int y,int z){
int count =0;
queue<point> q;
node.x = x; node.y = y; node.z = z;
q.push(node);
inq[x][y][z]=true;while(!q.empty()){
point temp = q.front();
count++;
q.pop();for(int i =0; i <6; i++){
/* temp.x=x+X[i];
temp.y=y+Y[i];
temp.z=z+Z[i];*///当处理别的点之后,x还是不会变,这样是不对的
node.x = temp.x + X[i];
node.y = temp.y + Y[i];
node.z = temp.z + Z[i];if(judge(node.x, node.y, node.z)){
q.push(node);//入队等待访问
inq[node.x][node.y][node.z]=true;}}}if(count >= t)return count;elsereturn0;}intmain(){
int temp =0;
cin >> n >> m >> l >> t;for(int z =0; z < l; z++){
for(int x =0; x < n; x++){
for(int y =0; y < m; y++){
cin >> v[x][y][z];}}}for(int z =0; z < l; z++){
for(int x =0; x < n; x++){
for(int y =0; y < m; y++){
if(judge(x, y, z)){
temp =bfs(x, y, z);
max1+=temp;}}}}
cout << max1;}