#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
bool vis[1300][130][70];
int dx[5] = {-1, 0, 1, 0, 0}, dy[5] = {0, 1, 0, -1, 0};
int dz[3] = {-1, 0, 1};
int m, n, l, t;
bool qiepian[1300][130][70];
struct XYZ {
int x, y, z;
};
bool check(int a, int b, int c) {
if (a < 0 || a >= m || b < 0 || b >= n || c < 0 || c >= l) return false;
if (qiepian[a][b][c] == 0) return false;
if (vis[a][b][c]) return false;
return true;
}
int bfs(int x, int y, int z) {
queue<XYZ> q;
q.push({x, y, z});
int cnt = 1;
while (q.size()) {
auto t = q.front();
q.pop();
int x = t.x, y = t.y, z = t.z;
for (int i = 0; i < 3; i++) {
if (dz[i] == 0) {
for (int j = 0; j < 4; j++) {
int xx = x + dx[j], yy = y + dy[j];
if (check(xx, yy, z)) {
cnt++;
vis[xx][yy][z] = true;
q.push({xx, yy, z});
}
}
} else {
int zz = z + dz[i];
if (check(x, y, zz)) {
cnt++;
vis[x][y][zz] = true;
q.push({x, y, zz});
}
}
}
}
return cnt;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> m >> n >> l >> t;
for (int z = 0; z < l; z++) {
for (int x = 0; x < m; x++) {
for (int y = 0; y < n; y++) {
cin >> qiepian[x][y][z];
}
}
}
int res = 0;
for (int z = 0; z < l; z++) {
for (int x = 0; x < m; x++) {
for (int y = 0; y < n; y++) {
if (!vis[x][y][z] && qiepian[x][y][z] == 1) {
vis[x][y][z] = true;
int num = bfs(x, y, z);
if (num >= t) res += num;
}
}
}
}
cout << res << "\n";
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端