Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
121516 | 余冠学 | 计算机病毒 | C++ | 解答错误 | 70 | 2 MS | 276 KB | 1299 | 2024-01-21 21:31:26 |
# include <iostream> # include <memory.h> using namespace std; int main(){ int n,m; cin >> n; char computer[n+1][n+1]; bool memory[n+1][n+1]; for (int i = 0;i < n;i++){ for (int j = 0;j < n;j++){ cin >> computer[i][j]; } }cin >> m; for (int hour = 1;hour < m;hour++){ memset(memory,true,sizeof(memory)); for (int i = 0;i < n;i++){ for (int j = 0;j < n;j++){ if (computer[i][j] == '@' && memory[i][j]){ if (i - 1 >= 0){ if (computer[i-1][j] != '#' && computer[i-1][j] != '@'){ computer[i-1][j] = '@'; memory[i-1][j] = !memory[i-1][j]; } }if (i + 1 < n){ if (computer[i+1][j] != '#' && computer[i+1][j] != '@'){ computer[i+1][j] = '@'; memory[i+1][j] = !memory[i+1][j]; } }if (j - 1 >= 0){ if (computer[i][j-1] != '#' && computer[i][j-1] != '@'){ computer[i][j-1] = '@'; memory[i][j-1] = !memory[i][j-1]; } }if (j + 1 < n){ if (computer[i][j+1] != '#' && computer[i][j+1] != '@'){ computer[i][j+1] = '@'; memory[i][j+1] = !memory[i][j+1]; } } } } } }int cnt = 0; for (int i = 0;i < n;i++){ for (int j = 0;j < n;j++){ if (computer[i][j] == '@') cnt++; } }cout << cnt; return 0; }