认证0级讲师
不就是簡單的元胞自動機模型?
不用謝,已經通過的C++程式碼:
using namespace std;
int main(){
int n, m, k, i, j; //ifstream cin("test.txt"); while (cin>>n>>m) { cin >> k; int max = k; int x = 0, y = 0, time = 1; int area[12][12]; memset(area, 0, sizeof(area)); for (i = 0;i < k; i++) { cin >> x >> y; area[x][y] = 1; } while(time++) { int num = 0; for (i = 1;i <= n;i++) { for (j = 1;j <= m;j++) { //为6永远不会感染别人 if (area[i][j] >=1 && area[i][j] <=5) area[i][j]++; //我靠,程序半天没调出来,这句写成了area[x][y]++; fuck!!! if (area[i][j] == 4) { if (area[i - 1][j] == 0) area[i - 1][j] = 1; if (area[i + 1][j] == 0) area[i + 1][j] = 1; if (area[i][j + 1] == 0) area[i][j + 1] = 1; if (area[i][j - 1] == 0) area[i][j - 1] = 1; } } } for (i = 1;i <= n; i++) { for (j = 1;j <= m;j++) { if (area[i][j] >= 1 && area[i][j] <= 5) num++; } } if (num > max) max = num; if (num < k) break; } cout << max << endl; } return 0;
}
如果有付費意願可以加我Q343275968幫你寫演算法
不就是簡單的元胞自動機模型?
不用謝,已經通過的C++程式碼:
include
include
include
using namespace std;
int main()
{
}
如果有付費意願可以加我Q343275968幫你寫演算法