Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
122679 刘嘉乐 计算机病毒 C++ 通过 100 3 MS 268 KB 667 2024-01-22 16:19:16

Tests(10/10):


#include<bits/stdc++.h> using namespace std; char ch[105][105]; const int dx[4] = {-1, 1, 0, 0}; const int dy[4] = {0, 0, -1, 1}; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ cin>>ch[i][j]; } } int m; cin>>m; for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ if(ch[j][k] == '*'||ch[j][k] =='#')continue; for(int q = 0;q<4;q++){ if(ch[j+dx[q]][k+dy[q]] == '#')continue; else ch[j+dx[q]][k+dy[q]] = '@'; } } } } int res = 0; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(ch[i][j] == '@')res++; } } cout<<res<<endl; return 0; }


测评信息: