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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

ZOJ 3804 YY's Minions (简单模拟)

發布時間:2025/3/8 编程问答 14 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ZOJ 3804 YY's Minions (简单模拟) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 /* 2 題意:一個矩陣中有 n*m個寵物,每一個寵物都有一個狀態, 1醒著的,0睡著的 3 X離開的!如果這個寵物(醒著的)的周圍醒著的個數>3 || <2它就會睡著, 4 如果這個寵物(睡著的)的周圍醒著的個數==3就會醒來! 5 每一分鐘都會有變換一個狀態! 6 其中會有些寵物會在給定的時間內離開! 7 */ 8 #include<iostream> 9 #include<cstring> 10 #include<cstdio> 11 #include<algorithm> 12 using namespace std; 13 14 int n, m, f, k; 15 16 char statu[55][55]; 17 int dir[8][2]={1, 0, 0, 1, 0, -1, -1, 0, 1, 1, -1, -1, 1, -1, -1, 1}; 18 int cnt[55][55];//記錄[i][j] 周圍minions 醒著 的個數 19 20 int leave[55][55]; 21 22 int main(){ 23 int t; 24 scanf("%d", &t); 25 while(t--){ 26 memset(leave, 0, sizeof(leave)); 27 scanf("%d%d%d%d", &n, &m, &f, &k); 28 for(int i=1; i<=n; ++i) 29 scanf("%s", statu[i]+1); 30 while(k--){ 31 int u, v, z; 32 scanf("%d%d%d", &z, &u, &v);//[u][v]這個寵物在z時間之后離開 33 leave[u][v]=z; 34 } 35 memset(cnt, 0, sizeof(cnt)); 36 for(int tt=1; tt<=f; ++tt){ 37 for(int i=1; i<=n; ++i) 38 for(int j=1; j<=m; ++j){ 39 for(int k=0; k<8; ++k){ 40 int x=i+dir[k][1]; 41 int y=j+dir[k][0]; 42 if(x<1 || y<1 || x>n || y>m) continue; 43 if(statu[x][y]=='1') ++cnt[i][j]; 44 } 45 } 46 for(int i=1; i<=n; ++i) 47 for(int j=1; j<=m; ++j){ 48 if(cnt[i][j]==3 && statu[i][j]=='0') 49 statu[i][j]='1'; 50 else if((cnt[i][j]<2 || cnt[i][j]>3) && statu[i][j]=='1') 51 statu[i][j]='0'; 52 53 if(leave[i][j]==tt) statu[i][j]='X';//該寵物到達時間后就會離開 54 cnt[i][j]=0; 55 } 56 } 57 for(int i=1; i<=n; ++i) 58 printf("%s\n", statu[i]+1); 59 } 60 return 0; 61 }

?

轉載于:https://www.cnblogs.com/hujunzheng/p/3933902.html

總結

以上是生活随笔為你收集整理的ZOJ 3804 YY's Minions (简单模拟)的全部內容,希望文章能夠幫你解決所遇到的問題。

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