认证0级讲师
Isn’t it just a simple cellular automaton model?
You’re welcome, passed C++ code:
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;
}
If you are willing to pay, you can add me Q343275968 to help you write an algorithm
Isn’t it just a simple cellular automaton model?
You’re welcome, passed C++ code:
include <iostream>
include <fstream>
include <memory.h>
using namespace std;
int main()
{
}
If you are willing to pay, you can add me Q343275968 to help you write an algorithm