• 个人简介

    #include <bits/stdc++.h>
    using namespace std;
    int n;
    int a[35][35];
    void dfs(int x,int y){
    	if(x >= 0 && x <= n + 1 && y >= 0 && y <= n + 1){
    		if(a[x][y] == 1 || a[x][y] == 3)
    			return;
    		else{
    			a[x][y] = 3;
    			dfs(x + 1,y);
    			dfs(x - 1,y);
    			dfs(x,y + 1);
    			dfs(x,y - 1);
    		}
    	}
    }
    int main(){
    	cin >> n;
    	for (int i = 1;i <= n;i ++)
    		for (int j = 1;j <= n;j ++)
    			cin >> a[i][j];
    	dfs(0,0);
    	for(int i = 1; i <= n; ++ i)
    		for(int j = 1; j <= n; ++ j)
    			if(a[i][j] == 3)
    				a[i][j] = 0;
    			else if(a[i][j] == 0)
    				a[i][j] = 2;
    	for (int i = 1;i <= n;i ++){
    		for (int j = 1;j <= n;j ++){
    			cout << a[i][j] << " ";
    		}
    		cout << endl;
    	}
    	return 0;
    }
    
  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.