ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#215389 | #1147. 扫雷游戏地雷数计算 | xuyongbin | Judgement Failed | / | / | C++11 | 1.3kb | 2024-11-29 00:30:16 | 2024-11-29 00:30:18 |
answer
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
char arr[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>arr[i][j];
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(arr[i][j]=='*'){
cout<<'*';
}else{
int count=0;
if(min(0,i-1)==0 && max(n,i-1)==n && min(0,j)==0 && max(m,j)==m && arr[i-1][j]=='*'){
count++;
}
if(min(0,i+1)==0 && max(n,i+1)==n && min(0,j)==0 && max(m,j)==m && arr[i+1][j]=='*'){
count++;
}
if(min(0,i)==0 && max(n,i)==n && min(0,j-1)==0 && max(m,j-1)==m && arr[i][j-1]=='*'){
count++;
}
if(min(0,i)==0 && max(n,i)==n && min(0,j+1)==0 && max(m,j+1)==m && arr[i][j+1]=='*'){
count++;
}
if(min(0,i-1)==0 && max(n,i-1)==n && min(0,j-1)==0 && max(m,j-1)==m && arr[i-1][j-1]=='*'){
count++;
}
if(min(0,i-1)==0 && max(n,i-1)==n && min(0,j+1)==0 && max(m,j+1)==m && arr[i-1][j+1]=='*'){
count++;
}
if(min(0,i+1)==0 && max(n,i+1)==n && min(0,j-1)==0 && max(m,j-1)==m && arr[i+1][j-1]=='*'){
count++;
}
if(min(0,i+1)==0 && max(n,i+1)==n && min(0,j+1)==0 && max(m,j+1)==m && arr[i+1][j+1]=='*'){
count++;
}
cout<<count;
}
}
cout<<endl;
}
return 0;
}
Details
Failed to show details