Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
29656 diandian 流感传染 C++ 解答错误 0 MS 248 KB 1095 2023-10-31 22:01:24

Tests(0/1):


#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[i][j] == '@'){ 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[i][j] == '!'){ a[i][j] = '@'; } } } } for (int i = 1; i <= n; ++ i){ for (int j = 1; j <= n; ++ j){ if (a[i][j] == '@') cnt ++; } } cout << cnt; return 0; }


测评信息: