Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
123263 | 陈志轩 | 计算机病毒 | C++ | 通过 | 100 | 3 MS | 268 KB | 1636 | 2024-01-22 18:38:25 |
#include<bits/stdc++.h> #define int long long using namespace std; namespace Fast{ inline int fr(){ register int x = 0,f = 1; static char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void fw(int x){ if (x == 0){ putchar('0'); return ; } if (x < 0){ putchar('-'); x = -x; } stack <char> s; while (x){ s.push(x % 10 + 48); x /= 10; } while (!s.empty()){ putchar(s.top()); s.pop(); } } inline void DEBUG(){ puts("awa"); } inline void CCF(){ ios::sync_with_stdio(false); cin.tie(0),cout.tie(0); } } using namespace Fast; char a[105][105],b[105][105]; int o[5][3] = {{-1,0},{1,0},{0,-1},{0,1}}; signed main(){ int n,m; n = fr(); for (int i = 1;i <= n;i++){ for (int j = 1;j <= n;j++){ cin>>a[i][j]; b[i][j] = a[i][j]; } } m = fr(); for (int k = 1;k <= m;k++){ for (int i = 1;i <= n;i++){ for (int j = 1;j <= n;j++){ if (a[i][j] == '@'){ for (int l = 0;l < 4;l++){ int ci = i + o[l][0]; int cj = j + o[l][1]; if (a[ci][cj] != '#'){ b[ci][cj] = '@'; } } } } } for (int i = 1;i <= n;i++){ for (int j = 1;j <= n;j++){ //cout<<b[i][j]; a[i][j] = b[i][j]; } //cout<<'\n'; } //cout<<'\n'; } int cnt = 0; for (int i = 1;i <= n;i++){ for (int j = 1;j <= n;j++){ cnt += (a[i][j] == '@'); } } fw(cnt); return 0; }