Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
29660 | diandian | 流感传染 | C++ | 通过 | 0 MS | 248 KB | 1095 | 2023-10-31 22:06:37 |
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0; cin >> n; char a[n + 1][n + 1]; for (int i = 1; i <= n; ++ i){ for (int j = 1; j <= n; ++ j){ cin >> a[i][j]; } } int d; cin >> d; for (int i = 1; i <= d - 1; ++ i){ for (int j = 1; j <= n; ++ j){ for (int k = 1; k <= n; ++ k){ if (a[j][k] == '@'){ if (a[j - 1][k] == '.') a[j - 1][k] = '!'; if (a[j + 1][k] == '.') a[j + 1][k] = '!'; if (a[j][k - 1] == '.') a[j][k - 1] = '!'; if (a[j][k + 1] == '.') a[j][k + 1] = '!'; } } } for (int j = 1; j <= n; ++ j){ for (int k = 1; k <= n; ++ k){ if (a[j][k] == '!'){ a[j][k] = '@'; } } } } for (int i = 1; i <= n; ++ i){ for (int j = 1; j <= n; ++ j){ if (a[i][j] == '@') cnt ++; } } cout << cnt; return 0; }