Topic Information
1091. Acute Stroke (30)
Time limit MS
Memory Limit 65536 KB
Code length limit 16000 B
One important factor to identify acute stroke (acute stroke) is the volume of the stroke core. Given the results of image analysis in which the core regions be identified in each MRI slice, your job was to calculate t He volume of the stroke core.
Input Specification:
Each input file contains the one test case. For each case, the first line contains 4 positive integers:m, N, L and T, where M and N is the sizes of each slice (i.e. Pixels of a slice is in an M by N matrix, and the maximum resolution is 1286 by 128); L (<=60) is the number of slices of a brain; And T is the integer threshold (i.e. if the volume of a connected core are less than T, then that core must isn't be counted) .
Then L slices is given. Each slice was represented by an M by N matrix of 0 ' and 1 ' s, where 1 represents a pixel of stroke, and 0 means normal. Since the thickness of a slice is a constant, we are only having to count the number of 1 ' s to obtain the volume. However, there might is several separated core regions in a brain, and only those with their volumes no less than T is Co Unted. Pixels is "connected" and hence belong to the same region if they share a common side, as shown by figure 1 where all The 6 red pixels is connected to the blue one.
Figure 1
Output Specification:
For each case, output in a line the total volume of the stroke core.
Sample Input:
3 4 5 2
1 1 1 1
1 1 1 1
1 1 1 1
0 0 1 1
0 0 1 1
0 0 1 1
1 0 1 1
0 1 0 0
0 0 0 0
1 0 1 1
0 0 0 0
0 0 0 0
0 0 0 1
0 0 0 1
1 0 0 0
Sample Output:
26
Thinking of solving problems
Search in six directions
AC Code
#include <cstdio>#include <queue>#include <map>using namespace STD;BOOLmp[ the][1300][ the];intM, N, L, T, V, S;structnode{intX, y, Z; Nodeoperator+ (node& b) {returnNode (x + b.x, y + b.y, z + b.z); } node (intAintBintc): X (a), Y (b), Z (c) {}};node dir[6] = {Node (0,0, -1), Node (0,0,1), Node (1,0,0), Node (-1,0,0), Node (0,1,0), Node (0, -1,0)};voidBFsintXintYintZ) { queue<node>QueintCNT =1; MP[Z][Y][X] =false; Que.push (node (x, Y, z)); while(!que.empty ()) {Node B = Que.front (); Que.pop (); for(inti =0; I <6; ++i) {Node c = b + dir[i];if(mp[c.z][c.y][c.x]) {mp[c.z][c.y][c.x] =false; Que.push (c); ++cnt; } } }if(CNT >= t) {s + = cnt; }}intMain () {scanf("%d%d%d%d", &m, &n, &l, &t); for(intK =1; K <= L; ++K) { for(inti =1; I <= m; ++i) { for(intj =1; J <= N; ++J) {scanf("%d", &v); MP[K][I][J] = (v = =1); } } } for(intK =1; K <= L; ++K) { for(inti =1; I <= m; ++i) { for(intj =1; J <= N; ++J) {if(Mp[k][i][j]) {BFS (J, I, K); } } } }printf("%d\n", s);return 0;}
1091. Acute Stroke (30) "Search"--pat (Advanced level) practise