303295: CF638D. Three-dimensional Turtle Super Computer

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Three-dimensional Turtle Super Computer

题意翻译

### 题目描述 一个超级计算机在海龟科学院被建成了。这个计算机包括了 $n\cdot m\cdot k$ 个中央处理器。该建筑是一个大小为 $n\cdot m\cdot k$ 的平行管道,分成 $1\times 1\times 1$ 的细胞,每个细胞里含有一个中央处理器。因此,每个中央处理器可以同时标识为三个数字,层号从 1 到 n,行号从 1 到 m,列号从 1 到 k。 在超级计算机的工作过程中,中央处理器之间可以通过著名的海龟计划互相发送信息。如,中央处理器 $(x,y,z)$ 可以向中央处理器 $(x+1,y,z),(x,y+1,z),(x,y,z+1)$ 发送信息(当然,如果它们都存在)。但是,这种发送消息的装置是不能回复的,所以后三者不能向前者发送消息。 一段时间后,一些中央处理器坏掉了并且停止了工作。这些中央处理器既不能收到信息和发送信息,也不能帮助转移信息。 如果存在一条链 $(x_i,y_i,z_i)$,满足 $(x_1=a,x_2=b,x_3=c),(x_p=d,y_p=e,z_p=f)$,并且链内对于每一个 $i<p$(这里的 p 指这条链的长度),中央处理器 $(x_i,y_i,z_i)$ 都能向中央处理器 $(x_{i+1},y_{i+1},z_{i+1})$ 发送消息,那么我们称中央处理器 $(a,b,c)$ 控制中央处理器 $(d,e,f)$。 海龟们非常担心这些剩下的中央处理器互相之间的消息可传递性。因此,它们想知道关键的中央处理器的数量。当关闭中央处理器 $(x,y,z)$ 会破坏一些控制关系时,我们就称这个中央处理器 $(x,y,z)$ 是关键的。如,如果关闭中央处理器 $(x,y,z)$ 之后,原本处于控制关系的中央处理器 $(a,b,c)$ 和中央处理器 $(d,e,f)$ 变得不控制了,那么中央处理器 $(x,y,z)$ 是一个关键的中央处理器。 ### 输入格式 第一行输入超级计算机的规模 n,m,k($1\leqslant n,m,k\leqslant 100$)。 接下来 n 个块,对应超级计算机的层数; 每个块中 m 行,对应超级计算机的行数;每行中 k 个数,对应超级计算机的列数。“1”表示正常运行的中央处理器,“0”表示坏了的中央处理器。每两个块之间用空行隔开。 ### 输出格式 第一行输出一个整数,表示关键的中央处理器的数量。

题目描述

A super computer has been built in the Turtle Academy of Sciences. The computer consists of $ n·m·k $ CPUs. The architecture was the paralellepiped of size $ n×m×k $ , split into $ 1×1×1 $ cells, each cell contains exactly one CPU. Thus, each CPU can be simultaneously identified as a group of three numbers from the layer number from $ 1 $ to $ n $ , the line number from $ 1 $ to $ m $ and the column number from $ 1 $ to $ k $ . In the process of the Super Computer's work the CPUs can send each other messages by the famous turtle scheme: CPU $ (x,y,z) $ can send messages to CPUs $ (x+1,y,z) $ , $ (x,y+1,z) $ and $ (x,y,z+1) $ (of course, if they exist), there is no feedback, that is, CPUs $ (x+1,y,z) $ , $ (x,y+1,z) $ and $ (x,y,z+1) $ cannot send messages to CPU $ (x,y,z) $ . Over time some CPUs broke down and stopped working. Such CPUs cannot send messages, receive messages or serve as intermediates in transmitting messages. We will say that CPU $ (a,b,c) $ controls CPU $ (d,e,f) $ , if there is a chain of CPUs $ (x_{i},y_{i},z_{i}) $ , such that $ (x_{1}=a,y_{1}=b,z_{1}=c) $ , $ (x_{p}=d,y_{p}=e,z_{p}=f) $ (here and below $ p $ is the length of the chain) and the CPU in the chain with number $ i $ ( $ i&lt;p $ ) can send messages to CPU $ i+1 $ . Turtles are quite concerned about the denial-proofness of the system of communication between the remaining CPUs. For that they want to know the number of critical CPUs. A CPU $ (x,y,z) $ is critical, if turning it off will disrupt some control, that is, if there are two distinctive from $ (x,y,z) $ CPUs: $ (a,b,c) $ and $ (d,e,f) $ , such that $ (a,b,c) $ controls $ (d,e,f) $ before $ (x,y,z) $ is turned off and stopped controlling it after the turning off.

输入输出格式

输入格式


The first line contains three integers $ n $ , $ m $ and $ k $ ( $ 1<=n,m,k<=100 $ ) — the dimensions of the Super Computer. Then $ n $ blocks follow, describing the current state of the processes. The blocks correspond to the layers of the Super Computer in the order from $ 1 $ to $ n $ . Each block consists of $ m $ lines, $ k $ characters in each — the description of a layer in the format of an $ m×k $ table. Thus, the state of the CPU $ (x,y,z) $ is corresponded to the $ z $ -th character of the $ y $ -th line of the block number $ x $ . Character "1" corresponds to a working CPU and character "0" corresponds to a malfunctioning one. The blocks are separated by exactly one empty line.

输出格式


Print a single integer — the number of critical CPUs, that is, such that turning only this CPU off will disrupt some control.

输入输出样例

输入样例 #1

2 2 3
000
000

111
111

输出样例 #1

2

输入样例 #2

3 3 3
111
111
111

111
111
111

111
111
111

输出样例 #2

19

输入样例 #3

1 1 10
0101010101

输出样例 #3

0

说明

In the first sample the whole first layer of CPUs is malfunctional. In the second layer when CPU $ (2,1,2) $ turns off, it disrupts the control by CPU $ (2,1,3) $ over CPU $ (2,1,1) $ , and when CPU $ (2,2,2) $ is turned off, it disrupts the control over CPU $ (2,2,3) $ by CPU $ (2,2,1) $ . In the second sample all processors except for the corner ones are critical. In the third sample there is not a single processor controlling another processor, so the answer is $ 0 $ .

Input

题意翻译

### 题目描述 一个超级计算机在海龟科学院被建成了。这个计算机包括了 $n\cdot m\cdot k$ 个中央处理器。该建筑是一个大小为 $n\cdot m\cdot k$ 的平行管道,分成 $1\times 1\times 1$ 的细胞,每个细胞里含有一个中央处理器。因此,每个中央处理器可以同时标识为三个数字,层号从 1 到 n,行号从 1 到 m,列号从 1 到 k。 在超级计算机的工作过程中,中央处理器之间可以通过著名的海龟计划互相发送信息。如,中央处理器 $(x,y,z)$ 可以向中央处理器 $(x+1,y,z),(x,y+1,z),(x,y,z+1)$ 发送信息(当然,如果它们都存在)。但是,这种发送消息的装置是不能回复的,所以后三者不能向前者发送消息。 一段时间后,一些中央处理器坏掉了并且停止了工作。这些中央处理器既不能收到信息和发送信息,也不能帮助转移信息。 如果存在一条链 $(x_i,y_i,z_i)$,满足 $(x_1=a,x_2=b,x_3=c),(x_p=d,y_p=e,z_p=f)$,并且链内对于每一个 $i<p$(这里的 p 指这条链的长度),中央处理器 $(x_i,y_i,z_i)$ 都能向中央处理器 $(x_{i+1},y_{i+1},z_{i+1})$ 发送消息,那么我们称中央处理器 $(a,b,c)$ 控制中央处理器 $(d,e,f)$。 海龟们非常担心这些剩下的中央处理器互相之间的消息可传递性。因此,它们想知道关键的中央处理器的数量。当关闭中央处理器 $(x,y,z)$ 会破坏一些控制关系时,我们就称这个中央处理器 $(x,y,z)$ 是关键的。如,如果关闭中央处理器 $(x,y,z)$ 之后,原本处于控制关系的中央处理器 $(a,b,c)$ 和中央处理器 $(d,e,f)$ 变得不控制了,那么中央处理器 $(x,y,z)$ 是一个关键的中央处理器。 ### 输入格式 第一行输入超级计算机的规模 n,m,k($1\leqslant n,m,k\leqslant 100$)。 接下来 n 个块,对应超级计算机的层数; 每个块中 m 行,对应超级计算机的行数;每行中 k 个数,对应超级计算机的列数。“1”表示正常运行的中央处理器,“0”表示坏了的中央处理器。每两个块之间用空行隔开。 ### 输出格式 第一行输出一个整数,表示关键的中央处理器的数量。

加入题单

算法标签: