日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1091. Acute Stroke (30)

發布時間:2025/5/22 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1091. Acute Stroke (30) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目如下:

One important factor to identify acute stroke (急性腦卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core.

Input Specification:

Each input file contains one test case. For each case, the first line contains 4 positive integers: M, N, L and T, where M and N are the sizes of each slice (i.e. pixels of a slice are 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 is less than T, then that core must not be counted).

Then L slices are given. Each slice is represented by an M by N matrix of 0's and 1's, where 1 represents a pixel of stroke, and 0 means normal. Since the thickness of a slice is a constant, we only have to count the number of 1's to obtain the volume. However, there might be several separated core regions in a brain, and only those with their volumes no less than T are counted. Two pixels are "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 are 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


這道題的敘述相當的費解,而且圖有些抽象,我讀了兩次都沒有讀懂,后來看了Uncle_Sugar的敘述和解法才明白了題意,其解法簡潔、高效、易懂,下面進行介紹。

題目的本質就是對一個三維數組中1的連通區域中所有1進行計數。因為是三維坐標,因此對1計數不再是簡單的四個方向,而是六個,分別是前后左右上下,也就是圖中給出的六個紅色。個人認為這張圖過于抽象,說白了就是進行三維廣度或者深度搜索,只不過鄰接點的判斷是通過六個方向是否為1來確定的。

Uncle_Sugar的算法巧妙地給出了六個方向的BFS實現,對于某個位置(x,y,z),我們先判斷(x+1,y,z),接著判斷(x-1,y,z),然后是(x,y+1,z)...以此類推,他巧妙的利用三個一維數組實現了用一個循環實現六個方向的遍歷,然后判斷是否是合法范圍,是則計數,最后即可得到1的總數。

下面是Uncle_Sugar的代碼

# include <cstdio> # include <queue> using std::queue;int map[1286][128][60]; struct loca {int x,y,z;loca(int _x,int _y,int _z):x(_x),y(_y),z(_z){} };int m,n,l,t; int dx[6] = {1,-1,0,0,0,0}; int dy[6] = {0,0,1,-1,0,0}; int dz[6] = {0,0,0,0,1,-1}; int ans = 0; int InRange(int x,int y,int z) {return x < m && x >=0 && y < n&&y >= 0 && z < l && z >= 0; } void bfs(int x,int y,int z) {int ret = 0;queue<loca> que;que.push(loca(x,y,z));map[x][y][z] = 0;ret++;while (!que.empty()){loca tp = que.front();que.pop();x = tp.x;y = tp.y;z = tp.z;for (int i=0;i<6;i++){int nx = x + dx[i];int ny = y + dy[i];int nz = z + dz[i];if (InRange(nx,ny,nz) && map[nx][ny][nz] == 1){map[nx][ny][nz] = 0;ret++;que.push(loca(nx,ny,nz));}}}if (ret>=t)ans += ret; } int main() {scanf("%d%d%d%d",&m,&n,&l,&t);for (int k=0;k<l;k++)for (int i=0;i<m;i++)for (int j=0;j<n;j++)scanf("%d",&map[i][j][k]);for (int k=0;k<l;k++)for (int i=0;i<m;i++)for (int j=0;j<n;j++)if (map[i][j][k]==1)bfs(i,j,k);printf("%d\n",ans);return 0; }

轉載于:https://www.cnblogs.com/aiwz/p/6154038.html

總結

以上是生活随笔為你收集整理的1091. Acute Stroke (30)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产人人爽 | 色污网站 | 午夜精品一区二区三区在线视频 | 日本一道本在线 | 国产亚州av | 日韩网站免费观看高清 | 亚洲综合在线五月 | 亚洲欲色 | 色悠久久综合 | 午夜久久视频 | 青青草手机在线 | 免费看一级黄色大片 | 日韩欧美日本 | 欧美福利视频在线 | 星铁乱淫h侵犯h文 | 不卡日韩 | 免费激情av| 欧美一区二区三区在线视频 | 天天爽天天射 | 亚洲性综合网 | 精品一区二区三区在线免费观看 | av黄色在线观看 | 久久久免费 | 国产在线麻豆精品观看 | 在线视频欧美亚洲 | 好看的av在线 | 久久久老熟女一区二区三区91 | 日韩精品一区中文字幕 | 精品无码av一区二区三区四区 | 国产精品无码天天爽视频 | 国产一线二线在线观看 | 国产日韩欧美精品在线观看 | 日韩在线视频网站 | 自拍第二页 | 一区二区欧美视频 | 欧美精品亚洲精品日韩精品 | 久久国产福利 | 青草青在线视频 | 懂色aⅴ国产一区二区三区 亚洲欧美国产另类 | 亚洲午夜精品久久久久久app | 天天热天天干 | 久久精品一区二区三区黑人印度 | 亚洲视频99 | 精品伦一区二区三区 | 2025国产精品视频 | 久久国产成人精品av | 丁香婷婷一区二区三区 | 好妞色妞国产在线视频 | 一区国产精品 | 成人av电影网站 | 男女视频免费看 | 亚洲一区视频在线播放 | 青娱乐在线视频免费观看 | 亚洲一区二区观看 | 国产视频1区2区3区 国产欧美一区二区精品性色99 | 色xxxxx| 在线不卡一区二区 | 国产123区在线观看 91国产一区二区 | 四虎影库永久在线 | 欧美日韩亚洲在线观看 | av黄色网 | 国产精品久久一 | 国产激情久久久久 | 韩国主播青草200vip视频 | 大胸喷奶水www视频妖精网站 | 欧美肉大捧一进一出免费视频 | 人人亚洲 | 高h调教冰块play男男双性文 | 欧州一区二区三区 | 国产日产精品一区二区三区四区 | 中文字幕一区二区三区在线观看 | 调教一区二区 | 国产麻豆一区二区三区 | 国产一区二区三区精品视频 | 国产色悠悠 | 肥老熟妇伦子伦456视频 | 成人靠逼视频 | 古代黄色片 | 国产一级久久久 | 欧美日韩少妇精品 | 久久影视精品 | 日韩在线观看视频免费 | 日韩精选在线观看 | 99资源网| 99蜜桃臀久久久欧美精品网站 | 免费视频污 | 国产精品一区二区无线 | 天天色视频 | 中文在线a√在线 | 成人黄色激情网 | 日本三级午夜理伦三级三 | 国产免费成人在线视频 | 国产午夜性春猛交ⅹxxx | 成人乱码一区二区三区av | 日韩欧美成人免费视频 | 美丽的姑娘观看在线播放 | 凹凸精品熟女在线观看 | 黄色一级片一级片 | 毛片天堂 |