UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#215389#1147. 扫雷游戏地雷数计算xuyongbinJudgement Failed//C++111.3kb2024-11-29 00:30:162024-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